这是用mcmc方法对SV模型的参数估计,对上证指数周收益率进行实证分析的winBUGS程序:
#data
list(n=168, y=c(0.045127583 ,
0.025693644 ,
0.018362051 ,
0.091428329 ,
0.062014581 ,
-0.025888179 ,
-0.082281358 ,
0.051535553 ,
-0.029691734 ,
0.069070156 ,
0.040108694 ,
0.018915023 ,
0.010052708 ,
0.024134986 ,
-0.022349104 ,
0.011763447 ,
0.058048743 ,
0.007443913 ,
-0.018182551 ,
0.013509353 ,
0.044917163 ,
-0.003684486 ,
0.048630447 ,
0.016431238 ,
0.053250816 ,
0.008243122 ,
0.024053815 ,
0.055744551 ,
0.011632254 ,
-0.045377385 ,
-0.067791175 ,
-0.028698285 ,
-0.034386515 ,
0.000321549 ,
0.043818747 ,
-0.009112262 ,
-0.042695371 ,
-0.021149647 ,
0.046498101 ,
0.022048824 ,
0.043137408 ,
-0.036702873 ,
0.054621414 ,
0.007434283 ,
0.037165340 ,
-0.066251820 ,
0.068877478 ,
-0.021244600 ,
-0.041957961 ,
0.008782135 ,
0.042317187 ,
-0.025071696 ,
0.008770881 ,
-0.030088185 ,
-0.045545214 ,
-0.016830411 ,
0.026432269 ,
0.011140009 ,
-0.006864394 ,
-0.005841051 ,
0.017871402 ,
-0.002622620 ,
0.031603525 ,
-0.004001082 ,
-0.004794732 ,
-0.048019976 ,
-0.038584610 ,
-0.065585001 ,
0.003062577 ,
-0.042848890 ,
0.027579918 ,
-0.039232115 ,
0.006381944 ,
-0.022317735 ,
0.015631860 ,
-0.068878802 ,
0.036273112 ,
-0.019060904 ,
0.059163832 ,
0.025137943 ,
0.007888792 ,
-0.019636375 ,
0.013567346 ,
-0.012017927 ,
0.016958571 ,
0.002938744 ,
-0.024524700 ,
-0.002750935 ,
0.024436306 ,
0.030806963 ,
0.081453028 ,
0.001306044 ,
0.001273792 ,
0.049340004 ,
-0.047126824 ,
-0.032985280 ,
-0.005856693 ,
-0.010243821 ,
-0.000489490 ,
0.018379601 ,
-0.020452468 ,
-0.009597407 ,
0.010881872 ,
-0.016858580 ,
-0.027622965 ,
0.013700177 ,
0.016647508 ,
0.010084176 ,
0.025306914 ,
-0.007347104 ,
0.021901722 ,
-0.002896480 ,
-0.009214743 ,
0.024107069 ,
-0.003499956 ,
0.020880032 ,
0.006744485 ,
-0.013202210 ,
-0.033439634 ,
-0.016492747 ,
0.002491755 ,
-0.004388530 ,
-0.053353591 ,
0.006646994 ,
-0.008421295 ,
-0.023309004 ,
0.038376371 ,
0.004777350 ,
0.013824607 ,
0.007972711 ,
-0.017664334 ,
-0.025240540 ,
-0.028269094 ,
-0.012740622 ,
-0.022941872 ,
0.030247834 ,
-0.032648955 ,
-0.012147702 ,
-0.006188655 ,
-0.020012459 ,
-0.030859357 ,
0.030125885 ,
-0.048065015 ,
0.065205839 ,
0.021947002 ,
-0.018849206 ,
-0.026349693 ,
-0.015151268 ,
-0.008251666 ,
-0.019416624 ,
-0.039841308 ,
-0.009055458 ,
-0.002437220 ,
-0.016513578 ,
0.036839674 ,
0.032668520 ,
0.004855131 ,
0.009215880 ,
0.002208462 ,
0.034379155 ,
0.008597449 ,
-0.008665494 ,
-0.014337397 ,
-0.023220988 ,
-0.037621457 ,
0.019156521 ,
0.022551845 ,
0.008220326 ));
#initial values
list(phistar=0.93, mu=0, itau2=0.0167);
#model
model volatility;
var y[n], yisigma2[n], theta0, theta[n], thmean[n], mu, beta, phi, phistar, tau, itau2;
{
#likelihood: joint distribution of ys
for (t in 1:n) { yisigma2[t]<-1/exp(theta[t]);
y[t]~dnorm(0, yisigma2[t]);
}
#prior distributions
mu~dnorm(0,0.1);
phistar~dbeta(20,1.5);
itau2~dgamma(2.5,0.025);
beta<-exp(mu/2);
phi<-2*phistar-1;
tau<-sqrt(1/itau2);
theta0~dnorm(mu, itau2);
thmean[1]<-mu+phi*(theta0-mu);
theta[1]~dnorm(thmean[1],itau2);
for (t in 2:n) { thmean[t]<-mu+phi*(theta[t-1]-mu);
theta[t]~dnorm(thmean[t],itau2);
}
}
在运行的时候,load inits说“this initial value does not correspond to a stochastic node”,请问哪里出错了呀?