Here is a fixed design with some comments re the above
# simulate data
obs = add_level(N = 100,
noise = rnorm(N)
# simulate real relationship
declare_potential_outcomes(Y ~ draw_ordered(0.5 * midcycle + noise, breaks = -3:3), assignment_variables = "midcycle") +
declare_assignment(prob=.2, assignment_variable = "midcycle") +
# simulate how we estimate relationship
# Technically this can be create automatically
#declare_reveal(outcome_variables = "Y", assignment_variables = c("midcycle")) +
Y ~ midcycle,
estimand = estimands_regression,
model = lm,
term = TRUE
In your design, where PO and assn were both using the default Z assignment variable, (and Z was unused in the PO formula), those two steps were merely creating unused variables Y_Z_1, Y_Z_0 and Z - they weren’t doing anything helpful anyway.
In my edits, I moved midcycle to the assnment step, and it seems like things work; also added the draw_ordered to the PO step (draw_likert didn’t work for me bc it created text?) which seems like a more natural place for it. I also set the assn variable on the two steps explicitly to midcycle.