How to use the pymer4.utils.get_resource_path function in pymer4

To help you get started, we’ve selected a few pymer4 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ejolly / pymer4 / pymer4 / test_install.py View on Github external
def test_install():
    """
    Quick function to test installation by import a lmm object and fitting a quick model.
    """
    try:
        from pymer4.models import Lmer
        from pymer4.utils import get_resource_path
        import os
        import pandas as pd
        import warnings

        warnings.filterwarnings("ignore")
        df = pd.read_csv(os.path.join(get_resource_path(), "sample_data.csv"))
        model = Lmer("DV ~ IV3 + (1|Group)", data=df)
        model.fit(summarize=False)
        print("Pymer4 installation working successfully!")
    except Exception as e:
        print("Error! {}".format(e))
github ejolly / pymer4 / docs / _build / html / _downloads / basic_usage.py View on Github external
This tutorial illustrates how to estimate a simple model with one continuous predictor. We're going to fit a model with random intercepts, slopes and their correlations. 95% confidence intevals will be estimated using the Wald-method assuming a quadratic likelihood surface.

"""
##########################################
# Import module and check out data
# --------------------------------
#

import os
import pandas as pd
import seaborn as sns
from pymer4.models import Lmer
from pymer4.utils import get_resource_path

df = pd.read_csv(os.path.join(get_resource_path(),'sample_data.csv'))
df.head()
print("Hello World!")

#######################################################################
# Estimate a model
# ----------------
#
# Initialize linear model with random intercepts, slopes and their correlation

model = Lmer('DV ~ IV2 + (IV2|Subject)',data=df)

#########################################################################
# Fit it

model.fit()
github nimh-mbdu / sklearn-lmer / examples / plot_lmerregressor.py View on Github external
#%%
# Imports
# -------

import numpy as np
from matplotlib import pyplot as plt
from sklmer import LmerRegressor
import pandas as pd
import os
from pymer4.utils import get_resource_path

#%%
# Load and prepare data
# ---------------------
# split out training and test data
df = pd.read_csv(os.path.join(get_resource_path(), "sample_data.csv"))
df = df.reset_index().rename(columns={'index':'orig_index'})
test = df.groupby('Group').apply(lambda x: x.sample(frac=0.2)).reset_index(drop=True)
train = df.loc[~df.orig_index.isin(test.orig_index), :]

#%%
# Fit and predict with some different estimator options
# -----------------------------------------------------
# First with defaults.

df_estimator = LmerRegressor("DV ~ IV2 + (IV2|Group)", X_cols=df.columns)
df_estimator.fit(data=train)
df_preds = df_estimator.predict(test)

#%%
# Then use random effects information in the prediction.
github ejolly / pymer4 / docs / _build / html / _downloads / continuous_models.py View on Github external
This tutorial illustrates how to estimate a simple model with one continuous predictor. We're going to fit a model with random intercepts, slopes and their correlations. 95% confidence intevals will be estimated using the Wald-method assuming a quadratic likelihood surface.

"""
##########################################
# Import module and check out data
# --------------------------------
#

import os
import pandas as pd
import seaborn as sns
from pymer4.models import Lmer
from pymer4.utils import get_resource_path

df = pd.read_csv(os.path.join(get_resource_path(),'sample_data.csv'))
df.head()

#######################################################################
# Estimate a model
# ----------------
#
# Initialize linear model with random intercepts, slopes and their correlation

model = Lmer('DV ~ IV2 + (IV2|Subject)',data=df)

#########################################################################
# Fit it

model.fit()

#######################################################################