PredictGLMER | R Documentation |
Generates predicted values from a generalized linear mixed-effects model and a data frame with values of the explanatory variables
PredictGLMER(model,data,se.fit=FALSE,seMultiplier = 1.96)
model |
A mixed-effects model, of class 'lmerMod' or 'glmerMod' |
data |
A data frame containing values of the explanatory variables for which to make predictions |
se.fit |
Whether to estimate uncertainty around the predictions (default is False) |
seMultiplier |
The multiplier to apply to the uncertainty estimates (default is 1.96, which generates 95 |
Code for calculating predicted values and confidence intervals was taken from the GLMM wiki (see references).
A data frame either containing a single column 'y', when uncertainty is not calculated, or 3 columns ('y', 'yplus' and 'yminus'), when uncertainty is calculated
Tim Newbold <t.newbold@ucl.ac.uk>
http://glmm.wikidot.com/faq
# Load example data (site-level effects of land use on biodiversity from the PREDICTS database)
data(PREDICTSSiteData)
# Run a model of species richness as a function of land use, human population density
# and distance to nearest road (with an interaction between human population density
# and road distance)
m1 <- GLMER(modelData = PREDICTSSites,responseVar = "Species_richness",fitFamily = "poisson",
fixedStruct = "LandUse",randomStruct = "(1|SS)+(1|SSB)+(1|SSBS)",REML = TRUE)
predDat <- data.frame(LandUse=factor(c("Primary Vegetation","Secondary Vegetation",
"Plantation forest","Cropland","Pasture","Urban"),levels=levels(m1$data$LandUse)),
Species_richness=0)
# Generate predicted values for each land use, with uncertainty of 1 standard error
# about the predicted mean values
preds <- PredictGLMER(preds <- PredictGLMER(model = m1$model,data = predDat,
se.fit = TRUE,seMultiplier = 1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.