# Install ISwR if needed
if (!requireNamespace("ISwR", quietly = TRUE)) {
install.packages("ISwR")
}
# Load package and dataset
library(ISwR)
data("cystfibr")
# Multiple linear regression
model <- lm(pemax ~ age + weight + bmp + fev1,
data = cystfibr)
# Regression coefficients, intercept, and R-squared
summary(model)
##
## Call:
## lm(formula = pemax ~ age + weight + bmp + fev1, data = cystfibr)
##
## 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
# ANOVA table
anova(model)
## 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