# vnet: Variance computation for linear regression of network... In netregR: Regression of Network Responses

## Description

Stand-alone estimation of exchangeable variance matrix based on residuals and design matrix.

## Usage

 1 2 vnet(e = NULL, X = NULL, directed = TRUE, nodes = NULL, type = "exchangeable", tmax = 1, fit = NULL) 

## Arguments

 e Optional vector of residuals, of length d. Column-wise unfolding of adjacency matrix without diagonal entries (self-loops). X Optional matrix of covariates from regression, must have d rows. directed Optional logical indicator of whether input data is for a directed network, default is TRUE. Undirected data format is lower triangle of adjacencey matrix. nodes Optional d \times 2 matrix indicating the (directed) relation pairs to which each entry in e and each row in X corresponds. If not input, complete network observation is assumed and the size d and directed must correspond to an appropriate network of size n. type Optional string indicating whether the ‘meat’ in the sandwich variance estimator is estimated using exchangeable theory (see Marrs et. al. (2017)) or using dyadic clustering (Fafchamps and Gubert (2007)). tmax Optional numeric of third dimension of relational data array, default is 1, i.e. a relational matrix. Currently only accepts tmax = 1. fit Optional fitted model object. One of either fit or the pair (e, X) must be specified. Defaults to fit if both entered. Designed around ‘lmnet’ class but may work for others, such as ‘lm’

## Details

This function takes X and e values computes the variance-covariance matrix of \hat{β} that resulted in the residuals e = Y - X \hat{β} assuming that the errors are exchangeable, as based on Marrs et. al. (2017) when type = "exchangeable". When type = "dyadic clustering", the theory from Fafchamps and Gubert (2007) is implemented.

## Value

A an object of class vhat containing summary information:

 vhat Estimated variance-covariance matrix of cofficient estimates \hat{β}. phi Vector of variance-covariance parameter estimates. corrected Logical of whether variance-covariance matrix was corrected from negative definite to positive semi-definite. type See inputs. tmax See inputs.

## References

Marrs, F. W., Fosdick, B. K., & McCormick, T. H., (2017). Standard errors for regression on relational data with exchangeable errors. arXiv preprint arXiv:1701.05530.

Fafchamps, M., & Gubert, F. (2007). Risk sharing and network formation. American Economic Review, 97(2), 75-79.

lmnet, inputs_lmnet
 1 2 3 4 5 6 set.seed(1) n <- 10 d <- n*(n-1) X <- cbind(1, rnorm(d), sample(c(0,1), d, replace=TRUE)) e <- rnorm(d) vnet(e=e,X=X)