[R-sig-ME] nonlinear models with warnOnly

Steven McKinney smckinney at bccrc.ca
Thu Feb 4 21:29:25 CET 2010


> -----Original Message-----
> From: r-sig-mixed-models-bounces at r-project.org [mailto:r-sig-mixed-
> models-bounces at r-project.org] On Behalf Of Chaehyung Ahn
> Sent: Thursday, February 04, 2010 9:36 AM
> To: r-sig-mixed-models at r-project.org
> Subject: [R-sig-ME] nonlinear models with warnOnly
> 
> Dear list,
> 
> I need to make nls() or gnls() function to return something like "NA"
> when
> it fails to fit. I found I can use "warnOnly", but I cannot make it
> work.
> 
> In the following program. I intentionally make it fail by making very
> wrong
> initial values, but the "out" is empty. What is wrong with my approach?
> 
> Many thanks in advance!
> 
> library(nlme)
> out<- gnls(conc~SSbiexp(time,A,lalpha,B,lbeta),
>           start=list(A=-1,lalpha=2,B=20,lbeta=4),
>           weights=varPower(fixed=1),control=list(warnOnly=TRUE),
>           data=Indometh,subset=Subject==1)

Have you explored using the "try()" or "tryCatch()"
strategies?


 out <- try(gnls(conc~SSbiexp(time,A,lalpha,B,lbeta),
           start=list(A=-1,lalpha=2,B=20,lbeta=4),
           weights=varPower(fixed=1),
           data=Indometh,subset=Subject==1))

Then if the fit fails, variable "out" will have class "try-error"
so you can check the class of out and decide what to do etc.


(I tried your example in R 2.10.1 on a Mac and R 2.9.2 on a PC and
get an error that I haven't been able to track down yet.
> require("nlme")
Loading required package: nlme
> out<- gnls(conc~SSbiexp(time,A,lalpha,B,lbeta),
+            start=list(A=-1,lalpha=2,B=20,lbeta=4),
+            weights=varPower(fixed=1),control=list(warnOnly=TRUE),
+            data=Indometh,subset=Subject==1)
Error: object 'convIter' not found
> 
> 
>  out<- try(gnls(conc~SSbiexp(time,A,lalpha,B,lbeta),
+            start=list(A=-1,lalpha=2,B=20,lbeta=4),
+            weights=varPower(fixed=1),
+            data=Indometh,subset=Subject==1))
Error : object 'convIter' not found
>
)

Best

Steve McKinney


> 
> 
> 
> 
> --
> Chaehyung Ahn, Ph.D.
> 4033 Remington Oaks Circle
> Cary, NC 27519
> Daum Cafe: http://cafe.daum.net/biometrika
> Blog: http://cahn88.blogspot.com/
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models




Steven McKinney, Ph.D.

Statistician
Molecular Oncology and Breast Cancer Program
British Columbia Cancer Research Centre

email: smckinney -at-  bccrc +dot+ ca
tel: 604-675-8000 x7561

BCCRC
Molecular Oncology
675 West 10th Ave, Floor 4
Vancouver B.C.
V5Z 1L3

Canada




More information about the R-sig-mixed-models mailing list