# \donttest{
require(nlme)
require(ggplot2)
## Fit a simple model and then compute IAs
data(swpg)
#' ## Linear model
fit0 <- lm(lfgr ~ ftsw + I(ftsw^2), data = swpg)
ias0 <- IA_tab(object = fit0)
ias0$IA_tab
## Nonlinear model
fit1 <- nls(lfgr ~ SSblin(ftsw, a, b, xs, c), data = swpg)
ias1 <- IA_tab(object = fit1)
ias1$IA_tab
plot(ias1)
## Linear Mixed Models
data(barley, package = "nlraa")
fit2 <- lme(yield ~ NF + I(NF^2), random = ~ 1 | year, data = barley)
ias2 <- IA_tab(object = fit2)
ias2$IA_tab
## Nonlinear Mixed Model
barleyG <- groupedData(yield ~ NF | year, data = barley)
fit3L <- nlsLMList(yield ~ SSquadp3(NF, a, b, c), data = barleyG)
fit3 <- nlme(fit3L, random = pdDiag(a + b ~ 1))
ias3 <- IA_tab(object = fit3)
ias3$IA_tab
plot(ias3)
## Plotting model
prds <- predict_nlme(fit3, interval = "conf", plevel = 0)
barleyGA <- cbind(barleyG, prds)
ggplot(data = barleyGA, aes(x = NF, y = yield)) +
geom_point() +
geom_line(aes(y = Estimate)) +
geom_ribbon(aes(ymin = Q2.5, ymax = Q97.5),
fill = "purple", alpha = 0.2)
## R2M for model 2
R2M(fit2)
## R2M for model 3
R2M(fit3)
# }
Run the code above in your browser using DataLab