Learn R Programming

languageR (version 0.2)

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, ...)

Arguments

object
An lmer model for a continuous response variable fitted with lmer.
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.
...
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.
  • 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)

  primingHeid.pvals = pvals.fnc(primingHeid.lmer)

  primingHeid.pvals$fixed
  primingHeid.pvals$random

Run the code above in your browser using DataLab