Documentation ¶
Overview ¶
Package duration supports various methods for statistical analysis of duration data (survival analysis).
Index ¶
- type Concordance
- type CumincRight
- type PHParameter
- type PHReg
- func (ph *PHReg) BaselineCumHaz(stratum int, params []float64) ([]float64, []float64)
- func (ph *PHReg) Dataset() [][]statmodel.Dtype
- func (ph *PHReg) Fit() (*PHResults, error)
- func (ph *PHReg) Focus(pos int, coeff []float64, offset []float64) statmodel.RegFitter
- func (ph *PHReg) Hessian(params statmodel.Parameter, ht statmodel.HessType, hess []float64)
- func (ph *PHReg) LogLike(param statmodel.Parameter, exact bool) float64
- func (ph *PHReg) NumObs() int
- func (ph *PHReg) NumParams() int
- func (ph *PHReg) Score(params statmodel.Parameter, score []float64)
- func (ph *PHReg) Xpos() []int
- type PHRegConfig
- type PHResults
- type PHSummary
- type SurvfuncRight
- type SurvfuncRightConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Concordance ¶
type Concordance struct {
// contains filtered or unexported fields
}
Concordance calculates the survival concordance of Uno et al. (https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3079915).
func NewConcordance ¶
func NewConcordance(time, status, score []float64) *Concordance
NewConcordance creates a new Concordance value with the given parameters.
func (*Concordance) Concordance ¶
func (c *Concordance) Concordance(trunc float64) float64
Concordance returns the concordance statistic, using the given truncation parameter.
func (*Concordance) Done ¶
func (c *Concordance) Done() *Concordance
Done signals that the Concordance value has been built and now can be fit.
func (*Concordance) NumPair ¶
func (c *Concordance) NumPair(npair int) *Concordance
NumPair sets the number of pairs of observations sampled at random to estimate the concordance.
type CumincRight ¶
type CumincRight struct { // Times at which events occur, sorted. Times []float64 // The number of occurrences of events of each type at each // time in Times. Events [][]float64 // Number of events of any type at each time in Times EventsAll []float64 // Risk set size at each time in times NRisk []float64 // The estimated all-cause survival function ProbsAll []float64 // The cause specific cumulative incidence rates. Probs[k] // contains the rates for the events with Status==k+1 // (Status==0 indicates censoring, cumulative incidences are // not estimated for the censored subjects). Probs [][]float64 // The standard errors of the values in Probs ProbsSE [][]float64 // contains filtered or unexported fields }
CumincRight estimates the cumulative incidence functions for duration data with competing risks.
func NewCumincRight ¶
func NewCumincRight(data dstream.Dstream, timevar, statusvar string) *CumincRight
NewCumincRight creates a CumincRight value that can be used to estimate the cumulative incidence function from the given data.
func (*CumincRight) Done ¶
func (ci *CumincRight) Done() *CumincRight
Done completes construction and computes all results.
func (*CumincRight) Entry ¶
func (ci *CumincRight) Entry(entryvar string) *CumincRight
Entry specifies a variable that provides entry times.
func (*CumincRight) Weights ¶
func (ci *CumincRight) Weights(weightvar string) *CumincRight
Weights specifies a variable that povides case weights.
type PHParameter ¶
type PHParameter struct {
// contains filtered or unexported fields
}
PHParameter contains a parameter value for a proportional hazards regression model.
func (*PHParameter) Clone ¶
func (p *PHParameter) Clone() statmodel.Parameter
Clone returns a deep copy of the parameter value.
func (*PHParameter) GetCoeff ¶
func (p *PHParameter) GetCoeff() []float64
GetCoeff returns the array of model coefficients from a parameter value.
func (*PHParameter) SetCoeff ¶
func (p *PHParameter) SetCoeff(x []float64)
SetCoeff sets the array of model coefficients for a parameter value.
type PHReg ¶
type PHReg struct {
// contains filtered or unexported fields
}
PHReg describes a proportional hazards regression model for right censored data.
func NewPHReg ¶
func NewPHReg(data statmodel.Dataset, time, status string, predictors []string, config *PHRegConfig) (*PHReg, error)
NewPHReg returns a PHReg value that can be used to fit a proportional hazards regression model.
func (*PHReg) BaselineCumHaz ¶
BaselineCumHaz returns the Nelson-Aalen estimator of the baseline cumulative hazard function for the given stratum.
func (*PHReg) Focus ¶
Focus returns a new PHReg instance with a single variable, which is variable j in the original model. The effects of the remaining covariates are captured through the offset.
func (*PHReg) Hessian ¶
Hessian computes the Hessian matrix for the model evaluated at the given parameter setting. The Hessian type parameter is not used here.
func (*PHReg) LogLike ¶
LogLike returns the log-likelihood at the given parameter value. The 'exact' parameter is ignored here.
func (*PHReg) NumParams ¶
NumParams returns the number of model parameters (regression coefficients).
type PHRegConfig ¶
type PHRegConfig struct { // A logger to which logging information is wreitten Log *log.Logger // Start contains starting values for the regression parameter estimates Start []float64 // WeightVar is the name of the variable for frequency-weighting the cases, if an empty // string, all weights are equal to 1. WeightVar string // OffsetVar is the name of a variable that defines an offset. OffsetVar string // StrataVar is the name of a variable that defines strata. StrataVar string // EntryVar is the name of a variable that defines entry (left truncation) times. EntryVar string L1Penalty map[string]float64 L2Penalty map[string]float64 // OptMethod is the Gonum optimization used to fit the model. OptMethod optimize.Method // OptSettings configures the Gonum optimization routine. OptSettings *optimize.Settings }
PHRegConfig defines configuration parameters for a proportional hazards regression..
func DefaultPHRegConfig ¶
func DefaultPHRegConfig() *PHRegConfig
DefaultPHRegConfig returns a default configuration struct for a proportional hazards regression.
type PHResults ¶
type PHResults struct {
statmodel.BaseResults
}
PHResults describes the results of a proportional hazards model..
type PHSummary ¶
type PHSummary struct {
// contains filtered or unexported fields
}
PHSummary summarizes a fitted proportional hazards regression model.
type SurvfuncRight ¶
type SurvfuncRight struct {
// contains filtered or unexported fields
}
SurvfuncRight uses the method of Kaplan and Meier to estimate the survival distribution based on (possibly) right censored data. The caller must set Data and TimeVar before calling the Fit method. StatusVar, WeightVar, and EntryVar are optional fields.
func NewSurvfuncRight ¶
func NewSurvfuncRight(data statmodel.Dataset, time, status string, config *SurvfuncRightConfig) (*SurvfuncRight, error)
NewSurvfuncRight creates a new value for fitting a survival function.
func (*SurvfuncRight) Fit ¶
func (sf *SurvfuncRight) Fit()
func (*SurvfuncRight) NumRisk ¶
func (sf *SurvfuncRight) NumRisk() []float64
NumRisk returns the number of people at risk at each time point where the survival function changes.
func (*SurvfuncRight) SurvProb ¶
func (sf *SurvfuncRight) SurvProb() []float64
SurvProb returns the estimated survival probabilities at the points where the survival function changes.
func (*SurvfuncRight) SurvProbSE ¶
func (sf *SurvfuncRight) SurvProbSE() []float64
SurvProbSE returns the standard errors of the estimated survival probabilities at the points where the survival function changes.
func (*SurvfuncRight) Time ¶
func (sf *SurvfuncRight) Time() []float64