Load required packages

library(tidyverse)
library(ggplot2)
library(lme4)
library(broom)
library(ggthemes)
install.packages("MuMIn")
library(MuMIn)
library(Matrix)
devtools::load_all(".")

Plot linear model

#library(lme4)
c <- lmer(log.oy ~ log.ml + (log.ml | order), data = mammals_sub)
summary(c)
lme4::ranef(c)
library(broom)
tidy(c, conf.int = TRUE)
broom::augment(c) %>%
    ggplot(aes(x = log.ml, y = .fixed)) +
    geom_line() +
    geom_point(aes(x = log.ml, y = log.oy, color = order), alpha = 0.15) +
    geom_line(aes(y = .fitted, color = order), alpha = 0.8) + 
    team_theme()

Plot the general linear model

base <- glm(log.oy ~ log.ml , data=mammals_sub)
summary(base)
tidy(c, conf.int=TRUE)
broom::augment(base) %>%
    ggplot(aes(x=log.ml, y=.fitted)) +
    geom_line() +
    geom_point(aes(x=log.ml, y=log.oy)) +
    geom_line(aes(y=.fitted)) + 
    team_theme()

Rank the fit of the models

MuMIn::model.sel(c, base, rank=AIC)


UofTCoders/eeb430.2017.Python documentation built on May 28, 2019, 3:19 p.m.