twopartm-class {twopartm}R Documentation

Class twopartm

Description

A fitted two-part regression model by tpm.

Slots

formula_part1

Formula specified for the first-part model, i.e., the binomial model for indicators about any non-zero responses.

formula_part2

Formula specified for the second-part model, i.e., the glm model for non-zero responses.

data

Data set used to fit the two-part model. It's the same data set as the data argument in tpm.

n:

Number of observations used in the two-part model (with weights > 0).

n_part1

Number of of observations used in the first-part model (with weights > 0), i.e., the binomial model for indicators about any non-zero responses.

n_part2

Number of of observations used in the second-part model (with weights > 0), i.e., the glm model for non-zero responses.

data_model1

The model frame for the first-part model, i.e., the binomial model for indicators about any non-zero responses.

data_model2

The model frame for the second-part model, i.e., the glm model for non-zero responses.

model_part1

An object of class glm of the fitted first-part model, i.e., the binomial model for indicators about any non-zero responses.

model_part2

An object of class glm of the fitted second-part model, i.e., the glm model for non-zero responses.

link_part1

Character string describing the link function of the first-part model, i.e., the binomial model for indicators about any non-zero responses.

family_part2

The family object used in the second-part model, i.e., the glm model for non-zero responses.

weights

A vector of weights used in the two-part model fitting, or NULL if no weights used.

fitted

Fitted mean values by the two-part model, obtained by multiplying the fitted probabilities of non-zero responses and the fitted means of non-zero responses.

residuals

A vector of raw residuals (observed - fitted).

loglik

Log-likelihood values of the fitted two-part model.

y

The response vector.

Author(s)

Yajie Duan, Birol Emir, Griffith Bell and Javier Cabrera

See Also

tpm, AME, margin, glm

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(formula_part1 = exp_tot~female+age, formula_part2 = exp_tot~female+age+ed_colplus,
data = meps,link_part1 = "logit",family_part2 = Gamma(link = "log"))

##get the formula specified for the first-part model
tpmodel@formula_part1

##get the formula specified for the second-part model
tpmodel@formula_part2

##get the log-likelihood for the fitted two-part model
tpmodel@loglik

##get the fitted glm model for the first part
tpmodel@model_part1
##get the fitted glm model for the second part
tpmodel@model_part2



[Package twopartm version 0.1.0 Index]