Dear all, How can I covert lm data to text in the form of "y=ax+b, r2" and how do I calculate R-squared(r2)? Thanks. Code: x=18:29 y=c(7.1,7,7.7,8.2,8.8,9.7,9.9,7.1,7.2,8.8,8.7,8.5) res=lm(y~x) -- View this message in context: http://r.789695.n4.nabble.com/Howto-convert-Linear-Regression-data-to-text-tp3766230p3766230.html Sent from the R help mailing list archive at Nabble.com.
Howto convert Linear Regression data to text
3 messages · ashz, Brad Patrick Schneid, PIKAL Petr
If I understand you correctly, see ?paste and the following to extract the values you require: summary(res)[[4]][1] summary(res)[[4]][2] summary(res)[[8]] HTH
ashz wrote:
Dear all, How can I covert lm data to text in the form of "y=ax+b, r2" and how do I calculate R-squared(r2)? Thanks. Code: x=18:29 y=c(7.1,7,7.7,8.2,8.8,9.7,9.9,7.1,7.2,8.8,8.7,8.5) res=lm(y~x)
-- View this message in context: http://r.789695.n4.nabble.com/Howto-convert-Linear-Regression-data-to-text-tp3766230p3767009.html Sent from the R help mailing list archive at Nabble.com.
Dear all, How can I covert lm data to text in the form of "y=ax+b, r2" and how do
I
calculate R-squared(r2)? Thanks. Code: x=18:29 y=c(7.1,7,7.7,8.2,8.8,9.7,9.9,7.1,7.2,8.8,8.7,8.5) res=lm(y~x)
I am not sure what do you mean by text. There are some lm extraction
functions for evaluating your results which you can use in some paste
construction according to your wished formating.
summary(res)
Call:
lm(formula = y ~ x)
Residuals:
Min 1Q Median 3Q Max
-1.27448 -0.62684 -0.07483 0.35079 1.62517
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 5.88322 1.97455 2.980 0.0138 *
x 0.09965 0.08313 1.199 0.2583
---
Signif. codes: 0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1
Residual standard error: 0.9941 on 10 degrees of freedom
Multiple R-squared: 0.1256, Adjusted R-squared: 0.0382
F-statistic: 1.437 on 1 and 10 DF, p-value: 0.2583
summary(res)$r.squared
[1] 0.1256375
coef(res)
(Intercept) x 5.88321678 0.09965035 Regards Petr
-- View this message in context:
http://r.789695.n4.nabble.com/Howto-convert-
Linear-Regression-data-to-text-tp3766230p3766230.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.