Re: [R] convergence of coxfilter and coxph
On Mon, 21 May 2007, carol white wrote: > Hi, coxfilter function in genefilter package uses coxph to fit a model > to filter genes. how come that coxfilter could converge to find a > solution in cox model fitting using a data matrix of 8000 variables and > 600 samples but coxph doesn't converge with the same matrix? coxfilter() fits 8000 one-variable models, which works (for appropriate values of "works"). coxph() refuses to fit one 8000-variable model. -thomas __ R-help@stat.math.ethz.ch 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.
Re: [R] convergence
Hi, > how can i write a loop that makes algorithm keeps repeating until a solution > is converged?do i use a for loop? i know that we can use for loop to ask for > a number of repetitions, but how to use it to ask the algorithm to keep > repeating until a solution is converged? I don't know what your problem is, and I am far from being a specialist, but it seems to me that in this case you often use a variable, for example 'epsilon', which measures your "level of convergence". Then you could you use a loop which repeats while this measure is above a certain threshold, for example : while (epsilon > 0.0001) { ... repeated expressions ... } Hope that helps, -- Julien __ R-help@stat.math.ethz.ch 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.
Re: [R] convergence
No. --- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Health Division of Geriatric Medicine and Gerontology Johns Hopkins University Ph: (410) 502-2619 Fax: (410) 614-9625 Email: [EMAIL PROTECTED] Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alberto Monteiro Sent: Thursday, April 19, 2007 9:24 AM To: [EMAIL PROTECTED]; r-help@stat.math.ethz.ch Subject: Re: [R] convergence Ted Harding wrote: > > There are various ways round this, but a 'for' loop with > a fixed number of iterations is not usully one of them! > > The simplest is to use while(). A possibly strategy is > > Y.old <- initial.Y > while(TRUE){ > Y <- compute.Y(Y.old, ...) > if(abs(Y - Y.old) < small.number) break > Y.old <- Y > } > > This will loop indefinitely until the convergence criterion > > abs(Y - Y.old) < small.number > > is met, and then stop. > I guess some precaution must be taken to prevent that the loop runs forever. Those algorithms that must optimize something, but run the risk of running forever, sound like the "chess playing" engine: we know that a deterministic solution exists (there is a finite number of chess positions), but it's not practical to check all of them. I read somewhere that computer loop problems are treated as if the computer was "playing chess" agains Murphy: it tries hard to solve the problem, but sometimes he must give up a path and backtrack to a less optimum but faster solution. Do I make any sense? Alberto Monteiro __ R-help@stat.math.ethz.ch 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. __ R-help@stat.math.ethz.ch 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.
Re: [R] convergence
Ted Harding wrote: > > There are various ways round this, but a 'for' loop with > a fixed number of iterations is not usully one of them! > > The simplest is to use while(). A possibly strategy is > > Y.old <- initial.Y > while(TRUE){ > Y <- compute.Y(Y.old, ...) > if(abs(Y - Y.old) < small.number) break > Y.old <- Y > } > > This will loop indefinitely until the convergence criterion > > abs(Y - Y.old) < small.number > > is met, and then stop. > I guess some precaution must be taken to prevent that the loop runs forever. Those algorithms that must optimize something, but run the risk of running forever, sound like the "chess playing" engine: we know that a deterministic solution exists (there is a finite number of chess positions), but it's not practical to check all of them. I read somewhere that computer loop problems are treated as if the computer was "playing chess" agains Murphy: it tries hard to solve the problem, but sometimes he must give up a path and backtrack to a less optimum but faster solution. Do I make any sense? Alberto Monteiro __ R-help@stat.math.ethz.ch 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.
Re: [R] convergence
rach.s wrote: > hie.. > how can i write a loop that makes algorithm keeps repeating until a solution > is converged?do i use a for loop? i know that we can use for loop to ask for > a number of repetitions, but how to use it to ask the algorithm to keep > repeating until a solution is converged? gregory.liebniz<-function(tol=0.0001) { pi.diff<-1 iter<-0 numer<-1 last.pi<-0 pi4<-0 while(pi.diff > tol) { pi4<-pi4+numer/(2*iter+1) this.pi<-pi4*4 pi.diff<-abs(this.pi-last.pi) last.pi<-this.pi iter<-iter+1 numer<- -numer } return(this.pi) } What you want is probably a while loop, testing for a level of convergence like this simple method for calculating pi. Jim __ R-help@stat.math.ethz.ch 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.
Re: [R] convergence
No, use a while loop. Something like change <- 1 while(abs(change) > .001 ){ do stuff change <- updated change } > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of rach.s > Sent: Thursday, April 19, 2007 8:00 AM > To: r-help@stat.math.ethz.ch > Subject: [R] convergence > > > hie.. > how can i write a loop that makes algorithm keeps repeating > until a solution is converged?do i use a for loop? i know > that we can use for loop to ask for a number of repetitions, > but how to use it to ask the algorithm to keep repeating > until a solution is converged? > Thanks > -- > View this message in context: > http://www.nabble.com/convergence-tf3606834.html#a10076822 > Sent from the R help mailing list archive at Nabble.com. > > __ > R-help@stat.math.ethz.ch 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. > __ R-help@stat.math.ethz.ch 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.
Re: [R] convergence
On 19-Apr-07 12:00:17, rach.s wrote: > > hie.. > how can i write a loop that makes algorithm keeps repeating > until a solution is converged?do i use a for loop? i know > that we can use for loop to ask for a number of repetitions, > but how to use it to ask the algorithm to keep repeating > until a solution is converged? > Thanks There are various ways round this, but a 'for' loop with a fixed number of iterations is not usully one of them! The simplest is to use while(). A possibly strategy is Y.old <- initial.Y while(TRUE){ Y <- compute.Y(Y.old, ...) if(abs(Y - Y.old) < small.number) break Y.old <- Y } This will loop indefinitely until the convergence criterion abs(Y - Y.old) < small.number is met, and then stop. Best wishes, Ted. E-Mail: (Ted Harding) <[EMAIL PROTECTED]> Fax-to-email: +44 (0)870 094 0861 Date: 19-Apr-07 Time: 14:01:51 -- XFMail -- __ R-help@stat.math.ethz.ch 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.
Re: [R] convergence error (lme) which depends on the version of nlme (?)
On 12/12/05, Leo Gürtler <[EMAIL PROTECTED]> wrote: > Dear list members, > > the following hlm was constructed: > > hlm <- groupedData(laut ~ design | grpzugeh, data = imp.not.I) > > the grouped data object is located at and can be downloaded: > > www.anicca-vijja.de/lg/hlm_example.Rdata > > The following works: > > library(nlme) > summary( fitlme <- lme(hlm) ) > > with output: > > ... >AIC BIClogLik > 425.3768 465.6087 -197.6884 > > Random effects: > Formula: ~design | grpzugeh > Structure: General positive-definite > StdDevCorr > (Intercept) 0.3772478 (Intr) dsgn:8 dsgn:7 > designmit:8 0.6776543 0.183 > designohne:7 0.6619983 -0.964 0.086 > designohne:8 1.0680576 -0.966 0.077 1.000 > Residual 1.3468816 Notice that the estimated variance-covariance matrix for the random effects is singular (a correlation of +1.000). The estimates of the parameters in the model are on the boundary and it is not a proper linear mixed model. The definition of a linear mixed model (or at least my definition) requires that the variance-covariance matrix of the random effects be positive definite and this one is only positive semidefinite. > Fixed effects: laut ~ design > Value Std.Error DF t-value p-value > (Intercept) 3.857143 0.2917529 102 13.220579 0. > designmit:8 -0.285714 0.4417919 102 -0.646717 0.5193 > designohne:7 -0.107143 0.4383878 102 -0.244402 0.8074 > designohne:8 0.607143 0.5408713 102 1.122527 0.2643 > Correlation: > (Intr) dsgnm:8 dsgn:7 > designmit:8 -0.451 > designohne:7 -0.775 0.363 > designohne:8 -0.763 0.304 0.699 > > Standardized Within-Group Residuals: >Min Q1Med Q3Max > -2.5074669 -0.4530573 0.1755326 0.5837670 2.374 > > Number of Observations: 112 > Number of Groups: 7 > > > The following does _not_ work and leads to a convergence error: > > fitlme1 <- lme(laut ~ design, random = ~ design | grpzugeh, data = hlm) > Fehler in lme.formula(laut ~ design, random = ~design | grpzugeh, data = > hlm) : > iteration limit reached without convergence (9) > > This was tried with > > R : Copyright 2005, The R Foundation for Statistical Computing > Version 2.2.0 (2005-10-06 r35749) > > Using another R version (2.1.0, also windows with nlme version built > under R 2.1.1) , it works. Thus, what's the problem then? I tried > without the random effects, i.e. > > random = ~ 1 | grpzugeh > > This works. Comparing both calls on the version R2.1.0 that goes well, > the following differences in the output of the random effects can be > identified: > > summary( fitlme <- lme(hlm) ) > > <--> > Random effects: > ... > Structure: General positive-definite > > compared to > > summary(lme(laut ~ design, random = ~ design | grpzugeh, data = hlm)) > > <--> > Random effects: > ... > Structure: General positive-definite, Log-Cholesky parametrization > > > The estimates of the fixed effects are similar, the S.E.s not. > The random effects are different, too. AIC/BIC/logLik are slightly > different. > > Thus my question: > > 1) Do I have overseen a switch for the structure of the random effects? > Is something wrong with the call/ formular? > 2) What is the cause of the convergence error which seems to depend on > the built of R/nlme? > > > Thank you very much. Best wishes, > > leo gürtler > As Dieter indicated in his response, the more current function lmer from the lme4 package (actually it's in the Matrix package but it would be in the lme4 package if a certain capability related to packages were available) is preferred to lme. Fitting your model with the control options for verbose output in both the EM and nlminb iterations produces > (fm1 <- lmer(laut ~ design + (design | grpzugeh), hlm, control = > list(msV=1,EMv=1))) EM iterations 0 407.611 ( 6.0 1.5 1.5 1.5 0.0 0.0 0.0 0.0 0.0 0.0: -0.409-1.07-2.19 -0.969 -0.0472 -0.344 -0.0282 -0.491 -0.1630.941) 1 402.107 ( 10.4497 1.95422 3.22722 2.22340 0.196761 1.02069 0.00757874 1.13553 0.110538 -0.685820: -0.122 -0.550 -0.567 -0.181 0.0294 -0.112 -0.00789 -0.204 -0.01840.361) 2 399.890 ( 14.8865 2.30933 5.18627 2.99207 0.242029 2.06595 -0.0167045 2.18847 0.173349 -1.51318: -0.0497 -0.331 -0.209 0.00812 0.0311 -0.0667 -0.00119 -0.129 0.009420.222) 3 398.756 ( 19.0686 2.58783 7.19874 3.76967 0.147926 3.04342 -0.0686073 3.14563 0.190736 -2.40480: -0.0224 -0.217 -0.0877 0.0682 0.0250 -0.0508 0.00304 -0.0968 0.01780.166) 4 398.074 ( 23.0243 2.81061 9.22509 4.55494 -0.0495774 3.95755 -0.140106 4.03331 0.174045 -3.33077:-0.00975 -0.150 -0.0362 0.0864 0.0192 -0.0422 0.00605 -0.0784 0.02130.134) 5 397.620 ( 26.8048 2.99284 11.2543 5.34938 -0.321835 4.82191 -0.225236 4.87317 0.132590 -4.27703:-0.00344 -0.108 -0.0119 0.0876 0.0145 -0.0360 0.00810
Re: [R] convergence error (lme) which depends on the version of nlme (?)
Leo Gürtler anicca-vijja.de> writes: > > > hlm <- groupedData(laut ~ design | grpzugeh, data = imp.not.I) > > the grouped data object is located at and can be downloaded: > www.anicca-vijja.de/lg/hlm_example.Rdata ... > > > 2) What is the cause of the convergence error which seems to depend on > the built of R/nlme? The optimization engine has in R 2.2.0 changed, with mixed results, see http://finzi.psych.upenn.edu/R/Rhelp02a/archive/64096.html In the short run, setting pnlsTol to a large value than the default worked for me sometimes. In the long run (hope I got Douglas Bates right) you could switch to lme4 which is work in progress, but currently it cannot handle your case. Dieter __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Convergence problem in GLMM
I was trying to install some more packages and ran into a problem I hadn't seen before. Version: platform sparc-sun-solaris2.9 arch sparc os solaris2.9 system sparc, solaris2.9 status major2 minor0.1 year 2004 month11 day 15 language R Fortran compilers available to me: f77: Sun WorkShop 6 update 2 FORTRAN 77 5.3 2001/05/15 f90: Sun WorkShop 6 update 2 Fortran 95 6.2 2001/05/15 f95: Sun WorkShop 6 update 2 Fortran 95 6.2 2001/05/15 Package: gam In fact I didn't ask for this one specifically, I had "dependencies=TRUE" in a call to install.packages(). Problem: Following the installation instructions for R, I had selected F95 as my Fortran compiler. The f95 compiler complained about nearly every line of gam/src/bsplvd.f From the error messages as displayed on the screen, I could see no reason for complaint. However, looking at the file with a text editor immediately revealed the problem. The files bsplvd.fbvalue.fbvalus.floessf.f qsbart.fsgram.f sinerp.fsslvrg.f stxwx.f all use CR-LF line termination. The files linear.flo.fsplsm.f all use LF line termination expected on UNIX. It turns out that the g77 and f77 compilers don't mind CR at the end of a line, but f90 and f95 hate them like poison. Removing the CRs makes f90 and f95 happy again. Second-order problem: I know how to fix the immediate problem. What I don't know is how to intervene in the installation process. What I need to do is - get and unpack files (steps normally done by install.packages) - make changes (remove CR, edit configuration, whatever) - resume whatever install.packages normally does __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
RE: [R] Convergence problem in GLMM
Dear Deepayan, Thanks for the explanation (and for pointing out that the data set is also in the lme4 package). I had tried control=lmeControl(tolerance=1e-4, PQLmaxIt=100) and control=lmeControl(PQLmaxIt=1000), but gave up at that point. I just tried lmeControl(tolerance=1e-4, PQLmaxIt=1000), and that works. I guess I just was insufficiently persistent. Regards, John John Fox Department of Sociology McMaster University Hamilton, Ontario Canada L8S 4M4 905-525-9140x23604 http://socserv.mcmaster.ca/jfox > -Original Message- > From: Deepayan Sarkar [mailto:[EMAIL PROTECTED] > Sent: Tuesday, November 23, 2004 5:10 PM > To: [EMAIL PROTECTED] > Cc: John Fox; 'R-Help' > Subject: Re: [R] Convergence problem in GLMM > > On Tuesday 23 November 2004 11:14, John Fox wrote: > > Dear list members, > > > > In re-running with GLMM() from the lme4 package a > generalized-linear > > mixed model that I had previously fit with glmmPQL() from MASS, I'm > > getting a warning of a convergence failure, even when I set > the method > > argument of > > > > GLMM() to "PQL": > > > bang.mod.1 <- glmmPQL(contraception ~ as.factor(children) > + cage + > > > urban, > > > > + random=~as.factor(children) + cage + urban|district, > > + family=binomial, data=Bangladesh) # works! > > > > > bang.mod.1 <- GLMM(contraception ~ as.factor(children) + cage + > > > urban, > > > > + random=~as.factor(children) + cage + urban|district, > > + family=binomial, data=Bangladesh, method="PQL") > > Warning message: > > IRLS iterations for glmm did not converge in: GLMM(formula = > > contraception ~ as.factor(children) + cage + urban, > > This dataset is also in lme4 as 'Contraception'. > > > Despite the indicated convergence failure, the two sets of > estimates > > are quite close, as one would expect. I've also played around with > > various arguments to lmeControl(), but without success. > > > > I'm curious about the source of the difference, since (as I > understand > > it), essentially the same algorithm is used by the two > functions. I'm > > using R 2.0.1 under Windows XP with the current version of lme4. > > Probably because the convergence criterion is different. glmmPQL has > > if (sum((eta - etaold)^2) < 1e-06 * sum(eta^2)) > break > > GLMM has > > crit <- max(abs(eta - etaold)) / (0.1 + max(abs(eta))) > ## use this to determine convergence > if (crit < controlvals$tolerance) { > conv <- TRUE > break > } > > I'm not sure why we chose that. Setting > > control = list(tolerance = 1e-3, PQLmaxIt = 100) > > converges for me, but that's probably a bit extreme. > > Deepayan __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] Convergence problem in GLMM
On Tuesday 23 November 2004 11:14, John Fox wrote: > Dear list members, > > In re-running with GLMM() from the lme4 package a generalized-linear > mixed model that I had previously fit with glmmPQL() from MASS, I'm > getting a warning of a convergence failure, even when I set the > method argument of > > GLMM() to "PQL": > > bang.mod.1 <- glmmPQL(contraception ~ as.factor(children) + cage + > > urban, > > + random=~as.factor(children) + cage + urban|district, > + family=binomial, data=Bangladesh) # works! > > > bang.mod.1 <- GLMM(contraception ~ as.factor(children) + cage + > > urban, > > + random=~as.factor(children) + cage + urban|district, > + family=binomial, data=Bangladesh, method="PQL") > Warning message: > IRLS iterations for glmm did not converge in: GLMM(formula = > contraception ~ as.factor(children) + cage + urban, This dataset is also in lme4 as 'Contraception'. > Despite the indicated convergence failure, the two sets of estimates > are quite close, as one would expect. I've also played around with > various arguments to lmeControl(), but without success. > > I'm curious about the source of the difference, since (as I > understand it), essentially the same algorithm is used by the two > functions. I'm using R 2.0.1 under Windows XP with the current > version of lme4. Probably because the convergence criterion is different. glmmPQL has if (sum((eta - etaold)^2) < 1e-06 * sum(eta^2)) break GLMM has crit <- max(abs(eta - etaold)) / (0.1 + max(abs(eta))) ## use this to determine convergence if (crit < controlvals$tolerance) { conv <- TRUE break } I'm not sure why we chose that. Setting control = list(tolerance = 1e-3, PQLmaxIt = 100) converges for me, but that's probably a bit extreme. Deepayan __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] convergence in polr
I am really sorry. I was supposed to send it to the Splus users but by mistake I sent to the R-users. Sorry once again On Feb 24 2004, Prof Brian Ripley wrote: Why have you sent a message about S-PLUS to R-help, one that has already been answered on S-news? There is no function nlminb in R. On 24 Feb 2004, C. Spanou wrote: > Hello splus-users, I am trying to fit a regression model for an > ordered response factor. So I am using the function polr in > library(MASS). My data is a matrix of 1665 rows and 63 columns (one of > the column is the dependent variable). The code I use is > polr(as.ordered(q23p)~.,data=newdatap) > but I am getting the following warning message singularity > encountered in: nlminb.1(temp, p, liv, lv, objective, gradient, bounds, > scale) > > I looked in the MASS help for nlminb and I found that for the function > nlminb(start, objective, gradient=NULL, hessian=NULL, >scale=1, control=NULL, lower=-Inf, upper=Inf) > > > when returning a warning message of singularity means that the > optimization algorithm thinks it can't make any further progress > because it has too many degrees of freedom. It usually means that the > objective function is either not differentiable, or it may not have an > optimum. > > So for my data an optimum can't be obtained. > Is this true? > > Can I ignore this warning message since what I want to find is values > for the boundaries? Will the values for the boundaries be accurate even > though I get the warning message? > > __ > [EMAIL PROTECTED] mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read > the posting guide! http://www.R-project.org/posting-guide.html > > __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] convergence in polr
Why have you sent a message about S-PLUS to R-help, one that has already been answered on S-news? There is no function nlminb in R. On 24 Feb 2004, C. Spanou wrote: > Hello splus-users, I am trying to fit a regression model for an ordered > response factor. So I am using the function polr in library(MASS). My data > is a matrix of 1665 rows and 63 columns (one of the column is the dependent > variable). The code I use is polr(as.ordered(q23p)~.,data=newdatap) > but I am getting the following warning message singularity encountered in: > nlminb.1(temp, p, liv, lv, objective, gradient, bounds, scale) > > I looked in the MASS help for nlminb and I found that for the function > nlminb(start, objective, gradient=NULL, hessian=NULL, >scale=1, control=NULL, lower=-Inf, upper=Inf) > > > when returning a warning message of singularity means that the optimization > algorithm thinks it can't make any further progress because it has too many > degrees of freedom. It usually means that the objective function is either > not differentiable, or it may not have an optimum. > > So for my data an optimum can't be obtained. > Is this true? > > Can I ignore this warning message since what I want to find is values for > the boundaries? Will the values for the boundaries be accurate even though > I get the warning message? > > __ > [EMAIL PROTECTED] mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > > -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html