Hi! S-plus users.
E-mail: s-news@wubios.wustl.edu
Let me modify the program I wrote in my previous
article. The two programs below work well.
I have heard that "<<-" and "rm())" are preferable
to "attach()" and "detach()". But I do not know
why.
-------------------- Program (C) --------------------
function()
{
xx <- seq(from = 1, by = 1, to = 10)
ex <- seq(from = 3, by = 0.3, length = 12)
yy <- sin(xx) + 2
data1 <<- data.frame(x = xx, y = yy)
span1 <- 0.4
formula.name <- paste("y ~ lo(x, span =", span1, ")")
fit.gam <- gam(formula.name, data = data1, family = "poisson", x = T,
model = T)
data2 <- data.frame(x = ex)
ey <- predict.gam(fit.gam, data2)
rm(data1)
ey
}
-------------------- End of Program (C) --------------------
-------------------- Program (D) --------------------
function()
{
xx <- seq(from = 1, by = 1, to = 10)
ex <- seq(from = 3, by = 0.3, length = 12)
yy <- sin(xx) + 2
data1 <- data.frame(x = xx, y = yy)
attach(data1)
span1 <- 0.4
formula.name <- paste("y ~ lo(x, span =", span1, ")")
fit.gam <- gam(formula.name, family = "poisson", x = T, model = T)
data2 <- data.frame(x = ex)
ey <- predict.gam(fit.gam, data2)
detach("data1")
ey
}
-------------------- End of Program (D) --------------------
***** Kunio Takezawa, Ph.D. (takezawa@affrc.go.jp) *****
***** Research Information Section *****
**** Hokuriku National Agricultural Experiment Station, JAPAN ****
***** <http://www.inada.affrc.go.jp/~takezawa/patent-e.html> *****
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news
|