Skip to content

Commit

Permalink
Merge pull request #101 from DeclareDesign/contribute-vignette-updates
Browse files Browse the repository at this point in the history
Updates to how-to vignette
  • Loading branch information
jaspercooper committed Jul 2, 2018
2 parents bf26399 + 90c9e35 commit 8ca08a5
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions vignettes/How_to_Write_and_Contribute_Designers.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ vignette: >

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(DesignLibrary)
```


Expand Down Expand Up @@ -42,7 +43,7 @@ Optionally, if you want your designer to work with [our online shiny inspector](

The following code creates a designer that creates a simple two-arm experiment of size, `N`, assigning units to treatment with probability `prob`. Note that the code is added to the attribute of the design using `construct_design_code`.

```{r, eval=FALSE}
```{r}
my_designer <- function(N = 100,
prob = .5){
if(0 > prob | 1 < prob) stop("prob must be in [0,1]")
Expand All @@ -54,19 +55,25 @@ my_designer <- function(N = 100,
estimand <- declare_estimand(ATE = mean(Y_Z_1 - Y_Z_0))
estimator <- declare_estimator(Y ~ Z, estimand = estimand)
reveal <- declare_reveal(Y,Z)
my_design <- declare_design(population,
potential_outcomes,
estimand,
assignment,
reveal,
estimator)
my_design <- population +
potential_outcomes +
estimand +
assignment +
reveal +
estimator
}}}
attr(my_design, "code") <- construct_design_code(designer = my_designer,
args = match.call.defaults())
my_design
}
```

```{r,include=F}
# For testing:
my_designer()
```


We'll discuss features of this designer below.

## Including Code in Design Attributes
Expand All @@ -85,12 +92,12 @@ One easy way to add code to the designs that your designer returns is to use our
estimand <- declare_estimand(ATE = mean(Y_Z_1 - Y_Z_0))
estimator <- declare_estimator(Y ~ Z, estimand = estimand)
reveal <- declare_reveal(Y,Z)
my_design <- declare_design(population,
potential_outcomes,
estimand,
assignment,
reveal,
estimator)
my_design <- population +
potential_outcomes +
estimand +
assignment +
reveal +
estimator
}}}
```

Expand Down Expand Up @@ -123,12 +130,12 @@ my_designer <- function(N = 100,
estimand <- declare_estimand(ATE = mean(Y_Z_1 - Y_Z_0))
estimator <- declare_estimator(Y ~ Z, estimand = estimand)
reveal <- declare_reveal(Y,Z)
my_design <- declare_design(population,
potential_outcomes,
estimand,
assignment,
reveal,
estimator)")
my_design <- population +
potential_outcomes +
estimand +
assignment +
reveal +
estimator")
my_design <- eval(parse(text = design_code))
attr(my_design, "code") <- design_code
my_design
Expand Down Expand Up @@ -212,7 +219,7 @@ You can also add keywords and reference other related designs and designers.
Finally, give yourself credit for your work.
```{r, eval=FALSE}
#'
#' @author DeclareDesign Team \url{https://declaredesign.org/}
#' @author \href{https://declaredesign.org/}{DeclareDesign Team}
#' @export
```

Expand Down

0 comments on commit 8ca08a5

Please sign in to comment.