emjun / tisane

Specification language for generating Generalized Linear Models (with or without mixed effects) from conceptual models
Apache License 2.0
21 stars 3 forks source link

Moderation on Nominal Not Working #31

Open shreyashnigam opened 3 years ago

shreyashnigam commented 3 years ago
import tisane as ts
import pandas as pd
import os

FILE_NAME = "schools.csv"

dir = os.path.dirname(__file__)
df = pd.read_csv(os.path.join(dir, FILE_NAME))

# Initialize Units
school = ts.Unit("schid", cardinality=10)
student = ts.Unit("stuid", cardinality=96)

homework = student.ordinal("homework", order=[0, 1, 2, 3, 4, 5, 6, 7])

# school variables
school_size = school.ordinal("scsize", order=[2,3,4,6])
school_region = school.nominal("region")
school_type = school.ordinal("sctype", order=[1, 4])
public = school.nominal("public")

# Define relationships
public.causes(homework)
public.moderates(school_region, on=homework)
school_size.associates_with(homework)
school_type.associates_with(homework)

design = ts.Design(dv=school_size, ivs=[school_region]).assign_data(df)

ts.infer_statistical_model_from_design(design=design)
emjun commented 3 years ago

Link to data: https://github.com/emjun/tisane/blob/main/examples/Schools/schools.csv