DeclareDesign / DesignLibrary

Library of Research Designs
https://declaredesign.org/library/
Other
30 stars 3 forks source link

Fix many fixed #247

Closed clarabicalho closed 5 years ago

clarabicalho commented 5 years ago

Issue #246: Designers were retuning error when all arguments were fixed for some designers. For example:

pretest_posttest_designer(args_to_fix = names(formals(pretest_posttest_designer)))

Error in parse(text = x) : :1:131: unexpected symbol 1: substitute({report <- declare_assignment(prob = 1 - attrition_rate, assignment_variable = R) reveal_t2

PR

Note

Current use of substitute does not preserve comments in line. It only preserves comment lines that are separated from previous and subsequent code lines by a new line. For example, all of the below are preserved:

# D: Data Strategy 1
    select_case <- declare_sampling(
      strata = paste(X, Y),
      strata_n = c("X0Y0" = 0, "X0Y1" = 0, "X1Y0" = 0, "X1Y1" = 1))
    # I: Inquiry
    estimand <-
      declare_estimand(did_X_cause_Y = causal_process == 'X_causes_Y')
    # D: Data Strategy 2
    # Calculate bivariate probabilities given correlation

    joint_prob <- function(p1, p2, rho) {
...

But not the following:

population <- declare_population(
      N = N,
      X = rbinom(N, 1, prob_X) == 1,
      Y = (X & causal_process == "X_causes_Y") | # 1. X causes Y
        (!X & causal_process == "X_causes_not_Y") | # 2. Not X causes Y
        (causal_process == "Y_regardless") # 3. Y happens irrespective of X
    )
clarabicalho commented 5 years ago

closes #246