My experience #10

For my adv stat assignment, I worked with a dataset with the goal to use multiple linear regression and ANOVA to see how age, weight, bmp, and fev1 relate to pemax.

##Load the ISwR package

library(ISwR)

## Load the cystfibr dataset data

(“cystfibr”, package = “ISwR”)

Output:

age sex height weight bmp fev1  rv frc tlc pemax

1    7   0    109   13.1  68   32 258 183 137    95

2    7   1    112   12.9  65   19 449 245 134    85

3    8   0    124   14.1  64   22 441 268 147   100

4    8   1    125   16.2  67   41 234 146 124    85

5    8   0    127   21.5  93   52 202 131 104    95

6    9   0    130   17.5  68   44 308 155 118    80

7   11   1    139   30.7  89   28 305 179 119    65

8   12   1    150   28.4  69   18 369 198 103   110

9   12   0    146   25.1  67   24 312 194 128    70

10  13   1    155   31.5  68   23 413 225 136    95

11  13   0    156   39.9  89   39 206 142  95   110

12  14   1    153   42.1  90   26 253 191 121    90

13  14   0    160   45.6  93   45 174 139 108   100

14  15   1    158   51.2  93   45 158 124  90    80

15  16   1    160   35.9  66   31 302 133 101   134

16  17   1    153   34.8  70   29 204 118 120   134

17  17   0    174   44.7  70   49 187 104 103   165

18  17   1    176   60.1  92   29 188 129 130   120

19  17   0    171   42.6  69   38 172 130 103   130

20  19   1    156   37.2  72   21 216 119  81    85

21  19   0    174   54.6  86   37 184 118 101    85

22  20   0    178   64.0  86   34 225 148 135   160

23  23   0    180   73.8  97   57 171 108  98   165

24  23   0    175   51.1  71   33 224 131 113    95

25  23   0    179   71.5  95   52 225 127 101   195

##Create the multiple linear regression model

model <- lm(pemax ~ age + weight + bmp + fev1, data = cystfibr)

summary(model)

Output:

Residuals:

Min      1Q  Median      3Q     Max

-42.521 -10.885   3.003  15.488  41.767

Coefficients:

Estimate Std. Error t value Pr(>|t|)  

(Intercept) 179.2957    61.8855   2.897  0.00891 **

age          -3.4181     3.3086  -1.033  0.31389  

weight        2.6882     1.1727   2.292  0.03287 *

bmp          -2.0657     0.8198  -2.520  0.02036 *

fev1          1.0882     0.5139   2.117  0.04695 *

Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 23.4 on 20 degrees of freedom

Multiple R-squared:  0.5918,              Adjusted R-squared:  0.5101

F-statistic: 7.248 on 4 and 20 DF,  p-value: 0.0008891

This means that weight and fev1 had a positive relationship with pemax, while age and bmp had a negative relationship when the other variables were held constant.

Weight, bmp, and fev1 were statistically significant because their p-values were below 0.05. Age was not statistically significant because its p-value was 0.3139. The R-squared value was 0.5918, meaning that about 59.2% of the variation in pemax can be explained by age, weight, bmp, and fev1. The overall regression model was also statistically significant because the p-value was 0.0008891.

Run the ANOVA for the regression model

anova(model)

Output:

Analysis of Variance Table

Response: pemax

Df  Sum Sq Mean Sq F value    Pr(>F)   

age        1 10098.5 10098.5 18.4385 0.0003538 ***

weight     1   945.2   945.2  1.7258 0.2038195   

bmp        1  2379.7  2379.7  4.3450 0.0501483 . 

fev1       1  2455.6  2455.6  4.4836 0.0469468 * 

Residuals 20 10953.7   547.7                     

—

Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

The ANOVA results were slightly different from the regression results. Age was statistically significant with a p-value of 0.0003538, while weight was not significant with a p-value of 0.2038. BMP was very close to the 0.05 cutoff with a p-value of 0.0501, and fev1 was statistically significant with a p-value of 0.0469.

Overall, the results show that the variables in the model explain a good amount of the variation in pemax. The regression results showed that weight, bmp, and fev1 were significant predictors when the other variables were held constant. The ANOVA results showed that age and fev1 were significant.

Leave a Reply