disgam                package:COZIGAM                R Documentation

_F_i_t_t_i_n_g _D_i_s_c_r_e_t_e _G_e_n_e_r_a_l_i_z_e_d _A_d_d_i_t_i_v_e _M_o_d_e_l_s _w_i_t_h _M_o_d_e_l _S_e_l_e_c_t_i_o_n _C_r_i_t_e_r_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     Fit a discrete Generalized Additive Model (GAM) to data and
     calculate the logarithmic marginal likelihood.

_U_s_a_g_e:

     disgam (formula, size=NULL, family = poisson(), data=list(), ...)

_A_r_g_u_m_e_n_t_s:

 formula: A GAM formula. This is exactly like the formula for a GLM
          except that smooth terms can be added to the right hand side
          of the formula (and a formula of the form 'y ~ .' is not
          allowed). Smooth terms are specified by expressions of the
          form: 's(var1,var2,...,k=12,fx=FALSE,bs="tp",by=a.var)' where
          'var1', 'var2', etc. are the covariates which the smooth is a
          function of and 'k' is the dimension of the basis used to
          represent the smooth term. 'by' can be used to specify a
          variable by which the smooth should be multiplied.

    size: Number of trials. Must be specified when 'family' is
          'binomial'.

  family: This is a family object specifying the distribution and link
          to use in fitting etc. See 'glm' and 'family' for more
          details. Currently support Poisson and binomial
          distributions.

    data: A data frame or list containing the model response variable
          and covariates required by the formula.

     ...: Additional arguments to be passed to the low level regression
          fitting functions.

_D_e_t_a_i_l_s:

     It is necessary to assess whether there is zero-inflation in count
     data, e.g., Poisson or binomial data.  The model selection
     approach can be used to determine whether a zero-inflated model is
     needed. To do that, we can fit both a ZIGAM and a regular GAM to
     the data, and then compare the logarithmic marginal likelihoods
     from these two models. Higher logarithmic marginal likelihood from
     the ZIGAM would indicate that there is zero-inflation in the count
     data. Otherwise, we can simply fit a regular GAM instead of a
     ZIGAM. See Liu and Chan (2008) for more detail.

_V_a_l_u_e:

     A list containing the following components: 

 fit.gam: A fitted GAM assuming there is no zero-inflation in the data.

  V.beta: The estimated covariance matrix of the GAM.

      mu: The fitted mean values.

 formula: Model formula.

  family: The family used.

loglik, ploglik: The (penalized) log-likelihood of the fitted model.

    logE: Approximated logarithmic marginal likelihood by Laplace
          method used for model selection.

_A_u_t_h_o_r(_s):

     Hai Liu and Kung-Sik Chan

_R_e_f_e_r_e_n_c_e_s:

     Liu, H and Chan, K.S. (2008) Constrained Generalized Additive
     Model with Zero-Inflated Data. Technical Report 388, Department of
     Statistics and Actuarial Science, The University of Iowa. <URL:
     http://www.stat.uiowa.edu/techrep/tr388.pdf>

_S_e_e _A_l_s_o:

     'zigam'

_E_x_a_m_p_l_e_s:

     ## Poisson Response
     set.seed(11)
     n <- 200
     x1 <- runif(n, 0, 1)

     eta0 <- f0(x1)/4 - 0.5
     mu0 <- exp(eta0)

     y <- rpois(rep(1,n), mu0) # generating non-zero-inflated data

     res.gam <- disgam(y~s(x1), family=poisson) # fit a regular GAM
     res.zigam <- zigam(y~s(x1), maxiter=10, family=poisson) # fit a ZIGAM

     res.gam$logE > res.zigam$logE # compare the model selction criterion

     # Another example
     set.seed(11)
     n <- 200
     x1 <- runif(n, 0, 1)
     eta0 <- f0(x1)/4 - 0.5
     mu0 <- exp(eta0)

     alpha0 <- 0.4
     delta0 <- 0.8
     p0 <- .Call("logit_linkinv", alpha0 + delta0 * eta0, PACKAGE = "stats")

     # Generating zero-inflated Poisson count data
     z <- rbinom(rep(1,n), 1, p0)
     y <- rpois(rep(1,n), mu0)
     y[z==0] <- 0

     res.gam <- disgam(y~s(x1), family=poisson) # fit a regular GAM
     res.zigam <- zigam(y~s(x1), family=poisson) # fit a ZIGAM

     res.gam$logE < res.zigam$logE # compare the model selction criterion

