Use this function to simulate a data of a TGMRF.

rtgmrf(rowid = 10, colid = 10, X = NULL, n_var = 1, neigh = NULL,
  n_trials = NULL, E = NULL, rho_s = 0.9, rho_t = 0, rho_st = 0,
  betas = c(-0.1, 0.3, 0.8), intercept = NULL, nu = 2, tau = 1,
  type_data = "gamma-shape", family = "poisson", mat_type = "car",
  seed = 1)

Arguments

rowid

Number of lines of a lattice. (Used if neigh = NULL)

colid

Number of columns of a lattice. (Used if neigh = NULL)

neigh

A object of class nb

betas

Coeficients

intercept

Should use intercept? NULL or coefficiente

nu

Dispersion parameter for gamma models

type_data

Depends of family. 'lognormal', 'lognormal-precision', 'gamma-shape', 'gamma-scale', 'weibull-shape', 'weibull-scale' for Poisson family 'beta-logit', 'beta-probit', 'beta-alpha', 'beta-beta' for Binomial family

family

'poisson' or 'binary'

seed

A seed to reproduce the reuslts

n

Vector with size of binomial trials

rho

Dependence parameter

Value

y Response variable

X Covariates matrix

neigh Neighborhood structure

Q Covariance matrix

mu Means (TGMRF)

eps Errors (GMRF)

Examples

#--- library(mvtnorm) #--- library(spdep) data(nenia)
#> Warning: data set ‘nenia’ not found
coord <- as.data.frame(cbind(x = nenia$x, y = nenia$y))
#> Error in cbind(x = nenia$x, y = nenia$y): object 'nenia' not found
coordinates(coord) <- c("x","y")
#> Error in coordinates(coord) <- c("x", "y"): object 'coord' not found
dst <- 3 neigh <- dnearneigh(coord, 0, dst)
#> Error in dnearneigh(coord, 0, dst): could not find function "dnearneigh"
data_poisson <- rtgmrf_s(neigh = neigh, rho_s = 0.9, betas = c(1, 0.9, -0.1), nu = 2, type_data = 'gamma-shape', family = 'poisson', seed = 1)
#> Error in rtgmrf_s(neigh = neigh, rho_s = 0.9, betas = c(1, 0.9, -0.1), nu = 2, type_data = "gamma-shape", family = "poisson", seed = 1): could not find function "rtgmrf_s"
data_binary <- rtgmrf_s(rowid = 10, colid = 10, rho_s = 0.9, betas = c(1, 0.9), nu = 5, type_data = 'gamma-shape', family = 'poisson', seed = 1)
#> Error in rtgmrf_s(rowid = 10, colid = 10, rho_s = 0.9, betas = c(1, 0.9), nu = 5, type_data = "gamma-shape", family = "poisson", seed = 1): could not find function "rtgmrf_s"