Running examples in 'DeclareDesign-Ex.R' failed
The error most likely occurred in:

> ### Name: declare_estimator
> ### Title: Declare estimator
> ### Aliases: declare_estimator declare_estimators label_estimator
> ###   model_handler
> 
> ### ** Examples
> 
> # base design
> design <-
+   declare_model(
+     N = 100,
+     female = rbinom(N, 1, 0.5),
+     U = rnorm(N),
+     potential_outcomes(
+      Y ~ rbinom(N, 1, prob = pnorm(0.2 * Z + 0.2 * female + 0.1 * Z * female + U)))
+   ) +
+   declare_inquiry(ATE = mean(Y_Z_1 - Y_Z_0)) + 
+   declare_assignment(Z = complete_ra(N, m = 50), legacy = FALSE) + 
+   declare_measurement(Y = reveal_outcomes(Y ~ Z))
> 
> # Most estimators are modeling functions like lm or glm.
>   
> # Default statistical model is estimatr::difference_in_means
> design + declare_estimator(Y ~ Z, inquiry = "ATE")

Design Summary

Step 1 (model): declare_model(N = 100, female = rbinom(N, 1, 0.5), U = rnorm(N),     potential_outcomes(Y ~ rbinom(N, 1, prob = pnorm(0.2 * Z +         0.2 * female + 0.1 * Z * female + U)))) 

N = 100 

Added variable: ID 
 N_missing N_unique     class
         0      100 character

Added variable: female 
    0    1
   52   48
 0.52 0.48

Added variable: U 
   min median  mean max   sd N_missing N_unique
 -1.91  -0.12 -0.02 2.4 0.94         0      100

Added variable: Y_Z_0 
    0    1
   46   54
 0.46 0.54

Added variable: Y_Z_1 
    0    1
   41   59
 0.41 0.59

Step 2 (inquiry): declare_inquiry(ATE = mean(Y_Z_1 - Y_Z_0)) -------------------

A single draw of the inquiry:
 inquiry_label estimand
           ATE     0.05

Step 3 (assignment): declare_assignment(Z = complete_ra(N, m = 50), legacy = FALSE) 

Added variable: Z 
    0    1
   50   50
 0.50 0.50

Step 4 (measurement): declare_measurement(Y = reveal_outcomes(Y ~ Z)) ----------

Added variable: Y 
    0    1
   41   59
 0.41 0.59

Step 5 (estimator): declare_estimator(Y ~ Z, inquiry = "ATE") ------------------

Formula: Y ~ Z 

A single draw of the estimator:
 estimator_label term estimate  std.error statistic   p.value   conf.low
       estimator    Z     0.02 0.09934479 0.2013191 0.8408664 -0.1771466
 conf.high       df outcome inquiry_label
 0.2171466 97.99457       Y           ATE

> 
> # lm from base R (classical standard errors assuming homoskedasticity)
> design + declare_estimator(Y ~ Z, model = lm, inquiry = "ATE")

Design Summary

Step 1 (model): declare_model(N = 100, female = rbinom(N, 1, 0.5), U = rnorm(N),     potential_outcomes(Y ~ rbinom(N, 1, prob = pnorm(0.2 * Z +         0.2 * female + 0.1 * Z * female + U)))) 

N = 100 

Added variable: ID 
 N_missing N_unique     class
         0      100 character

Added variable: female 
    0    1
   47   53
 0.47 0.53

Added variable: U 
   min median  mean  max   sd N_missing N_unique
 -2.28   -0.1 -0.02 3.27 1.16         0      100

Added variable: Y_Z_0 
    0    1
   49   51
 0.49 0.51

Added variable: Y_Z_1 
    0    1
   43   57
 0.43 0.57

Step 2 (inquiry): declare_inquiry(ATE = mean(Y_Z_1 - Y_Z_0)) -------------------

A single draw of the inquiry:
 inquiry_label estimand
           ATE     0.06

Step 3 (assignment): declare_assignment(Z = complete_ra(N, m = 50), legacy = FALSE) 

Added variable: Z 
    0    1
   50   50
 0.50 0.50

Step 4 (measurement): declare_measurement(Y = reveal_outcomes(Y ~ Z)) ----------

Added variable: Y 
    0    1
   45   55
 0.45 0.55

Step 5 (estimator): declare_estimator(Y ~ Z, model = lm, inquiry = "ATE") ------

Formula: Y ~ Z 

Model:	lm 

A single draw of the estimator:
 estimator_label term estimate std.error statistic   p.value    conf.low
       estimator    Z     0.14  0.099509  1.406908 0.1626182 -0.05747237
 conf.high inquiry_label
 0.3374724           ATE

> 
> # Use lm_robust (linear regression with heteroskedasticity-robust standard errors) 
> # from `estimatr` package
> 
> design + declare_estimator(Y ~ Z, model = lm_robust, inquiry = "ATE")

Design Summary

Step 1 (model): declare_model(N = 100, female = rbinom(N, 1, 0.5), U = rnorm(N),     potential_outcomes(Y ~ rbinom(N, 1, prob = pnorm(0.2 * Z +         0.2 * female + 0.1 * Z * female + U)))) 

N = 100 

Added variable: ID 
 N_missing N_unique     class
         0      100 character

Added variable: female 
    0    1
   52   48
 0.52 0.48

Added variable: U 
  min median mean  max  sd N_missing N_unique
 -2.6  -0.04    0 2.02 1.1         0      100

Added variable: Y_Z_0 
    0    1
   49   51
 0.49 0.51

Added variable: Y_Z_1 
    0    1
   39   61
 0.39 0.61

Step 2 (inquiry): declare_inquiry(ATE = mean(Y_Z_1 - Y_Z_0)) -------------------

A single draw of the inquiry:
 inquiry_label estimand
           ATE      0.1

Step 3 (assignment): declare_assignment(Z = complete_ra(N, m = 50), legacy = FALSE) 

Added variable: Z 
    0    1
   50   50
 0.50 0.50

Step 4 (measurement): declare_measurement(Y = reveal_outcomes(Y ~ Z)) ----------

Added variable: Y 
    0    1
   46   54
 0.46 0.54

Step 5 (estimator): declare_estimator(Y ~ Z, model = lm_robust, inquiry = "ATE") 

Formula: Y ~ Z 

Model:	lm_robust 

A single draw of the estimator:
 estimator_label term estimate std.error statistic   p.value   conf.low
       estimator    Z     0.08 0.1003667 0.7970773 0.4273331 -0.1191744
 conf.high df outcome inquiry_label
 0.2791744 98       Y           ATE

> 
> # use `term` to select particular coefficients
> design + declare_estimator(Y ~ Z*female, term = "Z:female", model = lm_robust)

Design Summary

Step 1 (model): declare_model(N = 100, female = rbinom(N, 1, 0.5), U = rnorm(N),     potential_outcomes(Y ~ rbinom(N, 1, prob = pnorm(0.2 * Z +         0.2 * female + 0.1 * Z * female + U)))) 

N = 100 

Added variable: ID 
 N_missing N_unique     class
         0      100 character

Added variable: female 
    0    1
   55   45
 0.55 0.45

Added variable: U 
   min median  mean max   sd N_missing N_unique
 -2.47  -0.01 -0.03 2.4 0.99         0      100

Added variable: Y_Z_0 
    0    1
   43   57
 0.43 0.57

Added variable: Y_Z_1 
    0    1
   41   59
 0.41 0.59

Step 2 (inquiry): declare_inquiry(ATE = mean(Y_Z_1 - Y_Z_0)) -------------------

A single draw of the inquiry:
 inquiry_label estimand
           ATE     0.02

Step 3 (assignment): declare_assignment(Z = complete_ra(N, m = 50), legacy = FALSE) 

Added variable: Z 
    0    1
   50   50
 0.50 0.50

Step 4 (measurement): declare_measurement(Y = reveal_outcomes(Y ~ Z)) ----------

Added variable: Y 
    0    1
   42   58
 0.42 0.58

Step 5 (estimator): declare_estimator(Y ~ Z * female, term = "Z:female", model = lm_robust) 

Formula: Y ~ Z * female 

Model:	lm_robust 

A single draw of the estimator:
 estimator_label     term  estimate std.error statistic  p.value   conf.low
       estimator Z:female 0.1209141 0.1983692 0.6095409 0.543606 -0.2728456
 conf.high df outcome
 0.5146738 96       Y

> 
> # Use glm from base R
> design + declare_estimator(
+   Y ~ Z + female,
+   family = "gaussian",
+   inquiry = "ATE",
+   model = glm
+ )

Design Summary

Step 1 (model): declare_model(N = 100, female = rbinom(N, 1, 0.5), U = rnorm(N),     potential_outcomes(Y ~ rbinom(N, 1, prob = pnorm(0.2 * Z +         0.2 * female + 0.1 * Z * female + U)))) 

N = 100 

Added variable: ID 
 N_missing N_unique     class
         0      100 character

Added variable: female 
    0    1
   60   40
 0.60 0.40

Added variable: U 
   min median  mean max   sd N_missing N_unique
 -2.77  -0.14 -0.08   2 0.98         0      100

Added variable: Y_Z_0 
    0    1
   55   45
 0.55 0.45

Added variable: Y_Z_1 
    0    1
   45   55
 0.45 0.55

Step 2 (inquiry): declare_inquiry(ATE = mean(Y_Z_1 - Y_Z_0)) -------------------

A single draw of the inquiry:
 inquiry_label estimand
           ATE      0.1

Step 3 (assignment): declare_assignment(Z = complete_ra(N, m = 50), legacy = FALSE) 

Added variable: Z 
    0    1
   50   50
 0.50 0.50

Step 4 (measurement): declare_measurement(Y = reveal_outcomes(Y ~ Z)) ----------

Added variable: Y 
    0    1
   52   48
 0.52 0.48

Step 5 (estimator): declare_estimator(Y ~ Z + female, family = "gaussian", inquiry = "ATE",     model = glm) 

Formula: Y ~ Z + female 

Model:	glm 

A single draw of the estimator:
 estimator_label term  estimate  std.error statistic   p.value    conf.low
       estimator    Z 0.1516779 0.09994535  1.517608 0.1323658 -0.04421144
 conf.high inquiry_label
 0.3475671           ATE

> 
> # If we use logit, we'll need to estimate the average marginal effect with 
> # margins::margins. We wrap this up in function we'll pass to model_summary
> 
> library(margins) # for margins
> library(broom) # for tidy
Error in library(broom) : there is no package called 'broom'
Execution halted