Unknown order linear regression parameters estimate

Hello, how can I modify this program of 2nd order linear regression parameters estimate when I don't now the order of regression. I have only a *.mat file with 2000 inputs(ut) and outputs(yt) and I need to determine the order and estimate the parameters of regression. Thank you for your help.
load ukol_A yt ut
nd=length(yt);
V=zeros(7)+1e-8*eye(7);
th=zeros(6,nd);
r=zeros(1,nd);
for t=3:nd
psi=[yt(t:-1:t-2) ut(t:-1:t-2) 1];
V=V+psi'*psi;
Vy=V(1,1); Vyp=V(2:end,1); Vp=V(2:end,2:end);
th(:,t)=inv(Vp)*Vyp;
r(t)=(Vy-Vyp'*inv(Vp)*Vyp)/t;
end
set(figure(1),'position',[500 60 600 600])
for i=1:6
subplot(6,1,i),plot(th(i,:))
if i==1, title('Regression coefficients'), end
end
set(figure(2),'position',[50 60 400 200])
plot(r)
title('Noise variance')

Answers (0)

This question is closed.

Asked:

on 6 Dec 2012

Closed:

on 20 Aug 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!