[SciPy-User] OT: advice on modelling a time series
Fri Mar 12 12:32:07 CST 2010
> -----Original Message-----
> From: email@example.com [mailto:firstname.lastname@example.org]
> On Behalf Of email@example.com
> Sent: Friday, March 12, 2010 9:53 AM
> To: SciPy Users List
> Subject: Re: [SciPy-User] OT: advice on modelling a time series
> If you have rpy and R installed, you can try something like this on
> your position data, to see whether GARCH is helpful (ret is my 1d
> numpy.array with the time series)
> from rpy import r
> # pure garch on mean corrected data
> f = r.formula('~garch(1, 1)')
> fit = r.garchFit(f, data = ret - ret.mean(), include_mean=False)
> #ARMA in mean, GARCH in variance
> f = r.formula('~arma(1,1) + ~garch(1, 1)')
> fit = r.garchFit(f, data = ret)
> I haven't figured out how to do many of the options for GARCH with rpy.
I don't know about rpy (classic), but in rpy2, you can input any R expression as a string.
import rpy2.robjects as ro
R = ro.r
[code that defines x and y in python]
# set the variables up in the R environment
R.globalEnv['xR'] = x # needs to be a list?
R.globalEnv['yR'] = y
Fit = R("some pure R expression using xR and yR")
Probably won't be all that fast, but it'll work.
More information about the SciPy-User