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

fitting a mixed linear model gives p values of 0 #6725

Closed
Jimmy2027 opened this issue May 17, 2020 · 4 comments
Closed

fitting a mixed linear model gives p values of 0 #6725

Jimmy2027 opened this issue May 17, 2020 · 4 comments
Milestone

Comments

@Jimmy2027
Copy link
Contributor

Hello, I am trying to fit a mixed linear model on my data in order to evaluate the interactions of different variables, but I get very small confidence intervals and p-values of zero.

The data looks like the following and can be found here:

  Contrast Processing  Uid  VCF_RMSE
0      CBV    Generic  0.1  0.090576
1     BOLD    Generic  0.2  0.051245
2      CBV     Masked  0.1  0.058238
3     BOLD     Masked  0.2  0.038187
4      CBV    Generic  1.1  0.092618
<class 'pandas.core.frame.DataFrame'>
Int64Index: 40000 entries, 0 to 39999
Data columns (total 4 columns):
Contrast      40000 non-null object
Processing    40000 non-null object
Uid           40000 non-null float64
VCF_RMSE      40000 non-null float64
dtypes: float64(2), object(2)
memory usage: 1.5+ MB

Code Sample, a copy-pastable example if possible

dependent_variable='VCF_RMSE'
expression='Processing*Contrast'
formula = 'Q("{}") ~ {}'.format(dependent_variable, expression)
model = smf.mixedlm(formula, df, groups='Uid')
fit = model.fit()
summary = fit.summary().tables[1]

Output

|                                      | Coef.  | Std.Err. | z        | P>\|z\| | [0.025 | 0.975] |
|--------------------------------------|--------|----------|----------|---------|--------|--------|
| Intercept                            | 0.060  | 0.000    | 975.536  | 0.000   | 0.060  | 0.061  |
| Processing[T.Masked]                 | -0.022 | 0.000    | -254.174 | 0.000   | -0.022 | -0.022 |
| Contrast[T.CBV]                      | 0.009  | 0.000    | 101.223  | 0.000   | 0.009  | 0.009  |
| Processing[T.Masked]:Contrast[T.CBV] | 0.011  | 0.000    | 86.837   | 0.000   | 0.011  | 0.011  |
| Uid Var                              | 0.000  | 0.000    |          |         |        |        |

Output of import statsmodels.api as sm; sm.show_versions()

``` INSTALLED VERSIONS ------------------ Python: 3.6.10.final.0 OS: Linux 5.4.10-gentoo #1 SMP Sun Jan 12 18:16:19 CET 2020 x86_64 byteorder: little LC_ALL: None LANG: en_GB.utf8 Statsmodels =========== Installed: 0.10.2 (/usr/lib64/python3.6/site-packages/statsmodels) Required Dependencies ===================== cython: 0.29.14 (/usr/lib64/python3.6/site-packages/Cython) numpy: 1.16.5 (/usr/lib64/python3.6/site-packages/numpy) scipy: 1.4.1 (/usr/lib64/python3.6/site-packages/scipy) pandas: 0.24.2 (/usr/lib64/python3.6/site-packages/pandas) dateutil: 2.8.1 (/usr/lib64/python3.6/site-packages/dateutil) patsy: 0.5.1 (/usr/lib64/python3.6/site-packages/patsy) Optional Dependencies ===================== matplotlib: 2.2.4 (/usr/lib64/python3.6/site-packages/matplotlib) backend: module://backend_interagg cvxopt: Not installed joblib: 0.12.2 (/usr/lib64/python3.6/site-packages/joblib) Developer Tools ================ IPython: Not installed jinja2: Not installed sphinx: Not installed pygments: 2.5.2 (/usr/lib64/python3.6/site-packages/pygments) pytest: 4.6.9 (/usr/lib64/python3.6/site-packages) virtualenv: Not installed ```
@kshedden
Copy link
Contributor

Is this a bug report? Do you have a question?

@kshedden
Copy link
Contributor

You have 20,000 paired observations (20K groups of size 2, with 40K total observations).

The estimated variance for the group variable is zero. That is, there seems to be no correlation within groups. In this case, the results of fitting a mixed model are equivalent to using ordinary least squares regression (ignoring the group variable).

I fit the model in R and got the same results, so I don't think there is a software issue here.

@Jimmy2027
Copy link
Contributor Author

okay, thank you. My question was whether this is a bug or not

@kshedden
Copy link
Contributor

I don't see any problem here.

@bashtage bashtage added this to the 0.12 milestone Jul 27, 2020
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

3 participants