library(Sleuth3)
str(ex0722)
## 'data.frame': 38 obs. of 3 variables:
## $ Force : num 3.2 6.4 2 2 4.9 3 2.9 9.5 4 3.4 ...
## $ Height : num 5 6 6.4 6.5 6.6 7 7.9 7.9 8 8.2 ...
## $ Species: Factor w/ 3 levels "Cancer productus",..: 2 2 2 2 2 2 2 2 2 2 ...
library(ggplot2)
`?`(ex0722)
qplot(log(Height), log(Force), data = ex0722, colour = Species, shape = Species)
fitex0722 <- lm(log(Force) ~ log(Height) + Species + log(Height):Species, data = ex0722)
summary(fitex0722)
##
## Call:
## lm(formula = log(Force) ~ log(Height) + Species + log(Height):Species,
## data = ex0722)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.7668 -0.2851 -0.0231 0.2425 0.8882
##
## Coefficients:
## Estimate Std. Error t value
## (Intercept) -1.967 1.449 -1.36
## log(Height) 2.068 0.621 3.33
## SpeciesHemigrapsus nudus 2.486 1.761 1.41
## SpeciesLophopanopeus bellus -1.813 1.853 -0.98
## log(Height):SpeciesHemigrapsus nudus -1.660 0.789 -2.10
## log(Height):SpeciesLophopanopeus bellus 0.905 0.830 1.09
## Pr(>|t|)
## (Intercept) 0.1840
## log(Height) 0.0022 **
## SpeciesHemigrapsus nudus 0.1675
## SpeciesLophopanopeus bellus 0.3354
## log(Height):SpeciesHemigrapsus nudus 0.0433 *
## log(Height):SpeciesLophopanopeus bellus 0.2837
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.433 on 32 degrees of freedom
## Multiple R-squared: 0.795, Adjusted R-squared: 0.762
## F-statistic: 24.8 on 5 and 32 DF, p-value: 3.94e-10
confint(fitex0722)
## 2.5 % 97.5 %
## (Intercept) -4.9187 0.98411
## log(Height) 0.8039 3.33299
## SpeciesHemigrapsus nudus -1.0997 6.07255
## SpeciesLophopanopeus bellus -5.5879 1.96236
## log(Height):SpeciesHemigrapsus nudus -3.2671 -0.05313
## log(Height):SpeciesLophopanopeus bellus -0.7858 2.59617
ex0722$Species <- relevel(ex0722$Species, ref = "Hemigrapsus nudus")
fitex0722.1 <- lm(log(Force) ~ log(Height) + Species + log(Height):Species,
data = ex0722)
summary(fitex0722.1)
##
## Call:
## lm(formula = log(Force) ~ log(Height) + Species + log(Height):Species,
## data = ex0722)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.7668 -0.2851 -0.0231 0.2425 0.8882
##
## Coefficients:
## Estimate Std. Error t value
## (Intercept) 0.519 1.000 0.52
## log(Height) 0.408 0.487 0.84
## SpeciesCancer productus -2.486 1.761 -1.41
## SpeciesLophopanopeus bellus -4.299 1.528 -2.81
## log(Height):SpeciesCancer productus 1.660 0.789 2.10
## log(Height):SpeciesLophopanopeus bellus 2.565 0.735 3.49
## Pr(>|t|)
## (Intercept) 0.6073
## log(Height) 0.4079
## SpeciesCancer productus 0.1675
## SpeciesLophopanopeus bellus 0.0083 **
## log(Height):SpeciesCancer productus 0.0433 *
## log(Height):SpeciesLophopanopeus bellus 0.0014 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.433 on 32 degrees of freedom
## Multiple R-squared: 0.795, Adjusted R-squared: 0.762
## F-statistic: 24.8 on 5 and 32 DF, p-value: 3.94e-10
confint(fitex0722.1)
## 2.5 % 97.5 %
## (Intercept) -1.51793 2.556
## log(Height) -0.58337 1.400
## SpeciesCancer productus -6.07255 1.100
## SpeciesLophopanopeus bellus -7.41212 -1.186
## log(Height):SpeciesCancer productus 0.05313 3.267
## log(Height):SpeciesLophopanopeus bellus 1.06743 4.063