DeclareDesign / DesignLibrary

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

FIXED only half working #201

Closed macartan closed 6 years ago

macartan commented 6 years ago

This is a problem: N is being substituted in; but sd_i is being removed from args list but is not substituted in for sd_i

> get_design_code( multi_arm_designer(N = 30, m_arms = 2, sd_i = 1, fixed = c("N", "sd_i")) )
 outcome_means  <-  c(0, 0)                                                                                                                                                                                                                                                                                                                                                                                                      
 outcome_sds  <-  c(0, 0)                                                                                                                                                                                                                                                                                                                                                                                                      
 # M: Model                                                                                                                                                                                                                                                                                                                                                                                                                       
 population <- declare_population(N = 30, 
    u_1 = rnorm(30, 0, outcome_sds[1L]),    
    u_2 = rnorm(30, 0, outcome_sds[2L]), u = rnorm(30) * sd_i)                                                                                                                                                                            
jaspercooper commented 6 years ago

Looks to me as though we need to add a line similar to these, but pertaining to sd_i:

  if (!"outcome_sds" %in% fixed) outcome_sds_ <-  sapply(1:m_arms, function(i) expr(outcome_sds[!!i]))
  if (!"outcome_means" %in% fixed) outcome_means_ <-  sapply(1:m_arms, function(i) expr(outcome_means[!!i]))
  if (!"N" %in% fixed) N_ <- expr(N)

Might be worth thinking about a test for designers with "fixed" arguments to make sure all arguments are included.

clarabicalho commented 6 years ago

Thanks for catching! Markus just brought up this issue. Editing now, will also look into @jaspercooper's suggestion.