imhr.Webgazer.model

@purpose: Build models for analysis.
@date: Created on Sat May 1 15:12:38 2019
@author: Semeon Risom

Functions

anova(config, y, f, df, csv, path, effects) Run analysis of variance model using rpy2, seaborn and pandas.
logistic(config, y, f, df, me, exclude, csv, …) Run logistic regression model, using rpy2, seaborn and pandas.
lmer(config, y, f, df, exclude, csv, path, …) Run linear mixed regression model, using rpy2, seaborn and pandas.
imhr.Webgazer.model.anova(config, y, f, df, csv, path, effects, is_html=True)[source]

Run analysis of variance model using rpy2, seaborn and pandas.

Parameters:
y : str

Response variable.

f : str

Formula to use for analysis.

df : pandas.core.frame.DataFrame

Pandas dataframe of raw data.

f : str

R-compatiable formula.

csv : str

Name of generated CSV file to run analysis in R.

path : str

The directory path to save the generated files.

effects : list

List of main effects.

is_html : bool

Whether html should be generated.

Returns:
model : rpy2.robjects.methods.RS4

Python representation of an R instance of class ‘S4’.

df_anova : pandas.core.frame.DataFrame

Pandas dataframe of model output.

get_anova : str

R script to run model.

html : :class:`str

Html output.

Notes

Resources
Definition:
A test that allows one to make comparisons between the means of multiple groups of data, where two independent variables are considered.
Assumptions of ANOVA
  1. Normal distribution (normality)
    • Short: Samples are drawn from a normally distributed population (Q-Q Plot, Shapiro-Wilks Test)
    • Detailed Definition: Residuals in data are normally distributed.
  2. Homogeneity of variance (homoscedasticity)
    • Short: Variances are equal (or similar).
    • Detailed: Varience for a DV is constant across the sample. (residual vs fitted plot, Scale-Location plot, Levene’s test)
  3. Independent observations
    • Samples have been drawn independently of each other. No analysis needed.
Hypothesis Interpretation
  • Null: The means of all levels of an IV groups are equal.
  • Alternative: The mean of at least level of an IV is different.
imhr.Webgazer.model.lmer(config, y, f, df, exclude, csv, path, effects, is_html=True)[source]

Run linear mixed regression model, using rpy2, seaborn and pandas.

Parameters:
y : str

Response variable.

f : list of str

Formula to use for analysis.

df : pandas.core.frame.DataFrame

Pandas dataframe of raw data.

f : str

R-compatiable formula.

exclude : list

List of participants to be excluded.

csv : str

Name of generated CSV file to run analysis in R.

path : str

The directory path to save the generated files.

effects : list

List of main effects.

is_html : bool

Whether html should be generated.

Returns:
model : rpy2.robjects.methods.RS4

Python representation of an R instance of class ‘S4’.

df_lmer : pandas.core.frame.DataFrame

Pandas dataframe of model output.

get_lmer : str

R script to run model.

html : :class:`str

Html output.

Notes

Resources
imhr.Webgazer.model.logistic(config, y, f, df, me, exclude, csv, path, is_html=True)[source]

Run logistic regression model, using rpy2, seaborn and pandas.

Parameters:
y : str

Response variable.

f : str

Formula to use for analysis.

df : pandas.core.frame.DataFrame

Pandas dataframe of raw data.

me : list of str

List of main effects.

exclude : list

List of participants to be excluded.

csv : str

Name of generated CSV file to run analysis in R.

path : str

The directory path to save the generated files.

is_html : bool

Whether html should be generated.

Returns:
model : rpy2.robjects.methods.RS4

Python representation of an R instance of class ‘S4’.

df_logit : pandas.core.frame.DataFrame

Pandas dataframe of model output.

get_logit : str

R script to run model.

html : :class:`str

Html output.

Notes

Resources