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

WIP 0.8.0 #106

Merged
merged 57 commits into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
e0fa17d
Store fits and residuals in Lm2 models. Also compute model r2 metrics
ejolly May 10, 2022
22acc02
Remove manual rhome set during dev
ejolly May 11, 2022
01b3946
lrt for lmer objects
dramanica Jul 13, 2022
17bd125
Fix pandas deprecated function
dramanica Jul 13, 2022
88b9b3d
Add BIC and deviance to lrt
dramanica Jul 13, 2022
e52c2df
Match behaviour in R
dramanica Jul 14, 2022
39f9206
Format code with black
dramanica Jul 14, 2022
96bd004
Get correct AIC
dramanica Jul 22, 2022
f618b49
Add tests for lrt
dramanica Jul 22, 2022
cc6252a
Add confint to test variances
dramanica Jul 22, 2022
dbdcd28
Add tests for confint
dramanica Aug 5, 2022
df6b19c
Guard against using lrt for non Lmer models
ejolly Sep 27, 2022
428521b
Temp fix for rpy2 3.5.1, but not until they fix #873 recursion error
ejolly Apr 24, 2022
18ff078
Bump rpy2 and pandas requirements
ejolly Nov 12, 2022
a77bfde
Update dep versions code changes to address rpy2 deprecation warnings
ejolly Dec 7, 2022
5103464
try fixing GA ci
ejolly Dec 7, 2022
d899289
try fixing GA ci
ejolly Dec 7, 2022
e885743
rename meta.yaml and bump numpy version
ejolly Dec 7, 2022
a915c2b
try fixing GA ci
ejolly Dec 7, 2022
cb84a1e
try fixing GA ci
ejolly Dec 7, 2022
391c5d1
remove deprecated future imports
ejolly Dec 7, 2022
113716b
refactor code to pull out R<->Py conversion into a separate module an…
ejolly Dec 7, 2022
eb3cb77
fix bug in saving confints
ejolly Dec 7, 2022
dd45f4f
fixes #88, #113
ejolly Dec 7, 2022
583b3fd
add sklearn dependency
ejolly Sep 27, 2022
e3f035b
initial implementation code
ejolly Sep 27, 2022
88bcf18
use pytest fixtures for data loading
ejolly Dec 7, 2022
5318a87
complete working (basic) implementation of Logistic Regression
ejolly Dec 7, 2022
8288fc3
logistic Lm estimate test against glm() in R
ejolly Dec 7, 2022
d48e7cd
add rpy2 back to requirements
ejolly Dec 7, 2022
7174439
reorg workflow files to run tests only on each push/pr
ejolly Dec 7, 2022
67a0bcf
whoops remove dev branch ref
ejolly Dec 7, 2022
bc2d80a
Update Tests.yml
ejolly Dec 7, 2022
fc83e50
Merge branch 'master' into dev
ejolly Dec 7, 2022
8c91863
try fixing GA ci
ejolly Dec 7, 2022
d3a3b28
try fixing GA ci
ejolly Dec 7, 2022
28bd42f
try fixing GA ci
ejolly Dec 7, 2022
f3d35f5
install rpy2 from conda-forge instead of pip to see if rpy2 linking w…
ejolly Dec 7, 2022
1533040
install rpy2 from conda-forge instead of pip to see if rpy2 linking w…
ejolly Dec 7, 2022
b36343e
try old optimizer for inverse_gaussian model
ejolly Dec 7, 2022
11efba5
comment out rfx only models that crash only on GA
ejolly Dec 7, 2022
d7eb161
GA try continuing on expected failure
ejolly Dec 7, 2022
4f00703
fix up conda build
ejolly Dec 8, 2022
7599f27
fix ci
ejolly Dec 8, 2022
52d653c
Update Tests.yml
ejolly Dec 8, 2022
8eff9db
Update Build.yml
ejolly Dec 8, 2022
cb69152
fix ci
ejolly Dec 8, 2022
46f1fb9
Merge branch 'dev' of https://github.com/ejolly/pymer4 into dev
ejolly Dec 8, 2022
57faa66
update meta.yaml for working local build
ejolly Dec 8, 2022
b344054
Merge branch 'master' into dev
ejolly Dec 8, 2022
8d036e0
Update Tests.yml
ejolly Dec 8, 2022
eae39c7
Merge remote-tracking branch 'origin' into dev
ejolly Dec 8, 2022
9696b38
store fits in logistic Lm and add support for .predict
ejolly Dec 9, 2022
5b11309
allow .predict to return probs or original scale vals. Fix bug in con…
ejolly Dec 9, 2022
6727141
add sphinx to dev reqs and update changelog
ejolly Dec 9, 2022
75dfba7
update gitignore
ejolly Dec 9, 2022
8723ea4
refactor Lm a bit
ejolly Dec 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ jobs:
PY_VER: ${{ matrix.py_ver }}
run: |
conda config --set always_yes yes --set changeps1 no
conda create -n pkg_test -c conda-forge python=$PY_VER 'r-lmerTest' 'r-emmeans' rpy2
conda create -n pkg_test -c conda-forge python=$PY_VER 'r-lmerTest' 'r-emmeans' 'rpy2'

conda activate pkg_test
pip install -r requirements-dev.txt
pip install .
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ dev/
.vscode/settings.json
*.key
pytest.ini
env/*
conda/build/*
.pytest_cache
.tox
.venv
environment.yml
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,29 @@ Check out the [documentation site](http://eshinjolly.com/pymer4/) for detailed t

Installing via [Anaconda](https://www.anacnda.com/products/individual) is the preferred installation method. Follow the directions [here](https://eshinjolly.com/pymer4/installation.html).

## Local build

```
conda create -n build python=3.8 pip conda-build
conda activate build
conda-build ./conda --python=3.8 -c https://conda.anaconda.org/conda-forge --output-folder ./conda/build --output ./conda/build
tarball=$(conda-build ./conda --python=3.8 --output | tail -1)
conda convert -p linux-64 -p win-64 $tarball -o ./conda/build
```

## Local upload

```
# after
# conda install anaconda-client
# anaconda login

# pre-release
anaconda upload ./conda/build/**/pymer4*.tar.bz2 -l "pre-release"

# main
anaconda upload ./conda/build/**/pymer4*.tar.bz2 -l "main"
```

## Contributing

Expand Down
2 changes: 0 additions & 2 deletions conda/conda_build_config.yaml

This file was deleted.

22 changes: 18 additions & 4 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ source:
path_url: ../ # so conda build will grab source to read version

build:
# script: python setup.py install --single-version-externally-managed --record=record.txt
script: pip install . -vv --no-deps
# abandoned conda build GIT_BUILD_STRING env variable
string: py{{environ.get("CONDA_PY", "XX")}}{{environ.get("GIT_ABBREV_COMMIT", "no_git_abbrev_commit") }}_{{ environ.get("PKG_BUILDNUM", "no_pkg_buildnum") }}
Expand All @@ -19,22 +18,37 @@ requirements:

host:
- python {{ python }}
# - r-base
# - r-lmerTest
# - r-base
- pip
- numpy >=1.20

run:
- python {{ python }}
- r-lmerTest
- r-emmeans
{% for req in data.get('install_requires', []) %}
- {{ req }}
{% endfor %}
- pandas >=1.1.0
- numpy >=1.20
- rpy2 >=3.5.3
- seaborn
- matplotlib
- patsy
- joblib
- scipy
- deepdish
- scikit-learn
# {% for req in data.get('install_requires', []) %}
# - {{ req }}
# {% endfor %}

test:
imports:
- pymer4
- pymer4.models
requires:
- pytest
- black

about:
home: "https://eshinjolly.com/pymer4/"
Expand Down
91 changes: 39 additions & 52 deletions docs/auto_examples/index.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
:orphan:



.. _sphx_glr_auto_examples:

Usage Guide
===========

Expand All @@ -21,131 +17,122 @@ Usage examples:



.. raw:: html

<div class="sphx-glr-thumbnails">


.. raw:: html

<div class="sphx-glr-thumbcontainer" tooltip="1. Basic Usage Guide">

.. only:: html

.. figure:: /auto_examples/images/thumb/sphx_glr_example_01_basic_usage_thumb.png
:alt: 1. Basic Usage Guide
.. image:: /auto_examples/images/thumb/sphx_glr_example_01_basic_usage_thumb.png
:alt: 1. Basic Usage Guide

:ref:`sphx_glr_auto_examples_example_01_basic_usage.py`
:ref:`sphx_glr_auto_examples_example_01_basic_usage.py`

.. raw:: html

<div class="sphx-glr-thumbnail-title">1. Basic Usage Guide</div>
</div>


.. toctree::
:hidden:

/auto_examples/example_01_basic_usage

.. raw:: html

<div class="sphx-glr-thumbcontainer" tooltip="2. Categorical Predictors">

.. only:: html

.. figure:: /auto_examples/images/thumb/sphx_glr_example_02_categorical_thumb.png
:alt: 2. Categorical Predictors
.. image:: /auto_examples/images/thumb/sphx_glr_example_02_categorical_thumb.png
:alt: 2. Categorical Predictors

:ref:`sphx_glr_auto_examples_example_02_categorical.py`
:ref:`sphx_glr_auto_examples_example_02_categorical.py`

.. raw:: html

<div class="sphx-glr-thumbnail-title">2. Categorical Predictors</div>
</div>


.. toctree::
:hidden:

/auto_examples/example_02_categorical

.. raw:: html

<div class="sphx-glr-thumbcontainer" tooltip="3. ANOVA tables and post-hoc comparisons">

.. only:: html

.. figure:: /auto_examples/images/thumb/sphx_glr_example_03_posthoc_thumb.png
:alt: 3. ANOVA tables and post-hoc comparisons
.. image:: /auto_examples/images/thumb/sphx_glr_example_03_posthoc_thumb.png
:alt: 3. ANOVA tables and post-hoc comparisons

:ref:`sphx_glr_auto_examples_example_03_posthoc.py`
:ref:`sphx_glr_auto_examples_example_03_posthoc.py`

.. raw:: html

<div class="sphx-glr-thumbnail-title">3. ANOVA tables and post-hoc comparisons</div>
</div>


.. toctree::
:hidden:

/auto_examples/example_03_posthoc

.. raw:: html

<div class="sphx-glr-thumbcontainer" tooltip="pymer4 gives you a lot of control over what you want your data to look like by setting properti...">

.. only:: html

.. figure:: /auto_examples/images/thumb/sphx_glr_example_04_simulating_data_thumb.png
:alt: 4. Simulating Data
.. image:: /auto_examples/images/thumb/sphx_glr_example_04_simulating_data_thumb.png
:alt: 4. Simulating Data

:ref:`sphx_glr_auto_examples_example_04_simulating_data.py`
:ref:`sphx_glr_auto_examples_example_04_simulating_data.py`

.. raw:: html

<div class="sphx-glr-thumbnail-title">4. Simulating Data</div>
</div>


.. toctree::
:hidden:

/auto_examples/example_04_simulating_data

.. raw:: html

<div class="sphx-glr-thumbcontainer" tooltip="5. Additional Statistics Functions">

.. only:: html

.. figure:: /auto_examples/images/thumb/sphx_glr_example_05_misc_stats_thumb.png
:alt: 5. Additional Statistics Functions
.. image:: /auto_examples/images/thumb/sphx_glr_example_05_misc_stats_thumb.png
:alt: 5. Additional Statistics Functions

:ref:`sphx_glr_auto_examples_example_05_misc_stats.py`
:ref:`sphx_glr_auto_examples_example_05_misc_stats.py`

.. raw:: html

<div class="sphx-glr-thumbnail-title">5. Additional Statistics Functions</div>
</div>


.. toctree::
:hidden:

/auto_examples/example_05_misc_stats
.. raw:: html

<div class="sphx-glr-clear"></div>

</div>


.. only :: html
.. toctree::
:hidden:

.. container:: sphx-glr-footer
:class: sphx-glr-footer-gallery
/auto_examples/example_01_basic_usage
/auto_examples/example_02_categorical
/auto_examples/example_03_posthoc
/auto_examples/example_04_simulating_data
/auto_examples/example_05_misc_stats


.. container:: sphx-glr-download sphx-glr-download-python
.. only:: html

:download:`Download all examples in Python source code: auto_examples_python.zip </auto_examples/auto_examples_python.zip>`
.. container:: sphx-glr-footer sphx-glr-footer-gallery

.. container:: sphx-glr-download sphx-glr-download-python

:download:`Download all examples in Python source code: auto_examples_python.zip </auto_examples/auto_examples_python.zip>`

.. container:: sphx-glr-download sphx-glr-download-jupyter
.. container:: sphx-glr-download sphx-glr-download-jupyter

:download:`Download all examples in Jupyter notebooks: auto_examples_jupyter.zip </auto_examples/auto_examples_jupyter.zip>`
:download:`Download all examples in Jupyter notebooks: auto_examples_jupyter.zip </auto_examples/auto_examples_jupyter.zip>`


.. only:: html
Expand Down
29 changes: 29 additions & 0 deletions docs/new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,35 @@ What's New
==========
Historically :code:`pymer4` versioning was a bit all over the place but has settled down since 0.5.0. This page includes the most notable updates between versions but github is the best place to checkout more details and `releases <https://github.com/ejolly/pymer4/releases/>`_.

0.8.0
----
- **NOTE:**
- there was no 0.7.9 release as there were enough major changes to warrant a new
minor release version
- this version unpins the maximum versions of :code:`rpy2` and :code:`pandas`
- if there are install issues with the :code:`conda` release accompanying this version you should be able to successfully install into a conda environment using pip with the following: :code:`conda install 'r-lmerTest' 'r-emmeans' rpy2 -c conda-forge` followed by :code:`pip install pymer4`
- **Bug fixes:**
- fixed as issue where :code:`Lmer` with :code:`family='binomial'` was not
converting logits into probabilities correctly
- fixes `#79 <https://github.com/ejolly/pymer4/issues/79>`_
- fixes `#88 <https://github.com/ejolly/pymer4/issues/88>`_
- fixes `#113 <https://github.com/ejolly/pymer4/issues/113>`_
- fixes `#114 <https://github.com/ejolly/pymer4/issues/114>`_
- generally more robust conversion of R types to pandas

- **New features:**
- :code:`Lm` models now support :code:`family='binomial'` and uses the
:code:`LogisticRegression` class from scikit-learn with no regularization for
estimation. Estimates and errors have been verified against the :code:`glm`
implementation in R
- new :code:`lrt` function for estimating likelihood-ratio tests between
:code:`Lmer` models thanks to `@dramanica <https://github.com/dramanica>`_. This
replicates the functionality of :code:`anova()` in R for :code:`lmer` models.
- new :code:`.confint()` method for :code:`Lmer` models thanks to `@dramanica
<https://github.com/dramanica>`_. This allows computing confidence intervals on 1
or more paramters of an already fit model including random effects which are not
computed by default when calling :code:`.fit()`

0.7.8
-----
- Maintenance release that pins :code:`rpy2 >= 3.4.5,< 3.5.1` due to R -> Python dataframe conversion issue on recent :code:`rpy2` versions that causes a `recursion error <https://github.com/rpy2/rpy2/issues/866>`_.
Expand Down
28 changes: 5 additions & 23 deletions pymer4/__init__.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,10 @@
from __future__ import absolute_import

__all__ = ["models", "utils", "simulate", "stats", "io", "__version__"]

from .models import Lmer, Lm, Lm2
from .simulate import easy_multivariate_normal, simulate_lm, simulate_lmm

from .utils import (
get_resource_path,
isPSD,
nearestPSD,
upper,
R2con,
con2R,
result_to_table,
)
from .io import save_model, load_model
from .stats import (
discrete_inverse_logit,
cohens_d,
perm_test,
tost_equivalence,
boot_func,
welch_dof,
vif,
)
from .simulate import *

from .utils import *
from .io import *
from .stats import *
from .bridge import *
from .version import __version__
Loading