This function returns the p-values for fitted model objects.

p_value(fit, ...)

# S3 method for lmerMod
p_value(fit, p.kr = FALSE, ...)

Arguments

fit

A model object.

...

Currently not used.

p.kr

Logical, if TRUE, the computation of p-values is based on conditional F-tests with Kenward-Roger approximation for the df (see 'Details').

Value

A data.frame with the model coefficients' names (term), p-values (p.value) and standard errors (std.error).

Details

For linear mixed models (lmerMod-objects), the computation of p-values (if p.kr = TRUE) is based on conditional F-tests with Kenward-Roger approximation for the df, using the pbkrtest-package. If pbkrtest is not available or p.kr = FALSE, or if x is a glmerMod-object, computation of p-values is based on normal-distribution assumption, treating the t-statistics as Wald z-statistics.

If p-values already have been computed (e.g. for merModLmerTest-objects from the lmerTest-package), these will be returned.

The print()-method has a summary-argument, that - in case p.kr = TRUE - also prints information on the approximated degrees of freedom (see 'Examples'). A shortcut is the summary()-method, which simply calls print(..., summary = TRUE).

Examples

data(efc) # linear model fit fit <- lm(neg_c_7 ~ e42dep + c172code, data = efc) p_value(fit)
#> term p.value std.error #> 1 (Intercept) 0.000 0.566 #> 2 e42dep 0.000 0.133 #> 3 c172code 0.207 0.198
# Generalized Least Squares fit library(nlme)
#> #> Attaching package: 'nlme'
#> The following object is masked from 'package:lme4': #> #> lmList
#> The following object is masked from 'package:dplyr': #> #> collapse
fit <- gls(follicles ~ sin(2*pi*Time) + cos(2*pi*Time), Ovary, correlation = corAR1(form = ~ 1 | Mare)) p_value(fit)
#> term p.value std.error #> 1 (Intercept) 0.000 0.665 #> 2 sin(2 * pi * Time) 0.000 0.645 #> 3 cos(2 * pi * Time) 0.198 0.698
# lme4-fit library(lme4) sleepstudy$mygrp <- sample(1:45, size = 180, replace = TRUE) fit <- lmer(Reaction ~ Days + (1 | mygrp) + (1 | Subject), sleepstudy) pv <- p_value(fit, p.kr = TRUE)
#> Computing p-values via Kenward-Roger approximation. Use `p.kr = FALSE` if computation takes too long.
# normal output pv
#> term p.value std.error #> 1 (Intercept) 0 9.790 #> 2 Days 0 0.815
# add information on df and t-statistic print(pv, summary = TRUE)
#> term p.value std.error df statistic #> 1 (Intercept) 0 9.790 22.938 25.670 #> 2 Days 0 0.815 160.967 12.868
# or summary(pv)
#> term p.value std.error df statistic #> 1 (Intercept) 0 9.790 22.938 25.670 #> 2 Days 0 0.815 160.967 12.868