s-news
[Top] [All Lists]

Re: Loess loop

To: "Myers, Brent" <MyersDB@missouri.edu>
Subject: Re: Loess loop
From: Sundar Dorai-Raj <sundar.dorai-raj@PDF.COM>
Date: Tue, 24 Feb 2004 13:49:31 -0600
Cc: s-news@lists.biostat.wustl.edu
In-reply-to: <9D3EEF15D954B14CA96120A90F5E508F2E68A0@UM-EMAIL06.um.umsystem.edu>
Organization: PDF Solutions, Inc.
References: <9D3EEF15D954B14CA96120A90F5E508F2E68A0@UM-EMAIL06.um.umsystem.edu>
Reply-to: sundar.dorai-raj@PDF.COM
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax)
Brent,
  You didn't assign the update call to anything:

for(i in ivect) {
  loess.calibration <- update(loess.model, span = i)
  span.out <- c(span.out, i)
  rss <- sum(loess.calibration$residuals^2)
  rss.out <- c(rss.out, rss)
}

Best,
Sundar

Myers, Brent wrote:
Group,

What is it I'm not understanding here?
The following code fits a loess model at a range of spans, however residual sum of squares is not changing. It makes no difference if the model is inside the loop or if update is used.
How could apply be used instead?


> loess.model <- loess(formula = Clay ~ CMDivergence, data = Soil.Profile.Data, subset = Study == "Calibration", na.action = na.exclude, span = i, degree = 2, normalize = T, family

         = "gaussian")
 > span.out <- 0
 > rss.out <- 0
 > ivect <- seq(0.1, 1, by = 0.1)
 > for(i in ivect) {
        update(loess.model, span = i)
        span.out <- c(span.out, i)
        rss <- sum(loess.calibration$residuals^2)
        rss.out <- c(rss.out, rss)
}
 > out.stats.loess <- data.frame(span.out, rss.out)
 > print(out.stats.loess)
   span.out  rss.out
 1      0.0     0.00
 2      0.1 32975.69
 3      0.2 32975.69
 4      0.3 32975.69
 5      0.4 32975.69
 6      0.5 32975.69
 7      0.6 32975.69
 8      0.7 32975.69
 9      0.8 32975.69
10      0.9 32975.69
11      1.0 32975.69
 > rm(span.out, rss.out)


D. Brenton Myers
Research Specialist
University of Missouri - Agronomy / USDA-ARS-ASEQ
158 Agriculture Engineering Building
Columbia, MO 65211
(573) 882-1146 wk
(573) 228-0929 cell
myersdb@missouri.edu


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