Rforch11 - R Material for Chapter 11 > dbp.data age dbp...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
R Material for Chapter 11 > dbp.data ## Our Data age dbp 1 27 73 2 21 66 3 22 63 4 24 75 5 25 71 6 23 70 7 20 65 8 20 70 9 29 79 10 24 72 11 25 68 12 28 67 13 26 79 14 38 91 15 32 76 16 33 69 17 31 66 18 34 73 19 37 78 20 38 87 21 33 76 22 35 79 23 30 73 24 31 80 25 37 68 26 39 75 27 46 89 28 49 101 29 40 70 30 42 72 31 43 80 32 46 83 33 43 75 34 44 71 35 46 80 36 47 96 37 45 92 38 49 80 39 48 70 40 40 90 41 42 85 42 55 76 43 54 71 44 57 99 45 52 86 46 53 79 47 56 92 48 52 85 49 50 71 50 59 90 51 50 91 52 52 100 53 58 80 54 57 109 > attach(dbp.data) > lm.dbp <- lm(dbp~age)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
> summary(lm.dbp) Call: lm(formula = dbp ~ age) Residuals: Min 1Q Median 3Q Max -16.47859 -5.78765 -0.07844 5.61173 19.78132 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 56.15693 3.99367 14.061 < 2e-16 *** age 0.58003 0.09695 5.983 2.05e-07 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 8.146 on 52 degrees of freedom Multiple R-squared: 0.4077, Adjusted R-squared: 0.3963 F-statistic: 35.79 on 1 and 52 DF, p-value: 2.050e-07 Weighted Least Squares: > res <- residuals(lm.dbp) ## residuals from the fit > plot(age,res) ## scatter plot of the residuals vs age > abres <- abs(res) ## absolute values of the residuals > reg2 <- lm(abres~age) ## regressing the absolute values on age > fit <- fitted(reg2) ## the fitted values from that regression > wt <- fit^-2 ## weights equal to 1/(square of fitted value) > wreg <- lm(dbp~age,weights=wt) ## weighted least squares regression > summary(wreg) Call: lm(formula = dbp ~ age, weights = wt) Residuals: Min 1Q Median 3Q Max -2.0230 -0.9939 -0.0327 0.9250 2.2008 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 55.56577 2.52092 22.042 < 2e-16 *** age 0.59634 0.07924 7.526 7.19e-10 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 1.213 on 52 degrees of freedom Multiple R-squared: 0.5214, Adjusted R-squared: 0.5122 F-statistic: 56.64 on 1 and 52 DF, p-value: 7.187e-10
Background image of page 2
> bfat.data tric thigh midarm bfat ## the data 1 19.5 43.1 29.1 11.9 2 24.7 49.8 28.2 22.8 3 30.7 51.9 37.0 18.7 4 29.8 54.3 31.1 20.1 5 19.1 42.2 30.9 12.9 6 25.6 53.9 23.7 21.7 7 31.4 58.5 27.6 27.1 8 27.9 52.1 30.6 25.4 9 22.1 49.9 23.2 21.3 10 25.5 53.5 24.8 19.3 11 31.1 56.6 30.0 25.4 12 30.4 56.7 28.3 27.2 13 18.7 46.5 23.0 11.7 14 19.7 44.2 28.6 17.8 15 14.6 42.7 21.3 12.8 16 29.5 54.4 30.1 23.9 17 27.7 55.3 25.7 22.6 18 30.2 58.6 24.6 25.4 19 22.7 48.2 27.1 14.8 20 25.2 51.0 27.5 21.1 > attach(bfat.data) > regbf <- lm(bfat~tric+thigh+midarm) > summary(regbf) Call: lm(formula = bfat ~ tric + thigh + midarm) Residuals: Min 1Q Median 3Q Max -3.7263 -1.6111 0.3923 1.4656 4.1277 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 117.085 99.782 1.173 0.258 tric 4.334 3.016 1.437 0.170 thigh -2.857 2.582 -1.106 0.285 midarm -2.186 1.595 -1.370 0.190 Residual standard error: 2.48 on 16 degrees of freedom Multiple R-squared: 0.8014,
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 10

Rforch11 - R Material for Chapter 11 &gt; dbp.data age dbp...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online