ego_variance function

Computes variance of YY at ego level

Computes variance of YY at ego level

ego_variance(graph, Y, funname, all = FALSE)

Arguments

  • graph: A matrix of size nnn*n of class dgCMatrix.
  • Y: A numeric vector of length nn.
  • funname: Character scalar. Comparison to make (see vertex_covariate_compare).
  • all: Logical scalar. When FALSE (default) fif_i is mean at ego level. Otherwise is fix for all i (see details).

Returns

A numeric vector of length nn.

Details

For each vertex ii the variance is computed as follows

%(\sum_j a_{ij})^{-1}\sum_j a_{ij} \left[f(y_i,y_j) - f_i\right]^2%(sum_j a(ij))^(-1) * \sum_j a(ij) * [f(y(i),y(j)) - f(i)]^2

Where a(ij)a(ij) is the ij-th element of graph, ff is the function specified in funname, and, if all=FALSE

f(i)=ja(ij)f(y(i),y(j))2/ja(ij)f(i)=\sum_j a(ij)f(y(i), y(j))^2/\sum_j a(ij), otherwise f(i)=f(j)=(1/n2)(i,j)f(yi,yj)f(i)=f(j)=(1/n^2)\sum_(i,j) f(y_i,y_j)

This is an auxiliary function for struct_test. The idea is to compute an adjusted measure of disimilarity between vertices, so the closest in terms of ff is ii to its neighbors, the smaller the relative variance.

See Also

struct_test

Other statistics: bass, classify_adopters(), cumulative_adopt_count(), dgr(), exposure(), hazard_rate(), infection(), moran(), struct_equiv(), threshold(), vertex_covariate_dist()