Error in lm prediction

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Error in lm prediction

amol gupta
Hi

I am most likely committing an error in trying to predict  using linear
regression lm model. please help me figure out what am I doing wrong. I am
trying to regress a index and its constituents. Here is the code


#split ts inttwo parts
a<-300;

x1<-x[1:a,];
y1<-y[1:a,];

x2<-x[(a+1):nrow(x),];
y2<-y[(a+1):nrow(y),];


#regression
m1<-lm( y1~x1)
r1<-residuals(m1)
coef(m1)

##out of sample
y_hat<-predict.lm(m1,x2);
r2<-y_hat-y2;


x,y are xts. X contains multiple time series. The y_ hat turns out to be of
300 samples only, whereas x2 contains 1400 samples.

Please help me figure out how to predict using model that I have found
using regression.


--
Regards
Amol
+91-9897860992
+91-8889676918

        [[alternative HTML version deleted]]

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
Loading...