rsglmm | R Documentation |
Fit a Restricted Spatial Generalized Linear Mixed model
rsglmm(data, formula, family,
E = NULL, n = NULL,
area = NULL, model = NULL, neigh = NULL,
proj = "none", nsamp = 1000, burnin = 5000, lag = 1,
priors = list(prior_prec = list(prec = list(prior = "loggamma", param = c(0.5, 0.0005)))),
approach = "inla",
...)
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 |
some allowed families are: 'gaussian', 'poisson' and 'binomial'. The family availability will depend on the approach. |
E |
known component, in the mean for the Poisson likelihoods defined as E = exp( |
n |
a vector containing the number of trials for the binomial likelihood, or the number of required successes for the nbinomial2 likelihood. Default value is set to 1. |
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", "rhz", "hh" or "spock" |
nsamp |
number of samples. Default = 1000. |
burnin |
burn-in size (just for hh). |
lag |
lag parameter (just for hh). |
priors |
a list containing:
|
approach |
'inla' or 'mcmc' |
... |
other parameters used in ?INLA::inla or ?ngspatial::sparse.sglmm |
The fitted model is given by
Y ~ Poisson(E\theta),
log(\theta) = X\beta + \psi,
\psi ~ ICAR(\tau).
$unrestricted |
A list containing
|
$restricted |
A list containing
|
$out |
INLA (unrestricted model) or ngspatial output |
$time |
time elapsed for fitting the model |
set.seed(123456)
##-- Spatial structure
data("neigh_RJ")
beta <- c(-0.5, -0.2)
tau <- 1
##-- Data ----
family <- "poisson"
data <- rglmm(beta = beta, tau = tau, family = family,
confounding = "none", neigh = neigh_RJ,
scale = TRUE)
##-- Models ----
sglm_mod <- rsglmm(data = data, formula = Y ~ X1 + X2,
family = family,
proj = "none", nsamp = 1000)
sglmm_mod <- rsglmm(data = data, formula = Y ~ X1 + X2,
family = family,
area = "reg", model = "besag", neigh = neigh_RJ,
proj = "none", nsamp = 1000)
rglmm_rhz <- rsglmm(data = data, formula = Y ~ X1 + X2,
family = family,
area = "reg", model = "r_besag", neigh = neigh_RJ,
proj = "rhz", nsamp = 1000)
rglmm_spock <- rsglmm(data = data, formula = Y ~ X1 + X2,
family = family,
area = "reg", model = "r_besag", neigh = neigh_RJ,
proj = "spock", nsamp = 1000)
rglmm_hh <- rsglmm(data = data, formula = Y ~ X1 + X2,
family = family,
area = "reg", model = "r_besag", neigh = neigh_RJ,
approach = "mcmc",
proj = "hh", burnin = 5000, nsamp = 1000, lag = 10)
sglm_mod$unrestricted$summary_fixed
sglmm_mod$unrestricted$summary_fixed
rglmm_rhz$unrestricted$summary_fixed
rglmm_rhz$restricted$summary_fixed
rglmm_spock$restricted$summary_fixed
rglmm_hh$restricted$summary_fixed
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.