sim1 <- function(n=100, f=function(x1,x2) {10+x1+x2^2}, sd=1, seed=1) {
if (!is.null(seed))
set.seed(seed)
x1 <- rnorm(n);
x2 <- rnorm(n)
X <- cbind(1,x1,x2)
y <- f(x1,x2) + rnorm(n,sd=sd)
d <- data.frame(y,x1,x2)
return(d)
}
d <- sim1(100); l <- lm(y ~ x1 + x2,d)
system.time(g <- cumres(l, R=100, plots=50))
g
plot(g)
g1 <- cumres(l, c("y"), R=100, plots=50)
g1
g2 <- cumres(l, c("y"), R=100, plots=50, b=0.5)
g2
Run the code above in your browser using DataLab