brainstat.stats.terms.MixedEffect

class brainstat.stats.terms.MixedEffect(ran=None, fix=None, name_ran=None, name_fix=None, ranisvar=False, add_intercept=True, add_identity=True, _check_categorical=True)[source]

Bases: object

Build a random term object for a linear model.

Parameters
  • ran (array-like or DataFrame, optional) – For the random effects. If None, the random term is empty. Default is None.

  • fix (array-like or DataFrame, optional) – If None, the fixed effects.

  • name_ran (str, list, optional) – Name(s) for the random term(s). If None, it defauts to ‘xi’. Default is None.

  • name_fix (str, optional) – Name for the fix term. If None, it defauts to ‘xi’. Default is None.

  • ranisvar (bool, optional) – If True, ran is already a term for the variance. Default is False.

Variables

See also

FixedEffect

FixedEffect object

Examples

>>> r = MixedEffect()
>>> r.is_empty
True
>>> r2 = MixedEffect(np.arange(5), name_ran='r1')
>>> r2.mean.is_empty
True
>>> r2.variance.shape
(25, 2)
__init__(ran=None, fix=None, name_ran=None, name_fix=None, ranisvar=False, add_intercept=True, add_identity=True, _check_categorical=True)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__([ran, fix, name_ran, name_fix, …])

Initialize self.

broadcast_to(r1, r2)

set_identity_last()

Sets the identity matrix column last.

Attributes

empty

shape

set_identity_last()[source]

Sets the identity matrix column last.

Raises

ValueError – Raised if “I” occurs more than once in the names.