Krunal Nanavati
2012-Jul-26 12:28 UTC
[R] Working with Numbers generated from Regression Output
Hi, I have a query on regression output generated by R.> result=lm( Y~X , data=trail)> summary(result)After running this 2 statements the following output is generated. Call: lm(formula = Y ~ X, data = trail) Residuals: Min 1Q Median 3Q Max -245.30 -90.77 -30.30 54.99 532.78 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 245.2982 62.1307 3.948 0.000376 *** X 0.5192 0.1752 2.963 0.005533 ** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 169.1 on 34 degrees of freedom Multiple R-squared: 0.2052, Adjusted R-squared: 0.1818 F-statistic: 8.777 on 1 and 34 DF, p-value: 0.005533>From this output, I intend to use the beta values to calculateelasticities. Is this possible directly in R? If not, then when I paste this output in Excel, It is pasted as an image, and thus I cannot use the beta values for calculating any other metric. Can anyone please help me out!!! Thanks & Regards, Krunal Nanavati 9769-919198 [[alternative HTML version deleted]]
Jean V Adams
2012-Jul-26 15:22 UTC
[R] Working with Numbers generated from Regression Output
You can learn a lot from the help files. Check out the help files for the lm() and summary.lm() functions ?lm ?summary.lm You can extract the beta values in a few different ways. These two will give you just the estimates in a vector: coef(result) result$coef These two will give you the estimates and more in a matrix: coef(summary(result)) summary(result)$coef Jean Krunal Nanavati <krunal.nanavati@cogitaas.com> wrote on 07/26/2012 07:28:02 AM:> > Hi, > > I have a query on regression output generated by R. > > > result=lm( Y~X , data=trail) > > summary(result) > > After running this 2 statements the following output is generated. > > Call: > lm(formula = Y ~ X, data = trail) > > Residuals: > Min 1Q Median 3Q Max > -245.30 -90.77 -30.30 54.99 532.78 > > Coefficients: > Estimate Std. Error t value Pr(>|t|) > (Intercept) 245.2982 62.1307 3.948 0.000376 *** > X 0.5192 0.1752 2.963 0.005533 ** > --- > Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 > > Residual standard error: 169.1 on 34 degrees of freedom > Multiple R-squared: 0.2052, Adjusted R-squared: 0.1818 > F-statistic: 8.777 on 1 and 34 DF, p-value: 0.005533 > > From this output, I intend to use the beta values to calculate > elasticities. Is this possible directly in R? > > If not, then when I paste this output in Excel, It is pasted as animage,> and thus I cannot use the beta values for calculating any other metric. > > Can anyone please help me out!!! > > Thanks & Regards, > > Krunal Nanavati > 9769-919198[[alternative HTML version deleted]]
suman kumar
2012-Jul-26 16:07 UTC
[R] Working with Numbers generated from Regression Output
Check str(lmobj). You can see the underlying structure of lm object. It is actually a list. You can access its individual components with $ operator. Bye -- View this message in context: http://r.789695.n4.nabble.com/Working-with-Numbers-generated-from-Regression-Output-tp4637919p4637957.html Sent from the R help mailing list archive at Nabble.com.