Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to fit linear mixed model with a fixed variance component #8711

Open
JJ-Zhang-DS opened this issue Mar 2, 2023 · 1 comment
Open

how to fit linear mixed model with a fixed variance component #8711

JJ-Zhang-DS opened this issue Mar 2, 2023 · 1 comment

Comments

@JJ-Zhang-DS
Copy link

Describe the bug

I want to build a linear mixed model with fixed var components.
variance components = 5 and 10 (experimental error and sampling error, respectively)

But looks like the var components can not be passed to the model. How to fix it? thank you.

UserWarning: Argument params not used by MixedLM.fit
warnings.warn("Argument %s not used by MixedLM.fit" % x)

Code Sample, a copy-pastable example if possible

formula = 'y ~ trt'

# Fit the model
model = smf.mixedlm(formula, data, groups=data['rep'])

# Fix the variance components
vcov = {'rep: Intercept': 10, 'Residual': 5}

# Create a MixedLMParams object with fixed variance components
params = sm.regression.mixed_linear_model.MixedLMParams.from_components(vcomp=vcov)

# Fit the model with fixed variance components
model_fix = model.fit(params=params, method='lbfgs')

# Print a summary of the model results
print(model_fix.summary())
@JJ-Zhang-DS JJ-Zhang-DS changed the title how to fix linear mixed model with a fixed variance component how to use linear mixed model with a fixed variance component Mar 2, 2023
@JJ-Zhang-DS JJ-Zhang-DS changed the title how to use linear mixed model with a fixed variance component how to fit linear mixed model with a fixed variance component Mar 2, 2023
@kshedden
Copy link
Contributor

kshedden commented Mar 2, 2023

This might be possible using the free argument to the fit method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants