Description Usage Arguments Value Author(s) References Examples
Function for variance estimates of a mean given general constraints on the degree of dependence of the observations.
1 |
y |
a vector with the outcome variable. |
theta |
a vector with the coefficients or weights. |
d |
a vector with the observed degree; if |
GR |
a matrix with the known dependencies. The default is |
case |
a string with the variance estimate to be calculated. If |
solver |
a string with the optimization solver to be used. The options are: |
approximate |
a scalar that determines whether an exact solution is to be found by solving the original integer programming problem ( |
A list with the following objects:
V_hat |
the variance estimate; |
A_max |
adjacency matrix that maximizes the variance; |
obj_val |
the objective value of the graph optimization problem at the optimum; |
time |
time elapsed to find the optimal solution. |
Peter M. Aronow <peter.aronow@yale.edu>, Forrest W. Crawford <forrest.crawford@yale.edu>, Jose R. Zubizarreta <zubizarreta@columbia.edu>.
Aronow, P. M., Crawford, F. W., and Zubizarreta, J. R., (2017), "Confidence intervals for linear unbiased estimators under constrained dependence," submitted, X, X-X.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #################################
# Data
#################################
# Example with 100 nodes
data(example)
# Total number of observations
n = nrow(dat)
# Observed data
# Observed dependencies (observed (known) a_ij's; this is A_R in (5) in the paper)
GR = GR
# Observed degrees
d = dat$degree
# Observed outcomes
y = dat$hiv
# Coefficients or weights
theta = rep(1, length(y))
#################################
# Heteroskedastic case, solve (5) in the paper
#################################
# No known dependencies (so in (5) in the paper A_R (the matrix of known dependencies) is the n times n matrix of 0's)
depvar(y, theta, d, NULL, case = "heteroskedastic", solver = "glpk", approximate = 1)$V_hat
# Some known dependencies
depvar(y, theta, d, GR, case = "heteroskedastic", solver = "glpk", approximate = 1)$V_hat
#################################
# Homoskedastic case, solve (8) in the paper
#################################
# Some known dependencies
depvar(y, theta, d, GR, case = "homoskedastic", solver = "glpk", approximate = 1)$V_hat
# Compare to the more conservative variance estimate from (9) in the paper
depvar(y, theta, d, NULL, case = "homoskedastic")$V_hat
var(y * theta)/n * (1 + sum(pmin(d, n-1))/n)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.