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

Lmer.fixef no longer has group labels #83

Closed
Shotgunosine opened this issue Apr 9, 2021 · 1 comment · Fixed by #84
Closed

Lmer.fixef no longer has group labels #83

Shotgunosine opened this issue Apr 9, 2021 · 1 comment · Fixed by #84
Labels

Comments

@Shotgunosine
Copy link
Contributor

1. Description

I'm pretty sure the fixef of LMER models used to have as its index the group labels. Now the index appears to be a range index.

2. Minimal reproducible example

In [1]: from pymer4.models import Lmer
...: from pymer4.utils import get_resource_path
...: import pandas as pd
...: import numpy as np
...: from scipy.special import logit
...: from scipy.stats import ttest_ind
...: import os

In [2]: import pymer4
...: pymer4.version
Out[2]: '0.7.2'

In [3]: df = pd.read_csv(os.path.join(get_resource_path(), "sample_data.csv"))
...: model = Lmer("DV ~ IV3 + IV2 + (IV2|Group) + (1|IV3)", data=df)
...: opt_opts = "optimizer='Nelder_Mead', optCtrl = list(FtolAbs=1e-8, XtolRel=1e-8)"
...: model.fit(summarize=False, control=opt_opts)
boundary (singular) fit: see ?isSingular

In [4]: model.fixef[0]
Out[4]:
(Intercept) IV3 IV2
0 6.031047 -1.529462 0.880139
1 20.356120 -1.529462 0.605304
2 10.322812 -1.529462 0.836379
3 12.222470 -1.529462 0.858911
4 11.251184 -1.529462 0.198474
5 12.626052 -1.529462 0.902386
6 2.466363 -1.529462 0.082339
7 -1.951063 -1.529462 1.070559
8 41.427467 -1.529462 0.256847
9 -0.327156 -1.529462 0.532686
10 3.409337 -1.529462 0.826673
11 4.183722 -1.529462 1.022796
12 17.441838 -1.529462 -0.170657
13 16.894473 -1.529462 0.719052
14 9.393190 -1.529462 0.630868
15 20.406180 -1.529462 0.112961
16 16.228585 -1.529462 0.670403
17 -0.947947 -1.529462 0.977892
18 2.960673 -1.529462 0.881681
19 15.081342 -1.529462 0.903035
20 3.099670 -1.529462 0.271275
21 11.046744 -1.529462 0.898630
22 1.995796 -1.529462 0.827309
23 0.502841 -1.529462 0.637432
24 16.325339 -1.529462 0.684816
25 28.728807 -1.529462 0.552281
26 0.282634 -1.529462 1.083250
27 12.274335 -1.529462 0.778643
28 2.900907 -1.529462 0.997698
29 25.969906 -1.529462 0.569460
30 18.774758 -1.529462 0.784060
31 41.014190 -1.529462 0.384460
32 17.825418 -1.529462 -0.101800
33 1.311976 -1.529462 0.714895
34 7.733580 -1.529462 0.970813
35 7.566232 -1.529462 0.603793
36 2.572444 -1.529462 0.991525
37 30.764099 -1.529462 0.557071
38 7.069487 -1.529462 0.870455
39 11.825799 -1.529462 0.858441
40 15.998152 -1.529462 0.395001
41 16.461600 -1.529462 0.839032
42 9.140041 -1.529462 0.900363
43 15.011776 -1.529462 0.765686
44 9.947849 -1.529462 0.858361
45 -2.077808 -1.529462 1.090571
46 32.480301 -1.529462 0.269124

In [5]: df.Group.unique()
Out[5]:
array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 27, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
40, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53])

In [6]: model.fixef[0].index
Out[6]: RangeIndex(start=0, stop=47, step=1)

3. Conda environment

Conda environment created with the following command
conda create -p potdys3 -c ejolly -c conda-forge python=3.8.8 numpy=1.19.2 pandas=1.1.5 pytest=6.2.2 joblib=1.0.1 rpy2=3.4.3 matplotlib=3.3.4 seaborn=0.11.1 scikit-learn=0.24.1 numexpr=2.7.3 patsy=0.5.1 statsmodels=0.12.2 openpyxl=3.0.7 pymer4=0.7.2 ipython jupyter notebook

conda list --explicit > pymer4_issue.txt
[pymer4_issue.txt](https://github.com/ejolly/pymer4/files/6286562/pymer4_issue.txt)

4. System information

  • Mac OSX, in a terminal window
	$ uname -mprsv
	Darwin 18.7.0 Darwin Kernel Version 18.7.0: Tue Jan 12 22:04:47 PST 2021; root:xnu-4903.278.56~1/RELEASE_X86_64 x86_64 i386

	$ sw_vers
        ProductName:	Mac OS X
        ProductVersion:	10.14.6
        BuildVersion:	18G8022
@Shotgunosine
Copy link
Contributor Author

Just confirmed that as of version 0.7.0 the index of the fixef was the group labels.

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

Successfully merging a pull request may close this issue.

1 participant