find_k: Find k Based on DIC

Description Usage Arguments Examples

View source: R/fun.r

Description

Fit a series of models with different ks to data, and select the k value based on DIC.

Usage

1
2
3
4
5
find_k(model = c("poisson", "negbinom", "cmp", "Tpoisson", "Tnegbinom",
  "Tcmp"), count, ks = 0:5, type = 0, model_par = list(Xc = NA, Xz =
  NA, Xrc = NA, Xrz = NA, maxiter = 50, size_upper = 100),
  jags_par = list(chain = 2, sample = 1, thin = 5, method = "rjparallel",
  burnin = 500, inits = inix, dic.sample = 1000))

Arguments

model

character string, partially matched to c('poisson', 'negbinom', 'cmp', 'Tpoisson','Tnegbinom', 'Tcmp'): see 'Details'.

ks

numeric vector of integers.

type

numeric value, specifying the type of regression model: 0: no covariates; 1: with covariates; 2: with covariates and random effects. Defaults to 0.

model_par

list of model parameters. Xc is the covariate dataframe for the count model, Xrc is the covariate dataframe of the random effect for the count model, Xz is the covariate dataframe for the zero/one model, Xrz is the covariate dataframe of the random effect for the zero/one model, size_upper is the upper bound of the prior of the size parameter of a negative binomial distribution (defaults to 100) and maxiter is a positive integer, specifying the number of positive term to keep in the calculation of the Conway-Maxwell-Poisson distribution (defaults to 50).

jags_par

list of variables to pass to run.jags function.

data

numeric vector of counts.

Examples

1
x = find_k('pois', legion) # Find k-aggregated zero-inflated Poisson model to the Legionnaires data

HVoltBb/konez documentation built on Nov. 7, 2019, 1:30 a.m.