## Load the sim5 data
data(sim5)
## View the first five entries
head(sim5)
## Explore the variables in sim5
str(sim5)
## Fit the functional group model, with theta, using DI and the FG tag
m1 <- DI(y = "response", prop = 3:11,
FG = c("FG1","FG1","FG1","FG1","FG1","FG2","FG2","FG3","FG3"), DImodel = "FG",
estimate_theta = TRUE, data = sim5)
summary(m1)
CI_95 <- theta_CI(m1, conf = .95)
CI_95
## Graph the profile likelihood
library(ggplot2)
ggplot(m1$profile_loglik, aes(x = grid, y = prof)) +
theme_bw() +
geom_line() +
xlim(0,1.5) +
xlab(expression(theta)) +
ylab("Log-likelihood") +
geom_vline(xintercept = CI_95, lty = 3) +
labs(title = " Log-likelihood versus theta",
caption = "dotted vertical lines are upper and lower bounds of 95% CI for theta")
Run the code above in your browser using DataLab