spdur {spduration}R Documentation

Split-population duration (cure) regression

Description

This function estimates a split-population duration model and returns a object of class spdur.

Usage

spdur(
  duration,
  atrisk,
  data = NULL,
  last = "end.spell",
  t.0 = "t.0",
  fail = "failure",
  distr = c("weibull", "loglog"),
  max.iter = 300,
  na.action,
  silent = FALSE,
  ...
)

Arguments

duration

A formula of the form Y ~ X1 + X2 ..., where Y is duration until failure or censoring.

atrisk

A formula of the form C ~ Z1 + Z2 ..., where C is a binary indicator of risk (1 - cure).

data

A data frame containing the variables in formula and formula2.

last

A string identifying the vector in data that indicates when a spell ends due to failure or right-censoring.

t.0

The starting point for time-varying covariate intervals, by default duration-1 when using add_duration.

fail

Name of the variable indicating that a spell ended in failure.

distr

The type of distribution to use in the hazard rate. Valid options are “weibull” or “loglog”; defaults to “weibull”.

max.iter

Maximum number of iterations to use in the likelihood maximization.

na.action

a function which indicates what should happen when the data contain NAs. The default is set by the na.action setting of options, and is na.fail if that is unset.

silent

Suppress optimization output, FALSE by default.

...

Optional arguments, see details.

Details

See summary.spdur, predict.spdur , and plot.spdur for post-estimation options.

Optional arguments:

base.inits

Initial values for the base duration model that is estimated to get initial values for the full split-population model. This needs to be a vector with starting values for the constant, coefficients in the duration equation, and an additional value for the shape parameter of the density used, e.g. Weibull. By default they are 0 for all coefficients and 0 or 1 for the Weibull and LogLog shape parameters respectively.

Value

Returns an object of class spdur, with attributes:

coefficients

A named vector of coefficient point estimates.

vcv

Estimated covariance matrix.

se

Standard error estimates.

zstat

Z-statistic values.

pval

P-values.

mf.dur

Model frame for the duration equation.

mf.risk

Model frame for the risk equation.

Y

Matrix of duration variables: risk, duration, end of spell, and t.0.

na.action

What action was taken for missing values in data.

call

The original, unevaluated spdur call.

distr

Distribution used for the hazard rate.

Examples

# Prepare data
data(coups)
dur.coups <- add_duration(coups, "succ.coup", unitID="gwcode", tID="year",
                           freq="year")

# Estimate model
model.coups <- spdur(duration ~ polity2, atrisk ~ polity2, data=dur.coups)
model.coups <- spdur(duration ~ polity2, atrisk ~ polity2, data=dur.coups,
                     distr="loglog")


[Package spduration version 0.17.2 Index]