Peter Hoitinga
2012-May-25 13:34 UTC
[R] Breakpoint in logistic GLM with 'segmented' package - error: replacement length zero
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
Vito Muggeo (UniPa)
2012-May-25 15:15 UTC
[R] Breakpoint in logistic GLM with 'segmented' package - error: replacement length zero
dear Peter, Your code appears correct, so it is difficult to reply without the data.. If you are interested in further details, please contact me off-list vito Il 25/05/2012 15.34, Peter Hoitinga ha scritto:> 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 > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- ===================================Vito M.R. Muggeo Dip.to Sc Statist e Matem `Vianelli' Universit? di Palermo viale delle Scienze, edificio 13 90128 Palermo - ITALY tel: 091 23895240 fax: 091 485726 http://dssm.unipa.it/vmuggeo