I have fitted a multiple regression model to the row of a matrix using lm: ft<-lm(datos[i, ]-r1 + r2+ r3 + r4,keep.data = TRUE,model=TRUE) If I use fitted(ft) I get the list of fitted values (which I think is the mean of the fitted values corresponding to each of the explanatory variables (r1, r2, r3, r4)). But I need to get the fitted values list for each explanatory variable. How to do it? I tried with: fitted(ft, level = 3) but the fitted list returned is the same for any value of level. I am missing an argument in lm or in fitted or in both? Thank you very much. Alberto Capurro Marie Curie Research Fellow Department of Cell Physiology and Pharmacology College of Medicine, Biological Sciences and Psychology Maurice Shock Medical Sciences Building, Room 330 University of Leicester Leicester LE1 9HN United Kingdom -- View this message in context: http://r.789695.n4.nabble.com/fitted-tp4674442.html Sent from the R help mailing list archive at Nabble.com.
If by fitted values corresponding to each predictor you mean the regression coefficients , then use coef(ft) -- David. Sent from my iPhone On Aug 24, 2013, at 6:43 AM, alR <ac331 at le.ac.uk> wrote:> I have fitted a multiple regression model to the row of a matrix using lm: > > ft<-lm(datos[i, ]-r1 + r2+ r3 + r4,keep.data = TRUE,model=TRUE) > > If I use fitted(ft) I get the list of fitted values (which I think is the > mean of the fitted values corresponding to each of the explanatory variables > (r1, r2, r3, r4)). But I need to get the fitted values list for each > explanatory variable. How to do it? > > I tried with: > > fitted(ft, level = 3) > > but the fitted list returned is the same for any value of level. > > I am missing an argument in lm or in fitted or in both? > > Thank you very much. > > Alberto Capurro > Marie Curie Research Fellow > Department of Cell Physiology and Pharmacology > College of Medicine, Biological Sciences and Psychology > Maurice Shock Medical Sciences Building, Room 330 > University of Leicester > Leicester LE1 9HN > United Kingdom > > > > > > -- > View this message in context: http://r.789695.n4.nabble.com/fitted-tp4674442.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
I don't fully understand what you are looking for, but you may want to check out ?predict, ?predict.lm On Sat, Aug 24, 2013 at 7:43 AM, alR <ac331@le.ac.uk> wrote:> I have fitted a multiple regression model to the row of a matrix using lm: > > ft<-lm(datos[i, ]-r1 + r2+ r3 + r4,keep.data = TRUE,model=TRUE) > > If I use fitted(ft) I get the list of fitted values (which I think is the > mean of the fitted values corresponding to each of the explanatory > variables > (r1, r2, r3, r4)). But I need to get the fitted values list for each > explanatory variable. How to do it? > > I tried with: > > fitted(ft, level = 3) > > but the fitted list returned is the same for any value of level. > > I am missing an argument in lm or in fitted or in both? > > Thank you very much. > > Alberto Capurro > Marie Curie Research Fellow > Department of Cell Physiology and Pharmacology > College of Medicine, Biological Sciences and Psychology > Maurice Shock Medical Sciences Building, Room 330 > University of Leicester > Leicester LE1 9HN > United Kingdom > > > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/fitted-tp4674442.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]