[R] Linear Modeling and Predictions

Tony Young wayoung at softbase.math.uwaterloo.ca
Mon Jun 27 19:27:42 CEST 2005


Hello all,

I need some help with linear modeling and making predictions using my  
model. What I have done is the following:

-Read my variable data into R using read.table
-Assigned the values to variable names so that each variable is a  
vector from the table
-Generated my model using the lm command and each of my variables
-Read some new data with which to make predictions into a new data  
frame (the variables have the same names as the ones used to build  
the model, but the new variables are in a frame called "new")

Now, what I want to do is use the model that R constructed and feed  
it new values for the variables, then get back the estimated response  
variable value. I can't seem to figure out how to do this using  
predict or predict.lm. I get a warning that the new data contained 36  
values (there are 36 new sets of values that I want predictions for  
using the model) when the original data set contains 5136 values.  
Then, the fitted values are the ones that were from the model creation

Any help would be appreciated!

ty




More information about the R-help mailing list