coef-methods {twopartm} | R Documentation |
Method for Function coef
for Two-part Model Objects in Package twopartm
Description
The coef
method for twopartm-class
that extracts model coefficients from a fitted two-part regression model object of class twopartm
.
Usage
## S4 method for signature 'twopartm'
coef(object,model = c("tpm","model1","model2"),...)
Arguments
object |
a fitted two-part model object of class |
model |
character specifying for which part of the model the coefficients should be extracted. It could be either “tpm” for the full two-part model, or “model1”, “model2” for the first-part model and the second-part model respectively.The default is “tpm”. |
... |
arguments passed to |
Details
The coef
method for twopartm-class
by default return a list including two vectors of estimated coefficients for both parts models. By setting the model
argument, the model coefficients for the corresponding model component can be extracted.
Value
Coefficients extracted from the model object twopartm
.
With argument model == "tpm"
this will be a list of two numeric vectors of model coefficients for both parts models. With model == "model1" | "model2"
it will be a numeric vector of coefficients for the selected part's model.
Author(s)
Yajie Duan, Birol Emir, Griffith Bell and Javier Cabrera
References
Belotti, F., Deb, P., Manning, W.G. and Norton, E.C. (2015). twopm: Two-part models. The Stata Journal, 15(1), pp.3-20.
Chambers, J. M. and Hastie, T. J. (1992) Statistical Models in S. Wadsworth & Brooks/Cole.
See Also
Examples
##data about health expenditures, i.e., non-negative continuous response
data(meps,package = "twopartm")
##fit two-part model with the same regressors in both parts, with logistic
##regression model for the first part, and glm with Gamma family with log
##link for the second-part model
tpmodel = tpm(exp_tot~female+age, data = meps,link_part1 = "logit",
family_part2 = Gamma(link = "log"))
tpmodel
##summary information
summary(tpmodel)
##estimated coefficients for both parts
coef(tpmodel)
##estimated coefficients for the first-part model
coef(tpmodel,model = "model1")