Migration Guide¶
This guide helps users transition from statsmodels (Python) and R packages (mgcv, lme4) to Aurora-GLM.
From statsmodels¶
API comparison:
Task |
statsmodels |
Aurora-GLM |
|---|---|---|
Gaussian GLM |
|
|
Logistic regression |
|
|
Poisson regression |
|
|
Gamma GLM |
|
|
Standard errors |
|
|
P-values |
|
|
Predict |
|
|
AIC |
|
|
Key differences:
Aurora-GLM uses
fit_glm()for all families; statsmodels has separate classes (sm.OLS,sm.Logit, etc.)Aurora result attributes use trailing underscores (
aic_vsaic)Aurora uses
family=andlink=string shortcuts; statsmodels requires importing family objects
# statsmodels
import statsmodels.api as sm
model = sm.GLM(y, sm.add_constant(X), family=sm.families.Gamma(sm.families.links.log()))
result_sm = model.fit()
# Aurora-GLM
from aurora.models.glm import fit_glm
result = fit_glm(X, y, family="gamma", link="log")
From R mgcv¶
GAM comparison:
Task |
R mgcv |
Aurora-GLM |
|---|---|---|
Single smooth |
|
|
Multiple smooths |
|
|
Mixed terms |
|
|
REML selection |
|
|
Basis dimension |
|
|
Plot smooth |
|
|
# R mgcv
library(mgcv)
m <- gam(y ~ s(x1, k=10) + s(x2) + x3, data = df, method = "REML")
summary(m)
# Aurora-GLM
from aurora.models.gam import fit_gam_formula
result = fit_gam_formula("y ~ s(x1, k=10) + s(x2) + x3", df, method="REML")
print(result.summary())
From R lme4¶
GAMM / mixed model comparison:
Task |
R lme4 |
Aurora-GLM |
|---|---|---|
Random intercept |
|
|
Random slope |
|
|
Intercept + slope |
|
|
Nested effects |
|
|
Crossed effects |
|
|
Variance |
|
|
Fixed effects |
|
|
Predict |
|
|
# R lme4
library(lme4)
m <- lmer(y ~ x + (1 + time | subject), data = df, REML = TRUE)
summary(m)
# Aurora-GLM
from aurora.models.gamm import fit_gamm
result = fit_gamm(
formula="y ~ x + (1 + time | subject)",
data=df,
covariance="unstructured",
)
print(result.summary())
Numerical validation¶
Aurora-GLM is validated against R and statsmodels to within 1e-6 tolerance:
GLM coefficients match
statsmodelsand R’sglm()GAM smooth terms match R’s
mgcv::gam()GAMM variance components match R’s
lme4::lmer()The 3,377 tests in the test suite verify this agreement
If results differ between Aurora and R, check:
Convergence tolerance (try decreasing
tol)Number of IRLS iterations (increase
max_iter)Basis dimension (try increasing
n_basisork=)Smoothing parameter (compare
lambda_vs R’ssp)