万谢!!!!!
>>sigma=[ 0.088787 -0.000839 -26.84277 0.010292 -0.051353
-0.000839 0.599623 55.85124 -0.126785 0.418719
-26.84277 55.85124 24567.27 -32.48659 60.56435
0.010292 -0.126785 -32.48659 0.316247 -0.182432
-0.051353 0.418719 60.56435 -0.182432 1.068015
];
A=chol(sigma);
Iterations=10000;
theta=zeros(Iterations,4);
y=zeros(4,1);x1=zeros(5,1);x2=zeros(5,1);x3=zeros(5,1);x4=zeros(5,1);
x1(1)= 7.7;
x2(1)=5089.23;
x3(1)=97.4;
x4(1)= 0.6;
x1(5)=6.6;
>>for i=Iterations
for t=1:3
r=normrnd(0,1,5,1);
e=A'*r;
x1(t+1)=-2.962+0.864*x1(t)+ 0.325*x3+e(2);
end
for t=1:5
r=normrnd(0,1,5,1);
e=A'*r;
x2(t+1)=-5023.613+1.078*x2(t)+49.951*x3(t)+49.669*x4(t)+e(3);
x3(t+1)=32.203-0.0006*x2(t)+0.498*x3(t)-0.285*x4(t)+e(4);
x4(t+1)=2.575+0.771*x3(t)+0.949*x4(t)+e(5);
y(t)=-11.01-0.196*x1(t)+0.196*x3(t)-0.0008*x2(t)+0.135*x4(t)+e(1);
end
theta(i,:)=[x2(5),x3(5),x4(5),y(4)];
end
>>p=exp(theta(:,4))./(1+exp(theta(:,4)));
pquantile=sort(p);
m=mean(p)
pq=[pquantile(9000),pquantile(9500),pquantile(9900)]
subplot(2,2,1);
hist(theta(:,4),-6:0.11,0);
subplot(2,2,2);
hist(p,0:0.01:0.3);