Estimate correlation between two time series

Hello, I’m a new Turing user and I’m not very familiar with probabilistic modeling, but the package is so cool that I couldn’t help trying to implement some of it :slight_smile:

Basically I have 2 Bernoulli/Poisson processes (binned spike trains) and I’d like to know if and how much one influences the other.

So my data has this form:

s₁ = [0, 0, 1, 0, 1]
s₂ = [1, 0, 0, 0, 1]

and I’ve computed a feature which is the delay of the closest spike of s₂

x = [0, 1, 2, 1, 0]

Then I’ve built the model:

@model my_naive_model(x, y, n, σ²) = begin
	b0 ~ Normal(0, σ²)
	b1 ~ Normal(0, σ²)
	for i = 1:n
		theta = b0 + b1*x[i, 1] 
		y[i] ~ Bernoulli(sigmoid(theta))
	end
end;

Trained it:

chain = sample(my_naive_model(x, s₁, length(x), 10), NUTS(200, 0.65), 1500, discard_adapt=false)

And took the predictions with:

function prediction(x::Vector, chain)
	p0 = mean(chain, :b0)
	p1 = mean(chain, :b1)
	r = zeros(size(x, 1))
	for i = 1:n
		theta = p0 + p1*x[i]
		r[i] = sigmoid(theta)
	end
	r
end;

And that was awesomely easy, but I’d like to do something a bit more complicated, so these are my questions:

1.

What could be a sensible transformation of x, or how could I figure this out?
For example, I guess I could fit a polynomial, but what about embedding a smoothing spline or another non parametric regression method?

2.

How do I understand the magnitude of the effect that s₂ has on s₁? In particular if I’m using a polynomial fit, how can I say that s₂ is actually having an effect on s₁?

3.

This follows directly from the second question: Let’s say that I have a third spike train, and I want to s₃, and I want to prove that it has no effect at all on s₁. How do I do that?

Thank you very much in advance, and thanks to all Turing developers for the marvelous work!

1 Like