I am trying to calculate the regression for the follwing input data stored in 'data.txt' file.I am reading this and storing it in the variable i .then i am trying to get the predicted value using f1 as dependent and others f2....f10 as independent variables.It is giving the following error. Also i want that i shoul get one predicted value for each row(y). What should i do. Please help me out i will be thankful to you. i<-read.table("data.txt",header=FALSE) i V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 1 molecule f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 2 m1 3 7 0 3 0 0 0 1 1 1 3 m2 2 7 0 2 0 2 0 1 0 1 4 m3 0 0 0 3 0 0 0 3 1 0 5 m4 3 7 0 1 3 0 0 0 0 1 attach(i) out<-lm(y~x1+x2+x3+x4+x5+x6+x7+x8+x9+x10) Error in eval(expr, envir, enclos) : object "y" not found -- View this message in context: http://www.nabble.com/problem-in-caluclaring-the-multiple-regression-tp16771241p16771241.html Sent from the R help mailing list archive at Nabble.com. [[alternative HTML version deleted]]
man4ish schreef:> I am trying to calculate the regression for the follwing input data stored in > 'data.txt' file.I am reading this and storing it in the variable i .then i > am trying to get the predicted value using f1 as dependent and others > f2....f10 as independent variables.It is giving the following error. Also i > want that i shoul get one predicted value for each row(y). What should i do. > Please help me out i will be thankful to you. > > i<-read.table("data.txt",header=FALSE) > i > V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 > 1 molecule f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 > 2 m1 3 7 0 3 0 0 0 1 1 1 > 3 m2 2 7 0 2 0 2 0 1 0 1 > 4 m3 0 0 0 3 0 0 0 3 1 0 > 5 m4 3 7 0 1 3 0 0 0 0 1 > > attach(i) > out<-lm(y~x1+x2+x3+x4+x5+x6+x7+x8+x9+x10) > Error in eval(expr, envir, enclos) : object "y" not found > >In the read.table command you have to specify if you have a header that gives the column names (which you have). You can do this by specifying "header = TRUE". Additionally, read the documentation of lm() carefully. Based on the object "i" the call to lm() should look like (after using header=TRUE in read.table) out <- lm(molecule~f1+...+f10) (used the dots to save some typing) cheers, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +31302535773 Fax: +31302531145 http://intamap.geo.uu.nl/~paul
Tom Backer Johnsen
2008-Apr-21 08:53 UTC
[R] problem in caluclaring the multiple regression
man4ish wrote:> I am trying to calculate the regression for the follwing input data stored in > 'data.txt' file.I am reading this and storing it in the variable i .then i > am trying to get the predicted value using f1 as dependent and others > f2....f10 as independent variables.It is giving the following error. Also i > want that i shoul get one predicted value for each row(y). What should i do. > Please help me out i will be thankful to you. > > i<-read.table("data.txt",header=FALSE) > i > V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 > 1 molecule f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 > 2 m1 3 7 0 3 0 0 0 1 1 1 > 3 m2 2 7 0 2 0 2 0 1 0 1 > 4 m3 0 0 0 3 0 0 0 3 1 0 > 5 m4 3 7 0 1 3 0 0 0 0 1 > > attach(i) > out<-lm(y~x1+x2+x3+x4+x5+x6+x7+x8+x9+x10) > Error in eval(expr, envir, enclos) : object "y" not foundThe explanation for the error message is trivial, there are no variables in the data frame with the names you specify in the call on lm (). The first row in the frame contains what probably are the intended names .. as data. Use header=TRUE in the read .table. On the other hand there are several other problem as well, the contents of the dependent variable as well as the number of dependent variables compared with the number of rows in the frame. Tom>