knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
Install the mammals milk package if needed.
# install_github("brouwern/mammalsmilk")
You can then load the package with library()
library(mammalsmilk)
The example data is milk_primates
data("milk_primates")
Log transformation makes things more linear.
#this could be done with dplyr::mutate() too milk_primates$mass.fem.log <- log(milk_primates$mass.fem)
library(ggplot2) library(ggpubr) library(cowplot) library(bbmle) library(broom)
Fit 2 models
lm.null <- lm(fat ~ 1, data = milk_primates)
lm.mass <- lm(fat ~ mass.fem.log, data = milk_primates)
The mean fat value is 8.6
summary(milk_primates[,"fat"])
plot
Nested Models:
Ho: y ~ 0*log(mass) + 8.6
Ha has TWO parameters (aka coefficients, betas)
r round(coef(lm.mass)[1],3)
#NOTE: order w/in anova() doesn't matter anova(lm.null, lm.mass)
The AIC() command in base R.
AIC(lm.null,
lm.mass)
AICtab() from the bbmle package is super handy. Can give AIC and dAIC. Also can do AICc (see below).
bbmle::AICtab(lm.null, lm.mass, base = T)
bbmle::ICtab(lm.null, lm.mass, type = c("AICc"), base = T)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.