Skip to content

Commit baf223c

Browse files
paldaynalimilan
andauthored
pointwise loglikelihood (#685)
* pointwiseloglikelihood * multiple dispatch instead of names * remove export * Apply suggestions from code review Co-authored-by: Milan Bouchet-Valat <[email protected]> Co-authored-by: Milan Bouchet-Valat <[email protected]>
1 parent e6a729a commit baf223c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/statmodels.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,25 @@ This is usually the model containing only the intercept.
7676
nullloglikelihood(model::StatisticalModel) =
7777
error("nullloglikelihood is not defined for $(typeof(model)).")
7878

79+
"""
80+
loglikelihood(model::StatisticalModel, ::Colon)
81+
82+
Return a vector of each observation's contribution to the log-likelihood of the model.
83+
In other words, this is the vector of the pointwise log-likelihood contributions.
84+
85+
In general, `sum(loglikehood(model, :)) == loglikelihood(model)`.
86+
"""
87+
loglikelihood(model::StatisticalModel, ::Colon) =
88+
error("loglikelihood(model::StatisticalModel, ::Colon) is not defined for $(typeof(model)).")
89+
90+
"""
91+
loglikelihood(model::StatisticalModel, observation)
92+
93+
Return the contribution of `observation` to the log-likelihood of `model`.
94+
"""
95+
loglikelihood(model::StatisticalModel, observation) =
96+
error("loglikelihood(model::StatisticalModel, observation) is not defined for $(typeof(model)).")
97+
7998
"""
8099
score(model::StatisticalModel)
81100

0 commit comments

Comments
 (0)