rsfm.Rd
Fit a Restricted Spatial Frailty model
rsfm(data, formula, family, area = NULL, model = NULL, neigh = NULL, proj = "none", nsamp = 1000, fast = TRUE, approach = "inla", priors, ...)
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 |
model | spatial model adopted. Examples: "besag", "besag2" or "r_besag". See INLA::inla.list.models() for other models. |
neigh | neighborhood structure. A |
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:
|
... | other parameters used in ?INLA::inla or ?R2OpenBUGS::bugs |
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
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
INLA or BUGS output
time elapsed for fitting the model
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#> mean median mode sd lower upper #> (Intercept) -0.522919 -0.522370 -0.519158 0.078081 -0.685750 -0.382050 #> X1 0.096648 0.097850 0.095730 0.074469 -0.040455 0.247275 #> X2 -0.067236 -0.065394 -0.067907 0.075124 -0.197489 0.087755rsfm_inla$unrestricted$summary_fixed#> mean median mode sd lower upper #> (Intercept) -0.414717 -0.412980 -0.412209 0.081163 -0.573901 -0.260027 #> X1 0.099152 0.097447 0.102316 0.081560 -0.057273 0.246594 #> X2 -0.028440 -0.023735 -0.048134 0.311641 -0.610567 0.617034rsfm_inla$restricted$summary_fixed#> mean median mode sd lower upper #> (Intercept) -0.405960 -0.405639 -0.401211 0.079557 -0.568732 -0.259484 #> X1 0.139742 0.140272 0.141981 0.078376 -0.024353 0.270532 #> X2 -0.108584 -0.107503 -0.107639 0.077109 -0.247772 0.058602