Learn R Programming

mpath (version 0.4-2.26)

zipath_fit: Internal function to fit zero-inflated count data linear model with lasso (or elastic net), snet or mnet regularization

Description

Fit zero-inflated regression models for count data via penalized maximum likelihood.

Usage

zipath_fit(X, Z, Y, weights, offsetx, offsetz, standardize=TRUE, 
           intercept = TRUE, family = c("poisson", "negbin", "geometric"), 
           link = c("logit", "probit", "cloglog", "cauchit", "log"), 
           penalty = c("enet", "mnet",  "snet"), start = NULL, y = TRUE, 
           x = FALSE, nlambda=100, lambda.count=NULL, lambda.zero=NULL, 
           type.path=c("active", "nonactive"), penalty.factor.count=NULL, 
           penalty.factor.zero=NULL, lambda.count.min.ratio=.0001, 
           lambda.zero.min.ratio=.1, alpha.count=1, alpha.zero=alpha.count, 
           gamma.count=3, gamma.zero=gamma.count, rescale=FALSE, 
           init.theta=NULL, theta.fixed=FALSE, EM=TRUE, maxit.em=200, 
           convtype=c("count", "both"), maxit= 1000, maxit.theta =10, 
           reltol = 1e-5, thresh=1e-6, eps.bino=1e-5, shortlist=FALSE, 
           trace=FALSE, ...)

Value

An object of class "zipath", i.e., a list with components including

coefficients

a list with elements "count" and "zero" containing the coefficients from the respective models,

residuals

a vector of raw residuals (observed - fitted),

fitted.values

a vector of fitted means,

weights

the case weights used,

terms

a list with elements "count", "zero" and "full" containing the terms objects for the respective models,

theta

estimate of the additional \(\theta\) parameter of the negative binomial model (if a negative binomial regression is used),

loglik

log-likelihood of the fitted model,

family

character string describing the count distribution used,

link

character string describing the link of the zero-inflation model,

linkinv

the inverse link function corresponding to link,

converged

logical value, TRUE indicating successful convergence of zipath, FALSE indicating otherwise

call

the original function call

formula

the original formula

levels

levels of the categorical regressors

model

the full model frame (if model = TRUE),

y

the response count vector (if y = TRUE),

x

a list with elements "count" and "zero" containing the model matrices from the respective models (if x = TRUE),

Arguments

X

predictor matrix of the count model

Z

predictor matrix of the zero model

Y

response variable

weights

optional numeric vector of weights.

offsetx

optional numeric vector with an a priori known component to be included in the linear predictor of the count model.

offsetz

optional numeric vector with an a priori known component to be included in the linear predictor of the zero model.

intercept

Should intercept(s) be fitted (default=TRUE) or set to zero (FALSE)

standardize

Logical flag for x variable standardization, prior to fitting the model sequence. The coefficients are always returned on the original scale. Default is standardize=TRUE.

family

character specification of count model family (a log link is always used).

link

character specification of link function in the binary zero-inflation model (a binomial family is always used).

y, x

logicals. If TRUE the corresponding response and model matrix are returned.

penalty

penalty considered as one of enet, mnet, snet.

start

starting values for the parameters in the linear predictor.

nlambda

number of lambda value, default value is 100. The sequence may be truncated before nlambda is reached if a close to saturated model for the zero component is fitted.

lambda.count

A user supplied lambda.count sequence. Typical usage is to have the program compute its own lambda.count and lambda.zero sequence based on nlambda and lambda.min.ratio.

lambda.zero

A user supplied lambda.zero sequence.

type.path

solution path with default value "active", which is less time computing than "nonactive". If type.path="nonactive", no active set for each element of the lambda sequence and cycle through all the predictor variables. If type.path="active", then cycle through only the active set, then cycle through all the variables for the same penalty parameter. See details below.

penalty.factor.count, penalty.factor.zero

These are numeric vectors with the same length as predictor variables. that multiply lambda.count, lambda.zero, respectively, to allow differential shrinkage of coefficients. Can be 0 for some variables, which implies no shrinkage, and that variable is always included in the model. Default is same shrinkage for all variables.

lambda.count.min.ratio, lambda.zero.min.ratio

Smallest value for lambda.count and lambda.zero, respectively, as a fraction of lambda.max, the (data derived) entry value (i.e. the smallest value for which all coefficients are zero except the intercepts). Note, there is a closed formula for lambda.max for penalty="enet". If rescale=TRUE, lambda.max is the same for penalty="mnet" or "snet". Otherwise, some modifications are required. In the current implementation, for small gamma value, the square root of the computed lambda.zero[1] is used when penalty="mnet" or "snet".

alpha.count

The elastic net mixing parameter for the count part of model. The default value 1 implies no L_2 penalty, as in LASSO.

alpha.zero

The elastic net mixing parameter for the zero part of model. The default value 1 implies no L_2 penalty, as in LASSO.

gamma.count

The tuning parameter of the snet or mnet penalty for the count part of model.

gamma.zero

The tuning parameter of the snet or mnet penalty for the zero part of model.

rescale

logical value, if TRUE, adaptive rescaling

init.theta

The initial value of theta for family="negbin". This is set to NULL since version 0.3-24.

theta.fixed

Logical value only used for family="negbin". If TRUE and init.theta is provided with a numeric value > 0, then init.theta is not updated. If theta.fixed=FALSE, then init.theta will be updated. In this case, if init.theta=NULL, its initial value is computed with intercept-only zero-inflated negbin model.

EM

Using EM algorithm. Not implemented otherwise

convtype

convergency type, default is for count component only for speedy computation

maxit.em

Maximum number of EM algorithm

maxit

Maximum number of coordinate descent algorithm

maxit.theta

Maximum number of iterations for estimating theta scaling parameter if family="negbin". Default value maxit.theta may be increased, yet may slow the algorithm

eps.bino

a lower bound of probabilities to be claimed as zero, for computing weights and related values when family="binomial".

reltol

Convergence criteria, default value 1e-5 may be reduced to make more accurate yet slow

thresh

Convergence threshold for coordinate descent. Defaults value is 1e-6.

shortlist

logical value, if TRUE, limited results return

trace

If TRUE, progress of algorithm is reported

...

Other arguments which can be passed to glmreg or glmregNB

Author

Zhu Wang <zwang145@uthsc.edu>

Details

The algorithm fits penalized zero-inflated count data regression models using the coordinate descent algorithm within the EM algorithm. The returned fitted model object is of class "zipath" and is similar to fitted "glm" and "zeroinfl" objects. For elements such as "coefficients" a list is returned with elements for the zero and count component, respectively.

If type.path="active", the algorithm iterates for a pair (lambda_count, lambda_zero) in a loop:
Step 1: For initial coefficients start_count of the count model and start_zero of the zero model, the EM algorithm is iterated until convergence for the active set with non-zero coefficients determined from start_count and start_zero, respectively.
Step 2: EM is iterated for all the predict variables once.
Step 3: If active set obtained from Step 2 is the same as in Step 1, stop; otherwise, repeat Step 1 and Step 2.
If type.path="nonactive", the EM algorithm iterates for a pair (lambda_count, lambda_zero) with all the predict variables until convergence.

A set of standard extractor functions for fitted model objects is available for objects of class "zipath", including methods to the generic functions print, coef, logLik, residuals, predict. See predict.zipath for more details on all methods.

The program may terminate with the following message:

Error in: while (j <= maxit.em && !converged) { :
Missing value, where TRUE/FALSE is necessary
Calls: zipath
Additionally: Warning:
In glmreg_fit(Znew, probi, weights = weights, standardize = standardize, :
saturated model, exiting ...
Execution halted

One possible reason is that the fitted model is too complex for the data. There are two suggestions to overcome the error. One is to reduce the number of variables. Second, find out what lambda values caused the problem and omit them. Try with other lambda values instead.

References

Zhu Wang, Shuangge Ma, Michael Zappitelli, Chirag Parikh, Ching-Yun Wang and Prasad Devarajan (2014) Penalized Count Data Regression with Application to Hospital Stay after Pediatric Cardiac Surgery, Statistical Methods in Medical Research. 2014 Apr 17. [Epub ahead of print]

Zhu Wang, Shuangge Ma, Ching-Yun Wang, Michael Zappitelli, Prasad Devarajan and Chirag R. Parikh (2014) EM for Regularized Zero Inflated Regression Models with Applications to Postoperative Morbidity after Cardiac Surgery in Children, Statistics in Medicine. 33(29):5192-208.

Zhu Wang, Shuangge Ma and Ching-Yun Wang (2015) Variable selection for zero-inflated and overdispersed data with application to health care demand in Germany, Biometrical Journal. 57(5):867-84.

See Also

zipath, glmreg, glmregNB