[R] Breakpoint in logistic GLM with 'segmented' package - error: replacement length zero
Peter Hoitinga
peter.hoitinga at gmail.com
Fri May 25 15:34:48 CEST 2012
Hello all,
I've been having trouble with assessing a breakpoint in a logistic GLM
with two explanatory variables. For this analysis I've been using the
'segmented' package version 0.2-9.1. But I keep getting an error and I
don't see where I would be going awry. The situation is the following:
Two explanatory variables:
bedekking - a variable with possible values between 0 and 1 - mine
runs from 0.05 to 0.5, increasing with steps of 0.05
s.size - a count variable - increases from 3 to 25 with steps of 1,
and from 25 to 60 with steps of 5
Each combination of s.size and bedekking has 100 repeats so the
resulting dataframe 'dat.al2' consists of 30000 observations of 3
variables.
Because the response variable has values between 0 and 1, I used a logistic GLM:
> gmodel <- glm(R.AUC ~ bedekking + s.size, data=dat.al2, family = quasibinomial(link=logit))
R.AUC increases with increasing s.size and decreasing bedekking,
looking at the graph shows that the association reaches a plateau at a
s.size of 10 and a bedekking of 0.45. So these are the values I use in
'psi' argument in the 'segmented' function
> psi.mod <- list(0.45, 10)
> names(psi.mod) <- c("bedekking", "s.size")
Then I attempt to run the 'segmented' function:
> seg.gm <- segmented(obj = gmodel, seg.Z= ~bedekking + s.size, psi = psi.mod)
When I run this, after half a minute I get the following error:
Error in ifelse(is.list(o0), o0$dev.no.gap, 10^12) :
replacement has length zero
Does anybody know what might be causing this error, and could somebody
point out where I might go wrong?
Thanks in advance,
Peter
More information about the R-help
mailing list