Skip to content

Commit

Permalink
Merge 8e9f41d into 47714b1
Browse files Browse the repository at this point in the history
  • Loading branch information
lilymedina committed Aug 2, 2018
2 parents 47714b1 + 8e9f41d commit 493364c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
20 changes: 10 additions & 10 deletions R/multi_arm_designer.R
Expand Up @@ -25,8 +25,8 @@
#'
# A design with fixed sds and means. N is the sole modifiable argument.
#' design <- multi_arm_designer(N = 80, m_arms = 4, means = 1:4,
#' fixed = list(m_arms = 4, sds = rep(1, 4),
#' means = 1:4))
#' fixed = c("m_arms" , "sds" ,
#' "means" ))
#'

multi_arm_designer <- function(N = 30,
Expand All @@ -47,9 +47,9 @@ multi_arm_designer <- function(N = 30,
length(conditions) != m_arms)
stop("means, sds and conditions arguments must be of length m_arms.")
if (any(sds <= 0)) stop("sds should be positive.")
if (!"sds" %in% names(fixed)) sds_ <- sapply(1:m_arms, function(i) expr(sds[!!i]))
if (!"means" %in% names(fixed)) means_ <- sapply(1:m_arms, function(i) expr(means[!!i]))
if (!"N" %in% names(fixed)) N_ <- expr(N)
if (!"sds" %in% fixed) sds_ <- sapply(1:m_arms, function(i) expr(sds[!!i]))
if (!"means" %in% fixed) means_ <- sapply(1:m_arms, function(i) expr(means[!!i]))
if (!"N" %in% fixed) N_ <- expr(N)

# Create helper vars to be used in design
errors <- sapply(1:m_arms, function(x) quos(rnorm(!!N_, 0, !!!sds_[x])))
Expand Down Expand Up @@ -126,23 +126,23 @@ multi_arm_designer <- function(N = 30,


{{{
# Model
# M: Model
population <- eval_bare(population_expr)

potential_outcomes <- eval_bare(potential_outcomes_expr)

# Inquiry
# I: Inquiry
estimand <- eval_bare(estimand_expr)

# Design
# D: Data Strategy
assignment <- eval_bare(assignment_expr)

reveal <- declare_reveal(assignment_variables = Z)

# Answer
# A: Answer Strategy
estimator <- eval_bare(estimator_expr)


# Design
multi_arm_design <-
population + potential_outcomes + assignment + reveal + estimand + estimator

Expand Down
4 changes: 2 additions & 2 deletions man/multi_arm_designer.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vignettes/multi_arm.Rmd
Expand Up @@ -40,7 +40,7 @@ diagnosis <- diagnose_design(multi_arm_design)
```

```{r,eval = TRUE, echo = FALSE}
kable(reshape_diagnosis(diagnosis)[,-c(1,2,3,5)], digits = 2)
kable(reshape_diagnosis(diagnosis)[,-c(1,12)], digits = 2)
```

The diagnosis of our design indicates that the regression provides unbiased estimates of the average treatment effect (ATE) in each arm. These estimates, however, are not so precise; The estimated standard deviation is large yielding wide confidence intervals that contain the true value of the ATEs more than 95\% of the time.
Expand Down

0 comments on commit 493364c

Please sign in to comment.