Displaying 1 result from an estimated 1 matches for "mpca1st".
Did you mean:
mcast
2012 Aug 27
0
How can I find the principal components and run regression/forecasting using dynlm
...results of dynlm properly. In lm model,
function "predict.lm" can do it.
For the case of first principal component (In order to accentuate the
main problem, I have simplify the codes):
Mpca<-prcomp(M1, center=TRUE, scale =TRUE) # M1 is the data matrix of
explanatory variables
Mpca1st<-Mpca$x[,1] # first principle component
X<-as.matrix(Mpca1st)
model<-dynlm(as.ts(y[(h+1):t]) ~ L(as.ts(X[1:(t-h)]), 0:i) +
L(as.ts(z[1:(t-h)]),0:j)) # y, X, z are a zoo objects defined earlier; i
and j, t, h are given earlier; h is the forecasting horizon; since dynlm
can't wo...