Last chance! 50% off unlimited learning
Sale ends in
.smart.prediction
from
smartpredenv
(R) or
frame 1 (S-PLUS).get.smart()
.smart.prediction
from
smartpredenv
(R)
or
frame 1 (S-PLUS),
in fact, .smart.prediction[[.smart.prediction.counter]]
.
The whole procedure mimics a first-in first-out stack (better known
as a queue)..smart.prediction.counter
in
smartpredenv
(R)
or
frame 1 (S-PLUS)
is incremented beforehand, and then written back to
smartpredenv
(R)
or
frame 1 (S-PLUS).get.smart
is used in "read"
mode within a smart function:
it retrieves parameters saved at the time of fitting, and
is used for prediction.
get.smart
is only used in smart functions such as
poly
;
get.smart.prediction
is only used in modelling functions
such as lm
and glm
.
The function
get.smart
gets only a part of .smart.prediction
whereas
get.smart.prediction
gets the entire .smart.prediction
.get.smart.prediction
."my1" <- function(x, minx=min(x)) { # Here is a smart function
x <- x # Needed for nested calls, e.g., bs(scale(x))
if(smart.mode.is("read")) {
smart <- get.smart()
minx <- smart$minx # Overwrite its value
} else
if(smart.mode.is("write"))
put.smart(list(minx=minx))
sqrt(x-minx)
}
attr(my1, "smart") <- TRUE
Run the code above in your browser using DataLab