BayesT1Sample

class robusta.groupwise.BayesT1Sample(null_interval=None, prior_scale: Union[str, float] = 0.7071067811865475, sample_from_posterior: bool = False, iterations: int = 10000, mu: float = 0.0, **kwargs)

Bases: robusta.groupwise.models.T1Sample

Run a Bayesian One-sample t-test.

Parameters
  • x (key in data or NumPy array of values, optional) – x can be used to specify. If str, x have to be key to column in data. If array-like, have to contain only objects that can be coerced into numeric. If not specified they are inferred based on the following arguments formula, and between or within (in this order).

  • mu (float, optional) – The null (H0) predicted value for the mean difference compared with the population’s mean (mu), in un-standardized effect size (e.g., raw measure units). Default value is 0.

  • y (float, optional) – y is an alias of mu, superseded by mu.

  • tail (str, optional) – Direction of the tested alternative hypothesis. Optional values are ‘x!=y’ (Two sided test; aliased by ‘two.sided’), ‘x<y’ (lower tail; aliased by ‘less’) ‘x>y’ (upper tail; aliased by ‘greater’). Whitespace characters in the input are ignored. Default value is ‘x != y’.

  • ci (int) – Width of confidence interval around the sample mean difference. Float between 0 and 100. Default value is 95.

  • independent (str, optional) – The name of the column identifying the independent variable in the data. The column could be either numeric or object, but can contain up to two unique values. Alias for within for paired, between for unpaired.

  • data (pd.DataFrame) – Containing the subject, dependent and independent variables as columns.

  • formula (str, optional) – An R-style formula describing the statistical model. In the form of (dependent ~ between + within | subject). If used, the parsed formula will overrides the following arguments dependent, between, within and subject.

  • dependent (key in data, optional) – The name of the column identifying the dependent variable (i.e., response variable) in the data. The column data type should be numeric or a string that can be coerced to numeric. Overriden by formula if specified. Required if formula is not specified.

  • between (key(s) in data (str or array-like), optional) – The name of the column identifying the independent variable (i.e., predictor variable) in the data. Identifies variables that are manipulated between different subject units (i.e., exogenous variable). Overriden by formula if specified. Not required if formula is not specified, given within is is specified.

  • within (key(s) in data (str or array-like), optional) – The name of the column identifying the independent variable in the data (i.e., predictor variable). The Identifies variables that are manipulated within different subject units (i.e., endogenous variable). Overriden by formula if specified. Not required if formula is not specified, given between is is specified.

  • subject (str or key in data, optional) – The name of the column identifying the sampling unit in the data (i.e., subject). Overriden by formula if specified. Required if formula is not specified.

  • agg_func (str (name of pandas aggregation function) or callable, optional) – Specified how to aggregate observations within sampling.

  • scale_prior (float, optional) – Controls the scale of the prior distribution. Default value is 1.0 which yields a standard Cauchy prior. It is also possible to pass ‘medium’, ‘wide’ or ‘ultrawide’ as input arguments instead of a float (matching the values of \(\frac{\sqrt{2}}{2}, 1, \sqrt{2}\), respectively). TODO - limit str input values.

  • sample_from_posterior (bool, optional) – If True return samples from the posterior, if False returns Bayes factor. Default is False.

  • iterations (int, optional) – Number of samples used to estimate Bayes factor or posterior. Default is 1000.

  • null_interval (tuple, optional) – Predicted interval for standardized effect size to test against the null hypothesis. Optional values for a ‘simple’ directional test are [-np.inf, np.inf], (H1: ES != 0), [-np.inf, 0] (H1: ES < 0) and [0, np.inf] (H1: ES > 0). However, it is better to confine null_interval specification to a more confined range (e.g., [0.2, 0.5], if you expect a positive small standardized effect size), if you have a prior belief regarding the expected effect size. Default value is [-np.inf, np.inf].

  • return_both (bool, optional) – If True returns Bayes factor for both H1 and H0, else, returns only for H1. Used only on directional hypothesis. Default is False. TODO - implement return of both bayes factors.

Notes

R function anovaBF: https://www.rdocumentation.org/packages/BayesFactor/versions/0.9.12-4.2/topics/anovaBF from the BayesFactor packages 1.

References

1

Morey, R. D., Rouder, J. N., Jamil, T., & Morey, M. R. D. (2015). Package ‘bayesfactor’.