The GAM of Furrycat’s data shows a strong relationship between speed and courage.
model <- gam(
formula = speed ~
s(hardiness) +
s(fortitude) +
s(dexterity) +
s(endurance) +
s(intellect) +
s(cleverness) +
s(courage) +
s(dependability) +
s(power) +
s(fierceness) +
armor,
family = gaussian(),
data = normalized_df
)
##
## Family: gaussian
## Link function: identity
##
## Formula:
## speed ~ s(hardiness) + s(fortitude) + s(dexterity) + s(endurance) +
## s(intellect) + s(cleverness) + s(courage) + s(dependability) +
## s(power) + s(fierceness) + armor
##
## Parametric coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.0717581 0.0009879 2097.188 <2e-16 ***
## armor 0.0056898 0.0028213 2.017 0.0445 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Approximate significance of smooth terms:
## edf Ref.df F p-value
## s(hardiness) 1.000 1.000 0.747 0.388
## s(fortitude) 1.000 1.000 1.081 0.299
## s(dexterity) 1.000 1.000 0.022 0.883
## s(endurance) 1.173 1.325 0.600 0.599
## s(intellect) 1.810 2.293 0.765 0.396
## s(cleverness) 1.000 1.000 0.299 0.585
## s(courage) 6.974 7.999 1140.548 <2e-16 ***
## s(dependability) 6.511 7.673 1.307 0.233
## s(power) 1.000 1.000 1.114 0.292
## s(fierceness) 1.152 1.287 0.090 0.803
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## R-sq.(adj) = 0.982 Deviance explained = 98.3%
## GCV = 0.00024299 Scale est. = 0.00022682 n = 370
This is easy to see with the graph.
ggplot(normalized_df, aes(x = courage, y = speed)) +
geom_point() +
ggtitle("Courage vs Speed")
And GAM shows a linear relationship.
plot(model, select = 7)
The linear model shows high correlation and low residuals.
model <- lm(speed ~ courage, data = normalized_df)
summary(model)
##
## Call:
## lm(formula = speed ~ courage, data = normalized_df)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.176062 -0.002234 0.000852 0.003135 0.198289
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.487e+00 3.730e-03 666.7 <2e-16 ***
## courage -9.821e-04 8.544e-06 -114.9 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.01862 on 368 degrees of freedom
## Multiple R-squared: 0.9729, Adjusted R-squared: 0.9728
## F-statistic: 1.321e+04 on 1 and 368 DF, p-value: < 2.2e-16
And looks like this.
Speed is roughly captured by the following formula, \(speed \approx 2.5 - courage / 1000\).