R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("pspline-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('pspline') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "predict.smooth.Pspline" > > ### * predict.smooth.Pspline > > flush(stderr()); flush(stdout()) > > ### Name: predict.smooth.Pspline > ### Title: Smoothing Spline of Arbitrary Order at New Data > ### Aliases: predict.smooth.Pspline > ### Keywords: smooth > > ### ** Examples > > example(smooth.Pspline) smth.P> data(cars) smth.P> attach(cars) smth.P> plot(speed, dist, main = "data(cars) & smoothing splines") smth.P> cars.spl <- sm.spline(speed, dist) smth.P> cars.spl Call: smooth.Pspline(x = ux, y = tmp[, 1], w = tmp[, 2], method = method) Smoothing Parameter (Spar): 366.8429 Equivalent Degrees of Freedom (Df): 2.428851 GCV Criterion: 29.54554 CV Criterion: 39.18787 smth.P> lines(cars.spl, col = "blue") smth.P> lines(sm.spline(speed, dist, df = 10), lty = 2, col = "red") > ## smoother line is given by > xx <- seq(4, 25, length=100) > lines(xx, predict(sm.spline(speed, dist, df=5), xx), col = "red") > ## add plots of derivatives > lines(xx, 10*predict(sm.spline(speed, dist), xx, 1), col = "blue") > lines(xx, 100*predict(sm.spline(speed, dist), xx, 2), col = "green") > > > > cleanEx(); ..nameEx <- "smooth.Pspline" > > ### * smooth.Pspline > > flush(stderr()); flush(stdout()) > > ### Name: smooth.Pspline > ### Title: Fit a Polynomial Smoothing Spline of Arbitrary Order > ### Aliases: smooth.Pspline lines.smooth.Pspline plot.smooth.Pspline > ### print.smooth.Pspline sm.spline > ### Keywords: smooth > > ### ** Examples > > data(cars) > attach(cars) > plot(speed, dist, main = "data(cars) & smoothing splines") > cars.spl <- sm.spline(speed, dist) > cars.spl Call: smooth.Pspline(x = ux, y = tmp[, 1], w = tmp[, 2], method = method) Smoothing Parameter (Spar): 366.8429 Equivalent Degrees of Freedom (Df): 2.428851 GCV Criterion: 29.54554 CV Criterion: 39.18787 > lines(cars.spl, col = "blue") > lines(sm.spline(speed, dist, df=10), lty=2, col = "red") > > > > ### *