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

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.

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.

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.

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)
#> Fitting base weibull... #> Fitting split weibull... #> initial value 350.011512 #> iter 10 value 323.772940 #> iter 20 value 319.813601 #> final value 319.809378 #> converged
model.coups <- spdur(duration ~ polity2, atrisk ~ polity2, data=dur.coups, distr="loglog")
#> Fitting base loglog... #> Fitting split loglog... #> initial value 347.703995 #> iter 10 value 319.703145 #> iter 20 value 317.637103 #> iter 20 value 317.637101 #> iter 20 value 317.637101 #> final value 317.637101 #> converged