Description Usage Arguments Value Examples
Produce Horvitz-Thompson estimators of treatment assignment with standard error estimates, confidence intervals and hypothesis tests.
1 2 | htestimate(outcome, assignment, contrasts, prob_matrix, approx = "youngs",
totals = F, cluster_id = NULL)
|
outcome |
Outcome vector for a given experiment. |
assignment |
Assignment vector for the experiment. |
contrasts |
A list of contasts. For example could be c(-1, 1, 0) for the above example if we wanted to compare treatment 1 to treatment 2. But in a factorial design, for example, we might want to compute the AMCE (see Hainmueller et al.). For example, if we had a 2x2x2 factorial design (8 treatment arms) and we wanted to look at an AMCE we might specify c(0.25, -0.25, 0.25, -0.25, 0.25, -0.25, 0.25, - 0.25) and the elements of the treatment vector should be ti 2 1,2,3,4,5,6,7,8 |
prob_matrix |
Probabilty matrix of assignment, as generated by createProbMatrix. |
approx |
Options for bounding unidentified part of equation. Default: "youngs" - Youngs inequality (see Aronow and Middleton). Other options: "constant effects" - constant effects assumption (See Aronow dissertation section 2.5), "sharp null" - sharp null hypothesis (a special case of the constant effects assumption). |
totals |
Calculate outcome totals rather than means, defaults to False. |
cluster_id |
Cluster identifier, if data is in clusters. Outcomes will then be converted to cluster-totals. |
estimate, standard_error, p value (two-tailed test of null)
1 2 3 4 5 6 7 8 9 | # Example using data from RI package.
y <- c(8,6,2,0,3,1,1,1,2,2,0,1,0,2,2,4,1,1)
z <- c(1,1,0,0,1,1,0,0,1,1,1,1,0,0,1,1,0,0)
# Generate 10,000 random permutations of the assignment vector.
perms = ri::genperms(z, maxiter=10000)
# Estimate the probability of assignment for each unit and assignment level.
prob_matrix = createProbMatrix(perms)
# Estimate the treatment effect using Horvitz-Thompson.
htestimate(y, z, contrasts = c(-1, 1), prob_matrix = prob_matrix)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.