
Generate prediction table from model
pred_table.RdGenerate a table of predicted values and CIs from an
asreml or glmmTMB model, for
the specified variables asreml or glmmTMB object.
Usage
pred_table(
mod,
classify,
link_fun = "identity",
tmb_component = "cond",
tmb_type = "response",
factor_combine = TRUE,
trt_col_label = "Treatment"
)Arguments
- mod
The model object to get predictions from.
The value may be:
asremlglmmTBM
- classify
charactervector. Variable for which predictions will be made.For
asreml::asreml()models, it is passed toclassifyargument ofasremlPlus::predictPlus.asreml(). For glmmTMB models it is used in thespecsargument ofemmeans::emmeans()- link_fun
charactervector. Specifies the transformation function to apply over the predictions. Only applies forasreml::asreml()objects.The value may be:
"identity"(default)"log""inverse""sqrt""logit""probit""cloglog"
- tmb_component
charactervector. Specifies the component of the glmmTMB model from which to get predictions.The value may be:
"cond"(default)"zi""cmean""response"
- tmb_type
charactervector. Specifies the prediction type for glmmTMB models.Only
"response"is supported at the moment.
- factor_combine
Logical Whether or not to combine the factors in
classifyinto a single column in the output table. IfTRUE(default), the factor levels are concatenated and labelled usingtrt_col_label.- trt_col_label
charactervector. Specifies the label for the combined factor column whenfactor_combineisTRUE. Defaults to"Treatment"
Value
data.frame.
Contains the predicted means, standard errors, and confidence intervals
for the specified variables. Includes the following columns:
- Treatment
The combined factor levels, if
factor_combineisTRUE.- Mean
The predicted mean values.
- Standard Error
The standard errors of the predicted means.
- Lower CL
The lower confidence limits.
- Upper CL
The upper confidence limits.
If factor_combine is FALSE, the factors specified in
classify remain as separate columns.
Author
Matthew Nguyen, matthew.nguyen@curtin.edu.au
Examples
library(CBADASReml)
library(asreml)
library(glmmTMB)
mod1 <- asreml(
fixed = yield ~ Variety + Nitrogen + Variety:Nitrogen,
random = ~ idv(Blocks) + idv(Blocks):idv(Wplots),
residual = ~ idv(units),
data = oats
)
# Zero inflated model
mod2 <- glmmTMB(
count ~ spp * mined + (1|site),
zi = ~ spp * mined,
data = Salamanders,
family = nbinom2
)
#> Warning: Model convergence problem; singular convergence (7). See vignette('troubleshooting'), help('diagnose')
pred_table(mod1, classify = "Variety")
#> Error: Classify must be type character