~vincent-vincentdavis/statsmodels/sum-stats-devel3

« back to all changes in this revision

Viewing changes to scikits/statsmodels/examples/tsa/ex_arma.py

merge josef, mostly refactoring fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
'''
2
2
 
3
3
doesn't seem to work so well anymore even with nobs=1000 ???
 
4
works ok if noise variance is large
4
5
'''
5
6
 
6
7
import numpy as np
15
16
 
16
17
 
17
18
print "\nExample 1"
18
 
ar = [1.0,  -0.1, 0.1]
 
19
ar = [1.0,  -0.6, 0.1]
19
20
ma = [1.0,  0.5, 0.3]
20
21
nobs = 1000
21
 
y22 = arma_generate_sample(ar, ma, nobs+1000, 0.2)[-nobs:]
 
22
y22 = arma_generate_sample(ar, ma, nobs+1000, 0.5)[-nobs:]
22
23
y22 -= y22.mean()
23
24
start_params = [0.1, 0.1, 0.1, 0.1]
24
25
start_params_lhs = [-0.1, -0.1, 0.1, 0.1]
57
58
                          #res_ols.scale]
58
59
                          #areste.var()]
59
60
                          np.sqrt(res_ols.scale)]
60
 
#need to iterate, ar1 too large ma terms too small                 
 
61
#need to iterate, ar1 too large ma terms too small      
 
62
#fix large parameters, if hannan_rissannen are too large
 
63
start_params_mle[:-1] = (np.sign(start_params_mle[:-1]) 
 
64
                         * np.minimum(np.abs(start_params_mle[:-1]),0.75))
61
65
 
62
66
 
63
67
print 'conditional least-squares'