rsfm | R Documentation |
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 |
$unrestricted |
A list containing
|
$restricted |
A list containing
|
$out |
INLA or BUGS output |
$time |
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 rsfm_inla$unrestricted$summary_fixed rsfm_inla$restricted$summary_fixed
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.