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

Issue with... #113

Closed
artembelopolsky opened this issue Nov 4, 2022 · 0 comments
Closed

Issue with... #113

artembelopolsky opened this issue Nov 4, 2022 · 0 comments
Labels

Comments

@artembelopolsky
Copy link

I am having trouble running the example in the tutorial using a binomial dependent variable. I used a clean conda installation (on Windows 11), as suggested in the tutorial:

conda create --name pymer4 -c ejolly -c conda-forge -c defaults pymer4

I haven't tried other installations that were suggested in the template bug report.

Here is the snippet:

from pymer4.utils import get_resource_path
from pymer4.models import Lmer

df = pd.read_csv(os.path.join(get_resource_path(), "sample_data.csv"))
model = Lmer("DV ~ IV2 + (IV2|Group)", data=df)
print(model.fit())

I get the following error:

File "C:\Users\artem\anaconda3\envs\pymer4\lib\site-packages\pymer4\models\Lmer.py", line 534, in fit
df.index = out_rownames

ValueError: Length mismatch: Expected axis has 7 elements, new values have 2 elements

I traced it back to Lmer.py and can print the df:
0 1
0 10.301072 6.821235e-01
1 2.803971 6.436641e-02
2 20.178790 4.238855e+01
3 3.673744 1.059751e+01
4 0.001489 1.720351e-13
5 4.805390 5.559677e-01
6 15.796755 8.082794e-01

The values in df look like the summary table in the tutorial. The bug seems in that dimensions do not match: out_rownames has 2 elements, and the df.index has 7. But I couldn't figure out how to fix it.

So, everything seems to be working, just formatting the summary table seems to be the problem.

Any help is appreciated!

@ejolly ejolly mentioned this issue Nov 12, 2022
ejolly added a commit that referenced this issue Dec 7, 2022
ejolly added a commit that referenced this issue Dec 9, 2022
* Store fits and residuals in Lm2 models. Also compute model r2 metrics

* Remove manual rhome set during dev

* lrt for lmer objects

Implement loglik ratio test analogous to the one implemented in lme4

* Fix pandas deprecated function

* Add BIC and deviance to lrt

Make output closer to lme4

* Match behaviour in R

Make sure npar are correct and other values are in the same order

* Format code with black

* Get correct AIC

AICTab in summary of an lmer fitted by REML gives the deviance, not the AIC.

* Add tests for lrt

For the moment, we use a static dump of the R output, as rpy2 seems to clash with pytest

* Add confint to test variances

* Add tests for confint

* Guard against using lrt for non Lmer models

* Temp fix for rpy2 3.5.1, but not until they fix #873 recursion error

* Bump rpy2 and pandas requirements

* Update dep versions code changes to address rpy2 deprecation warnings

* try fixing GA ci

* try fixing GA ci

* rename meta.yaml and bump numpy version

* try fixing GA ci

* try fixing GA ci

* remove deprecated future imports

* refactor code to pull out R<->Py conversion into a separate module and remove global conversion activators

* fix bug in saving confints

* fixes #88, #113

* add sklearn dependency

* initial implementation code

* use pytest fixtures for data loading

* complete working (basic) implementation of Logistic Regression

* logistic Lm estimate test against glm() in R

* add rpy2 back to requirements

* reorg workflow files to run tests only on each push/pr

* whoops remove dev branch ref

* Update Tests.yml

* try fixing GA ci

* try fixing GA ci

* try fixing GA ci

* install rpy2 from conda-forge instead of pip to see if rpy2 linking works on macos

* install rpy2 from conda-forge instead of pip to see if rpy2 linking works on macos

* try old optimizer for inverse_gaussian model

* comment out rfx only models that crash only on GA

* GA try continuing on expected failure

* fix up conda build

* fix ci

* Update Tests.yml

* Update Build.yml

* fix ci

* update meta.yaml for working local build

* Update Tests.yml

* store fits in logistic Lm and add support for .predict

* allow .predict to return probs or original scale vals. Fix bug in converting logits to probs in Lmer. Fixes #78"

* add sphinx to dev reqs and update changelog

* update gitignore

* refactor Lm a bit

Co-authored-by: Andrea Manica <am315@cam.ac.uk>
@ejolly ejolly closed this as completed Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants