[R] Help to get fitted and residual value
Data- read.csv(C:/FE and RE.csv) Formula=Y~X2+X3+X4 + X5+X6 fit=lm(formula=Formula,data=Data) My sample Data State Year Y X2 X3 X4 X5 X6 S2 1960 27.8 397.5 42.2 50.7 78.3 65.8 S1 1960 29.9 413.3 38.1 52 79.2 66.9 S2 1961 29.8 439.2 40.3 54 79.2 67.8 S1 1961 30.8 459.7 39.5 55.3 79.2 69.6 Is there any way to fitted and residual for the new set of data. or should i create formula manually and pass the values individually S2 1962 31.2 492.9 37.3 54.7 77.4 68.7 S1 1962 33.3 528.6 38.1 63.7 80.2 73.6 S2 1963 35.6 560.3 39.3 69.8 80.4 76.3 -- View this message in context: http://r.789695.n4.nabble.com/Help-to-get-fitted-and-residual-value-tp4167808p4167808.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.
Re: [R] Help to get fitted and residual value
Hi arunkumar; fit$residuals , fit$fitted to extract respectively residuals and fitted values Regrads Mohamed Le 07/12/11 07:20, arunkumar a écrit : Data- read.csv(C:/FE and RE.csv) Formula=Y~X2+X3+X4 + X5+X6 fit=lm(formula=Formula,data=Data) My sample Data State Year Y X2 X3 X4 X5 X6 S2 1960 27.8 397.5 42.2 50.7 78.3 65.8 S1 1960 29.9 413.3 38.1 52 79.2 66.9 S2 1961 29.8 439.2 40.3 54 79.2 67.8 S1 1961 30.8 459.7 39.5 55.3 79.2 69.6 Is there any way to fitted and residual for the new set of data. or should i create formula manually and pass the values individually S2 1962 31.2 492.9 37.3 54.7 77.4 68.7 S1 1962 33.3 528.6 38.1 63.7 80.2 73.6 S2 1963 35.6 560.3 39.3 69.8 80.4 76.3 -- View this message in context: http://r.789695.n4.nabble.com/Help-to-get-fitted-and-residual-value-tp4167808p4167808.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. -- Mohamed Lajnef,IE INSERM U955 eq 15# P?le de Psychiatrie# H?pital CHENEVIER # 40, rue Mesly # 94010 CRETEIL Cedex FRANCE # mohamed.laj...@inserm.fr # tel : 01 49 81 32 79 # Sec : 01 49 81 32 90 # fax : 01 49 81 30 99 # [[alternative HTML version deleted]] __ 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.
Re: [R] Help to get fitted and residual value
Hei, i) get names of object returned by lm(). in this case fit names(fit) output from command : names(fit) [1] coefficients residuals effects rank [5] fitted.values assignqrdf.residual [9] contrasts xlevels call terms ii) To get residuals, enter the command myFitRes - fit$residuals; iii) myFitVals - fit$fitted.values I hope will help, M.O On ti., 2011-12-06 at 22:20 -0800, arunkumar wrote: Data- read.csv(C:/FE and RE.csv) Formula=Y~X2+X3+X4 + X5+X6 fit=lm(formula=Formula,data=Data) My sample Data State Year Y X2 X3 X4 X5 X6 S2 1960 27.8 397.5 42.2 50.7 78.3 65.8 S1 1960 29.9 413.3 38.1 52 79.2 66.9 S2 1961 29.8 439.2 40.3 54 79.2 67.8 S1 1961 30.8 459.7 39.5 55.3 79.2 69.6 Is there any way to fitted and residual for the new set of data. or should i create formula manually and pass the values individually S2 1962 31.2 492.9 37.3 54.7 77.4 68.7 S1 1962 33.3 528.6 38.1 63.7 80.2 73.6 S2 1963 35.6 560.3 39.3 69.8 80.4 76.3 -- View this message in context: http://r.789695.n4.nabble.com/Help-to-get-fitted-and-residual-value-tp4167808p4167808.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. __ 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.
Re: [R] Help to get fitted and residual value
Hi Hei, i) get names of object returned by lm(). in this case fit names(fit) output from command : names(fit) [1] coefficients residuals effects rank [5] fitted.values assignqrdf.residual [9] contrasts xlevels call terms ii) To get residuals, enter the command myFitRes - fit$residuals; myFitRes - residuals(fit) iii) myFitVals - fit$fitted.values myFitVals - fitted(fit) shall be prefered. Regards Petr I hope will help, M.O On ti., 2011-12-06 at 22:20 -0800, arunkumar wrote: Data- read.csv(C:/FE and RE.csv) Formula=Y~X2+X3+X4 + X5+X6 fit=lm(formula=Formula,data=Data) My sample Data State Year Y X2 X3 X4 X5 X6 S2 1960 27.8 397.5 42.2 50.7 78.3 65.8 S1 1960 29.9 413.3 38.1 52 79.2 66.9 S2 1961 29.8 439.2 40.3 54 79.2 67.8 S1 1961 30.8 459.7 39.5 55.3 79.2 69.6 Is there any way to fitted and residual for the new set of data. or should i create formula manually and pass the values individually S2 1962 31.2 492.9 37.3 54.7 77.4 68.7 S1 1962 33.3 528.6 38.1 63.7 80.2 73.6 S2 1963 35.6 560.3 39.3 69.8 80.4 76.3 -- View this message in context: http://r.789695.n4.nabble.com/Help-to-get- fitted-and-residual-value-tp4167808p4167808.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. __ 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. __ 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.