[R] withTimeout does not timeout nlme anymore

Ramiro Barrantes ramiro at precisionbioassay.com
Sun Nov 26 19:02:55 CET 2017


Hello,

I was relying on withTimeout (from R.utils) to help me stop nlme when it “hangs”.  However, recently this stopped working.  I am pasting a reproducible example below: withTimeout should stop nlme after 10 seconds but in this example it does not.  I tried this both on a linux (64 bit, CentOS 7, R 3.4.1, nlme 3.1-131 R.util 2.6) and mac (Sierra 10.13.1, R 3.4.2, same versions or nlme and R.utils).  It takes over R and I need to use brute-force to stop it.  As mentioned, this used to work.

Note that I made my example with fake data so that it would not fit for the purposes of asking for advice on how to create a timeout for it (with withTimeout or other alternatives), so my question is not about convergence.

Thank you in advance for any help,
Ramiro

library(nlme)
library(R.utils)

dat<-data.frame(x=c(3.68887945411394,3.68887945411394,3.68887945411394,3.68887945411394,3.68887945411394,3.68887945411394,3.68887945411394,3.68887945411394,3.68887945411394,3.68887945411394,3.68887945411394,3.68887945411394,2.99573227355399,2.99573227355399,2.99573227355399,2.99573227355399,2.99573227355399,2.99573227355399,2.99573227355399,2.99573227355399,2.99573227355399,2.99573227355399,2.99573227355399,2.99573227355399,2.30258509299405,2.30258509299405,2.30258509299405,2.30258509299405,2.30258509299405,2.30258509299405,2.30258509299405,2.30258509299405,2.30258509299405<tel:(850)%20929-9405>,2.30258509299405,2.30258509299405,2.30258509299405,1.6094379124341,1.6094379124<tel:(609)%20437-9124>341,1.6094379124341,1.6094379124341,1.6094379124341,1.6094379124341,1.6094379124341,1.6094379124341,1.6094379124341,1.6094379124341,1.6094379124341,1.6094379124341,0.916290731874155,0.9162907318<tel:(916)%20290-7318>74155,0.916290731874155,0.916290731874155,0.916290731874155,0.916290731874155,0.9162907318<tel:(916)%20290-7318>74155,0.916290731874155,0.916290731874155,0.916290731874155,0.916290731874155,0.9162907318<tel:(916)%20290-7318>74155,0.22314355131421,0.22314355131421,0.22314355131421,0.22314355131421<tel:(435)%20513-1421>,0.22314355131421,0.22314355131421,0.22314355131421,0.22314355131421,0.22314355131421,0.22314355131421,0.22314355131421<tel:(435)%20513-1421>,0.22314355131421,-0.470003629245736,-0.470003629245736,-0.470003629245736,-0.470003629245736,-0.470003629245736,-0.470003629245736,-0.470003629245736,-0.470003629245736,-0.470003629245736,-0.470003629245736,-0.470003629245736,-0.470003629245736,-1.8562979903<tel:(856)%20297-9903>6563,-1.85629799036563,-1.85629799036563<tel:(979)%20903-6563>,-1.85629799036563,-1.85629799036563,-1.8562979903<tel:(856)%20297-9903>6563,-1.85629799036563,-1.85629799036563<tel:(979)%20903-6563>,-1.85629799036563,-1.85629799036563,-1.8562979903<tel:(856)%20297-9903>6563,-1.85629799036563),y=c(2.3306628084907,-0.306486430184119,3.01207464681402,2.70060231852225,1.33725293267784,5.34369780941295,-0.267201590516114,-1.84139069320937,6.72827177196847,4.52822844192102,1.29157107569539<tel:(710)%20756-9539>,6.91891489430213,-0.759969537970881,1.3082989382<tel:(308)%20298-9382>3302,5.71564722091342,0.436763799674933,1.57330523686824,0.59916586097872,-2.71489460284645,0.711401656644295,-1.17314498858428,-3.34898667814291,3.25224958038328,4.49653456047519,3.40551393855124,3.50650476797142,-1.03926072184952,-2.10354107253151,1.02223260549667,1.33664269096021,4.11266309099612,0.515909252507941,2.8675357708<tel:(867)%20535-7708>4899,2.30080960365487,-4.05493845681005,1.29014437931301,-0.345028313039861,-0.270467043587825,2.18311160982943,0.103101257423303,1.44085444118562,1.44323046208807,1.01066792503854,1.21135794615458,1.32870697360187,1.23403866773281,-0.0960240778852603,-0.580707472247756,1.86075279947663,-1.22088596363264,2.14706773430471,2.52940367724292,0.0632800795606095,-0.857701981133018,1.56980334185512,-1.04879027396504,3.7755553345997,3.02040837800239,3.14723252808468,-1.70718593989965,2.66032762515534,-0.436415482887527<tel:(548)%20288-7527>,2.93587449357705,-0.216693302109348,1.13180451539961,-2.30917214206847,2.03616728416112,-0.027042599451753,4.13768334184361,3.63437837292452,-0.336366845605401,0.0607021250007267,-0.546652566416743,-1.48502861431819,-0.4416995677<tel:(441)%20699-5677>41434,-1.18356734673208,2.19947568241773,-3.3731107438774,-0.569618141275733,-1.34910482405571,-0.821676122645021,-0.210494924487845,2.76805610971345,-1.50099018527536,2.81874922657008,-2.47892179680143,-0.237168391583651,1.05384076104419,1.35730105037783,-0.889060319407602,1.29407560544756,-0.0145655801680721,2.62874531083287,-0.188992792468916,-2.36877528363888,0.193706203424581),id=c("a2","a2","a2","a2","a1","a1","a1","a1","a3","a3","a3","a3","a2","a2","a2","a2","a1","a1","a1","a1","a3","a3","a3","a3","a2","a2","a2","a2","a1","a1","a1","a1","a3","a3","a3","a3","a2","a2","a2","a2","a1","a1","a1","a1","a3","a3","a3","a3","a2","a2","a2","a2","a1","a1","a1","a1","a3","a3","a3","a3","a2","a2","a2","a2","a1","a1","a1","a1","a3","a3","a3","a3","a2","a2","a2","a2","a1","a1","a1","a1","a3","a3","a3","a3","a2","a2","a2","a2","a1","a1","a1","a1","a3","a3","a3","a3"),f.block=c(1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4))
fpl.B.range <- function(lx,logbase,A,B,C,D) {
  A/(1+logbase^(-B*(lx-C)))+D
}
myFormula<-list(formula(A~id),formula(B~id),formula(C~id),formula(D~id))
INIT <- c(A.a1=1,A.a2<https://maps.google.com/?q=1,A.a2&entry=gmail&source=g>=0,A.a3=0,B=1,B.a2=0,B.a3=0,C=0,C.a2=0,C.a3=0,D=1,D.a2<https://maps.google.com/?q=1,D.a2&entry=gmail&source=g>=0,D.a3=0)

try({withTimeout(nlme(model=y~fpl.B.range(x,exp(1),A,B,C,D),
                      control=nlmeControl(maxIter=50,pnlsMaxIter=7,msMaxIter=50,niterEM=25),
                      data=dat, na.action=na.omit,
                      fixed=myFormula,random=list(f.block=pdSymm(A+B+C+D~1)),
                      start=INIT),timeout=10)})



	[[alternative HTML version deleted]]



More information about the R-help mailing list