-
Notifications
You must be signed in to change notification settings - Fork 10
/
regressionmodel.jl
95 lines (70 loc) · 2.05 KB
/
regressionmodel.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
"""
RegressionModel <: StatisticalModel
Abstract supertype for all regression models.
"""
abstract type RegressionModel <: StatisticalModel end
"""
fitted(model::RegressionModel)
Return the fitted values of the model.
"""
function fitted end
"""
response(model::RegressionModel)
Return the model response (a.k.a. the dependent variable).
"""
function response end
"""
responsename(model::RegressionModel)
Return the name of the model response (a.k.a. the dependent variable).
"""
function responsename end
"""
meanresponse(model::RegressionModel)
Return the mean of the response.
"""
function meanresponse end
"""
modelmatrix(model::RegressionModel)
Return the model matrix (a.k.a. the design matrix).
"""
function modelmatrix end
"""
crossmodelmatrix(model::RegressionModel)
Return `X'X` where `X` is the model matrix of `model`.
This function will return a pre-computed matrix stored in `model` if possible.
"""
crossmodelmatrix(model::RegressionModel) = (x = modelmatrix(model); Symmetric(x' * x))
"""
leverage(model::RegressionModel)
Return the diagonal of the projection matrix of the model.
"""
function leverage end
"""
cooksdistance(model::RegressionModel)
Compute [Cook's distance](https://en.wikipedia.org/wiki/Cook%27s_distance)
for each observation in linear model `model`, giving an estimate of the influence
of each data point.
"""
function cooksdistance end
"""
residuals(model::RegressionModel)
Return the residuals of the model.
"""
function residuals end
"""
predict(model::RegressionModel, [newX])
Form the predicted response of `model`. An object with new covariate values `newX` can be supplied,
which should have the same type and structure as that used to fit `model`; e.g. for a GLM
it would generally be a `DataFrame` with the same variable names as the original predictors.
"""
function predict end
"""
predict!
In-place version of [`predict`](@ref).
"""
function predict! end
"""
dof_residual(model::RegressionModel)
Return the residual degrees of freedom of the model.
"""
function dof_residual end