multiNetLeroux {netcmc}R Documentation

A function that generates samples for a multivariate fixed effects, spatial, and network model.

Description

This function that generates samples for a multivariate fixed effects, spatial, 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} + \phi_{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{\phi}_{r} = (\phi_{1r},\ldots, \phi_{Sr}) \sim \textrm{N}(\boldsymbol{0}, \tau_{r}^{2}(\rho_{r}(\textrm{diag}(\boldsymbol{A1})-\boldsymbol{A})+(1-\rho_{r})\boldsymbol{I})^{-1}),

\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}}),

\tau_{r}^{2} \sim \textrm{Inverse-Gamma}(a_{1}, b_{1}),

\rho_{r} \sim \textrm{Uniform}(0, 1),

\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.

Spatial correlation in these areal unit level random effects is most often modelled by a conditional autoregressive (CAR) prior distribution. Using this model spatial correlation is induced into the random effects via a non-negative spatial adjacency matrix \boldsymbol{A} = (a_{sl})_{S \times S}, which defines how spatially close the S areal units are to each other. The elements of \boldsymbol{A}_{S \times S} can be binary or non-binary, and the most common specification is that a_{sl} = 1 if a pair of areal units (\mathcal{G}_{s}, \mathcal{G}_{l}) share a common border or are considered neighbours by some other measure, and a_{sl} = 0 otherwise. Note, a_{ss} = 0 for all s. \tau^{2}_{r} measures the variance of these random effects for the rth response, where a conjugate Inverse-Gamma prior is specified for \tau^{2}_{r} and the corresponding hyperparamaterers (a_{1}, b_{1}) can be chosen by the user. \rho_{r} controls the level of spatial autocorrelation. A non-conjugate uniform prior is specified for \rho_{r}.

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

multiNetLeroux(formula, data, trials, family, squareSpatialNeighbourhoodMatrix,
spatialAssignment, W, numberOfSamples = 10, burnin = 0, thin = 1, seed = 1,
trueBeta = NULL, trueSpatialRandomEffects = NULL, trueURandomEffects = NULL, 
trueSpatialTauSquared = NULL, trueSpatialRho = NULL, 
trueVarianceCovarianceU = NULL, trueSigmaSquaredE = NULL, 
covarianceBetaPrior = 10^5, a1 = 0.001, b1 = 0.001, xi, omega, a3 = 0.001, 
b3 = 0.001, centerSpatialRandomEffects = 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".

squareSpatialNeighbourhoodMatrix

An S \times S symmetric and non-negative neighbourhood matrix \boldsymbol{A} = (a_{sl})_{S \times S}.

W

A matrix \boldsymbol{W} that encodes the social network structure and whose rows sum to 1.

spatialAssignment

The binary matrix of individual's assignment to spatial area used in the model fitting process.

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}.

trueSpatialRandomEffects

If available, the true values of \boldsymbol{\phi}_{1}, \ldots, \boldsymbol{\phi}_{R}.

trueURandomEffects

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

trueSpatialTauSquared

If available, the true values of \tau^{2}_{1}, \ldots, \tau^{2}_{R}.

trueSpatialRho

If available, the true value of \rho_{1}, \ldots, \rho_{R}.

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}.

a1

The shape parameter for the Inverse-Gamma distribution relating to the spatial random effects \alpha_{1}.

b1

The scale parameter for the Inverse-Gamma distribution relating to the spatial random effects \xi_{1}.

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".

centerSpatialRandomEffects

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.

squareSpatialNeighbourhoodMatrix

The spatial neighbourhood matrix used.

spatialAssignment

The spatial 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.

spatialTauSquaredSamples

Type: matrix. The matrix of simulated samples from the posterior distribution of \tau^{2}_{1}, \ldots, \tau^{2}_{R} in the model.

spatialRhoSamples

The vector of simulated samples from the posterior distribution of \rho_{1}, \ldots, \rho_{R} in the model.

varianceCovarianceUSamples

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

spatialRandomEffectsSamples

The matrix of simulated samples from the posterior distribution of spatial random effects \boldsymbol{\phi}_{1}, \ldots, \boldsymbol{\phi}_{R} 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 .

spatialRandomEffectsAcceptanceRate

The acceptance rates of spatial 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]