-1

I am trying to follow the example detailed here: Mixed effects logistic regression, but I get a "PackageNotInstalledError: The R package "lme4" is not installed" at the line results = model.fit()

The dataset can be downloaded here: https://web.stanford.edu/class/archive/cs/cs109/cs109.1166/stuff/titanic.csv

My code is:

import os 
import pandas as pd
import statsmodels.genmod.bayes_mixed_glm as smgb
from pymer4.models import Lmer

titanic = pd.read_csv(os.path.join(os.getcwd(), 'titanic.csv'))

model = Lmer("Survived  ~ Age  + (1|Pclass)",
             data=titanic, family = 'binomial')

results = model.fit())

print (results)

The Lmer function works, it's just when I try to fit the model that I get the error. I had assumed the required packages would have been included within pymer4. Any ideas about how to install this package would be much appreciated.

Hoppity81
  • 61
  • 8
  • 1
    How did you install `pymer4` to begin with? – esqew Sep 16 '21 at 00:31
  • Did you read [Installation](http://eshinjolly.com/pymer4/installation.html), specifically the part where the authors explicitly recommend against installing with `pip`, and the section where they mention how to install the requisite R packages in tandem with the library itself (and what to do in the event the error you mention above is raised)? – esqew Sep 16 '21 at 00:51
  • Apologies that you feel my assistance was provided “*grudgingly*” by simply asking two questions requesting key details you failed to initially provide in your question. – esqew Sep 16 '21 at 01:01

1 Answers1

1

I fixed this by reinstalling pymer4 using:

conda install -c ejolly -c defaults -c conda-forge pymer4
Hoppity81
  • 61
  • 8