Today, I looked into the application of MLE.
Summary:
function [theta] = LG_RML(u,y,oa,ob,od)
na = oa - 1;nb = ob - 1;nc = od - 1;d = 1;
L = length(u);
nn = max(na,nc);
uk = zeros(d + nb,1);
yk = zeros(na,1);
vk = zeros(nc,1);
yfk = zeros(nn,1);ufk = zeros(nn,1);vfk = zeros(nc,1);
thetae_1 = zeros(na+nb+1+nc,1);
thetae = zeros(na+nb+1+nc,L);
P = eye(na+nb+1+nc);
for k = 1:L
hk = [-yk;uk(d:d+nb);vk];
v = y(k) - hk'*thetae_1;
hkf=[-yfk(1:na);ufk(d:d+nb);vfk];
K=P*hkf/(1+hkf'*P*hkf);
thetae(:,k)=thetae_1+K*v;
P=( eye(na+nb+1+nc)-K*hkf' )*P;
yf=y(k)-thetae(na+nb+2:na+nb+1+nc,k)*yfk(1:nc);%yf(k)
uf=u(k)-thetae(na+nb+2:na+nb+1+nc,k)*ufk(1:nc);%uf(k)
vf=v-thetae(na+nb+2:na+nb+1+nc,k)*vfk(1:nc);%vf(k)
thetae_1=thetae(:,k);
for i=d+nb:-1:2
uk(i)=uk(i-1);
end
uk(1)=u(k);
for i=na:-1:2
yk(i)=yk(i-1);
end
yk(1)=y(k);
for i=nc:-1:2
vk(i)=vk(i-1);
vfk(i)=vfk(i-1);
end
vk(1)=v;
vfk(1)=vf;
for i=nn:-1:2
yfk(i)=yfk(i-1);
ufk(i)=ufk(i-1);
end
yfk(1)=yf;
ufk(1)=uf;
end
theta = thetae;
end
a=[1 -1.5 0.7];b=[1 0.5];c=[1 -0.5];d=1;
L=1000;
na=length(a)-1;nb=length(b)-1;nc=length(c)-1;
uk=zeros(d+nb,1);
yk=zeros(na,1);
u=randn(L,1);
xi=randn(L,1);
xik=zeros(nc,1);
for k=1:L
y(k)=-a(2:na+1)*yk+b *uk(d:d+nb)+c *[xi(k);xik];
for i=d+nb:-1:2
uk(i)=uk(i-1);
end
uk(1)=u(k);
for i=na:-1:2
yk(i)=yk(i-1);
end
yk(1)=y(k);
xik(1)=xi(k);
end
thetae = LG_RML(u,y,3,2,2);
figure(1)
plot([1:L],thetae(1:na,:),[1:L],thetae(na+nb+2:na+nb+1+nc,:));
xlabel(k);ylabel('parameter estimation a&d');
legend('a_1' ,'a_2' ,'d_1' );axis([0 L -2 2]);
figure(2)
plot([1:L],thetae(na+1:na+nb+1,:));
xlabel(k);ylabel('parameter estimation b' );
legend('b_0' ,'b_1' );axis([0 L 0 1.5]);
There are many applications of MLE. I will try to find one that is the most similar to my research.
Tomorrow, I will look more into MLE.
No comments:
Post a Comment