Closed akuz closed 8 years ago
That would be a great addition. It shouldn't be too difficult. There's a pretty good description and model in the stan manual: http://mc-stan.org/manual.html which should be easy to port.
Taking the GARCH (1,1) model here just to put it down as an example.
data {
int<lower=0> T;
real r[T];
real<lower=0> sigma1;
}
parameters {
real mu;
// number of time points
// return at time t
// average return
real<lower=0> alpha0;
real<lower=0,upper=1> alpha1;
real<lower=0,upper=(1-alpha1)> beta1;
}
transformed parameters {
real<lower=0> sigma[T];
sigma[1] <- sigma1;
for (t in 2:T)
sigma[t] <- sqrt(alpha0
+ alpha1 * pow(r[t-1] - mu, 2)
+ beta1 * pow(sigma[t-1], 2));
} model {
r ~ normal(mu,sigma);
}
I've no experience of porting from STAN to PyMC3 but I reckon I could give it a shot in the new year.
You would probably have to implement this similarly to the GaussianRandomWalk
class, by using 2 views of sigma
indexed at different offsets. I predict it will be ugly.
Should not be harder than the stochastic volatility example, maybe I can have a go in the future ;)
Once https://github.com/pymc-devs/pymc3/pull/963 is added in - we have this issue resolved :) Only 8 months later :)
Assuming https://github.com/pymc-devs/pymc3/pull/965 is accepted this can be closed :) Can someone close this for me and @akuz
Feature request: implement GARCH in timeseries.py