Learn R Programming

sjstats (version 0.7.1)

get_model_pval: Get p-values from regression model objects

Description

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

Usage

get_model_pval(fit, p.kr = FALSE)
merMod_p(fit, p.kr = TRUE)

Arguments

fit
A fitted model object of lm, glm, merMod, merModLmerTest, pggls or gls. Other classes may work as well.
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 tibble 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 \href{https://CRAN.R-project.org/package=#1}{\pkg{#1}}pbkrtestpbkrtest-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 \href{https://CRAN.R-project.org/package=#1}{\pkg{#1}}lmerTestlmerTest-package), these will be returned.

Examples

Run this code
data(efc)
# linear model fit
fit <- lm(neg_c_7 ~ e42dep + c172code, data = efc)
get_model_pval(fit)

# Generalized Least Squares fit
library(nlme)
fit <- gls(follicles ~ sin(2*pi*Time) + cos(2*pi*Time), Ovary,
           correlation = corAR1(form = ~ 1 | Mare))
get_model_pval(fit)

# lme4-fit
library(lme4)
fit <- lmer(Reaction ~ Days + (Days | Subject), data = sleepstudy)
get_model_pval(fit, p.kr = TRUE)

Run the code above in your browser using DataLab