s-news
[Top] [All Lists]

Trapping loess errors in a loop

To: s-news@wubios.wustl.edu
Subject: Trapping loess errors in a loop
From: Madeline Bauer <mbauer@usc.edu>
Date: Sat, 30 May 2009 16:35:23 -0700
Greetings!
I have constructed a function to fit a loess model so I can call that function in a loop in order to fit multiple models (thanks to Dr. Bill Venables for the example).

My the problem comes when loess gags on the data for one of the models. When this happens, the loop stops rather ungracefully.

Is there any way add code inside my loop or in the function to detect that loess has a problem so I can store the identification of the data with the problem and then continue with the loop?

I am using S-Plus 8.1 (aka Tibco Spotfire) on a Windows XP Pro machine.

Thanks in advance!
Madeline Bauer

#########  the function to fit the loess model

fitCommand.Loess <- Quote ({
        my.model <- loess ( Log10CFU ~ AmB,
                 subset=Subset,
                 span=Span,
                 degree=Degree,
                 normalize=F,
                  family="symmetric" )
})

########### the loop that calls the function (omitting some definitions for brevity)
attach (tmp.rep)

        for (iname in 2:length(Isolate.Names)){
                 mname <- paste ("Loess", Isolate.Names [iname],"Rep", Rep, sep = ".")
                 Subset <- I(Log.No == Isolate.Names [iname])
                 if ( length (unique (tmp.rep [Subset,"Log10CFU"])) >= n.unique ){
                          thisFitCommand <- do.call ("substitute", list (fitCommand.Loess,
                                   list (my.model = as.name (mname), degree=Degree, span=Span )))
                          print (mname)
                          eval (thisFitCommand)
                 }
        }
                          
detach ("tmp.rep")


===
Madeline Bauer, Ph.D.        University of Southern California
Keck School of Medicine (Infectious Diseases)
IRD Room 620 (MC9520), 2020 Zonal Ave, Los Angeles 90033
(323) 226-2775 [Voice] (FAX by appointment ;-)
mbauer@usc.edu  [Fastest communication method]

<Prev in Thread] Current Thread [Next in Thread>