Average predictions from several (non)linear models based on IC weights
Computes weights based on AIC, AICc, or BIC and it generates weighted predictions by the relative value of the IC values
predict function for objects of class gam
predict_nls( ..., criteria = c("AIC", "AICc", "BIC"), interval = c("none", "confidence", "prediction"), level = 0.95, nsim = 1000, resid.type = c("none", "resample", "normal", "wild"), newdata = NULL ) predict_gam( ..., criteria = c("AIC", "AICc", "BIC"), interval = c("none", "confidence", "prediction"), level = 0.95, nsim = 1000, resid.type = c("none", "resample", "normal", "wild"), newdata = NULL )
... |
‘nls’ or ‘lm’ objects (‘glm’ and ‘gam’ objects inherit ‘lm’). |
criteria |
either ‘AIC’, ‘AICc’ or ‘BIC’. |
interval |
either ‘none’, ‘confidence’ or ‘prediction’. |
level |
probability level for the interval (default 0.95) |
nsim |
number of simulations to perform for intervals. Default 1000. |
resid.type |
either ‘none’, “resample”, “normal” or “wild”. |
newdata |
new data frame for predictions |
numeric vector of the same length as the fitted object.
all the objects should be fitted to the same data. Weights are
based on the chosen IC value (exp(-0.5 * IC)).
For models of class gam
there is very limited support.
## Example require(ggplot2) require(mgcv) data(barley, package = "nlraa") fm.L <- lm(yield ~ NF, data = barley) fm.Q <- lm(yield ~ NF + I(NF^2), data = barley) fm.A <- nls(yield ~ SSasymp(NF, Asym, R0, lrc), data = barley) fm.LP <- nls(yield ~ SSlinp(NF, a, b, xs), data = barley) fm.QP <- nls(yield ~ SSquadp3(NF, a, b, c), data = barley) fm.BL <- nls(yield ~ SSblin(NF, a, b, xs, c), data = barley) fm.G <- gam(yield ~ s(NF, k = 6), data = barley) ## Print the table with weights IC_tab(fm.L, fm.Q, fm.A, fm.LP, fm.QP, fm.BL, fm.G) ## Each model prediction is weighted according to their AIC values prd <- predict_nls(fm.L, fm.Q, fm.A, fm.LP, fm.QP, fm.BL, fm.G) ggplot(data = barley, aes(x = NF, y = yield)) + geom_point() + geom_line(aes(y = fitted(fm.L), color = "Linear")) + geom_line(aes(y = fitted(fm.Q), color = "Quadratic")) + geom_line(aes(y = fitted(fm.A), color = "Asymptotic")) + geom_line(aes(y = fitted(fm.LP), color = "Linear-plateau")) + geom_line(aes(y = fitted(fm.QP), color = "Quadratic-plateau")) + geom_line(aes(y = fitted(fm.BL), color = "Bi-linear")) + geom_line(aes(y = fitted(fm.G), color = "GAM")) + geom_line(aes(y = prd, color = "Avg. Model"), size = 1.2)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.