depgraph: Maximum Variance Adjacency Matrix

Description Usage Arguments Value Author(s) References Examples

Description

Function for finding the adjacency matrix that maximizes the variance of a mean estimate given general constraints on the degree of dependence of the observations.

Usage

1
	depgraph(v, d, GR = NULL, solver = "glpk", approximate = 1)

Arguments

v

a matrix with the estimated (sample) covariance matrix.

d

a vector with the observed degree; if length(d)=1 then d is the total number of non-zero (off-diagonal) elements of the adjancency matrix A (for solving a more relaxed version of the problem); if length(d)=nrow(v) then d is the total number of non-zero (off-diagonal) elements of each row of A.

GR

a matrix with the known dependencies. The default is GR = NULL.

solver

a string with the optimization solver to be used. The options are: cplex, glpk and gurobi. The default solver is glpk but cplex or gurobi are much faster. Note that cplex and gurobi require a license, which is free for people affiliated to universities, but not otherwise. Between cplex and gurobi, the gurobi interface for R is much easier to install.

approximate

a scalar that determines whether an exact solution is to be found by solving the original integer programming problem (approximate = 0), or whether an approximate solution is to be obtained by solving the relaxed problem via linear programming (approximate = 1). Of course, obtaining the approximate solution is faster but will result in more conservative variance estimates. The default is approximate = 1.

Value

A list with the following objects:

A_max

adjacency matrix that maximizes the variance;

obj_val

objective value of the graph optimization problem at the optimum;

time

time elapsed to find the optimal solution.

Author(s)

Peter M. Aronow <peter.aronow@yale.edu>, Forrest W. Crawford <forrest.crawford@yale.edu>, Jose R. Zubizarreta <zubizarreta@columbia.edu>.

References

Aronow, P. M., Crawford, F. W., and Zubizarreta, J. R., (2017), "Confidence intervals for linear unbiased estimators under constrained dependence," submitted, X, X-X.

Examples

 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
42
################################# 
# 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

################################# 
# General case
#################################

# Solve (5) in the paper
# Sample covariance matrix
my = mean(y)
v = outer(y-my, y-my)
# 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)
A_max_gral_no_dep = depgraph(v, d, NULL, "glpk", 1)$A_max
# Some known dependencies
A_max_gral_some_dep = depgraph(v, d, GR, "glpk", 1)$A_max

################################# 
# Homoskedastic case
#################################

# Solve (8) in the paper
# No known dependencies (so in (8) in the paper A_R (the matrix of known dependencies) is the n times n matrix of 0's)
v = matrix(1, nrow=n, ncol=n)
A_max_homo_no_dep = depgraph(v, d, NULL, "glpk", 0)$A_max
# Some known dependencies
A_max_homo_some_dep = depgraph(v, d, GR, "glpk", 0)$A_max
	

jrzubizarreta/depinf documentation built on May 20, 2019, 2:07 a.m.