Learn R Programming

languageR (version 1.0)

pvals.fnc: Compute p-values and MCMC confidence intervals for mixed models

Description

This function calculates p-values and HPD intervals for the parameters of models fitted with lmer. For the fixed-effects parameters, anticonservative p-values based on the t statistic with the upper bound for the degrees of freedom are added.

Usage

pvals.fnc(object, nsim = 10000, ndigits = 4, withMCMC = FALSE, 
addPlot=TRUE, ...)

Arguments

object
An lmer or glmer model object fitted with lmer. Currently, MCMC sampling for generalized linear mixed models may not work off the shelf when there is more than one random intercept in the model. The code for random effects
nsim
An integer denoting the required number of Markov chain Monte Carlo samples.
ndigits
An integer denoting the number of decimal digits in the output.
withMCMC
A logical indicating whether the output of mcmcsamp should be returned.
addPlot
If TRUE (default), a trellis graph for the posterior distributions of the parameters is shown on the current graphics device.
...
Optional arguments that can be passed down.

Value

  • A list with components
  • fixedA data frame with the estimated coefficients, their MCMC mean, the HPD 95 and the probability based on the t distribution with the number of observations minus the number of fixed-effects coefficients as degrees of freedom. This last p-value is anti-conservative, especially for small data sets.
  • randomA table with the MCMC means and HPD 95 for the standard deviations and correlations of the random effects. The HPD intervals are based on the untransformed values (log for standard deviations, atanhs for correlations), the endpoints of the HPD interval are back-transformed to the scale of the input data frame for ease of interpretation.
  • mcmcThe output of mcmcsamp.

See Also

See also lmer, mcmcsamp, and HPDinterval.

Examples

Run this code
data(primingHeid) 
  library(lme4, keep.source=FALSE)

  # remove extreme outliers
  primingHeid = primingHeid[primingHeid$RT < 7.1,]

  # fit mixed-effects model

  primingHeid.lmer = lmer(RT ~ RTtoPrime * ResponseToPrime + 
    Condition + (1|Subject) + (1|Word), data = primingHeid)

  mcmc = pvals.fnc(primingHeid.lmer, nsim=10000, withMCMC=TRUE)

  mcmc$fixed
  mcmc$random

Run the code above in your browser using DataLab