rscm: Restricted Shared Component model

View source: R/rscm.R

rscmR Documentation

Restricted Shared Component model

Description

Fit a Restricted Shared Component model for two diseases

Usage

rscm(data, formula1, formula2, family = c("poisson", "poisson"),
            E1 = NULL, E2 = NULL, area = NULL, neigh = NULL,
            proj = "none", nsamp = 1000,
            priors = list(prior_gamma = c(0, 0.35),
                          prior_prec = list(tau_s = c(0.01, 0.01),
                                            tau_1 = c(0.01, 0.01),
                                            tau_2 = c(0.01, 0.01))),
            random_effects = list(shared = TRUE,
                                  specific_1 = TRUE,
                                  specific_2 = TRUE),
            ...)

Arguments

data

a data frame or list containing the variables in the model.

formula1

an object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted for disease 1.

formula2

an object of class "formula" (or one that can be coerced to that class): a symbolic description of the model to be fitted for disease 2.

family

a vector of size two with two families. Some allowed families are: poisson, nbinomial, zeroinflatedpoisson0, zeroinflatednbinomial0. See INLA::inla.list.models() for more information.

E1

known component, for disease 1, in the mean for the Poisson likelihoods defined as E = exp(η), where η is the linear predictor. Default = 1.

E2

known component, for disease 2, in the mean for the Poisson likelihoods defined as E = exp(η), where η is the linear predictor. Default = 1.

area

areal variable name in data.

neigh

neighborhood structure. A SpatialPolygonsDataFrame or sf object.

proj

"none" or "spock".

nsamp

number of samples. Default = 1000.

priors

a list containing:

  • prior_gamma: a vector of size two containing mean and precision for the normal distribution applied for γ

  • prior_prec: a list with:

    • tau_s: a vector of size two containing shape and scale for the gamma distribution applied for τ_s

    • tau_1: a vector of size two containing shape and scale for the gamma distribution applied for τ_1

    • tau_2: a vector of size two containing shape and scale for the gamma distribution applied for τ_2

random_effects

a list determining which effects should we include in the model. Default: list(shared = TRUE, specific_1 = TRUE, specific_2 = TRUE).

...

other parameters used in ?INLA::inla

Details

The fitted model is given by

Y_1 ~ Poisson(E_1θ_1),

Y_2 ~ Poisson(E_2θ_2),

log(θ_1) = Xβ + γψ + φ_1,

log(θ_2) = Xβ + ψ + φ_2,

ψ ~ ICAR(τ_s); φ_1 ~ ICAR(τ_1); φ_2 ~ ICAR(τ_2).

δ = √γ

Value

$sample

a sample of size nsamp for all parameters in the model

$summary_fixed

summary measures for the coefficients

$summary_hyperpar

summary measures for hyperparameters

$summary_random

summary measures for random quantities

$out

INLA output

$time

time elapsed for fitting the model

Examples

library(spdep)

set.seed(123456)

##-- Spatial structure
data("neigh_RJ")

##-- Parameters
alpha_1 <- 0.5
alpha_2 <- 0.1
beta_1 <- c(-0.5, -0.2)
beta_2 <- c(-0.8, -0.4)
tau_s <- 1
tau_1 <- tau_2 <- 10
delta <- 1.5

##-- Data
data <- rshared(alpha_1 = alpha_1, alpha_2 = alpha_2,
                beta_1 = beta_1, beta_2 = beta_2,
                delta = delta,
                tau_1 = tau_1, tau_2 = tau_2, tau_s = tau_s,
                confounding = "linear",
                neigh = neigh_RJ)

##-- Models
scm_inla <- rscm(data = data,
                 formula1 = Y1 ~ X11 + X12,
                 formula2 = Y2 ~ X21 + X12,
                 family = c("nbinomial", "poisson"),
                 E1 = E1, E2 = E2,
                 area = "reg", neigh = neigh_RJ,
                 priors = list(prior_prec = list(tau_s = c(0.5, 0.05)), prior_gamma = c(0, 0.5)),
                 proj = "none", nsamp = 1000,
                 random_effects = list(shared = TRUE, specific_1 = TRUE, specific_2 = TRUE))

rscm_inla <- rscm(data = data,
                  formula1 = Y1 ~ X11 + X12,
                  formula2 = Y2 ~ X21 + X12,
                  family = c("nbinomial", "poisson"),
                  E1 = E1, E2 = E2,
                  area = "reg", neigh = neigh_RJ,
                  priors = list(prior_prec = list(tau_s = c(0.5, 0.05)), prior_gamma = c(0, 0.5)),
                  proj = "spock", nsamp = 1000,
                  random_effects = list(shared = TRUE, specific_1 = TRUE, specific_2 = TRUE))

##-- Summary
scm_inla$summary_fixed
rscm_inla$summary_fixed

scm_inla$summary_hyperpar
rscm_inla$summary_hyperpar


DouglasMesquita/RASCO documentation built on Nov. 16, 2022, 9:42 p.m.