| plot.HLfit | R Documentation |
This function provides diagnostic plots for residual errors from the mean model and for random effects. Plots for the mean models are similar to those for GLMs. However, "std_dev_res" ended as the type of the residuals plotted by the old version of plot.HLfit instead of the intended "std_dev_rt" (the standardized deviance residuals as described by Lee et al. 2006, p.52), by historical accident and lack of interest for the dubious results even with "std_dev_rt" (see Details). The "RQR" type may be more interesting type, for count data in particular.
Plots for random effects likewise consider standardized values.
## S3 method for class 'HLfit'
plot(x,
which=c("mean","ranef"),
res_type="std_dev_rt",
form = residuals(., type=res_type) ~ fitted(.),
titles = list(
meanmodel=list(outer="Mean model",devres="residuals", absdevres="|residuals|",
resq="Residual quantiles", devreshist="residuals"),
ranef=list(outer="Random effects and leverages",qq="Random effects Q-Q plot",
levphi=expression(paste("Leverages for ",phi)),
levlambda=expression(paste("Leverages for ",lambda)))
),
control = list() , ask=TRUE, ...)
x |
An object of class |
which |
A vector of keywords for different types of plots.
By default, two types of plots are presented on different devices: diagnostic plots for mean values, and diagnostic plots for random effects.
Either one can be selected using this argument. Use keyword |
titles |
A list of the |
control |
A list of default options for the plots. Defaults are |
ask |
Logical; passed to |
res_type |
Character string: the type of residual in the plots, passed to |
form |
Either a formula specifying the desired type of plot for residuals, wherein
the fit object |
... |
Options passed from |
In principle the standardized deviance residuals for the mean model should have a nearly Gaussian distribution hence form a nearly straight line on a Q-Q plot. However this is (trivially) not so for well-specified (nearly-)binary response data nor even for well-specified Poisson response data with moderate expectations. Hence this plot is not so useful. The DHARMa package proposes better-behaved diagnostic plots, but the p-value that appears on one of these plots may not stand for a valid goodness-of-fit test; see instead the gof procedure using the randomized quantile residuals ("RQR"). The current version of DHARMa should handle spaMM fit objects; otherwise, see https://github.com/florianhartig/DHARMa/issues/95 for how to run DHARMa procedures on spaMM output.
Returns the input object invisibly.
Lee, Y., Nelder, J. A. and Pawitan, Y. (2006). Generalized linear models with random effects: unified analysis via h-likelihood. Chapman & Hall: London.
data("blackcap")
fit <- fitme(migStatus ~ 1+ Matern(1|longitude+latitude),data=blackcap,
fixed=list(lambda=1,nu=1,rho=1))
plot(fit)
# compare Q-Q plots for count data
set.seed(123)
dat <- data.frame(
x=(x <- seq(1,2,1/100)),
y=rpois(101, lambda=x)
)
fit <- fitme(y ~ x, family=poisson(), data=dat)
plot(fit, res_type="RQR", which="mean")
plot(fit, which="mean")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.