[R] Linear Modeling and Predictions

Spencer Graves spencer.graves at pdf.com
Mon Jun 27 22:09:36 CEST 2005


	  Have you considered "predict" (including the examples with 
"?predict.lm")?

	  spencer graves

Tony Young wrote:

> 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
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

-- 
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

spencer.graves at pdf.com
www.pdf.com <http://www.pdf.com>
Tel:  408-938-4420
Fax: 408-280-7915




More information about the R-help mailing list