mass<-read.csv(url("http://cknudson.com/data/mussels.csv"))
attach(mass)
mmod<-lm(AvgAmmonia~AvgMass+attached,mass)
mmod
##
## Call:
## lm(formula = AvgAmmonia ~ AvgMass + attached, data = mass)
##
## Coefficients:
## (Intercept) AvgMass attachedRock
## 0.001140 0.239279 -0.002563
summary(mmod)
##
## Call:
## lm(formula = AvgAmmonia ~ AvgMass + attached, data = mass)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.019e-03 -5.240e-04 -5.959e-05 3.429e-04 2.526e-03
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.0011398 0.0005533 2.060 0.05 *
## AvgMass 0.2392793 0.0215863 11.085 3.86e-11 ***
## attachedRock -0.0025629 0.0003931 -6.519 7.91e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.00103 on 25 degrees of freedom
## Multiple R-squared: 0.8574, Adjusted R-squared: 0.846
## F-statistic: 75.18 on 2 and 25 DF, p-value: 2.66e-11
head(mass)
## GroupID dry.mass count attached lipid protein carbo ash Kcal ammonia
## 1 1 0.55 20 Rock 8.14 47.43 21.59 5.51 3.61 0.07
## 2 2 0.45 19 Rock 9.34 53.89 23.41 6.34 4.06 0.07
## 3 3 0.37 20 Rock 9.12 49.01 21.10 5.63 3.74 0.07
## 4 4 0.63 20 Rock 10.32 49.25 16.55 5.41 3.66 0.11
## 5 5 0.57 20 Rock 10.08 50.17 17.51 6.10 3.72 0.11
## 6 6 0.57 22 Rock 10.83 53.84 19.97 6.36 4.04 0.11
## O2 AvgAmmonia AvgO2 AvgMass
## 1 0.82 0.00350000 0.04100 0.027500
## 2 0.70 0.00368421 0.03684 0.023684
## 3 0.62 0.00350000 0.03100 0.018500
## 4 0.89 0.00550000 0.04450 0.031500
## 5 1.09 0.00550000 0.05450 0.028500
## 6 1.00 0.00500000 0.04545 0.025909
mcoef<-coef(summary(mmod))[2,1]/coef(summary(mmod))[2,2]
mcoef
## [1] 11.08476
# with the T of 3.430024, we can compute the probabily of this occuring with 25 degrees of freedom.
confint(mmod)
## 2.5 % 97.5 %
## (Intercept) 1.999745e-07 0.002279427
## AvgMass 1.948215e-01 0.283737200
## attachedRock -3.372584e-03 -0.001753235
#We are 95% confident that for any given average mass, the count would be between .000034 and .000129
newdata<-data.frame(AvgMass=.05, attached="Rock")
predy<-predict(mmod,newdata,interval="predict")
predy
## fit lwr upr
## 1 0.01054087 0.008065655 0.01301609
#This tells us that we are 95% confident that for any given average mass, the average
#count will be between 73.31 and 82.86