3.5 Regression analysis
Finally, let’s run a regression analysis to see if a pirate’s age, weight, and number of tattoos (s)he has predicts how many treasure chests he/she’s found:
# Create a linear regression model: DV = tchests, IV = age, weight, tattoos
tchests.model <- lm(formula = tchests ~ age + weight + tattoos,
data = pirates)
# Show summary statistics
summary(tchests.model)
##
## Call:
## lm(formula = tchests ~ age + weight + tattoos, data = pirates)
##
## Residuals:
## Min 1Q Median 3Q Max
## -33.30 -15.83 -6.86 8.41 119.97
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5.1908 7.1844 0.72 0.47
## age 0.7818 0.1344 5.82 8e-09 ***
## weight -0.0901 0.0718 -1.25 0.21
## tattoos 0.2540 0.2255 1.13 0.26
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 24 on 996 degrees of freedom
## Multiple R-squared: 0.0406, Adjusted R-squared: 0.0377
## F-statistic: 14 on 3 and 996 DF, p-value: 5.75e-09
It looks like the only significant predictor of the number of treasure chests that a pirate has found is his/her age. There does not seem to be significant effect of weight or tattoos.