dEdq_nb: Compute Partial Derivatives of Expected Values for a...

View source: R/dEdq_nb.R

dEdq_nbR Documentation

Compute Partial Derivatives of Expected Values for a One-inflated Zero-truncated Negative Binomial Model

Description

This internal function computes the partial derivatives of expected values for a one-inflated zero-truncated negative binomial regression model with respect to covariates. It also accounts for marginal effects of dummy variables.

Usage

dEdq_nb(b, g, a, X, Z, dummies, formula)

Arguments

b

Numeric vector of coefficients for the rate parameter.

g

Numeric vector of coefficients for the inflation process.

a

Numeric scalar, the overdispersion parameter of the negative binomial distribution.

X

Matrix of predictors for the main model, where rows correspond to observations and columns to covariates.

Z

Matrix of predictors for the inflation process, structured similarly to X.

dummies

Character vector of column names from X and Z that are considered dummy variables for which marginal effects need to be computed.

Details

This function performs the following tasks:

  • Computes partial derivatives of expected values with respect to covariates in X and Z.

  • Handles marginal effects for dummy variables by comparing expected values when the dummy variable is set to 0 versus 1.

The function is designed for internal use in the package and assumes that all input matrices and vectors are correctly specified. Any unexpected input structure may result in errors.

Value

A matrix of partial derivatives (or marginal effects) with rows corresponding to observations and columns to covariates. For dummy variables, marginal effects are calculated directly.

See Also

E_negbin for expected values in the negative binomial model.


oneinfl documentation built on April 4, 2025, 12:05 a.m.