Learn R Programming

⚠️There's a newer version (0.22.0) of this package.Take me there.

parameters

Describe and understand your model’s parameters!

parameters’ primary goal is to provide utilities for processing the parameters of various statistical models. Beyond computing p-values, CIs, Bayesian indices and other measures for a wide variety of models, this package implements features like standardization or bootstrapping of parameters and models, feature reduction (feature extraction and variable selection) as well as conversion between indices of effect size.

Installation

Run the following:

install.packages("devtools")
devtools::install_github("easystats/parameters")
library("parameters")

Documentation

Click on the buttons above to access the package documentation and the easystats blog, and check-out these vignettes:

Parameters Description

Parameters Engineering

Parameters Selection

Dimension Reduction

Features

Model’s parameters description

The model_parameters() function (that can be accessed via the parameters() shortcut) allows you to extract the parameters and their characteristics from various models in a consistent way. It can be considered as a lightweight alternative to broom::tidy(), with some notable differences:

  • The column names of the returned data frame are specific to their content. For instance, the column containing the statistic is named following the statistic name, i.e., t, z, etc., instead of a generic name such as statistic (however, you can get standardized (generic) column names using standardize_names()).
  • It is able to compute or extract indices not available by default, such as p-values, CIs, etc.
  • It includes feature engineering capabilities, including bootstrapping and standardization of parameters.
library(lme4)

model <- lmer(Sepal.Width ~ Petal.Length + (1|Species), data = iris)
model_parameters(model, standardize = "refit")
# Parameter    | Coefficient |   SE |       95% CI |    t |      p | Coefficient (std.)
# -------------------------------------------------------------------------------------
# (Intercept)  |        2.00 | 0.56 | [0.90, 3.10] | 3.56 | < .001 |               0.00
# Petal.Length |        0.28 | 0.06 | [0.17, 0.40] | 4.75 | < .001 |               1.14

Besides many types of regression models and packages, it also works for other types of models, such as structural models (EFA, CFA, SEM…).

library(psych)

model <- psych::fa(attitude, nfactors = 3)
model_parameters(model)
# # Rotated loadings from Principal Component Analysis (oblimin-rotation)
# 
# Variable   |   MR1 |   MR2 |   MR3 | Complexity | Uniqueness
# ------------------------------------------------------------
# rating     |  0.90 | -0.07 | -0.05 |       1.02 |       0.23
# complaints |  0.97 | -0.06 |  0.04 |       1.01 |       0.10
# privileges |  0.44 |  0.25 | -0.05 |       1.64 |       0.65
# learning   |  0.47 |  0.54 | -0.28 |       2.51 |       0.24
# raises     |  0.55 |  0.43 |  0.25 |       2.35 |       0.23
# critical   |  0.16 |  0.17 |  0.48 |       1.46 |       0.67
# advance    | -0.11 |  0.91 |  0.07 |       1.04 |       0.22
# 
# The 3 latent factors (oblimin rotation) accounted for 66.60% of the total variance of the original data (MR1 = 38.19%, MR2 = 22.69%, MR3 = 5.72%).

Variable and parameters selection

library(dplyr)

lm(disp ~ ., data = mtcars) %>% 
  parameters_selection() %>% 
  model_parameters()
# Parameter   | Coefficient |     SE |             95% CI |     t | df |      p
# -----------------------------------------------------------------------------
# (Intercept) |      141.70 | 125.67 | [-116.62,  400.02] |  1.13 | 26 | > .1  
# cyl         |       13.14 |   7.90 | [  -3.10,   29.38] |  1.66 | 26 | > .1  
# hp          |        0.63 |   0.20 | [   0.22,    1.03] |  3.18 | 26 | < .01 
# wt          |       80.45 |  12.22 | [  55.33,  105.57] |  6.58 | 26 | < .001
# qsec        |      -14.68 |   6.14 | [ -27.31,   -2.05] | -2.39 | 26 | < .05 
# carb        |      -28.75 |   5.60 | [ -40.28,  -17.23] | -5.13 | 26 | < .001

The parameters_selection() can also help you quickly select and retain the most relevant predictors using methods tailored for the model type. This function also works for mixed or Bayesian models:

library(rstanarm)

model <- stan_glm(mpg ~ ., data = mtcars) %>% 
  parameters_selection() %>% 
  model_parameters()
# Parameter   | Median |         89% CI |     pd | % in ROPE |  Rhat |  ESS |               Prior
# -----------------------------------------------------------------------------------------------
# (Intercept) |  19.31 | [-5.95, 41.92] | 90.55% |     1.15% | 1.001 | 1083 | Normal (0 +- 60.27)
# wt          |  -3.97 | [-6.00, -1.91] | 99.70% |     0.90% | 1.000 | 1222 | Normal (0 +- 15.40)
# cyl         |  -0.44 | [-1.66,  0.98] | 70.90% |    46.95% | 0.999 | 1250 |  Normal (0 +- 8.44)
# hp          |  -0.02 | [-0.04,  0.00] | 89.70% |      100% | 1.003 | 1191 |  Normal (0 +- 0.22)
# am          |   3.00 | [ 0.08,  6.08] | 94.70% |     6.55% | 0.999 | 1480 | Normal (0 +- 15.07)
# qsec        |   0.83 | [-0.12,  1.91] | 90.80% |    33.35% | 1.002 | 1049 |  Normal (0 +- 8.43)
# disp        |   0.01 | [-0.01,  0.03] | 86.10% |      100% | 0.999 | 1300 |  Normal (0 +- 0.12)

Miscellaneous

This packages also contains a lot of other useful functions:

Describe a Distribution

x <- rnorm(300)
describe_distribution(x)
knitr::kable(describe_distribution(rnorm(300)), digits = 1)
MeanSDMinMaxSkewnessKurtosisnn_Missing
01-240.10.13000

Standardization and normalization

df <- standardize(iris)
describe_distribution(df$Sepal.Length)
df <- standardize(iris)
knitr::kable(describe_distribution(df$Sepal.Length), digits = 1)
MeanSDMinMaxSkewnessKurtosisnn_Missing
01-220.3-0.61500
df <- normalize(iris)
describe_distribution(df$Sepal.Length)
df <- normalize(iris)
knitr::kable(describe_distribution(df$Sepal.Length), digits = 1)
MeanSDMinMaxSkewnessKurtosisnn_Missing
0.40.2010.3-0.61500

Copy Link

Version

Install

install.packages('parameters')

Monthly Downloads

87,418

Version

0.2.0

License

GPL-3

Maintainer

Dominique Makowski

Last Published

September 26th, 2019

Functions in parameters (0.2.0)

check_kmo

Kaiser, Meyer, Olkin (KMO) Measure of Sampling Adequacy (MSA) for Factor Analysis
d_to_r

Conversion between standardized difference d and correlation r
data_partition

Partition data into a test and a training set
odds_to_d

Conversion between (log)odds and standardized difference
cohens_f

ANOVA Effect Size (Omega Squared, Eta Squared, Epsilon Squared)
odds_to_probs

Conversion between (log)odds and probabilities
model_bootstrap

Model bootstrapping
format_standardize

Transform a standardized vector into character
equivalence_test.lm

Equivalence test
.n_factors_sescree

Standard Error Scree and Coefficient of Determination Procedures
.flatten_list

Flatten a list
.n_factors_bentler

Bentler and Yuan's Procedure
.data_frame

help-functions
model_parameters.befa

Format PCA/FA from the psych package
model_parameters.aov

ANOVAs Parameters
model_parameters.gam

Parameters of Generalized Additive (Mixed) Models
.n_factors_scree

Non Graphical Cattell's Scree Test
format_p

p-values formatting
describe_distribution

Describe a Distribution
.n_factors_mreg

Multiple Regression Procedure
.n_factors_cng

Cattell-Nelson-Gorsuch CNG Indices
.factor_to_numeric

Safe transformation from factor/character to numeric
standardize_names

Standardize column names
standardize

Standardization (Z-scoring)
parameters_reduction

Dimensionality reduction (DR) / Features Reduction
parameters_table

Parameters Table Formatting
model_parameters.htest

Correlations and t-test Parameters
parameters_selection

Parameters Selection
parameters_type

Type of Model Parameters
format_rope

Percentage in ROPE Formatting
.recode_to_zero

Recode a variable so its lowest value is beginning with zero
format_pd

Probability of direction (pd) Formatting
.find_most_common

Find most common occurence
.n_factors_bartlett

Bartlett, Anderson and Lawley Procedures
format_bf

Bayes Factor Formatting
model_parameters.lm

Parameters of (General) Linear Models
normalize

Normalization
print

Print model parameters
model_parameters.lavaan

Format CFA/SEM from the lavaan package
principal_components

Principal Component Analysis (PCA)
n_parameters

Count how many parameters in a model
format_parameters

Parameters Names Formatting
model_parameters.glmmTMB

Mixed Model Parameters
n_factors

Number of Components/Factors to Retain
format_order

Order (first, second, ...) formatting
model_parameters

Model Parameters
standard_error

Extract standard errors
model_parameters.BFBayesFactor

BayesFactor objects Parameters
model_simulate

Simulated draws from model coefficients
skewness

Compute Skewness and Kurtosis
format_number

Convert number to words
format_ci

Confidence/Credible Interval (CI) Formatting
model_parameters.stanreg

Bayesian Models Parameters
model_parameters.zeroinfl

Model Parameters for Zero-Inflated Models
reshape_loadings

Reshape loadings between wide/long formats
ci_wald

Wald-test approximation for CIs and p-values
reexports

Objects exported from other packages
parameters_bootstrap

Parameters bootstrapping
model_parameters.PCA

Structural Models (PCA, EFA, ...)
p_value

p-values
parameters_simulate

Parameters simulation
p_value_kenward

p-values using Kenward-Roger approximation
parameters_standardize

Parameters standardization
check_smoothness

Quantify the smoothness of a vector
convert_efa_to_cfa

Conversion between EFA results and CFA structure
check_sphericity

Bartlett's Test of Sphericity
ICA

Independent Component Analysis (ICA)
check_factorstructure

Check suitability of data for Factor Analysis (FA)
ci.merMod

Confidence Interval (CI)
convert_data_to_numeric

Convert data to numeric
DRR

Dimensionality Reduction via Regression (DRR)
cmds

Classical Multidimensional Scaling (cMDS)