specify_priors {JANE}R Documentation

Specify prior hyperparameters for EM algorithm

Description

A function that allows the user to specify the prior hyperparameters for the EM algorithm in a structure accepted by JANE.

Usage

specify_priors(D, K, model, n_interior_knots = NULL, a, b, c, G, nu, e, f)

Arguments

D

An integer specifying the dimension of the latent positions.

K

An integer specifying the total number of clusters.

model

A character string specifying the model:

  • 'NDH': undirected network with no degree heterogeneity

  • 'RS': undirected network with degree heterogeneity

  • 'RSR': directed network with degree heterogeneity

n_interior_knots

An integer specifying the number of interior knots used in fitting a natural cubic spline for degree heterogeneity models (i.e., 'RS' and 'RSR' only; default is NULL).

a

A numeric vector of length D specifying the mean of the multivariate normal prior on \mu_k for k = 1,\ldots,K, where \mu_k represents the mean of the multivariate normal distribution for the latent positions of the k^{th} cluster.

b

A numeric value specifying the scaling factor on the precision of the multivariate normal prior on \mu_k for k = 1,\ldots,K, where \mu_k represents the mean of the multivariate normal distribution for the latent positions of the k^{th} cluster.

c

A numeric value specifying the degrees of freedom of the Wishart prior on \Omega_k for k = 1,\ldots,K, where \Omega_k represents the precision of the multivariate normal distribution for the latent positions of the k^{th} cluster.

G

A numeric D \times D matrix specifying the inverse of the scale matrix of the Wishart prior on \Omega_k for k = 1,\ldots,K, where \Omega_k represents the precision of the multivariate normal distribution for the latent positions of the k^{th} cluster.

nu

A numeric vector of length K specifying the concentration parameters of the Dirichlet prior on p, where p represents the mixture weights of the finite multivariate normal mixture distribution for the latent positions.

e

A numeric vector of length 1 + (model =='RS')*(n_interior_knots + 1) + (model =='RSR')*2*(n_interior_knots + 1) specifying the mean of the multivariate normal prior on \beta, where \beta represents the coefficients of the logistic regression model.

f

A numeric square matrix of dimension 1 + (model =='RS')*(n_interior_knots + 1) + (model =='RSR')*2*(n_interior_knots + 1) specifying the precision of the multivariate normal prior on \beta, where \beta represents the coefficients of the logistic regression model.

Details

Prior on \mu_k and \Omega_k (note: the same prior is used for k = 1,\ldots,K) :

\pi(\mu_k, \Omega_k) = \pi(\mu_k | \Omega_k) \pi(\Omega_k), thus

\mu_k | \Omega_k \sim MVN(a, (b\Omega_k)^{-1})

\Omega_k \sim Wishart(c, G^{-1})

Prior on p:

For the current implementation we require that all elements of the nu vector be >= 1 to prevent against negative mixture weights for empty clusters.

p \sim Dirichlet(\nu_1 ,\ldots,\nu_K)

Prior on \beta:

\beta \sim MVN(e, f^{-1})

Value

A list of prior hyperparameters for the EM algorithm generated from the input values in a structure accepted by JANE.

Examples


# Simulate network
mus <- matrix(c(-1,-1,1,-1,1,1), 
              nrow = 3,
              ncol = 2, 
              byrow = TRUE)
omegas <- array(c(diag(rep(7,2)),
                  diag(rep(7,2)), 
                  diag(rep(7,2))), 
                  dim = c(2,2,3))
p <- rep(1/3, 3)
beta0 <- 1.0
sim_data <- JANE::sim_A(N = 100L, 
                        model = "RS",
                        mus = mus, 
                        omegas = omegas, 
                        p = p, 
                        beta0 = beta0, 
                        remove_isolates = TRUE)
                        
                        
# Specify prior hyperparameters
D <- 3L
K <- 5L
n_interior_knots <- 5L

a <- rep(1, D)
b <- 3
c <- 4
G <- 10*diag(D)
nu <- rep(2, K)
e <- rep(0.5, 1 + (n_interior_knots + 1))
f <- diag(c(0.1, rep(0.5, n_interior_knots + 1)))

my_prior_hyperparameters <- specify_priors(D = D,
                                           K = K,
                                           model = "RS",
                                           n_interior_knots = n_interior_knots,
                                           a = a,
                                           b = b,
                                           c = c,
                                           G = G,
                                           nu = nu,
                                           e = e,
                                           f = f)
                                           
# Run JANE on simulated data using supplied prior hyperparameters
res <- JANE::JANE(A = sim_data$A,
                  D = D,
                  K = K,
                  initialization = "GNN",
                  model = "RS",
                  case_control = FALSE,
                  DA_type = "none",
                  control = list(priors = my_prior_hyperparameters))
                                                         


[Package JANE version 0.2.1 Index]