Sundar,
You are correct, in the example I posted I forgot the assignment, but it
doesn't matter. For instance, whether you use the update or just the
model statement (with the appropriate assignment, the RSS does not
change. Run manually, the value does (of course) differ. Is there a
problem with the function accepting the i-th iteration value.
loess.model <- update(loess.model, span = i) . . . still doesn't work.
Regards,
Brent
-----Original Message-----
From: Sundar Dorai-Raj [mailto:sundar.dorai-raj@PDF.COM]
Sent: Tuesday, February 24, 2004 1:50 PM
To: Myers, Brent
Cc: s-news@lists.biostat.wustl.edu
Subject: Re: [S] Loess loop
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
>
>
|