I'm trying to apply segmented regression to a response variable that is bounded by 0 and 1, however I am struggling to interpret the error I have encountered. Reproducible example in R:
The error occurs in seg.def.fit in line 300 (call trace() with edit=TRUE to see the code: trace("seg.def.fit", edit = TRUE)). I could not figure out how to work around this error. The source of this problem is surely that betareg$coefficients is not organized as lm$coefficients. Additionally, coef() has a method for betareg objects, further complicating the issue.
I would write to the author: Vito M. R. Muggeo, vito.muggeo[at]unipa.it
The error occurs in seg.def.fit in line 300 (call trace() with edit=TRUE to see the code: trace("seg.def.fit", edit = TRUE)). I could not figure out how to work around this error. The source of this problem is surely that betareg$coefficients is not organized as lm$coefficients. Additionally, coef() has a method for betareg objects, further complicating the issue.
I would write to the author: Vito M. R. Muggeo, vito.muggeo[at]unipa.it
For interest, I can get the above code working with version 0.5-4.0 of segmented and 3.1-1.0 of betareg, though it doesn't detect a breakpoint while other GLM models with less appropriate distribution families do.
As Jochen suggests, the error comes from betareg$coefficients which is a list rather than a vector. I am fixing that and I hope to release next version in a couple of days. Thank you.
I am also trying to implement a segmented beta regression, however, I get a similar error when trying to use predict.segmented(): Error in UseMethod("predict") :
no applicable method for 'predict' applied to an object of class "list"
segmented beta regression is fitted via the default method segmented.default(). It means, as reported in the help file, that you can get the breakpoint estimate with corresponding SE, but you can't use plot.segmented() or predict.segmented().