From: Anthony on 13 Jul 2010 12:24 Hey folks, I'm using the System ID toolbox to fit some AR models. And then using resid function to get the residuals from the fitted model to run some diagnostic tests. Firstly, is there another way to access the residuals without calling the resid function. I couldn't figure it out so if there is that would help! Secondly, my main problem. When I call the resid function, it outputs a graph. But it the help file it says if you call the function with output, there would be no graph. Since I'm calling the function in a loop (48 times)...it takes a long time to run through my script... Note: "lags" is a vector of optimal lags for each series. (48x1). %Estimate optimal AR(p) for each country split = 0.5; for i = 1:size(P,2) y = P(:,i); y = y(~isnan(y)); dy = y - mean(y); %Demeaned data is still not stationary dydiff = diff(dy); %First difference of dy - stationary %Split data dest = dydiff(1:round(split*length(dydiff))); %Data for estimation dfor = dydiff(round(split*length(dydiff))+1:end); %Data for forecast evaluation m = ar(dest,lags(i),'yw'); %Estimate AR(p), solving Yule-Walker equations err = resid(m,dest); arcoefs{i} = m.a; resids{i} = err; end Thanks a bunch Anthony
|
Pages: 1 Prev: Using multiple webcams in matlab Next: using fscanf to read a datafile |