# Two-Way ANOVA or Mixed model

I have a dataset organized with time points on the x-axis: baseline (0 days), 3, 7, 14, 21, and 28 days. These time points correspond to periods where I measure deficit scores (y-axis) in animal subjects.

A stroke is induced between baseline and day 3, resulting in an initial increase in deficits post-stroke, followed by a recovery phase where deficits decrease over time.

My dataset includes approximately 100 subjects measured over these time points. Each time point has two groups: a stroke group (subjects subjected to stroke induction) and a control group (no operation, no expected change). My goal is to perform appropriate statistical analyses on this data.

Some subjects have missing values at different time points, randomly distributed. For instance, one subject might lack data at time points 21 and 3, while another might miss data at 0 and 3. However, most subjects have data for all 6 time points.

Initially, after considering various examples, I attempted to use the following model:

smf.mixedlm("Deficit_score ~ TimePoint * Group", df_sorted, groups=df_sorted["SubjectID"], re_formula="~TimePoint")


In this model, "Group" denotes stroke or control subjects, and re_formula indicates that different slopes and intercepts are allowed for each subject.

However, I am concerned because I read that mixedlm is designed for linear models (?). In my data, deficits increase from baseline to day 3 due to stroke induction, but decrease from day 1 to day 28, suggesting a non-linear pattern.

I also attempted to use AnovaRM, but encountered issues with missing values and the absence of between-subject factors implementation.

For reference, I found a related discussion on Stack Overflow: [https://stackoverflow.com/q/69859587/16528477]

"Linear" here, as in "linear regression", means linear in the parameters. You can have nonlinear effects in linear regression (or linear mixed models). For instance, $$Y = b_0 + b_1x + b_2x^2$$ is a linear model. What isn't allowed is things like $$Y = b_0 + x^{b_1}$$