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 n_{i_sr}. Only used if \texttt{family}=“binomial".

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 \boldsymbol{W} that encodes the social network structure and whose rows sum to 1.

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 \texttt{numberOfSamples}.

seed

A seed for the MCMC algorithm.

trueBeta

If available, the true value of \boldsymbol{\beta}_{1}, \ldots, \boldsymbol{\beta}_{R}.

trueVRandomEffects

If available, the true values of \boldsymbol{v}_{1}, \ldots, \boldsymbol{v}_{S}.

trueURandomEffects

If available, the true values of \boldsymbol{u}_{1}, \ldots, \boldsymbol{u}_{J}, \boldsymbol{u}^{*}.

trueVarianceCovarianceV

If available, the true value of \boldsymbol{\Sigma}_{\boldsymbol{v}}.

trueVarianceCovarianceU

If available, the true value of \boldsymbol{\Sigma}_{\boldsymbol{u}}.

trueSigmaSquaredE

If available, the true value of \sigma_{e1}^{2}, \ldots, \sigma_{eR}^{2}. Only used if \texttt{family}=“gaussian".

covarianceBetaPrior

A scalar prior \alpha for the covariance parameter of the beta prior, such that the covariance is \alpha\boldsymbol{I}.

xiV

The degrees of freedom parameter for the Inverse-Wishart distribution relating to the grouping random effects \xi_{\boldsymbol{v}}.

omegaV

The scale parameter for the Inverse-Wishart distribution relating to the grouping random effects \boldsymbol{\Omega}_{\boldsymbol{v}}.

xi

The degrees of freedom parameter for the Inverse-Wishart distribution relating to the network random effects \xi_{\boldsymbol{u}}.

omega

The scale parameter for the Inverse-Wishart distribution relating to the network random effects \boldsymbol{\Omega}_{\boldsymbol{u}}.

a3

The shape parameter for the Inverse-Gamma distribution relating to the error terms \alpha_{3}. Only used if \texttt{family}=“gaussian".

b3

The scale parameter for the Inverse-Gamma distribution relating to the error terms \xi_{3}. Only used if \texttt{family}=“gaussian".

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 \boldsymbol{\beta}_{1}, \ldots, \boldsymbol{\beta}_{R} parameters in the model.

varianceCovarianceVSamples

The matrix of simulated samples from the posterior distribution of \boldsymbol{\Sigma}_{\boldsymbol{v}} in the model.

varianceCovarianceUSamples

The matrix of simulated samples from the posterior distribution of \boldsymbol{\Sigma}_{\boldsymbol{u}} in the model.

vRandomEffectsSamples

The matrix of simulated samples from the posterior distribution of spatial random effects \boldsymbol{v}_{1}, \ldots, \boldsymbol{v}_{S} in the model.

uRandomEffectsSamples

The matrix of simulated samples from the posterior distribution of network random effects \boldsymbol{u}_{1}, \ldots, \boldsymbol{u}_{J}, \boldsymbol{u}^{*} in the model.

sigmaSquaredESamples

The vector of simulated samples from the posterior distribution of \sigma_{e1}^{2}, \ldots, \sigma_{eR}^{2} in the model. Only used if \texttt{family}=“gaussian".

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 \texttt{numberOfSamples}.

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


[Package netcmc version 1.0.2 Index]