@@ -26,6 +26,7 @@ get_exposure_AS <- function(obs_exposure) {
2626# '
2727# ' Runs estimates estimation function from interference package and returns tidy data frame output
2828# '
29+ # '
2930# ' The estimator_AS_tidy function requires the 'interference' package, which is not yet available on CRAN.
3031# '
3132# ' To use this function:
@@ -34,9 +35,30 @@ get_exposure_AS <- function(obs_exposure) {
3435# '
3536# ' See https://book.declaredesign.org/experimental-causal.html#experiments-over-networks
3637# '
37- # ' @param data a data.frame
38- # ' @param permutatation_matrix a permutation matrix of random assignments
39- # ' @param adj_matrix an adjacency matrix
38+ # ' @param data A `data.frame` containing the observed data.
39+ # '
40+ # ' @param permutation_matrix A matrix of random treatment assignments. Each row
41+ # ' corresponds to one permutation of the treatment vector.
42+ # '
43+ # ' @param adj_matrix An adjacency matrix defining the network structure. This
44+ # ' can be created, for example, as follows:
45+ # ' \preformatted{
46+ # ' adjacency <- fairfax |>
47+ # ' as("Spatial") |>
48+ # ' spdep::poly2nb(queen = TRUE) |>
49+ # ' spdep::nb2mat(style = "B", zero.policy = TRUE)
50+ # ' }
51+ # '
52+ # ' @param obs_prob_exposure A set of exposure probabilities. These can be
53+ # ' generated, for example, using:
54+ # ' \preformatted{
55+ # ' prob_exposure <- interference::make_exposure_prob(
56+ # ' potential_tr_vector = permutations,
57+ # ' adj_matrix = adjacency,
58+ # ' exposure_map_fn = interference::make_exposure_map_AS,
59+ # ' exposure_map_fn_add_args = list(hop = 1)
60+ # ' )
61+ # ' }
4062# '
4163# ' @return a data.frame of estimates
4264# '
@@ -45,7 +67,28 @@ get_exposure_AS <- function(obs_exposure) {
4567# ' @importFrom tibble tibble
4668# '
4769estimator_AS_tidy <-
48- function (data , permutatation_matrix , adj_matrix ) {
49- message(" The estimator_AS_tidy function requires the 'interference' package, which is not yet available on CRAN. To use this function, install the developer version of interference via remotes::install_github('szonszein/interference') and then install the developer version of rdss via remotes::install_github('DeclareDesign/rdss@remotes')" )
50- return (invisible ())
70+ function (data , p_matrix , adj_matrix , obs_prob_exposure ) {
71+
72+ obs_exposure <-
73+ interference :: make_exposure_map_AS(
74+ adj_matrix = adj_matrix ,
75+ tr_vector = data $ Z ,
76+ hop = 1
77+ )
78+
79+ out_AS <-
80+ interference :: estimates(
81+ obs_exposure = obs_exposure ,
82+ obs_outcome = data $ Y ,
83+ obs_prob_exposure = obs_prob_exposure ,
84+ n_var_permutations = 30
85+ )
86+
87+ tibble(
88+ term = c(names(out_AS $ tau_ht ), names(out_AS $ tau_h )),
89+ inquiry = rep(c(" total_ATE" , " direct_ATE" , " indirect_ATE" ), 2 ),
90+ estimator = rep(c(" Horvitz-Thompson" , " Hajek" ), each = 3 ),
91+ estimate = c(out_AS $ tau_ht , out_AS $ tau_h )
92+ )
5193 }
94+
0 commit comments