I’m having trouble finding examples on your site where there is no random assignment. This is not a problem in itself, but I’m finding that I’m having trouble adapting the logic to the question I want to ask.
That is to say, I’m adding my predictor of interest under declare_population
because that’s where I’d expect to be able to add the complex contingencies I expect to hold (omitted in example below).
However, later declaring the same variable as the “assignment_variable” in declare_assignment
leads to an error.
Error in eval(predvars, data, env) : object ‘Y’ not found
Leaving declare_assignment with the default of Z works, but this seems superfluous. Am I misunderstanding something and not using DD the way it’s intended?
Simplified reproducible example
design <-
# simulate data
declare_population(
obs = add_level(N = 100,
midcycle = draw_binary(N, prob = 0.2),
noise = rnorm(N)
)
) +
# simulate real relationship
declare_potential_outcomes(Y ~ 0.5 * midcycle + noise) +
declare_assignment(m = 50, assignment_variable = "midcycle") +
# simulate how we estimate relationship
declare_estimator(
Y ~ midcycle,
estimand = estimands_regression,
model = lm,
term = TRUE
)
Speciyfing estimand
Then, later I’m surprised I have to declare a custom estimand just to get the slope of a variable in a regression. Can I not just specify the term? This seems like it will get confusing quickly, when I’m looking at a higher-order interaction.
estimands_regression <- declare_estimand(
`midcycle` = mean(Y_midcycle_1 - Y_midcycle_0),
term = TRUE,
label = "Regression_Estimands"
)