| multiNetRand {netcmc} | R Documentation | 
A function that generates samples for a multivariate fixed effects, grouping, and network model.
Description
This function that generates samples for a multivariate fixed effects, grouping, and network model, which is given by
Y_{i_sr}|\mu_{i_sr} \sim f(y_{i_sr}| \mu_{i_sr}, \sigma_{er}^{2}) ~~~ i=1,\ldots, N_{s},~s=1,\ldots,S ,~r=1,\ldots,R,
g(\mu_{i_sr}) = \boldsymbol{x}^\top_{i_s} \boldsymbol{\beta}_{r} v_{sr} + \sum_{j\in \textrm{net}(i_s)}w_{i_sj}u_{jr}+ w^{*}_{i_s}u^{*}_{r},
\boldsymbol{\beta}_{r} \sim \textrm{N}(\boldsymbol{0}, \alpha\boldsymbol{I})
\boldsymbol{v}_{s} = (v_{s1},\ldots, v_{sR}) \sim \textrm{N}(\boldsymbol{0}, \boldsymbol{\Sigma}_{\boldsymbol{v}})\boldsymbol{v}_{s} = (v_{s1},\ldots, v_{sR}) \sim \textrm{N}(\boldsymbol{0}, \boldsymbol{\Sigma}_{\boldsymbol{v}}),
\boldsymbol{u}_{j} = (u_{1j},\ldots, u_{Rj}) \sim \textrm{N}(\boldsymbol{0}, \boldsymbol{\Sigma}_{\boldsymbol{u}}),
\boldsymbol{u}^{*} = (u_{1}^*,\ldots, u_{R}^*) \sim \textrm{N}(\boldsymbol{0}, \boldsymbol{\Sigma}_{\boldsymbol{u}}),
\boldsymbol{\Sigma}_{\boldsymbol{v}} \sim \textrm{Inverse-Wishart}(\xi_{\boldsymbol{v}}, \boldsymbol{\Omega}_{\boldsymbol{v}}),
\boldsymbol{\Sigma}_{\boldsymbol{u}} \sim \textrm{Inverse-Wishart}(\xi_{\boldsymbol{u}}, \boldsymbol{\Omega}_{\boldsymbol{u}}),
\sigma_{er}^{2} \sim \textrm{Inverse-Gamma}(\alpha_{3}, \xi_{3}).
The covariates for the ith individual in the sth spatial unit or other grouping are included in a p \times 1 vector \boldsymbol{x}_{i_s}. The corresponding p \times 1 vector of fixed effect parameters relating to the rth response are denoted by \boldsymbol{\beta}_{r}, which has an assumed multivariate Gaussian prior with mean \boldsymbol{0} and diagonal covariance matrix \alpha\boldsymbol{I} that can be chosen by the user. A conjugate Inverse-Gamma prior is specified for \sigma_{er}^{2}, and the corresponding hyperparamaterers (\alpha_{3}, \xi_{3}) can be chosen by the user.
The R \times 1 vector of random effects for the $s$th group is denoted by \boldsymbol{v}_{s} = (v_{s1}, \ldots, v_{sR})_{R \times 1}, which is assigned a joint Gaussian prior distribution with an unstructured covariance matrix \boldsymbol{\Sigma}_{\boldsymbol{v}} that captures the covariance between the R outcomes. A conjugate Inverse-Wishart prior is specified for the random effects covariance matrix \boldsymbol{\Sigma}_{\boldsymbol{v}}. The corresponding hyperparamaterers (\xi_{\boldsymbol{v}}, \boldsymbol{\Omega}_{\boldsymbol{v}}) can be chosen by the user.
The R \times 1 vector of random effects for the jth alter is denoted by \boldsymbol{u}_{j} = (u_{j1}, \ldots, u_{jR})_{R \times 1}, while the R \times 1 vector of isolation effects for all R outcomes is  denoted by \boldsymbol{u}^{*} = (u_{1}^*,\ldots, u_{R}^*), and both are assigned multivariate Gaussian prior distributions. The unstructured covariance matrix \boldsymbol{\Sigma}_{\boldsymbol{u}} captures the covariance between the R outcomes at the network level, and a conjugate Inverse-Wishart prior is specified for this covariance matrix \boldsymbol{\Sigma}_{\boldsymbol{u}}. The corresponding hyperparamaterers (\xi_{\boldsymbol{u}}, \boldsymbol{\Omega}_{\boldsymbol{u}}) can be chosen by the user.
The exact specification of each of the likelihoods (binomial, Gaussian, and Poisson) are given below:
\textrm{Binomial:} ~ Y_{i_sr} \sim \textrm{Binomial}(n_{i_sr}, \theta_{i_sr}) ~ \textrm{and} ~ g(\mu_{i_sr}) = \textrm{ln}(\theta_{i_sr} / (1 - \theta_{i_sr})),
\textrm{Gaussian:} ~ Y_{i_sr} \sim \textrm{N}(\mu_{i_sr}, \sigma_{er}^{2}) ~ \textrm{and} ~ g(\mu_{i_sr}) = \mu_{i_sr},
\textrm{Poisson:} ~ Y_{i_sr} \sim \textrm{Poisson}(\mu_{i_sr}) ~ \textrm{and} ~ g(\mu_{i_sr}) = \textrm{ln}(\mu_{i_sr}).
Usage
multiNetRand(formula, data, trials, family, V, W, numberOfSamples = 10, burnin = 0, 
thin = 1, seed = 1, trueBeta = NULL, trueVRandomEffects = NULL, 
trueURandomEffects = NULL, trueVarianceCovarianceV = NULL, 
trueVarianceCovarianceU = NULL, trueSigmaSquaredE = NULL, 
covarianceBetaPrior = 10^5, xiV, omegaV, xi, omega, a3 = 0.001, 
b3 = 0.001, centerVRandomEffects = TRUE, centerURandomEffects = TRUE)
Arguments
formula | 
 A formula for the covariate part of the model using a similar syntax to that used in the lm() function.  | 
data | 
 An optional data.frame containing the variables in the formula.  | 
trials | 
 A vector the same length as the response containing the total number of trials 
  | 
family | 
 The data likelihood model that must be “gaussian", “poisson" or “binomial".  | 
V | 
 The binary matrix of individual's assignment to groups used in the model fitting process.  | 
W | 
 A matrix   | 
numberOfSamples | 
 The number of samples to generate pre-thin.  | 
burnin | 
 The number of MCMC samples to discard as the burn-in period.  | 
thin | 
 The value by which to thin   | 
seed | 
 A seed for the MCMC algorithm.  | 
trueBeta | 
 If available, the true value of   | 
trueVRandomEffects | 
 If available, the true values of   | 
trueURandomEffects | 
 If available, the true values of   | 
trueVarianceCovarianceV | 
 If available, the true value of   | 
trueVarianceCovarianceU | 
 If available, the true value of   | 
trueSigmaSquaredE | 
 If available, the true value of   | 
covarianceBetaPrior | 
 A scalar prior   | 
xiV | 
 The degrees of freedom parameter for the Inverse-Wishart
distribution relating to the grouping random effects   | 
omegaV | 
 The scale parameter for the Inverse-Wishart distribution 
relating to the grouping random effects   | 
xi | 
 The degrees of freedom parameter for the Inverse-Wishart
distribution relating to the network random effects   | 
omega | 
 The scale parameter for the Inverse-Wishart distribution 
relating to the network random effects   | 
a3 | 
 The shape parameter for the Inverse-Gamma distribution 
relating to the error terms   | 
b3 | 
 The scale parameter for the Inverse-Gamma distribution 
relating to the error terms   | 
centerVRandomEffects | 
 A choice to center the spatial random effects after each iteration of the MCMC sampler.  | 
centerURandomEffects | 
 A choice to center the network random effects after each iteration of the MCMC sampler.  | 
Value
call | 
 The matched call.  | 
y | 
 The response used.  | 
X | 
 The design matrix used.  | 
standardizedX | 
 The standardized design matrix used.  | 
V | 
 The grouping assignment matrix used.  | 
W | 
 The network matrix used.  | 
samples | 
 The matrix of simulated samples from the posterior distribution of each parameter in the model (excluding random effects).  | 
betaSamples | 
 The matrix of simulated samples from the posterior 
distribution of   | 
varianceCovarianceVSamples | 
 The matrix of simulated samples from the posterior 
distribution of   | 
varianceCovarianceUSamples | 
 The matrix of simulated samples from the posterior 
distribution of   | 
vRandomEffectsSamples | 
 The matrix of simulated samples from the posterior 
distribution of spatial random effects   | 
uRandomEffectsSamples | 
 The matrix of simulated samples from the posterior 
distribution of network random effects   | 
sigmaSquaredESamples | 
 The vector of simulated samples from the posterior 
distribution of   | 
acceptanceRates | 
 The acceptance rates of parameters in the model from the MCMC sampling scheme.  | 
vRandomEffectsAcceptanceRate | 
 The acceptance rates of grouping random effects in the model from the MCMC sampling scheme.  | 
uRandomEffectsAcceptanceRate | 
 The acceptance rates of network random effects in the model from the MCMC sampling scheme.  | 
timeTaken | 
 The time taken for the model to run.  | 
burnin | 
 The number of MCMC samples to discard as the burn-in period.  | 
thin | 
 The value by which to thin   | 
DBar | 
 DBar for the model.  | 
posteriorDeviance | 
 The posterior deviance for the model.  | 
posteriorLogLikelihood | 
 The posterior log likelihood for the model.  | 
pd | 
 The number of effective parameters in the model.  | 
DIC | 
 The DIC for the model.  | 
Author(s)
George Gerogiannis