### Example Pixi pyproject.toml Configuration File Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/installation.md Displays a sample `pyproject.toml` file, which acts as the blueprint for a Pixi environment. It illustrates how Pixi tracks project metadata, specified channels (`ejolly`, `conda-forge`, `pip`), platforms, and both `conda` and PyPI dependencies with version constraints. ```toml [project] authors = [{ name = "ejolly", email = "eshin.jolly@gmail.com" }] name = "myproject" requires-python = ">= 3.11" version = "0.1.0" dependencies = ["polars"] [build-system] build-backend = "hatchling.build" requires = ["hatchling"] [tool.pixi.workspace] channels = ["ejolly", "conda-forge"] platforms = ["osx-arm64"] [tool.pixi.pypi-dependencies] myproject = { path = ".", editable = true } [tool.pixi.tasks] [tool.pixi.dependencies] pymer4 = ">=0.9.1,<0.10" ipykernel = ">=6.29.5,<7" seaborn = ">=0.13.2,<0.14" ``` -------------------------------- ### Install XZ Utility via Homebrew Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/installation.md Install the xz compression utility, which is a common dependency for various packages, using Homebrew. ```bash brew install xz ``` -------------------------------- ### Update Homebrew Package Definitions Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/installation.md Update Homebrew to ensure all local package definitions are current, which is good practice before installing new packages. ```bash brew update ``` -------------------------------- ### Verify pymer4 Installation via Python Command Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/installation.md Executes a Python command within the terminal to confirm that `pymer4` has been successfully installed and is importable within the current environment. This serves as a quick check for installation integrity. ```bash python -c "from pymer4 import test_install; test_install()" ``` -------------------------------- ### Install pymer4 Development Version via Conda Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/installation.md Installs the latest 'bleeding-edge' development version of `pymer4` directly from the `pre-release` channel on anaconda.org. This provides access to the most recent fixes and features from the `main` branch. ```bash conda install -c ejolly/label/pre-release -c conda-forge pymer4 ``` -------------------------------- ### Initialize New Pixi Project with pymer4 Channels Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/installation.md Initializes a new Pixi project named `myproject` using the `pyproject.toml` format. This command configures the project to use the `ejolly` and `conda-forge` channels for dependency resolution, preparing it for `pymer4` installation. ```bash pixi init --format pyproject --channel ejolly --channel conda-forge myproject ``` -------------------------------- ### Check Homebrew Installation Status Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/installation.md Verify if Homebrew is already installed on your macOS system by checking for its executable path in the terminal. ```bash which brew ``` -------------------------------- ### Pixi Package and Environment Management Commands Source: https://github.com/ejolly/pymer4/blob/main/docs/development/design.md A guide to common Pixi commands for adding, removing, and managing packages and environments, similar to 'pip' or 'conda'. This includes commands for initial setup ('pixi install'), adding packages ('pixi add'), removing packages ('pixi remove'), running commands in the environment ('pixi run'), and activating the shell ('pixi shell'). Specific options are available for 'dev' features and 'pypi' packages. ```bash pixi install ``` ```bash pixi add package_name ``` ```bash pixi add --feature dev package_name ``` ```bash pixi add --pypi package_name ``` ```bash pixi add --pypi --feature dev package_name ``` ```bash pixi remove --pypi package_name ``` ```bash pixi remove package_name ``` ```bash pixi run task_name ``` ```bash pixi shell ``` -------------------------------- ### Install Rpy2 with Configured Compiler Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/installation.md Install the rpy2 package using either pip (if R/RStudio is installed) or conda (if not), leveraging the newly configured GCC compiler to avoid installation errors. ```python pip install rpy2 ``` ```conda conda install -c conda-forge rpy2 ``` -------------------------------- ### Install pymer4 into Existing Conda Environment Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/installation.md Installs the `pymer4` package and its dependencies into an already active Conda environment. It specifies the `ejolly` and `conda-forge` channels to ensure all necessary R package dependencies are resolved correctly. ```bash conda install -c ejolly -c conda-forge pymer4 ``` -------------------------------- ### Install Pymer4 After Dependencies Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/installation.md Install the pymer4 package using pip after successfully resolving its rpy2 dependency and any underlying compiler issues. ```python pip install pymer4 ``` -------------------------------- ### Clone Pymer4 Fork and Install Development Dependencies Source: https://github.com/ejolly/pymer4/blob/main/docs/development/contributing.md After forking the `main` branch, use these commands to clone your fork, navigate into the project directory, and install all development dependencies using `pixi` in an isolated Python environment. ```bash git clone https://github.com/YOURFORK/pymer4.git cd pymer4 pixi install ``` -------------------------------- ### Install Pixi Python Project Manager Source: https://github.com/ejolly/pymer4/blob/main/docs/development/contributing.md This command downloads and installs the `pixi` Python project manager, which handles environments and dependencies without conflicting with existing Python tools. ```bash curl -fsSL https://pixi.sh/install.sh | bash ``` -------------------------------- ### Add pymer4 Dependency to Pixi Project Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/installation.md Adds the `pymer4` package as a dependency to the current Pixi project. This command automatically updates the `pyproject.toml` file to reflect the new dependency. ```bash pixi add pymer4 ``` -------------------------------- ### Install pymer4 in Google Colab using Mamba Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/installation.md Installs `pymer4` and its dependencies within the Google Colab environment using the `mamba` package manager. This step should be performed after `condacolab` has been successfully set up and the kernel has restarted. ```bash !mamba install -q pymer4 -c ejolly -c conda-forge ``` -------------------------------- ### Install Pixi Package Manager Source: https://github.com/ejolly/pymer4/blob/main/docs/development/design.md Provides the command to install Pixi, a cross-platform package manager that operates without affecting existing Python installations. ```bash curl -fsSL https://pixi.sh/install.sh | bash ``` -------------------------------- ### Create New Conda Environment for pymer4 Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/installation.md Creates a new dedicated Conda environment named `pymer4` and installs the `pymer4` package within it. This command also pulls dependencies from the `ejolly` and `conda-forge` channels, which are crucial for `pymer4`'s cross-language requirements. ```bash conda create --n pymer4 -c ejolly -c conda-forge pymer4 ``` -------------------------------- ### Manually Configure GCC Compiler Path Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/installation.md If automatic detection fails, manually set the CC environment variable to the full path of the GCC compiler. Replace 'pathYouCopiedInQuotes' with the actual path found using 'brew info gcc'. ```bash export CC= pathYouCopiedInQuotes export CFLAGS="-W" ``` -------------------------------- ### Add Multiple Python Dependencies to Pixi Project Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/installation.md Adds `seaborn` and `ipykernel` as additional dependencies to the Pixi project. These packages are commonly used for data visualization and Jupyter notebook support, respectively. ```bash pixi add seaborn ipykernel ``` -------------------------------- ### Install Pymer4 via Conda Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/new.md Instructions for installing Pymer4 using the Conda package manager, leveraging channels from ejolly, defaults, and conda-forge for easier setup and dependency management. ```Shell conda install -c ejolly -c defaults -c conda-forge pymer4 ``` -------------------------------- ### Configure New GCC Compiler Environment Variables Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/installation.md Set environment variables (CC and CFLAGS) to enable the newly installed GCC compiler for subsequent build processes. This command attempts to automatically locate the correct compiler path. ```bash export CC="$(find `brew info gcc | grep usr | sed 's/(.*//' | awk '{printf $1"/bin"}'` -name 'x86*gcc-?')" export CFLAGS="-W" ``` -------------------------------- ### Install or Upgrade GCC Compiler via Homebrew Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/installation.md Install or upgrade the GNU Compiler Collection (GCC) on macOS using Homebrew. An updated compiler is often necessary to resolve compilation issues for Python packages like rpy2. ```bash brew install gcc ``` ```bash brew upgrade gcc ``` -------------------------------- ### Perform Marginal Effects Estimation and Comparisons Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/comingfromR.md Demonstrates how to estimate marginal means, perform pairwise comparisons, and analyze interaction contrasts. Examples are provided for both R using `emmeans` and Python using `pymer4`'s `.emmeans()` method, showcasing flexible API for statistical estimates. ```R library(emmeans) # Fit model mtcars$cyl <- as.factor(mtcars$cyl) model <- lm(mpg ~ wt * cyl, data = mtcars) # Get marginal means emm <- emmeans(model, ~ cyl) summary(emm) # Pairwise comparisons pairs(emm) # Interaction contrasts emmeans(model, pairwise ~ cyl | wt) ``` ```Python # Fit model model = lm("mpg ~ wt * cyl", data=data) model.set_factors("cyl") model.fit() # Get marginal means model.emmeans("cyl") # Pairwise comparisons model.emmeans("cyl", contrasts="pairwise") # Interaction contrasts model.emmeans(["cyl", "wt"], contrasts="pairwise") ``` -------------------------------- ### Pymer4 Functionality API Migration Guide (v0.9.X+) Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/migrating.md This snippet provides a comprehensive guide to migrating common `pymer4` functionalities from older versions to the `v0.9.X+` API. It covers changes in model creation, fitting, ANOVA table generation, marginal estimates, parameter access, fit statistics, and handling of fixed/random effects, highlighting the shift from Python-based `pymer4.stats` to R-based `pymer4.tidystats`. ```APIDOC Function | New models API | Old model API --------------------------------|---------------------------------|--------------------------------- Create a model | model('y ~ x', data=polars_df) | Model('y ~ x', data=pandas_df) Fit a model | .fit() | same ANOVA table | .anova() | same Marginal estimates & comparisons| .emmeans() / .empredict() | .post_hoc() Parameter estimates | .params, .result_fit | .coef Fit statistics | .result_fit_stats | .AIC, .BIC, etc Fixed-effects LMMs/GLMMs | .fixef | .fixef Random-effects LMMs/GLMMs | .ranef | .ranef Random-effects-variances LMMs/GLMMs| .ranef_var | .ranef_var Use various statistical functions| pymer4.tidystats (R-based) | pymer4.stats (python-based) ``` -------------------------------- ### Install Condacolab for Conda Support in Google Colab Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/installation.md Installs the `condacolab` package within a Google Colab notebook, which is necessary to enable `conda` and `mamba` commands. Running this code is expected to cause the notebook kernel to restart. ```python !pip install -q condacolab import condacolab condacolab.install() ``` -------------------------------- ### Fix Homebrew Permissions on macOS Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/installation.md Correct Homebrew directory permissions on macOS Sierra (10.12) or higher. This step is crucial to prevent permission-related issues during package installations. ```bash sudo chown -R $(whoami) $(brew --prefix)/* ``` -------------------------------- ### Add PyPI Package to Pixi Project Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/installation.md Adds the `polars` package, sourced from PyPI, as a dependency to the Pixi project. This demonstrates Pixi's capability to manage both `conda` and `pip` packages within the same environment. ```bash pixi add --pypi polars ``` -------------------------------- ### Initialize pymer4 lmer Model and Load Dataset Source: https://github.com/ejolly/pymer4/blob/main/docs/tutorials/03_lmms.ipynb This snippet imports the necessary `lmer` class from `pymer4.models` and the `load_dataset` function from `pymer4`. It then loads the 'sleep' dataset, which will be used in subsequent linear mixed model examples. ```python from pymer4.models import lmer from pymer4 import load_dataset sleep = load_dataset('sleep') ``` -------------------------------- ### Linear Regression with pymer4.models.skmer Source: https://github.com/ejolly/pymer4/blob/main/docs/api/models/skmer.md This Python example demonstrates how to perform linear regression using `pymer4.models.skmer`, adhering to the scikit-learn API. It shows data preparation, model initialization with a formula, fitting the model to training data, making predictions on test data, and evaluating performance using R-squared. ```python from pymer4 import load_dataset from pymer4.models import skmer from sklearn.metrics import r2_score from sklearn.model_selection import train_test_split # Prepare data sklearn style penguins = load_dataset('penguins') penguins = penguins.drop_nulls() # Features X = penguins[["bill_length_mm", "bill_depth_mm", "body_mass_g"]].to_numpy() # Labels y = penguins["flipper_length_mm"].to_numpy() # Split up X_train, X_test, y_train, y_test = train_test_split( X, y, test_size=0.3, random_state=42 ) # Linear Regression initialized with a formula ols = skmer("flipper_length_mm ~ bill_length_mm + bill_depth_mm + body_mass_g") # Fit & predict ols.fit(X_train, y_train) preds = ols.predict(X_test) # Evaluate r2_score(y_test, preds) ``` -------------------------------- ### Simplifying pymer4 Model Random Effects to Address Convergence Source: https://github.com/ejolly/pymer4/blob/main/docs/tutorials/03_lmms.ipynb This example demonstrates simplifying a pymer4 `lmer` model by removing the correlation between random-effects terms to improve convergence. Although the model still uses bootstrapping, it shows an attempt to resolve issues by reducing complexity. ```Python simple_model = lmer('mpg ~ 1 + (1 | cyl) + (0 + hp | cyl)', data=mtcars) simple_model.set_factors('cyl') simple_model.fit(conf_method='boot') simple_model.ranef_var ``` -------------------------------- ### Fitting a pymer4 Model with Potential Convergence Issues Source: https://github.com/ejolly/pymer4/blob/main/docs/tutorials/03_lmms.ipynb This example illustrates fitting a complex multi-level model using pymer4's `lmer` function. Such models, especially with redundant parameters, can frequently lead to convergence or singularity warnings during the fitting process. ```Python bad_model = lmer('Reaction ~ Days + (Days | Subject) + (1 | Days)', data=sleep) bad_model.fit() ``` -------------------------------- ### Multi-level Regression with pymer4.models.skmer Source: https://github.com/ejolly/pymer4/blob/main/docs/api/models/skmer.md This Python example illustrates how to implement multi-level regression using `pymer4.models.skmer`, specifically demonstrating the inclusion of a random-effect term. It shows data preparation, including the random-effect column in `X`, and using `sklearn.model_selection.LeaveOneGroupOut` for cross-validation to evaluate out-of-sample R-squared per group. ```python from pymer4 import load_dataset from pymer4.models import skmer from sklearn.metrics import r2_score from sklearn.model_selection import LeaveOneGroupOut # Prepare data sklearn style penguins = load_dataset('penguins') penguins = penguins.drop_nulls() # We pass in the rfx column as the last column of X X_with_group = penguins[["bill_length_mm", "species"]].to_numpy() y = penguins["flipper_length_mm"].to_numpy() # This is for the cross-validator to know how to split up the data groups = pengins[['species']].to_numpy() lmm = skmer("flipper_length_mm ~ bill_length_mm + (bill_length_mm | species)") # Out-of-sample r2 per species scores = cross_val_score(lmm, X_with_group, y, cv=LeaveOneGroupOut(), groups=group) ``` -------------------------------- ### Apply R `tidy_lm` to `pymer4` model and inspect output Source: https://github.com/ejolly/pymer4/blob/main/docs/development/extending.ipynb This example demonstrates how to apply the `broom.tidy_lm` function to a linear model created using `pymer4.tidystats.lm`. It initializes a Polars DataFrame, fits an R linear model, and then processes it with `tidy_lm`, showing that the direct output is an R DataFrame. ```python import pymer4.tidystats as ts import polars as pl df = pl.DataFrame({"x": [1, 2, 3, 4, 5], "y": [10, 30, 20, 50, 40]}) model = ts.lm("y ~ x", data=df) tidy_summary = broom.tidy_lm(model) tidy_summary ``` -------------------------------- ### Fitting Linear Mixed Models with pymer4 Source: https://github.com/ejolly/pymer4/blob/main/docs/api/models/lmer.md This snippet demonstrates how to fit Linear Mixed Models (LMMs) using the pymer4 library. It shows examples of fitting a random intercept model and a random intercept and slope model for subjects, and then compares these models. The 'sleep' dataset is used for illustration. ```python from pymer4 import load_dataset from pymer4.models import lmer, compare sleep = load_dataset('sleep') # Random intercept for each Subject lmm_i = lmer('Reaction ~ Days + (1 | Subject)', data=sleep) # Random intercept and slope for each Subject lmm_s = lmer('Reaction ~ Days + (Days | Subject)', data=sleep) # Compare models with different rfx compare(lmm_s, lmm_i) ``` -------------------------------- ### Identifying Convergence Issues with Random Slopes in pymer4 Source: https://github.com/ejolly/pymer4/blob/main/docs/tutorials/03_lmms.ipynb This example demonstrates fitting a pymer4 `lmer` model with a random slope, which can cause convergence issues if the random effect has very low variability. It uses the 'mtcars' dataset to illustrate this common problem. ```Python mtcars = load_dataset('mtcars') bad_model = lmer('mpg ~ 1 + (hp | cyl)', data=mtcars) bad_model.set_factors('cyl') bad_model.fit() ``` -------------------------------- ### Sphinx Automodule Directive for pymer4.config Source: https://github.com/ejolly/pymer4/blob/main/docs/api/config.md This reStructuredText directive instructs Sphinx to automatically generate comprehensive API documentation for the `pymer4.config` Python module. It ensures that all public members of the module are included in the generated documentation, ordered alphabetically, providing a structured and complete overview of its functionalities related to configuration and installation status. ```reStructuredText .. automodule:: pymer4.config :members: :member-order: alphabetical ``` -------------------------------- ### Preview Pymer4 Documentation Source: https://github.com/ejolly/pymer4/blob/main/docs/development/contributing.md Launch a local server to preview the generated `pymer4` documentation using `pixi run docs-preview`. ```bash pixi run docs-preview ``` -------------------------------- ### Initialize Project Dependencies with Pixi Source: https://github.com/ejolly/pymer4/blob/main/docs/development/design.md After cloning the repository, this command sets up all project dependencies in an isolated environment. ```bash pixi install ``` -------------------------------- ### Build Pymer4 Documentation Source: https://github.com/ejolly/pymer4/blob/main/docs/development/contributing.md Generate the project documentation using `jupyterbook` and Sphinx extensions with `pixi run docs-build`. ```bash pixi run docs-build ``` -------------------------------- ### Fit Mixed-Effects Logistic Regression with pymer4 Source: https://github.com/ejolly/pymer4/blob/main/docs/api/models/glmer.md Demonstrates how to fit a mixed-effects logistic regression model using `pymer4.models.glm` for binary outcomes, accounting for repeated observations within groups (e.g., `pclass`). The example shows how to load data, define a GLMM formula with a random intercept, set categorical factors, and interpret estimates on the odds scale by exponentiating the results. ```python from pymer4 import load_dataset from pymer4.models import glm titanic = load_dataset('titanic') # Logistic regression accounting repeated observations within pclass # by estimating a random intercept per level of pclass log_reg = glm('survived ~ fare + (1|pclass)', family='binomial', data=titanic) log_reg.set_factors('pclass') # See parameter estimates on odds scale log_reg.fit(exponentiate=True) ``` -------------------------------- ### Run Pymer4 Test Suite Source: https://github.com/ejolly/pymer4/blob/main/docs/development/contributing.md Execute the full test suite for the `pymer4` project using the `pixi run tests` command, ensuring all changes work as expected. ```bash pixi run tests ``` -------------------------------- ### Check Pymer4 Code Formatting Source: https://github.com/ejolly/pymer4/blob/main/docs/development/contributing.md Verify code formatting against PEP standards using `pixi run lint`, which leverages Ruff for checks. ```bash pixi run lint ``` -------------------------------- ### Manage and Run Pixi Project Tasks Source: https://github.com/ejolly/pymer4/blob/main/docs/development/design.md Commands to list available pre-configured development tasks and execute a specific task within the project's isolated environment. ```bash pixi task list ``` ```bash pixi run *cmd* ``` -------------------------------- ### Pre-configured Pixi Development Tasks Reference Source: https://github.com/ejolly/pymer4/blob/main/docs/development/design.md A comprehensive list of common development and maintenance tasks configured for the project, executable via 'pixi run'. These include commands for running tests ('pixi run tests'), linting code ('pixi run lint', 'pixi run lint-fix'), and building/managing documentation ('pixi run docs-build', 'pixi run docs-preview', 'pixi run docs-clean'). ```bash pixi run tests ``` ```bash pixi run lint ``` ```bash pixi run lint-fix ``` ```bash pixi run docs-build ``` ```bash pixi run docs-preview ``` ```bash pixi run docs-clean ``` -------------------------------- ### Automated Testing and Deployment Workflow Source: https://github.com/ejolly/pymer4/blob/main/docs/development/design.md Details the 'pixi.yml' Github Actions workflow responsible for automated testing, documentation building, and package deployment to Anaconda.org. ```APIDOC Github Actions Workflow (pixi.yml): - Setup up Pixi - Configure an environment and install runtime & development dependencies - Runs tests using 'pixi run tests' - Build and deploys docs using 'pixi run docs-build' - Build and deploys the package to Anaconda.org (ejolly channel, pre-release or main labels) using 'conda-build' and 'anaconda-client' Notes: - Conda packages are 'noarch' builds, cross-compatible for macOS & Linux (Windows not officially supported). - Workflow runs on any commits/PRs against the 'main' branch and weekly every Sunday. - Built packages are available on the 'ejolly' channel on Anaconda.org/ejolly/pymer4 under two labels: - 'main': built from official Github Release only. - 'pre-release': built from every new commit to the 'main' branch on github. ``` -------------------------------- ### pymer4 Quick Reference API Mapping to R Functions Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/comingfromR.md A quick reference mapping common statistical modeling functionalities from R libraries to their equivalent `pymer4` models, methods, and attributes. ```APIDOC Functionality: Linear models R: stats::lm() Python: pymer4.models.lm Functionality: Generalized linear models R: stats::glm() Python: pymer4.models.glm Functionality: Mixed models R: lme4::lmer(), lmerTest Python: pymer4.models.lmer Functionality: Generalized mixed models R: lme4::glmer() Python: pymer4.models.glmer Functionality: Model summaries R: broom/broom.mixed::tidy() Python: .summary() Functionality: Model fit statistics R: broom/broom.mixed::glance(), performance::model_performance() Python: .result_fit_stats Functionality: Model predictions, residuals, etc R: broom/broom.mixed::augment() Python: .data gains extra cols after using .fit() Functionality: ANOVA (Type-III, Type-I) R: emmeans::joint_tests(), stats::anova() Python: .anova(), .anova(auto_ss_3=False) Functionality: Marginal effects estimation and comparison R: emmeans::emmeans(), emtrends(), contrasts(), refgrid() Python: .emmeans(), .empredict() ``` -------------------------------- ### Perform ANOVA and Post-Hoc Tests with pymer4 Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/faqs.ipynb Demonstrates how to obtain traditional ANOVA results and perform post-hoc comparisons using pymer4. It covers setting categorical factors, running Type-III Sum-of-Squares F-tests, and exploring marginal estimates and contrasts with .emmeans(). ```python from pymer4.models import lm from pymer4 import load_dataset poker = load_dataset("poker") ``` ```python model = lm('balance ~ hand * skill', data=poker) model.set_factors(['hand', 'skill']) model.anova(summary=True) ``` ```python model.emmeans('hand', by='skill', contrasts='pairwise') ``` ```python model.emmeans('skill', by='hand', contrasts='pairwise') ``` ```python # 15 comparisons just print the first 5 model.emmeans(['hand', 'skill'], contrasts='pairwise').head() ``` -------------------------------- ### Fitting Logistic Regression Models with pymer4.glm Source: https://github.com/ejolly/pymer4/blob/main/docs/api/models/glm.md Demonstrates how to initialize and fit logistic regression models using `pymer4.models.glm` for binary outcomes. Shows usage of `family` and `link` arguments, and how to exponentiate estimates for odds ratios to aid interpretability. Also illustrates fitting with a probit link. ```python from pymer4 import load_dataset from pymer4.models import glm titanic = load_dataset('titanic') # Logistic regression with logit link log_reg = glm('survived ~ fare', family='binomial', data=titanic) # See parameter estimates on odds scale log_reg.fit(exponentiate=True) # Logistic regression with probit link probit_reg = glm('survived ~ fare', family='binomial', link='probit', data=titanic) # Now estimates on the link scale # which is z-score of p(survived) probit_reg.fit() ``` -------------------------------- ### New Module: pymer4.simulate Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/new.md Introduced the `simulate` module, likely containing general simulation functionalities beyond just Lmer models. ```APIDOC pymer4.simulate ``` -------------------------------- ### Managing Factors, Contrasts, and Transforms in R and pymer4 Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/comingfromR.md This section demonstrates how to handle variable transformations, factor conversions, and contrast adjustments. In R, these operations are typically applied directly to the dataframe, whereas in `pymer4`, they are managed using dedicated `.set_*` methods on the model object itself. ```R # Load data data(mtcars) # Convert variables to factors mtcars$cyl <- as.factor(mtcars$cyl) # Center a predictor mtcars$wt_c <- scale(mtcars$wt, center = TRUE, scale = FALSE) # Fit model model <- lm(mpg ~ wt_c * cyl, data = mtcars) # Change the default contrasts and refit contrasts(mtcars$cyl) <- contr.sum(3) model <- lm(mpg ~ wt_c * cyl, data = mtcars) ``` ```Python # Load data from pymer4 import load_dataset from pymer4.models import lm mtcars = load_dataset('mtcars') # Create model model = lm("mpg ~ wt * cyl", data=mtcars) # Convert variable to factor model.set_factors("cyl") # Center a predictor model.set_transforms({"wt": "center"}) # Fit model model.fit() # Change the default contrasts and refit model.set_contrasts({'cyl': 'contr.sum'}) model.fit() ``` -------------------------------- ### New Module: pymer4.io for Model Persistence Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/new.md Added the `pymer4.io` module to enable saving and loading pymer4 models to and from disk. ```APIDOC pymer4.io ``` -------------------------------- ### Fix Pymer4 Code Formatting Source: https://github.com/ejolly/pymer4/blob/main/docs/development/contributing.md Automatically fix code formatting issues in the `pymer4` project using `pixi run lint-fix`. ```bash pixi run lint-fix ``` -------------------------------- ### Initial Models: Linear and Logit Multi-level Models Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/new.md Initial release introducing core support for Linear and Logit multi-level models (`Lmer`), forming the foundation of the pymer4 library. ```APIDOC Lmer model class (initial support for Linear and Logit) ``` -------------------------------- ### Implementing Mixed-Effects Models in R and pymer4 Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/comingfromR.md This section compares the implementation of mixed-effects models. In R, obtaining p-values and various model components often requires multiple packages and functions (e.g., `lmerTest`, `broom.mixed`). `pymer4` streamlines this process by handling these aspects through integrated methods and attributes of the model object, including bootstrapping. ```R # Load libraries library(lme4) library(lmerTest) # for p-values library(broom.mixed) library(performance) # Load data data(sleepstudy) # Fit model model <- lmer(Reaction ~ Days + (Days | Subject), data = sleepstudy) # Get results summary(model) # Get nicer summary tidy(model, conf.int=TRUE) # Extract params coef(model) fixef(model) ranef(model) # Or nicer tidy(model, effects = "ran_pars") # Model diagnostics and variance partitioning icc(model) model_performance(model) # Bootstrapping bootMer(model, ...) # Without saving bootstraps bootstrap_model(model) ``` ```Python # Load data from pymer4 import load_dataset from pymer4.models import lmer sleepstudy = load_dataset("sleep") # Fit model model = lmer("Reaction ~ Days + (Days | Subject)", data=sleepstudy) # Print all-inclusive summary after fit model.fit(summary=True) # Params saved for you model.params # BLUPs model.fixef # RFX model.ranef # Variances model.ranef_var # As well as ICC, variance partitioning, etc model.result_fit_stats # Bootstrapping model.fit(conf_method='boot') ``` -------------------------------- ### New Module: pymer4.stats for Statistical Functions Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/new.md Introduced the `pymer4.stats` module, providing various parametric and non-parametric statistics functions, such as permutation testing and bootstrapping. ```APIDOC pymer4.stats ``` -------------------------------- ### Summarizing Model Fit and Extracting Results in R and pymer4 Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/comingfromR.md This section illustrates how to obtain model summaries and extract various results. R typically uses functions from different packages (e.g., `broom::tidy()`), while `pymer4` automatically calculates and stores these as accessible model attributes or methods. ```R # Load packages library(broom) library(performance) library(emmeans) # Fit model model <- lm(mpg ~ wt * cyl, data = mtcars) # Standard R summary summary(model) # Enhanced tidy summary tidy(model, conf.int = TRUE) # Predictions, residuals, etc augment(model) # Type-III ANOVA joint.tests(model) # Model fit metrics model_performance(model) ``` ```Python from pymer4 import load_dataset from pymer4.models import lm mtcars = load_dataset('mtcars') # Fit model model = lm("mpg ~ wt * cyl", data=mtcars) model.fit() # Standard R summary model.summary(pretty=False) # Enhanced tidy summary model.summary() # Predictions, residuals, etc model.data # Type-III ANOVA model.anova() # Model fit metrics model.result_fit_stats ``` -------------------------------- ### Fit and Analyze Linear Mixed Model with Pymer4 in Python Source: https://github.com/ejolly/pymer4/blob/main/paper.md This snippet demonstrates a typical Pymer4 workflow in Python, from data loading to model fitting and post-hoc analysis. It shows how to import necessary libraries, load sample data using pandas, fit a multi-level model with `Lmer`, perform post-hoc comparisons, and visualize model coefficients. This integrates Pymer4 seamlessly into a scientific Python environment. ```Python # imports import os import pandas as pd import seaborn as sns from pymer4.models import Lmer from pymer4.utils import get_resource_path # Load included example data with pandas df = pd.read_csv(os.path.join(get_resource_path(),'sample_data.csv')) # Fit a multi-level model with 1 categorical predictor using dummy-codes with '1.0' as the reference level model = Lmer('DV ~ IV3 + (IV3|Group)',data=df) model.fit(factors={'IV3':['1.0','0.5','1.5']}) # Perform post-hoc comparisons on the fitted model model.post_hoc(marginal_vars='IV3') # Plot model coefficients model.plot_summary() ``` -------------------------------- ### Load dataset and select columns with pymer4 and Polars Source: https://github.com/ejolly/pymer4/blob/main/docs/api/expressions.ipynb Demonstrates how to load a sample dataset using `pymer4.load_dataset` and select specific columns (`mpg`, `disp`, `cyl`) into a Polars DataFrame for further analysis. ```python from pymer4 import load_dataset import polars as pl mtcars = load_dataset('mtcars').select('mpg', 'disp', 'cyl') ``` -------------------------------- ### pymer4.models.base.model Summary Methods Source: https://github.com/ejolly/pymer4/blob/main/docs/api/models/lm.md Offers methods to generate formatted outputs from the results of a fitted pymer4 model, providing clear summaries of model attributes and ANOVA tables. ```APIDOC Methods: - pymer4.models.base.model.summary Description: Returns nicely formatted outputs of model results. - pymer4.models.base.model.summary_anova Description: Returns nicely formatted ANOVA summary outputs. ``` -------------------------------- ### Inspect Individual Bootstraps in pymer4 Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/comingfromR.md Access the raw bootstrap results from a `pymer4` model fit to inspect individual resamples and their statistics. ```Python model.result_boots ``` -------------------------------- ### pymer4.models.lm.lm Estimation Methods Source: https://github.com/ejolly/pymer4/blob/main/docs/api/models/lm.md Provides core methods for estimating model parameters, performing omnibus-tests, marginal estimations, predictions, and simulations within pymer4's linear models. These are the primary methods for routine model analysis. ```APIDOC Methods: - pymer4.models.lm.lm.fit Description: Primary method for estimating model parameters. - pymer4.models.base.model.anova Description: Performs omnibus-tests on model results. - pymer4.models.base.model.emmeans Description: Computes estimated marginal means. - pymer4.models.base.model.empredict Description: Computes estimated marginal predictions. - pymer4.models.base.model.predict Description: Generates predictions from the model. - pymer4.models.base.model.simulate Description: Runs simulations based on the model. - pymer4.models.base.model.vif Description: Calculates Variance Inflation Factors to assess multicollinearity. ``` -------------------------------- ### Importing pymer4 Model Classes Source: https://github.com/ejolly/pymer4/blob/main/docs/api/models/index.md Demonstrates how to import the four primary model classes (lm, glm, lmer, glmer) from the `pymer4.models` module for use in statistical analysis. ```python from pymer4.models import lm, glm, lmer, glmer ``` -------------------------------- ### pymer4.models.glm Summary Methods API Reference Source: https://github.com/ejolly/pymer4/blob/main/docs/api/models/glm.md API documentation for methods that provide nicely formatted outputs of the results attributes from a fitted `pymer4.models.glm` model. ```APIDOC pymer4.models.glm.glm.summary pymer4.models.base.model.summary_anova ``` -------------------------------- ### API Reference: `pymer4.tidystats.easystats` Module Source: https://github.com/ejolly/pymer4/blob/main/docs/api/tidystats.md Wraps functionality from various sub-libraries in the `easystats` ecosystem. ```APIDOC .. automodule:: pymer4.tidystats.easystats :members: :member-order: alphabetical ``` -------------------------------- ### Load Dataset and Inspect Data with pymer4 Source: https://github.com/ejolly/pymer4/blob/main/docs/tutorials/nn_mediation.ipynb This snippet demonstrates how to load a built-in dataset, 'mtcars', using `pymer4.load_dataset` and display the first few rows of the DataFrame to inspect its structure. ```python from pymer4 import load_dataset from pymer4.models import lm, lmer cars = load_dataset("mtcars") cars.head() ``` -------------------------------- ### pymer4.models.base.model Auxiliary Methods Source: https://github.com/ejolly/pymer4/blob/main/docs/api/models/lm.md Helper methods providing advanced functionality and debugging tools for pymer4 models, including comprehensive reporting and internal log management. ```APIDOC Methods: - pymer4.models.base.model.report Description: Generates a detailed report of the model and its results. - pymer4.models.base.model.show_logs Description: Displays internal logs for debugging and tracking operations. - pymer4.models.base.model.clear_logs Description: Clears internal logs. ``` -------------------------------- ### pymer4.models.glm Estimation Methods API Reference Source: https://github.com/ejolly/pymer4/blob/main/docs/api/models/glm.md API documentation for the primary methods used to estimate model parameters, perform omnibus tests, marginal estimations, predictions, and simulations for `pymer4.models.glm` objects. ```APIDOC pymer4.models.glm.glm.fit pymer4.models.base.model.anova pymer4.models.base.model.emmeans pymer4.models.base.model.empredict pymer4.models.glm.glm.predict pymer4.models.base.model.simulate pymer4.models.base.model.vif ``` -------------------------------- ### pymer4.models.glm.glm Class API Reference Source: https://github.com/ejolly/pymer4/blob/main/docs/api/models/glm.md API reference for the `pymer4.models.glm.glm` class, which is used for initializing and working with Generalized Linear Models. The `fit` method is documented separately under Estimation Methods. ```APIDOC class pymer4.models.glm.glm ``` -------------------------------- ### Feature: Standard Linear Regression Models Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/new.md Initial support for standard linear regression models (`Lm`), including robust standard errors, bootstrapped confidence intervals, and permuted inference for more reliable results. ```APIDOC Lm model class (initial support) ``` -------------------------------- ### Import R package and inspect functions in Python Source: https://github.com/ejolly/pymer4/blob/main/docs/development/extending.ipynb This Python snippet uses `rpy2.robjects.packages.importr` to load the `broom` R package. It then uses the `help()` function to inspect the Python-converted name and documentation of the `tidy_lm` function, which is part of the `broom` package. ```python from rpy2.robjects.packages import importr broom = importr("broom") help(broom.tidy_lm) ``` -------------------------------- ### API Documentation for pymer4.models.compare Source: https://github.com/ejolly/pymer4/blob/main/docs/api/models/index.md API documentation for the `compare()` function, which enables nested model comparison across all `pymer4` model types. ```APIDOC pymer4.models.compare() Description: Compares nested models across different pymer4 model types. ``` -------------------------------- ### pymer4.models.glm Auxiliary Methods API Reference Source: https://github.com/ejolly/pymer4/blob/main/docs/api/models/glm.md API documentation for helper methods in `pymer4.models.glm` that offer advanced functionality and debugging capabilities. ```APIDOC pymer4.models.base.model.report pymer4.models.base.model.show_logs pymer4.models.base.model.clear_logs ``` -------------------------------- ### API Reference: `pymer4.tidystats.emmeans_lib` Module Source: https://github.com/ejolly/pymer4/blob/main/docs/api/tidystats.md Wraps functionality from the `emmeans` library. ```APIDOC .. automodule:: pymer4.tidystats.emmeans_lib :members: :member-order: alphabetical ``` -------------------------------- ### pymer4 `compare()` Function Enhancements Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/new.md Describes improvements to the `compare()` function, making it more robust. The function now automatically refits models if they are not yet fit or if they have been fit via bootstrapping, ensuring consistent and reliable model comparisons. ```APIDOC function compare(): # Automatically refits models if not fit or if bootstrapped # Ensures robust model comparison ``` -------------------------------- ### Executing R's VarCorr Function in Python using pymer4.make_rfunc Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/faqs.ipynb This snippet demonstrates how to wrap an R function, specifically `VarCorr`, using `pymer4.make_rfunc()` to make it callable from Python. It includes loading a dataset, fitting an `lmer` model, defining the R function as a Python string, and then executing it on the `pymer4` model's R representation. ```Python from pymer4 import make_rfunc, load_dataset from pymer4.models import lmer # Load dataset and fit the model sleep = load_dataset("sleep") model = lmer("Reaction ~ Days + (Days | Subject)", data=sleep) model.fit() # Make a function that returns the coefficients of a model varcorr = make_rfunc(""" function(model) { output <- VarCorr(model, condVar=TRUE) return(output) } """) # Use the function passing in a model's .r_model attribute out = varcorr(model.r_model) ``` -------------------------------- ### Summary Methods for pymer4 Models Source: https://github.com/ejolly/pymer4/blob/main/docs/api/models/lmer.md This section details methods that provide formatted outputs of the results attributes from a fitted pymer4 model, facilitating easy inspection and reporting of model outcomes. ```APIDOC Method: pymer4.models.base.model.summary ``` ```APIDOC Method: pymer4.models.base.model.summary_anova ``` -------------------------------- ### pymer4.models.skmer.skmer.fit Method API Reference Source: https://github.com/ejolly/pymer4/blob/main/docs/api/models/skmer.md API documentation for the `fit` method of the `skmer` class. This method trains the model using the provided feature matrix `X` and target vector `y`. ```APIDOC pymer4.models.skmer.skmer.fit(X: numpy.ndarray, y: numpy.ndarray) Parameters: X (numpy.ndarray): The feature matrix. For multi-level models, this should include an extra column at the end with values for the random-effect term. y (numpy.ndarray): The target vector. Returns: None ``` -------------------------------- ### Pymer4 Model Class API Changes (v0.9.X+) Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/migrating.md This snippet details the mapping of old `pymer4` model classes to their new equivalents in `v0.9.X` and later. It clarifies how `Lm()` and `Lmer()` from older versions are now replaced by more specific `lm()`, `glm()`, `lmer()`, and `glmer()` classes, including notes on family argument usage for GLMs. ```APIDOC New model classes | Old model classes ------------------|------------------ lm() | Lm() glm() | Lm(); only family ='binomial' lmer() | Lmer() glmer() | Lmer(); with family kwarg ``` -------------------------------- ### pymer4.models.base.model Transformation and Factor Methods Source: https://github.com/ejolly/pymer4/blob/main/docs/api/models/lm.md Essential methods for handling categorical predictors (factors), defining custom linear hypotheses, and transforming continuous predictors (e.g., mean-centering) within pymer4 models. ```APIDOC Methods: - pymer4.models.base.model.set_factors Description: Sets categorical predictors (factors) for the model. - pymer4.models.base.model.unset_factors Description: Unsets previously defined categorical predictors. - pymer4.models.base.model.show_factors Description: Displays the currently defined factors. - pymer4.models.base.model.set_contrasts Description: Customizes specific linear hypotheses or contrasts for factors. - pymer4.models.base.model.show_contrasts Description: Displays the currently set contrasts. - pymer4.models.base.model.set_transforms Description: Applies transformations to continuous predictors (e.g., mean-centering). - pymer4.models.base.model.unset_transforms Description: Removes previously applied transformations. - pymer4.models.base.model.show_transforms Description: Displays the currently active transformations. ``` -------------------------------- ### Lmer Model: Simulation Method Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/new.md Added the `.simulate()` method to Lmer models, allowing for the simulation of new data based on the estimated model parameters. ```APIDOC Lmer.simulate() ``` -------------------------------- ### pymer4 lmer Class Core Methods Source: https://github.com/ejolly/pymer4/blob/main/docs/tutorials/03_lmms.ipynb This section outlines the primary methods available for the `lmer` class in `pymer4`, detailing their purpose and functionality for model fitting, analysis, and prediction. ```APIDOC .fit(): Fit a model using lmer() & lmerTest() .anova(): Calculate a Type-III ANOVA table using joint_tests() in R .summary(): Get a nicely formatted table containing .result_fit .empredict(): Compute marginal predictions are arbitrary values of predictors .emmeans(): Compute marginal means/contrasts as specific factor levels .simulate(): Simulate new observations from the fitted model .predict(): Make predictions given a new dataset ``` -------------------------------- ### API Reference: `pymer4.tidystats.base` Module Source: https://github.com/ejolly/pymer4/blob/main/docs/api/tidystats.md Wraps functionality from the `base` R library. ```APIDOC .. automodule:: pymer4.tidystats.base :members: :member-order: alphabetical ``` -------------------------------- ### Verifying No Warnings in a Converged pymer4 Model Source: https://github.com/ejolly/pymer4/blob/main/docs/tutorials/03_lmms.ipynb This snippet confirms that a successfully converged pymer4 model has no suppressed warnings. Checking the `show_logs()` output, which should be empty, provides verification of a clean fit. ```Python # Empty simpler_model.show_logs() ``` -------------------------------- ### API Reference: `pymer4.tidystats.broom` Module Source: https://github.com/ejolly/pymer4/blob/main/docs/api/tidystats.md Wraps functionality from the `broom` and `broom.mixed` libraries. ```APIDOC .. automodule:: pymer4.tidystats.broom :members: :member-order: alphabetical ``` -------------------------------- ### Estimation Methods for pymer4 Models Source: https://github.com/ejolly/pymer4/blob/main/docs/api/models/lmer.md This section outlines the primary methods used for estimating model parameters, performing omnibus tests, marginal estimations, predictions, and simulations within pymer4 models. These methods are crucial for routine analysis. ```APIDOC Method: pymer4.models.lmer.lmer.fit ``` ```APIDOC Method: pymer4.models.lmer.lmer.anova ``` ```APIDOC Method: pymer4.models.lmer.lmer.emmeans ``` ```APIDOC Method: pymer4.models.base.model.empredict ``` ```APIDOC Method: pymer4.models.lmer.lmer.predict ``` ```APIDOC Method: pymer4.models.lmer.lmer.simulate ``` ```APIDOC Method: pymer4.models.base.model.vif ``` -------------------------------- ### Fit lmer Model with Bootstrapped Confidence Intervals Source: https://github.com/ejolly/pymer4/blob/main/docs/tutorials/03_lmms.ipynb This snippet demonstrates fitting the random slopes model (`model_s`) while calculating bootstrapped confidence intervals for both fixed and random effects terms. The `conf_method='boot'` argument enables bootstrapping, and `summary=True` displays the results immediately, providing uncertainty estimates for the model parameters. ```python model_s.fit(conf_method='boot', summary=True) ``` -------------------------------- ### API Reference: `pymer4.tidystats.tables` Module Source: https://github.com/ejolly/pymer4/blob/main/docs/api/tidystats.md Functions to generate `great tables` formatted summary tables for models. ```APIDOC .. automodule:: pymer4.tidystats.tables :members: :member-order: alphabetical ``` -------------------------------- ### Lmer Model: Post-Hoc Analysis Method Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/new.md Added the `.post_hoc()` method to Lmer models, enabling users to perform follow-up comparisons after detecting significant overall effects. ```APIDOC Lmer.post_hoc() ``` -------------------------------- ### Generate Summary Table for lmer Model Source: https://github.com/ejolly/pymer4/blob/main/docs/tutorials/03_lmms.ipynb This snippet shows how to obtain a comprehensive summary table for the fitted `lmer` model using the `.summary()` method. This table consolidates parameter estimates, errors, inferential statistics, and other relevant model information. ```python model_i.summary() ``` -------------------------------- ### Specify Custom Contrasts in Pymer4 Lmer Models Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/new.md Demonstrates how to specify custom contrasts in Pymer4's Lmer models using a human-readable dictionary format. Pymer4 automatically handles the inversion operation required by R behind the scenes, making contrast specification more intuitive for users. ```Python model.fit(factors = {"Col1": {'A': 1, 'B': -.5, 'C': -.5}}) ``` -------------------------------- ### Add R package dependency with Pixi Source: https://github.com/ejolly/pymer4/blob/main/docs/development/extending.ipynb This command adds the `r-broom` package as a new dependency to your `pymer4` project using the Pixi package manager. It ensures the R library is available for use within your Python environment. ```bash pixi add r-broom ``` -------------------------------- ### Auxiliary Methods for pymer4 Models Source: https://github.com/ejolly/pymer4/blob/main/docs/api/models/lmer.md This section covers helper methods designed for advanced functionality and debugging purposes within pymer4 models, providing additional utilities beyond standard estimation and summary. ```APIDOC Method: pymer4.models.base.model.report ``` ```APIDOC Method: pymer4.models.base.model.show_logs ``` ```APIDOC Method: pymer4.models.base.model.clear_logs ``` -------------------------------- ### Estimate Linear and Multi-level Regression Models with Pymer4 Source: https://github.com/ejolly/pymer4/blob/main/README.md This snippet demonstrates how to use Pymer4 to perform both simple linear regression (OLS) and multi-level modeling (LMM). It loads a sample dataset and then fits the models using R-like formula syntax. Pymer4 leverages rpy2 to provide robust statistical capabilities in Python. ```python from pymer4.models import lm, lmer from pymer4 import load_dataset('sleep') sleep = load_dataset('sleep') # Linear regression ols = lm('Reaction ~ Days', data=sleep) ols.fit() # Multi-level model lmm = lmer('Reaction ~ Days + (Days | Subject)', data=sleep) lmm.fit() ``` -------------------------------- ### API Reference: `pymer4.tidystats.stats` Module Source: https://github.com/ejolly/pymer4/blob/main/docs/api/tidystats.md Wraps functionality from the `stats` library. ```APIDOC .. automodule:: pymer4.tidystats.stats :members: :member-order: alphabetical ``` -------------------------------- ### pymer4.models.glm Transformation and Factor Methods API Reference Source: https://github.com/ejolly/pymer4/blob/main/docs/api/models/glm.md API documentation for methods crucial for handling categorical predictors (factors), defining specific linear hypotheses, and transforming continuous predictors within `pymer4.models.glm`. ```APIDOC pymer4.models.base.model.set_factors pymer4.models.base.model.unset_factors pymer4.models.base.model.show_factors pymer4.models.base.model.set_contrasts pymer4.models.base.model.show_contrasts pymer4.models.base.model.set_transforms pymer4.models.base.model.unset_transforms pymer4.models.base.model.show_transforms ``` -------------------------------- ### Converting R Objects to Python Dictionary using pymer4.tidystats.to_dict Source: https://github.com/ejolly/pymer4/blob/main/docs/pages/faqs.ipynb This snippet demonstrates a general-purpose method to convert an R object, such as the output from `make_rfunc`, into a Python dictionary. It utilizes the `to_dict()` function from the `pymer4.tidystats` module for this conversion. ```Python import pymer4.tidystats as ts ts.to_dict(out) ``` -------------------------------- ### API Reference: `pymer4.tidystats.lmerTest` Module Source: https://github.com/ejolly/pymer4/blob/main/docs/api/tidystats.md Wraps functionality from the `lme4` and `lmerTest` libraries. ```APIDOC .. automodule:: pymer4.tidystats.lmerTest :members: :member-order: alphabetical ```