-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
logLik() should return an object of class "logLik" #77
Comments
Thanks for starting a discussion on this. There are a couple of reasons I avoided returning the logLik class:
I'm open to hearing rebuttal to these points. |
Thanks for the quick response! FWIW, I still think it would be better to:
With respect to your reasoning:
In general, I think function names should reflect what the function does as much as possible, and methods should work within the guidelines of their corresponding generic. So Thanks for considering this. If you're curious, this is the compatibility layer I've written for |
I'm open to changing this functionality, especially for logLik() as it is bad practice. As a side note, no one should ever be using AIC() with changepoint models - it asymptotically recovers too many changepoints. |
Thanks for indulging me. :) FYI, I'm now using library(tidychangepoint)
x <- segment(CET, method = "pelt")
#> method: pelt
fitness(x)
#> MBIC
#> 23.56658
x$segmenter
#> Class 'cpt' : Changepoint Object
#> ~~ : S4 class containing 12 slots with names
#> cpttype date version data.set method test.stat pen.type pen.value minseglen cpts ncpts.max param.est
#>
#> Created on : Thu Jun 8 14:09:02 2023
#>
#> summary(.) :
#> ----------
#> Created Using changepoint version 2.2.4
#> Changepoint type : Change in mean and variance
#> Method of analysis : PELT
#> Test Statistic : Normal
#> Type of penalty : MBIC with value, 23.56658
#> Minimum Segment Length : 2
#> Maximum no. of cpts : Inf
#> Changepoint Locations : 55 57 309 311 330 Created on 2024-04-23 with reprex v2.1.0 |
Oh, but also, I just realized my computation is wrong, because |
Thanks for the great work on this package!
The behavior of
changepoint::logLik.cpt()
is problematic for three reasons:double
instead of an object of classlogLik
, and thus the resulting object doesn't have the attributes thatlogLik
objects should have.This means that other generic functions already defined in
stats
likeAIC()
andBIC()
don't work as expected.Created on 2024-04-03 with reprex v2.1.0
I think it would be better if
changepoint::logLik.cpt()
returned alogLik
object with the appropriate attributes and values. Something like this should do the trick:Created on 2024-04-03 with reprex v2.1.0
The text was updated successfully, but these errors were encountered: