tisane.variable.AbstractVariable

class tisane.variable.AbstractVariable(name, data)

Bases: object

Super class for all variables, containing basic common attributes.

Parameters
  • name (str) – The name of the variable. If you have data, this should correspond to the column’s name. The dataset must be in long format.

  • data (DataVector, optional) – For internal use only.

relationships

The relationships this variable has with other variables

Type

list of Has, Repeats, Nests, Associates, or Moderates

name

The name of the variable. If you are going to use data, this should correspond to the column’s name.

Type

str

data

The data for this variable, in long format.

Type

DataVector

Methods

associates_with(variable)

Adds a correlation relationship to a data variable.

causes(effect)

Adds a causes relationship to a data variable.

moderates(moderator, on)

Adds an interaction relationship to a data variable

add_data

associates_with(variable)

Adds a correlation relationship to a data variable.

Parameters

variable ("AbstractVariable") – The variable that this variable is associated with/correlated to.

See also

causes

add a causal relationship

Examples

>>> import tisane as ts
>>> adult = ts.Unit(name="adult", cardinality=386)
>>> pounds_lost = adult.numeric(name="pounds_lost")
>>> age = adult.numeric(name="age")
>>> age.associates_with(pounds_lost)
causes(effect)

Adds a causes relationship to a data variable.

Parameters

effect (AbstractVariable) – The effect of the data variable

See also

associates_with

create a correlation relationship

Examples

>>> import tisane as ts
>>> adult = ts.Unit(name="adult")
>>> pounds_lost = adult.numeric("pounds_lost")
>>> group = ts.Unit(name="group")
>>> exercise_regimen = group.nominal(name="exercise_regimen")
>>> exercise_regimen.causes(pounds_lost) # the exercise regimen causes the number of pounds lost
moderates(moderator, on)

Adds an interaction relationship to a data variable

Parameters

Examples

Race interacts with SES to cause math achievement:

>>> import tisane as ts
>>> student = ts.Unit(name="student_id")
>>> race = student.nominal(name="race")
>>> ses = student.ordinal(name="SES")
>>> math_achievement = student.numeric(name="math_score")
>>> race.moderates(moderator=ses, on=math_achievement)