mcmcsamp {lme4} | R Documentation |
This generic function generates a sample from the posterior distribution of the parameters of a fitted model using Markov Chain Monte Carlo methods.
mcmcsamp(object, n, verbose, ...)
object |
An object of a suitable class - usually an
lmer or glmer object.
|
n |
integer - number of samples to generate. Defaults to 1. |
verbose |
logical - if TRUE verbose output is printed.
Defaults to FALSE . |
... |
Some methods for this generic function may take
additional, optional arguments. The method for
lmer objects takes the optional argument
saveb which, if TRUE , causes the values of the random
effects in each sample to be saved. Note that this can result in
very large objects being saved. Use with caution. A second optional
argument is trans which, if TRUE (the default), returns
a sample of transformed parameters. All variances are expressed on
the logarithm scale and any covariances are converted to Fisher's "z"
transformation of the corresponding correlation. |
An object of (S3) class "mcmc"
suitable for use with the
functions in the "coda" package.
(fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)) set.seed(101) samp1 <- mcmcsamp(fm1, n = 1000) if (require("coda", quietly = TRUE, character.only = TRUE)) { densityplot(samp1) qqmath(samp1) xyplot(samp1, scales = list(x = list(axs = 'i'))) print(summary(samp1)) print(autocorr.diag(samp1)) } (eDF <- mean(samp1[,"deviance"]) - deviance(fm1, REML=FALSE)) # potentially useful approximate D.F.