@@ -10,14 +10,14 @@ abstract type StatisticalModel end
10
10
11
11
Return the coefficients of the model.
12
12
"""
13
- coef (model :: StatisticalModel ) = error ( " coef is not defined for $( typeof (model)) . " )
13
+ function coef end
14
14
15
15
"""
16
16
coefnames(model::StatisticalModel)
17
17
18
18
Return the names of the coefficients.
19
19
"""
20
- coefnames (model :: StatisticalModel ) = error ( " coefnames is not defined for $( typeof (model)) . " )
20
+ function coefnames end
21
21
22
22
"""
23
23
coeftable(model::StatisticalModel; level::Real=0.95)
@@ -29,14 +29,14 @@ The returned `CoefTable` object implements the
29
29
[Tables.jl](https://github.com/JuliaData/Tables.jl/) interface, and can be
30
30
converted e.g. to a `DataFrame` via `using DataFrames; DataFrame(coeftable(model))`.
31
31
"""
32
- coeftable (model :: StatisticalModel ) = error ( " coeftable is not defined for $( typeof (model)) . " )
32
+ function coeftable end
33
33
34
34
"""
35
35
confint(model::StatisticalModel; level::Real=0.95)
36
36
37
37
Compute confidence intervals for coefficients, with confidence level `level` (by default 95%).
38
38
"""
39
- confint (model :: StatisticalModel ) = error ( " confint is not defined for $( typeof (model)) . " )
39
+ function confint end
40
40
41
41
"""
42
42
deviance(model::StatisticalModel)
@@ -45,39 +45,36 @@ Return the deviance of the model relative to a reference, which is usually when
45
45
the saturated model. It is equal, *up to a constant*, to ``-2 \\ log L``, with ``L``
46
46
the likelihood of the model.
47
47
"""
48
- deviance (model :: StatisticalModel ) = error ( " deviance is not defined for $( typeof (model)) . " )
48
+ function deviance end
49
49
50
50
"""
51
51
islinear(model::StatisticalModel)
52
52
53
53
Indicate whether the model is linear.
54
54
"""
55
- islinear (model :: StatisticalModel ) = error ( " islinear is not defined for $( typeof (model)) . " )
55
+ function islinear end
56
56
57
57
"""
58
58
nulldeviance(model::StatisticalModel)
59
59
60
60
Return the deviance of the null model, that is the one including only the intercept.
61
61
"""
62
- nulldeviance (model:: StatisticalModel ) =
63
- error (" nulldeviance is not defined for $(typeof (model)) ." )
62
+ function nulldeviance end
64
63
65
64
"""
66
65
loglikelihood(model::StatisticalModel)
67
66
68
67
Return the log-likelihood of the model.
69
68
"""
70
- loglikelihood (model:: StatisticalModel ) =
71
- error (" loglikelihood is not defined for $(typeof (model)) ." )
69
+ function loglikelihood end
72
70
73
71
"""
74
72
loglikelihood(model::StatisticalModel)
75
73
76
74
Return the log-likelihood of the null model corresponding to `model`.
77
75
This is usually the model containing only the intercept.
78
76
"""
79
- nullloglikelihood (model:: StatisticalModel ) =
80
- error (" nullloglikelihood is not defined for $(typeof (model)) ." )
77
+ function nullloglikelihood end
81
78
82
79
"""
83
80
loglikelihood(model::StatisticalModel, ::Colon)
@@ -87,24 +84,22 @@ In other words, this is the vector of the pointwise log-likelihood contributions
87
84
88
85
In general, `sum(loglikehood(model, :)) == loglikelihood(model)`.
89
86
"""
90
- loglikelihood (model:: StatisticalModel , :: Colon ) =
91
- error (" loglikelihood(model::StatisticalModel, ::Colon) is not defined for $(typeof (model)) ." )
87
+ function loglikelihood end
92
88
93
89
"""
94
90
loglikelihood(model::StatisticalModel, observation)
95
91
96
92
Return the contribution of `observation` to the log-likelihood of `model`.
97
93
"""
98
- loglikelihood (model:: StatisticalModel , observation) =
99
- error (" loglikelihood(model::StatisticalModel, observation) is not defined for $(typeof (model)) ." )
94
+ function loglikelihood end
100
95
101
96
"""
102
97
score(model::StatisticalModel)
103
98
104
99
Return the score of the model, that is the gradient of the
105
100
log-likelihood with respect to the coefficients.
106
101
"""
107
- score (model :: StatisticalModel ) = error ( " score is not defined for $( typeof (model)) . " )
102
+ function score end
108
103
109
104
"""
110
105
nobs(model::StatisticalModel)
@@ -114,76 +109,75 @@ when using this information, as the definition of an independent observation may
114
109
depending on the model, on the format used to pass the data, on the sampling plan
115
110
(if specified), etc.
116
111
"""
117
- nobs (model :: StatisticalModel ) = error ( " nobs is not defined for $( typeof (model)) . " )
112
+ function nobs end
118
113
119
114
"""
120
115
dof(model::StatisticalModel)
121
116
122
117
Return the number of degrees of freedom consumed in the model, including
123
118
when applicable the intercept and the distribution's dispersion parameter.
124
119
"""
125
- dof (model :: StatisticalModel ) = error ( " dof is not defined for $( typeof (model)) . " )
120
+ function dof end
126
121
127
122
"""
128
123
mss(model::StatisticalModel)
129
124
130
125
Return the model sum of squares.
131
126
"""
132
- mss (model :: StatisticalModel ) = error ( " mss is not defined for $( typeof (model)) . " )
127
+ function mss end
133
128
134
129
"""
135
130
rss(model::StatisticalModel)
136
131
137
132
Return the residual sum of squares of the model.
138
133
"""
139
- rss (model :: StatisticalModel ) = error ( " rss is not defined for $( typeof (model)) . " )
134
+ function rss end
140
135
141
136
"""
142
137
informationmatrix(model::StatisticalModel; expected::Bool = true)
143
138
144
139
Return the information matrix of the model. By default the Fisher information matrix
145
140
is returned, while the observed information matrix can be requested with `expected = false`.
146
141
"""
147
- informationmatrix (model:: StatisticalModel ; expected:: Bool = true ) =
148
- error (" informationmatrix is not defined for $(typeof (model)) ." )
142
+ function informationmatrix end
149
143
150
144
"""
151
145
stderror(model::StatisticalModel)
152
146
153
147
Return the standard errors for the coefficients of the model.
154
148
"""
155
- stderror (model :: StatisticalModel ) = sqrt .( diag ( vcov (model)))
149
+ function stderror end
156
150
157
151
"""
158
152
vcov(model::StatisticalModel)
159
153
160
154
Return the variance-covariance matrix for the coefficients of the model.
161
155
"""
162
- vcov (model :: StatisticalModel ) = error ( " vcov is not defined for $( typeof (model)) . " )
156
+ function vcov end
163
157
164
158
"""
165
159
weights(model::StatisticalModel)
166
160
167
161
Return the weights used in the model.
168
162
"""
169
- weights (model :: StatisticalModel ) = error ( " weights is not defined for $( typeof (model)) . " )
163
+ function weights end
170
164
171
165
"""
172
166
isfitted(model::StatisticalModel)
173
167
174
168
Indicate whether the model has been fitted.
175
169
"""
176
- isfitted (model :: StatisticalModel ) = error ( " isfitted is not defined for $( typeof (model)) . " )
170
+ function isfitted end
177
171
178
172
"""
179
173
Fit a statistical model.
180
174
"""
181
- fit (model :: StatisticalModel , args ... ) = error ( " fit is not defined for $( typeof (model)) . " )
175
+ function fit end
182
176
183
177
"""
184
178
Fit a statistical model in-place.
185
179
"""
186
- fit! (model :: StatisticalModel , args ... ) = error ( " fit! is not defined for $( typeof (model)) . " )
180
+ function fit! end
187
181
188
182
"""
189
183
aic(model::StatisticalModel)
@@ -192,7 +186,7 @@ Akaike's Information Criterion, defined as ``-2 \\log L + 2k``, with ``L`` the l
192
186
of the model, and `k` its number of consumed degrees of freedom
193
187
(as returned by [`dof`](@ref)).
194
188
"""
195
- aic (model :: StatisticalModel ) = - 2 loglikelihood (model) + 2 dof (model)
189
+ function aic end
196
190
197
191
"""
198
192
aicc(model::StatisticalModel)
@@ -202,7 +196,7 @@ defined as ``-2 \\log L + 2k + 2k(k-1)/(n-k-1)``, with ``L`` the likelihood of t
202
196
``k`` its number of consumed degrees of freedom (as returned by [`dof`](@ref)),
203
197
and ``n`` the number of observations (as returned by [`nobs`](@ref)).
204
198
"""
205
- function aicc (model :: StatisticalModel )
199
+ function aicc end
206
200
k = dof (model)
207
201
n = nobs (model)
208
202
- 2 loglikelihood (model) + 2 k + 2 k* (k+ 1 )/ (n- k- 1 )
@@ -216,7 +210,7 @@ the likelihood of the model, ``k`` its number of consumed degrees of freedom
216
210
(as returned by [`dof`](@ref)), and ``n`` the number of observations
217
211
(as returned by [`nobs`](@ref)).
218
212
"""
219
- bic (model :: StatisticalModel ) = - 2 loglikelihood (model) + dof (model) * log ( nobs (model))
213
+ function bic end
220
214
221
215
"""
222
216
r2(model::StatisticalModel)
@@ -227,7 +221,7 @@ Coefficient of determination (R-squared).
227
221
For a linear model, the R² is defined as ``ESS/TSS``, with ``ESS`` the explained sum of squares
228
222
and ``TSS`` the total sum of squares.
229
223
"""
230
- r2 (model :: StatisticalModel ) = error ( " r2/r² is not defined for $( typeof (model)) . " )
224
+ function r2 end
231
225
232
226
const r² = r2
233
227
@@ -241,6 +235,6 @@ For linear models, the adjusted R² is defined as ``1 - (1 - (1-R^2)(n-1)/(n-p))
241
235
the coefficient of determination, ``n`` the number of observations, and ``p`` the number of
242
236
coefficients (including the intercept). This definition is generally known as the Wherry Formula I.
243
237
"""
244
- adjr2 (model :: StatisticalModel ) = error ( " adjr2 is not defined for $( typeof (model)) . " )
238
+ function adjr2 end
245
239
246
240
const adjr² = adjr2
0 commit comments