[R] How to automatically restart nlme in a user-defined function

David Winsemius dwinsemius at comcast.net
Sun Jul 11 05:55:15 CEST 2010


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



More information about the R-help mailing list