rsfm: Restricted Spatial Frailty Model

View source: R/rsfm.R

rsfmR Documentation

Restricted Spatial Frailty Model

Description

Fit a Restricted Spatial Frailty model

Usage

rsfm(data, formula, family, area = NULL,
            model = NULL, neigh = NULL,
            proj = "none", nsamp = 1000,
            fast = TRUE, approach = "inla", priors,
            ...)

Arguments

data

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

formula

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

family

"exponential", "weibull", "weibullcure", "loglogistic", "gamma", "lognormal" or "pwe".

area

areal variable name in data.

model

spatial model adopted. Examples: "besag", "besag2" or "r_besag". See INLA::inla.list.models() for other models.

neigh

neighborhood structure. A SpatialPolygonsDataFrame or sf object

proj

"none" or "rhz".

nsamp

number of samples. Default = 1000.

fast

TRUE to use the reduction operator.

approach

"inla" or "mcmc". "mcmc" has less model options.

priors

a list containing:

  • prior_prec: a vector of size two, representing shape and scale for the gamma distribution applied for model precision

...

other parameters used in ?INLA::inla or ?R2OpenBUGS::bugs

Value

$unrestricted

A list containing

  • $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

$restricted

A list containing

  • $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 or BUGS output

$time

time elapsed for fitting the model

Examples

set.seed(123456)

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

##-- Individuals and regions
n_reg <- length(neigh_RJ)
n_id <- sample(x = 3:5, size = n_reg, replace = TRUE)
coefs <- c(0.1, -0.3)
tau <- 1 # Scale of spatial effect

##-- Data
data <- rsurv(n_id = n_id,
              coefs = coefs, cens = 0.5, scale = FALSE,
              cens_type = "right", hazard = "weibull",
              hazard_params = list(weibull = list(alpha = 0.8, variant = 0)),
              spatial = "ICAR",
              neigh = neigh_RJ, tau = tau, confounding = "linear", proj = "none")

##-- Models
weibull_inla <- rsfm(data = data,
                     formula = surv(time = L, event = status) ~ X1 + X2,
                     family = "weibull", model = "none",
                     proj = "rhz", nsamp = 1000, approach = "inla")

rsfm_inla <- rsfm(data = data,
                  formula = surv(time = L, event = status) ~ X1 + X2,
                  family = "weibull", area = "reg",
                  model = "r_besag", neigh = neigh_RJ,
                  proj = "rhz", nsamp = 1000, approach = "inla")

weibull_inla$unrestricted$summary_fixed
rsfm_inla$unrestricted$summary_fixed
rsfm_inla$restricted$summary_fixed


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