pymer4.models

pymer4.models#

Overview#

pymer4 includes 4 types of models that share a consistent API and can be imported like this:

from pymer4.models import lm, glm, lmer, glmer

Clicking the links below will take you to their respective API documentation pages.

Model

Description

lm()

linear regression fit via ordinary-least-squares (OLS)

glm()

generalized linear models (e.g logistic regression) fit via maximum-likelihood-estimate (MLE)

lmer()

linear-mixed / multi-level models

glmer()

geneneralized linear-mixed / multi-level models

Comparing Models#

Nested model comparison is available across all model types using the compare() function

pymer4.models.compare(*models, as_dataframe=False, test='F')[source]#

Compare 2 or models using an F-test or Likelihood-Ratio-Test. Uses the anova function in R.

Parameters:
  • as_dataframe (bool, optional) – Return a dataframe instead of a table. Defaults to False.

  • test (str, optional) – Test to use for model comparison. Defaults to ‘F’ for lm/glm models and ‘LRT’ for lmer/glmer models

Returns:

A dataframe with the model comparison results

Return type:

result (polars.DataFrame or GreatTables)