View source: R/multiNetLeroux.R
multiNetLeroux | R Documentation |
This function that generates samples for a multivariate fixed effects, spatial, and network model, which is given by
Y_{i_sr}|μ_{i_sr} \sim f(y_{i_sr}| μ_{i_sr}, σ_{er}^{2}) ~~~ i=1,…, N_{s},~s=1,…,S ,~r=1,…,R,
g(μ_{i_sr}) = \boldsymbol{x}^\top_{i_s} \boldsymbol{β}_{r} + φ_{sr} + ∑_{j\in \textrm{net}(i_s)}w_{i_sj}u_{jr}+ w^{*}_{i_s}u^{*}_{r},
\boldsymbol{β}_{r} \sim \textrm{N}(\boldsymbol{0}, α\boldsymbol{I})
\boldsymbol{φ}_{r} = (φ_{1r},…, φ_{Sr}) \sim \textrm{N}(\boldsymbol{0}, τ_{r}^{2}(ρ_{r}(\textrm{diag}(\boldsymbol{A1})-\boldsymbol{A})+(1-ρ_{r})\boldsymbol{I})^{-1}),
\boldsymbol{u}_{j} = (u_{1j},…, u_{Rj}) \sim \textrm{N}(\boldsymbol{0}, \boldsymbol{Σ}_{\boldsymbol{u}}),
\boldsymbol{u}^{*} = (u_{1}^*,…, u_{R}^*) \sim \textrm{N}(\boldsymbol{0}, \boldsymbol{Σ}_{\boldsymbol{u}}),
τ_{r}^{2} \sim \textrm{Inverse-Gamma}(a_{1}, b_{1}),
ρ_{r} \sim \textrm{Uniform}(0, 1),
\boldsymbol{Σ}_{\boldsymbol{u}} \sim \textrm{Inverse-Wishart}(ξ_{\boldsymbol{u}}, \boldsymbol{Ω}_{\boldsymbol{u}}),
σ_{er}^{2} \sim \textrm{Inverse-Gamma}(α_{3}, ξ_{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{β}_{r}, which has an assumed multivariate Gaussian prior with mean \boldsymbol{0} and diagonal covariance matrix α\boldsymbol{I} that can be chosen by the user. A conjugate Inverse-Gamma prior is specified for σ_{er}^{2}, and the corresponding hyperparamaterers (α_{3}, ξ_{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. τ^{2}_{r} measures the variance of these random effects for the rth response, where a conjugate Inverse-Gamma prior is specified for τ^{2}_{r} and the corresponding hyperparamaterers (a_{1}, b_{1}) can be chosen by the user. ρ_{r} controls the level of spatial autocorrelation. A non-conjugate uniform prior is specified for ρ_{r}.
The R \times 1 vector of random effects for the jth alter is denoted by \boldsymbol{u}_{j} = (u_{j1}, …, 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}^*,…, u_{R}^*), and both are assigned multivariate Gaussian prior distributions. The unstructured covariance matrix \boldsymbol{Σ}_{\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{Σ}_{\boldsymbol{u}}. The corresponding hyperparamaterers (ξ_{\boldsymbol{u}}, \boldsymbol{Ω}_{\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_s}, θ_{i_sr}) ~ \textrm{and} ~ g(μ_{i_sr}) = \textrm{ln}(θ_{i_sr} / (1 - θ_{i_sr})),
\textrm{Gaussian:} ~ Y_{i_sr} \sim \textrm{N}(μ_{i_sr}, σ_{er}^{2}) ~ \textrm{and} ~ g(μ_{i_sr}) = μ_{i_sr},
\textrm{Poisson:} ~ Y_{i_sr} \sim \textrm{Poisson}(μ_{i_sr}) ~ \textrm{and} ~ g(μ_{i_sr}) = \textrm{ln}(μ_{i_sr}).
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)
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{β}_{1}, …, \boldsymbol{β}_{R}. |
trueSpatialRandomEffects |
If available, the true values of \boldsymbol{φ}_{1}, …, \boldsymbol{φ}_{R}. |
trueURandomEffects |
If available, the true values of \boldsymbol{u}_{1}, …, \boldsymbol{u}_{J}, \boldsymbol{u}^{*}. |
trueSpatialTauSquared |
If available, the true values of τ^{2}_{1}, …, τ^{2}_{R}. |
trueSpatialRho |
If available, the true value of ρ_{1}, …, ρ_{R}. |
trueVarianceCovarianceU |
If available, the true value of \boldsymbol{Σ}_{\boldsymbol{u}}. |
trueSigmaSquaredE |
If available, the true value of σ_{e1}^{2}, …, σ_{eR}^{2}. Only used if \texttt{family}=“gaussian". |
covarianceBetaPrior |
A scalar prior α for the covariance parameter of the beta prior, such that the covariance is α\boldsymbol{I}. |
a1 |
The shape parameter for the Inverse-Gamma distribution relating to the spatial random effects α_{1}. |
b1 |
The scale parameter for the Inverse-Gamma distribution relating to the spatial random effects ξ_{1}. |
xi |
The degrees of freedom parameter for the Inverse-Wishart distribution relating to the network random effects ξ_{\boldsymbol{u}}. |
omega |
The scale parameter for the Inverse-Wishart distribution relating to the network random effects \boldsymbol{Ω}_{\boldsymbol{u}}. |
a3 |
The shape parameter for the Inverse-Gamma distribution relating to the error terms α_{3}. Only used if \texttt{family}=“gaussian". |
b3 |
The scale parameter for the Inverse-Gamma distribution relating to the error terms ξ_{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. |
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{β}_{1}, …, \boldsymbol{β}_{R} parameters in the model. |
spatialTauSquaredSamples |
Type: matrix. The matrix of simulated samples from the posterior distribution of τ^{2}_{1}, …, τ^{2}_{R} in the model. |
spatialRhoSamples |
The vector of simulated samples from the posterior distribution of ρ_{1}, …, ρ_{R} in the model. |
varianceCovarianceUSamples |
The matrix of simulated samples from the posterior distribution of \boldsymbol{Σ}_{\boldsymbol{u}} in the model. |
spatialRandomEffectsSamples |
The matrix of simulated samples from the posterior distribution of spatial random effects \boldsymbol{φ}_{1}, …, \boldsymbol{φ}_{R} in the model. |
uRandomEffectsSamples |
The matrix of simulated samples from the posterior distribution of network random effects \boldsymbol{u}_{1}, …, \boldsymbol{u}_{J}, \boldsymbol{u}^{*} in the model. |
sigmaSquaredESamples |
The vector of simulated samples from the posterior distribution of σ_{e1}^{2}, …, σ_{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. |
George Gerogiannis
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.