Jun Shen
2010-Jul-11 03:39 UTC
[R] How to automatically restart nlme in a user-defined function
Hi, everyone, I wrote a function, which includes an nlme estimation. The problem is sometimes nlme may not converge due to too many random effects. Say a, b are two parameters. if I specify random effects by: random = a+b~1, nlme fails to converge. Then I have to constrain the random effects in a positive definite diagonal matrix by: random = list(pdDiag(a+b~1)) My question is how I can restart nlme within my function. If random = a+b~1 fails, it won't quit and will go back to try random = list(pdDiag(a+b~1)) automatically. Currently I just have to do this manually. Thanks a lot. Jun Shen [[alternative HTML version deleted]]
David Winsemius
2010-Jul-11 03:55 UTC
[R] How to automatically restart nlme in a user-defined function
On Jul 10, 2010, at 11:39 PM, Jun Shen wrote:> Hi, everyone, > > I wrote a function, which includes an nlme estimation. The problem is > sometimes nlme may not converge due to too many random effects. > > Say a, b are two parameters. if I specify random effects by: > > random = a+b~1, > > nlme fails to converge. > > Then I have to constrain the random effects in a positive definite > diagonal > matrix by: > > random = list(pdDiag(a+b~1)) > > My question is how I can restart nlme within my function. If random > = a+b~1 > fails, it won't quit and will go back to try random = list(pdDiag(a > +b~1)) > automatically. Currently I just have to do this manually. Thanks a > lot.?try -- David Winsemius, MD West Hartford, CT