opynfield.stat_test package

Submodules

opynfield.stat_test.stat_test module

class opynfield.stat_test.stat_test.ManovaModels(full_model: statsmodels.multivariate.manova.MANOVA, component_model_results: dict[str, statsmodels.regression.linear_model.RegressionResultsWrapper], independent_var: str)

Bases: object

This dataclass associates information for the MANOVA, ANOVA, and t-test models of a specific parameter set

full_model

the full MANOVA model for all the parameters in the model parameter set

Type

MANOVA

component_model_results

a dict of the ANOVA model for each parameter in the set

Type

dict[str, RegressionResultsWrapper]

independent_var

the independent variable in the models

Type

str

parameter_names()

supplies the list of parameters in the sets

display_results()

prints results of MANOVA, ANOVA, and t-test models

component_model_results: dict[str, statsmodels.regression.linear_model.RegressionResultsWrapper]
display_results()

This method prints the results of all the MANOVA, ANOVA, and t-test models

full_model: statsmodels.multivariate.manova.MANOVA
independent_var: str
parameter_names()

This method returns all the parameters used in the MANOVA models

Returns

the parameters in the set

Return type

list[str]

opynfield.stat_test.stat_test.create_full_formula(test_df)

This function creates the formula for the full MANOVA test (of the form ‘group ~ param1 + param 2 + …’)

Parameters

test_df (pd.DataFrame) – df of the parameter fits for each individual

Returns

the full formula

Return type

str

opynfield.stat_test.stat_test.format_group_params(group_fits: dict[str, dict[str, dict[str, pandas.core.frame.DataFrame]]], defaults: opynfield.config.defaults_settings.Defaults, user_inputs: opynfield.config.user_input.UserInput)

This function takes the parameter fits of the group models and saves them out to .csv files

Parameters
  • group_fits (dict[str, dict[str, dict[str, pd.DataFrame]]]) – the parameters to re-format

  • defaults (Defaults) – the default settings to use

  • user_inputs (UserInput) – the user inputs to use

opynfield.stat_test.stat_test.format_params(bounded_fits: dict[str, dict[str, dict[str, pandas.core.frame.DataFrame]]], defaults: opynfield.config.defaults_settings.Defaults, user_inputs: opynfield.config.user_input.UserInput) pandas.core.frame.DataFrame

This function takes the parameter fits of the individuals bounded models and saves them out to .csv files

Parameters
  • bounded_fits (dict[str, dict[str, dict[str, pd.DataFrame]]]) – the parameters to re-format

  • defaults (Defaults) – the default settings to use

  • user_inputs (UserInput) – the user inputs to use

Returns

the formatted individual parameters

Return type

pd.DataFrame

opynfield.stat_test.stat_test.generate_models(test_df: pandas.core.frame.DataFrame, prefix: str, independent_var: str = 'group')

This function generates the ANOVA and t-test models for a specific parameter

Parameters
  • test_df (pd.DataFrame) – df of the parameter fits for each individual

  • prefix (str) – the parameter name

  • independent_var (str) – the independent variable of the test, defaults to group

Returns

a ManovaModels instance containing the test information for the parameter

Return type

ManovaModels

opynfield.stat_test.stat_test.get_col_names_from_prefix(test_df: pandas.core.frame.DataFrame, prefix: str) list[str]

This function generates a list of parameters that have the same prefix as the parameter being tested (the parameters that belong to the same model fit)

Parameters
  • test_df (pd.DataFrame) – df of the parameter fits for each individual

  • prefix (str) – the parameter name beginning

Returns

the parameters from the same model

Return type

list[str]

opynfield.stat_test.stat_test.make_formula_from_list(dependent_vars: list[str], independent_var: str) str

This function creates the formula for the MANOVA of all the parameters from the same model fit

Parameters
  • dependent_vars (list[str]) – the list of parameters from the same model fit

  • independent_var (str) – the independent variable of the formula

Returns

the formula for the test

Return type

str

opynfield.stat_test.stat_test.run_component_tests(test_df: pandas.core.frame.DataFrame, defaults: opynfield.config.defaults_settings.Defaults)

This function coordinates running follow-up ANOVA and t-tests for each parameter from the full model

Parameters
  • test_df (pd.DataFrame) – df of the parameter fits for each individual

  • defaults (Defaults) – the default settings to use

opynfield.stat_test.stat_test.run_full_test(formatted_bounded_fits: pandas.core.frame.DataFrame)

This function runs the MANOVA test on every parameter by group

Parameters

formatted_bounded_fits (pd.DataFrame) – df of the parameter fits for each individual

Returns

a deepcopy of the df of parameters (needed to memory consolidation)

Return type

pd.DataFrame

opynfield.stat_test.stat_test.run_tests(formatted_bounded_fits: pandas.core.frame.DataFrame, defaults: opynfield.config.defaults_settings.Defaults, user_inputs: opynfield.config.user_input.UserInput)

This function coordinates running all the relevant statistical tests on the individual parameters

Parameters
  • formatted_bounded_fits (pd.DataFrame) – df of the parameter fits for each individual

  • defaults (Defaults) – the default settings to use

  • user_inputs (UserInput) – the user inputs to use

Module contents