##################################### # Low Birth Weight Analysis Using R # ##################################### lowbwt <- read.table("lowbwt.data.txt",header=TRUE) sbp <- lowbwt[,1] gender <- lowbwt[,2] tox <- lowbwt[,3] grhem <- lowbwt[,4] gestage <- lowbwt[,5] apgar5 <- lowbwt[,6] mreg1.results <- lm(sbp ~ gestage + apgar5) print(summary(mreg1.results)) print(predict(mreg1.results, list(gestage=c(31),apgar5=c(7)), interval="confidence", se.fit=TRUE)) mreg2.results <- lm(sbp ~ gestage + apgar5 + gender) print(summary(mreg2.results)) print(predict(mreg2.results, list(gestage=c(31,31),apgar5=c(7,7),gender=c(0,1)), interval="confidence", se.fit=TRUE)) ############################ # Output of above analysis # ############################ Call: lm(formula = sbp ~ gestage + apgar5) Residuals: Min 1Q Median 3Q Max -22.374 -8.180 -1.088 4.985 39.424 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 9.8034 12.6629 0.774 0.4407 gestage 1.1848 0.4424 2.678 0.0087 ** apgar5 0.4875 0.4613 1.057 0.2932 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 10.99 on 97 degrees of freedom Multiple R-squared: 0.08944, Adjusted R-squared: 0.07066 F-statistic: 4.764 on 2 and 97 DF, p-value: 0.01063 $fit fit lwr upr 1 49.94562 47.07655 52.81469 $se.fit [1] 1.445578 $df [1] 97 $residual.scale [1] 10.99297 Call: lm(formula = sbp ~ gestage + apgar5 + gender) Residuals: Min 1Q Median 3Q Max -21.854 -7.996 -1.046 5.092 38.737 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 9.3235 12.7371 0.732 0.46595 gestage 1.1853 0.4440 2.670 0.00892 ** apgar5 0.4747 0.4635 1.024 0.30840 gender 1.2434 2.2253 0.559 0.57764 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 11.03 on 96 degrees of freedom Multiple R-squared: 0.09239, Adjusted R-squared: 0.06403 F-statistic: 3.257 on 3 and 96 DF, p-value: 0.02494 $fit fit lwr upr 1 49.38987 45.89836 52.88137 2 50.63322 46.85702 54.40943 $se.fit 1 2 1.758960 1.902385 $df [1] 96 $residual.scale [1] 11.03215 ############################ # lowbwt.txt file contents # ############################ sbp gender tox grmhem gestage apgar5 43 1 0 0 29 7 51 1 0 0 31 8 42 0 0 0 33 0 39 0 0 0 31 8 48 0 1 0 30 7 31 1 0 1 25 0 31 1 1 0 27 7 40 0 0 0 29 9 57 0 0 0 28 6 64 0 1 0 29 9 46 0 0 0 26 7 47 0 0 1 30 6 63 0 0 0 29 8 56 0 0 0 29 1 49 1 0 0 29 8 87 1 0 0 29 7 46 0 0 0 29 8 66 0 0 0 33 8 42 0 1 0 33 8 52 0 0 0 29 7 51 1 0 0 28 7 47 0 0 0 30 9 54 1 0 0 27 4 64 1 0 0 33 9 37 0 0 0 32 7 36 1 1 0 28 3 45 0 0 1 29 7 39 1 0 0 28 7 29 0 0 0 29 4 61 0 0 0 30 3 53 1 0 0 31 7 64 0 0 0 30 7 35 0 0 0 31 6 34 1 0 0 29 9 62 0 0 0 27 7 59 0 0 0 27 8 36 1 0 0 27 9 47 0 0 0 32 8 45 1 0 1 31 2 62 0 0 1 28 5 75 1 1 0 30 7 44 1 0 0 29 0 39 1 0 0 28 8 48 0 0 1 31 7 43 0 1 0 27 6 19 0 0 1 25 4 63 1 0 0 30 7 42 1 0 0 28 6 44 0 0 0 28 9 25 0 0 0 25 8 26 0 0 0 23 8 27 1 0 0 27 9 35 1 0 0 28 8 40 1 0 0 27 7 44 0 0 0 27 6 66 1 0 0 26 8 59 0 0 0 25 3 24 0 0 0 23 7 40 0 0 1 26 3 49 0 0 0 24 5 53 1 1 0 29 9 45 0 0 0 29 9 50 1 0 1 27 8 64 1 0 0 30 7 48 0 0 0 30 6 48 0 0 1 32 4 58 0 1 0 33 7 67 0 0 0 27 8 40 0 0 1 31 8 48 0 0 0 26 8 36 1 0 0 27 5 44 1 0 0 27 6 53 0 1 0 35 9 45 0 1 0 28 6 54 1 0 0 30 8 44 1 1 0 31 2 42 1 0 0 30 5 50 0 0 0 27 0 48 0 0 0 25 5 29 0 0 1 25 5 30 0 0 1 26 2 36 0 0 0 29 0 44 0 0 0 29 0 46 0 1 0 34 9 51 1 1 0 30 4 51 1 0 0 29 5 43 1 1 0 33 7 48 1 0 0 30 5 52 1 0 0 29 8 43 1 0 0 24 6 42 1 1 0 33 8 48 1 0 1 25 5 49 0 1 0 32 8 62 1 1 0 31 7 45 1 0 0 31 9 51 0 1 1 31 6 52 1 0 0 29 8 47 1 1 0 32 5 40 0 1 0 33 8 50 0 0 0 28 7