运行 MixedLM 并希望将输出推送到 Excel 或 CSV,请参阅下面的模型代码和输出:
model = smf.mixedlm('y_var ~ gas_prices', dfModel,
groups = dfModel['region'])
mdf = model.fit()
print(mdf.summary())
Mixed Linear Model Regression Results
======================================================================
Model: MixedLM Dependent Variable: yVar
No. Observations: 420 Method: REML
No. Groups: 4 Scale: 45635645671.2271
Min. group size: 105 Likelihood: -5720.8133
Max. group size: 105 Converged: Yes
Mean group size: 105.0
----------------------------------------------------------------------
Coef. Std.Err. z P>|z| [0.025 0.975]
----------------------------------------------------------------------
Intercept 3241461.947 112718.823 28.757 0.000 3020537.112 3462386.781
gas_prices -118128.471 46931.809 -2.517 0.012 -210113.126 -26143.816
xVar2 275.017 …Run Code Online (Sandbox Code Playgroud)