/
LSurvival.jl
193 lines (171 loc) · 3.8 KB
/
LSurvival.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
module LSurvival
####### imports #######
using Documenter
using RecipesBase
using Reexport
using Printf
using Random, LinearAlgebra, Tables
#using Zygote
#using Distributions
#import Distributions: Chisq, Normal
import SpecialFunctions: gamma_inc, erfinv, erf, gamma, loggamma, digamma
#using SpecialFunctions
@reexport using StatsModels # ModelFrame, modelframe
#
#import DataFrames: DataFrame
using StatsBase
import StatsBase: CoefTable, StatisticalModel, RegressionModel
import Base: length, size, popat!, push!
#using Optim
import Optim: BFGS, optimize, Options, OnceDifferentiable, TwiceDifferentiable, only_fgh!, LineSearches, InitialHagerZhang
import StatsBase:
aic,
aicc,
bic,
coef,
coeftable,
coefnames,
confint,
deviance,
nulldeviance, #, dof_residual,
dof,
fitted,
fit,
isfitted,
loglikelihood,
#lrtest,
modelmatrix,
model_response,
nullloglikelihood,
nobs,
PValue,
stderror,
residuals,
predict,
predict!,
response,
score,
var,
vcov,
weights
import Base: convert, show
####### exports #######
# Structs
export AbstractPH,
AbstractPSModel,
AbstractNPSurv,
AbstractLSurvivalID,
AbstractLSurvivalParms,
AbstractSurvDist,
AbstractSurvTime,
AJSurv,
ID,
KMSurv,
LSurvivalResp,
LSurvivalCompResp,
PHModel,
PSModel,
PHParms,
PSParms,
PHSurv,
# Strata
Surv
# functions
export kaplan_meier, # interface for estimating cumulative risk from non-parametric estimator
aalen_johansen, # interface for estimating cumulative risk from non-parametric competing risk estimator
coxph, # interface for Cox model
survreg, # interface for parametric survival model
risk_from_coxphmodels, # interface for estimating cumulative risk from hazard specific Cox models
# deprecated
coxmodel, # (deprecated) interface for Cox model
cox_summary, # (deprecated) convenience function to summarize Cox model results
ci_from_coxmodels # (deprecated) interface for estimating cumulative risk from hazard specific Cox models
#re-exports
export aic,
aicc,
bic,
bootstrap,
basehaz!,
coef,
coeftable,
coefnames,
confint,
nulldeviance,
deviance,
dof,
fit,
fit!,
fitted,
lpdf,
lsurv,
model_response,
modelmatrix, #PValue
params,
isfitted,
jackknife,
loglikelihood,
logpartiallikelihood,
lrtest, # re-exported
modelmatrix,
modelresponse,
length,
scale,
shape,
size,
nullloglikelihood,
nulllogpartiallikelihood,
nobs,
response,
score,
stderror,
residuals,
params,
predict,
predict!,
vcov,
weights
# data
export survivaldata
####### Documentation #######
include("docstr.jl")
####### Abstract types #######
"""
$DOC_ABSTRACTLSURVRESP
"""
abstract type AbstractLSurvivalResp end
"""
$DOC_ABSTRACTLSURVPARMS
"""
abstract type AbstractLSurvivalParms end
"""
$DOC_ABSTRACTPH
"""
abstract type AbstractPH <: RegressionModel end # model based on a linear predictor
"""
AbstractPS
Abstract type for parametric survival models
"""
abstract type AbstractPSModel <: RegressionModel end # model based on a linear predictor
"""
$DOC_ABSTRACTNPSURV
"""
abstract type AbstractNPSurv end
"""
AbstractSurvDist
Abstract type for parametric survival distributions
"""
abstract type AbstractSurvDist end
####### function definitions #######
include("shared_structs.jl")
include("distributions.jl")
include("coxmodel.jl")
include("parsurvival.jl")
include("residuals.jl")
include("npsurvival.jl")
include("data_generators.jl")
include("bootstrap.jl")
include("jackknife.jl")
include("plot_recipes.jl")
include("example_data.jl")
include("deprecated.jl")
end