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

Yisrμisrf(yisrμisr,σer2)   i=1,,Ns, s=1,,S, r=1,,R,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(μisr)=xisβr+ϕsr+jnet(is)wisjujr+wisur,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},

βrN(0,αI)\boldsymbol{\beta}_{r} \sim \textrm{N}(\boldsymbol{0}, \alpha\boldsymbol{I})

ϕr=(ϕ1r,,ϕSr)N(0,τr2(ρr(diag(A1)A)+(1ρr)I)1),\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}),

uj=(u1j,,uRj)N(0,Σu),\boldsymbol{u}_{j} = (u_{1j},\ldots, u_{Rj}) \sim \textrm{N}(\boldsymbol{0}, \boldsymbol{\Sigma}_{\boldsymbol{u}}),

u=(u1,,uR)N(0,Σu),\boldsymbol{u}^{*} = (u_{1}^*,\ldots, u_{R}^*) \sim \textrm{N}(\boldsymbol{0}, \boldsymbol{\Sigma}_{\boldsymbol{u}}),

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

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

ΣuInverse-Wishart(ξu,Ωu),\boldsymbol{\Sigma}_{\boldsymbol{u}} \sim \textrm{Inverse-Wishart}(\xi_{\boldsymbol{u}}, \boldsymbol{\Omega}_{\boldsymbol{u}}),

σer2Inverse-Gamma(α3,ξ3).\sigma_{er}^{2} \sim \textrm{Inverse-Gamma}(\alpha_{3}, \xi_{3}).

The covariates for the iith individual in the ssth spatial unit or other grouping are included in a p×1p \times 1 vector xis\boldsymbol{x}_{i_s}. The corresponding p×1p \times 1 vector of fixed effect parameters relating to the rrth response are denoted by βr\boldsymbol{\beta}_{r}, which has an assumed multivariate Gaussian prior with mean 0\boldsymbol{0} and diagonal covariance matrix αI\alpha\boldsymbol{I} that can be chosen by the user. A conjugate Inverse-Gamma prior is specified for σer2\sigma_{er}^{2}, and the corresponding hyperparamaterers (α3\alpha_{3}, ξ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 A=(asl)S×S\boldsymbol{A} = (a_{sl})_{S \times S}, which defines how spatially close the SS areal units are to each other. The elements of AS×S\boldsymbol{A}_{S \times S} can be binary or non-binary, and the most common specification is that asl=1a_{sl} = 1 if a pair of areal units (Gs\mathcal{G}_{s}, Gl\mathcal{G}_{l}) share a common border or are considered neighbours by some other measure, and asl=0a_{sl} = 0 otherwise. Note, ass=0a_{ss} = 0 for all ss. τr2\tau^{2}_{r} measures the variance of these random effects for the rrth response, where a conjugate Inverse-Gamma prior is specified for τr2\tau^{2}_{r} and the corresponding hyperparamaterers (a1a_{1}, b1b_{1}) can be chosen by the user. ρr\rho_{r} controls the level of spatial autocorrelation. A non-conjugate uniform prior is specified for ρr\rho_{r}.

The R×1R \times 1 vector of random effects for the jjth alter is denoted by uj=(uj1,,ujR)R×1\boldsymbol{u}_{j} = (u_{j1}, \ldots, u_{jR})_{R \times 1}, while the R×1R \times 1 vector of isolation effects for all RR outcomes is denoted by u=(u1,,uR)\boldsymbol{u}^{*} = (u_{1}^*,\ldots, u_{R}^*), and both are assigned multivariate Gaussian prior distributions. The unstructured covariance matrix Σu\boldsymbol{\Sigma}_{\boldsymbol{u}} captures the covariance between the RR outcomes at the network level, and a conjugate Inverse-Wishart prior is specified for this covariance matrix Σu\boldsymbol{\Sigma}_{\boldsymbol{u}}. The corresponding hyperparamaterers (ξu\xi_{\boldsymbol{u}}, Ω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:

Binomial: YisrBinomial(nisr,θisr) and g(μisr)=ln(θisr/(1θisr)),\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})),

Gaussian: YisrN(μisr,σer2) and g(μisr)=μisr,\textrm{Gaussian:} ~ Y_{i_sr} \sim \textrm{N}(\mu_{i_sr}, \sigma_{er}^{2}) ~ \textrm{and} ~ g(\mu_{i_sr}) = \mu_{i_sr},

Poisson: YisrPoisson(μisr) and g(μisr)=ln(μisr).\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 nisrn_{i_sr}. Only used if family\texttt{family}=“binomial".

family

The data likelihood model that must be “gaussian", “poisson" or “binomial".

squareSpatialNeighbourhoodMatrix

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

W

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

seed

A seed for the MCMC algorithm.

trueBeta

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

trueSpatialRandomEffects

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

trueURandomEffects

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

trueSpatialTauSquared

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

trueSpatialRho

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

trueVarianceCovarianceU

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

trueSigmaSquaredE

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

covarianceBetaPrior

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

a1

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

b1

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

xi

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

omega

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

a3

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

b3

The scale parameter for the Inverse-Gamma distribution relating to the error terms ξ3\xi_{3}. Only used if family\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 β1,,βR\boldsymbol{\beta}_{1}, \ldots, \boldsymbol{\beta}_{R} parameters in the model.

spatialTauSquaredSamples

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

spatialRhoSamples

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

varianceCovarianceUSamples

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

spatialRandomEffectsSamples

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

uRandomEffectsSamples

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

sigmaSquaredESamples

The vector of simulated samples from the posterior distribution of σe12\sigma_{e1}^{2}, \ldots, σeR2\sigma_{eR}^{2} in the model. Only used if family\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 numberOfSamples\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]