1、我用R 2.12.2作LSTAR 回归。
2、之前用EVIEWS 6.0 进解决序列X、Y变量的LSATR模型时,发现其非常不稳定、经常出现(overflow)之错,大为心烦。为此,想用MATLAB来作,又不懂。只好用自己一知半解的R来解决,经过二天的努力搜寻终于找到了一般的办法,尽管还是不太了解其中的意义;但必竞有了一个好的结果。
3、二时序列为月度数据,经过季节调整后,经单位根检验是平稳的时序,并且有格兰杰双向因果关系。
4、经过用EVIEWS 6.0,X、Y自回归方程是:(ls) y c y(-1) y(-2) y(-3) x;经过线性与非线性检验,发现拒绝线性假设,接受STAR模型;转换变量St(Xt-d)存在,拒绝H03假设的结果,为此,有LSTAR型。
5、以下是部分步骤:结果是成功的。
6、写出这些是为了一些需求这方面的学子提供方便。同时感谢“EPOH”等学者,提供参考!
7、愿“EPOH“能进一步,提供这一方面的材料,最好是中文材料;同时也希望学者能为”计量经济学”开设不同的专题栏目,如“SATAR“模型栏目,这样就更能发挥知识的力量。
> y.lstar<-lstar(y,m=2,d=1,thVar=x,control=list(maxit=3000))
Using maximum autoregressive order for low regime: mL = 2
Using maximum autoregressive order for high regime: mH = 2
Using only first 214 elements of thVar
Performing grid search for starting values...
Starting values fixed: gamma = 40 , th = -0.3553135 ; SSE = 200.8684
Optimization algorithm converged
Optimized values fixed for regime 2 : gamma = 40.00305 , th = -0.3473805
>y.lstar
Non linear autoregressive model
LSTAR model
Coefficients:
Low regime:
phi1.0 phi1.1 phi1.2
-0.1977353 1.0044579 -0.2679540
High regime:
phi2.0 phi2.1 phi2.2
0.37677633 0.28857978 -0.07975238
Smoothing parameter: gamma = 40
Threshold
Variable: external
Value: -0.3474
> error<-residuals(y.lstar)
> error
Time Series:
Start = 1
End = 216
Frequency = 1
[1] NA NA 0.7245178006 0.6706844591 0.7622682607 0.1102448166 -0.5452139850 0.8176878174
[9] 0.0838997028 0.2084677191 0.3494380641 1.2226995599 0.1240683021 -0.3002827221 -1.6090500228 -1.4328548659
[17] 1.2986441393 -1.1154548120 -0.0141480804 1.0942577469 0.5068491370 -0.6620878787 0.0325707003 -0.3160992056
[25] 0.2924211845 -0.9489559399 -0.2490356533 0.0669975442 -0.4018340489 -0.0691557539 -0.6160131503 -1.0480959975
[33] 0.2100363785 0.0605086933 -1.05...................................
> names(y.lstar)
[1] "str" "coefficients" "fitted.values" "residuals" "k" "model" "model.specific"
> g=cpi.lstar$coefficients[7]
> g=y.lstar$coefficients[7]
> th=cpi.lstar$coefficients[8]
> gfun<-function(y,g,th) 1/(1+exp(-g*(y-th)))
> G=gfun(x,g,th)
> par=(mfrow=c(2,1))
> plot(G,type = "l", col = "red")
>plot(x,G)
OK
一直困了我很多时间的问题得以解决!!谢谢“epoh”.