9
Appendix
# import data file into R
Data <- read.csv("mammalsleeping.csv")
Data <- subset(Data,select = -c(Species))
summary(Data)
## BodyWt BrainWt NonDreaming Dreaming
## Min. : 0.005 Min. : 0.14 Min. : 2.100 Min. :0.000
## 1st Qu.: 0.600 1st Qu.: 4.25 1st Qu.: 6.250 1st Qu.:0.900
## Median : 3.342 Median : 17.25 Median : 8.350 Median :1.800
## Mean : 198.790 Mean : 283.13 Mean : 8.673 Mean :1.972
## 3rd Qu.: 48.203 3rd Qu.: 166.00 3rd Qu.:11.000 3rd Qu.:2.550
## Max. :6654.000 Max. :5712.00 Max. :17.900 Max. :6.600
## NA's :14 NA's :12
## TotalSleep LifeSpan Gestation Index
## Min. : 2.60 Min. : 2.000 Min. : 12.00 Min. : 3.000
## 1st Qu.: 8.05 1st Qu.: 6.625 1st Qu.: 35.75 1st Qu.: 4.250
## Median :10.45 Median : 15.100 Median : 79.00 Median : 6.500
## Mean :10.53 Mean : 19.878 Mean :142.35 Mean : 7.903
## 3rd Qu.:13.20 3rd Qu.: 27.750 3rd Qu.:207.50 3rd Qu.:12.000
## Max. :19.90 Max. :100.000 Max. :645.00 Max. :15.000
## NA's :4 NA's :4 NA's :4
Data <- na.omit(Data)
################
Data = log(Data)
Data <- subset(Data,select = -c(NonDreaming, Dreaming))
mod0 = lm(TotalSleep ~1 , data = Data)
add1(mod0, ~.+BrainWt + LifeSpan + Gestation + BodyWt + Index, data = Data,
test = 'F')
mod1 = lm(TotalSleep ~ BodyWt, data = Data)
add1(mod1, ~.+ Gestation + LifeSpan + BrainWt + Index, data = Data, test =
'F')
mod2 = lm(TotalSleep ~ BodyWt + Index, data = Data)
add1(mod2, ~.+ LifeSpan + Gestation + BrainWt, test = 'F')
mod3 = lm(TotalSleep ~ BodyWt + Gestation + Index, data = Data)
add1(mod3, ~.+ LifeSpan + BrainWt, test = 'F')
mod.final = mod3
summary(mod.final)
##
## Call:
## lm(formula = TotalSleep ~ BodyWt + Gestation + Index, data = Data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.68526 -0.25015 -0.00442 0.22299 0.52962
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.60424 0.31762 11.348 9.08e-14 ***