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("sm-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('sm') Library `sm', version 2; Copyright (C) 1997, 2000 A.W.Bowman & A.Azzalini type help(sm) for summary information > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "ask" > > ### * ask > > flush(stderr()); flush(stdout()) > > ### Name: ask > ### Title: Ask data to be typed on the keyboard. > ### Aliases: ask > ### Keywords: utilities > > ### ** Examples > > ## Not run: > ##D n <- ask("sample size") > ##D nv <- ask("vector of sample sizes") > ##D # in the second case, the user could reply eg with `c(5,10,30)' > ## End(Not run) > > > cleanEx(); ..nameEx <- "binning" > > ### * binning > > flush(stderr()); flush(stdout()) > > ### Name: binning > ### Title: Construct frequency table from raw data > ### Aliases: binning > ### Keywords: nonparametric > > ### ** Examples > > # example of 1-d use > x <- rnorm(1000) > xb <- binning(x) > xb <- binning(x, breaks=seq(-4,4,by=0.5)) > # example of 2-d use > x <- rnorm(1000) > y <- 2*x + 0.5*rnorm(1000) > x <- cbind(x, y) > xb<- binning(x, nbins=12) > > > > cleanEx(); ..nameEx <- "cv" > > ### * cv > > flush(stderr()); flush(stdout()) > > ### Name: cv > ### Title: Cross-validation criterion for nonparametric density estimation > ### Aliases: cv > ### Keywords: nonparametric smooth > > ### ** Examples > > x <- rnorm(50) > hgrid <- seq(0.1, 1, length = 10) > cvgrid <- vector("numeric", length = length(hgrid)) > for (i in 1:10) cvgrid[i] <- cv(x, hgrid[i]) > plot(hgrid, cvgrid, type="l") > > > > cleanEx(); ..nameEx <- "hcv" > > ### * hcv > > flush(stderr()); flush(stdout()) > > ### Name: hcv > ### Title: Cross-validatory choice of smoothing parameter > ### Aliases: hcv > ### Keywords: nonparametric smooth > > ### ** Examples > > # Density estimation > > x <- rnorm(50) > par(mfrow=c(1,2)) > h.cv <- hcv(x, display="lines", ngrid=32) > sm.density(x, h=hcv(x)) > par(mfrow=c(1,1)) > > # Nonparametric regression > > x <- seq(0, 1, length = 50) > y <- rnorm(50, sin(2 * pi * x), 0.2) > par(mfrow=c(1,2)) > h.cv <- hcv(x, y, display="lines", ngrid=32) > sm.regression(x, y, h=hcv(x, y)) > par(mfrow=c(1,1)) > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > cleanEx(); ..nameEx <- "hnorm" > > ### * hnorm > > flush(stderr()); flush(stdout()) > > ### Name: hnorm > ### Title: Normal optimal choice of smoothing parameter in density > ### estimation > ### Aliases: hnorm > ### Keywords: nonparametric smooth > > ### ** Examples > > x <- rnorm(50) > hnorm(x) [1] 0.4027176 > > > > cleanEx(); ..nameEx <- "hsj" > > ### * hsj > > flush(stderr()); flush(stdout()) > > ### Name: hsj > ### Title: Sheather-Jones choice of smoothing parameter for density > ### estimation > ### Aliases: hsj > ### Keywords: nonparametric smooth > > ### ** Examples > > x <- rnorm(50) > hsj(x) [1] 0.3867385 > > > > cleanEx(); ..nameEx <- "nise" > > ### * nise > > flush(stderr()); flush(stdout()) > > ### Name: nise > ### Title: integrated squared error between a density estimate and a Normal > ### density > ### Aliases: nise > ### Keywords: nonparametric smooth > > ### ** Examples > > x <- rnorm(100) > nise(x) [1] 0.0004764364 > > > > cleanEx(); ..nameEx <- "nmise" > > ### * nmise > > flush(stderr()); flush(stdout()) > > ### Name: nmise > ### Title: mean integrated squared error for density estimation with normal > ### data > ### Aliases: nmise > ### Keywords: nonparametric smooth > > ### ** Examples > > x <- rnorm(50) > sd <- sqrt(var(x)) > n <- length(x) > h <- seq(0.1, 2, length=32) > plot(h, nmise(sd, n, h), type = "l") > > > > cleanEx(); ..nameEx <- "nnbr" > > ### * nnbr > > flush(stderr()); flush(stdout()) > > ### Name: nnbr > ### Title: nearest neighbour distances from data in one or two dimensions > ### Aliases: nnbr > ### Keywords: nonparametric smooth > > ### ** Examples > > x <- rnorm(50) > hw <- nnbr(x, 10) > hw <- hw/exp(mean(log(hw))) > sm.density(x, h.weights=hw) > > > > cleanEx(); ..nameEx <- "provide.data" > > ### * provide.data > > flush(stderr()); flush(stdout()) > > ### Name: provide.data > ### Title: Making data available as data.frame > ### Aliases: provide.data > ### Keywords: utilities > > ### ** Examples > > provide.data(birth) Data file being loaded Low birthweight data The data refer to a study on low birthweight in babies, defined as "less than 2500 grams", and related factors. The variables are: Smoke: indicator of whether the mother is a smoker. Lwt: last menstrual weight of the mother, Low: indicator variable of low weight, Source: Hosmer & Lemeshow (1989). Applied Logistic Regresion. Wiley, NY. The original source contains additional variables; see Appendix 1 of Hosmer & Lemeshow for a full list of the data, pp.29-30 and p.92 for additional information. > > > > cleanEx(); ..nameEx <- "sig.trace" > > ### * sig.trace > > flush(stderr()); flush(stdout()) > > ### Name: sig.trace > ### Title: A significance trace for a hypothesis test > ### Aliases: sig.trace > ### Keywords: nonparametric smooth > > ### ** Examples > > x <- runif(50, 0, 1) > y <- 5*x^2 + rnorm(50) > sig.trace(sm.regression(x, y, model = "linear", display="none"), + hvec = seq(0.05, 0.3, length = 10)) [1] "Test of linear model: significance = 0.771" [1] "Test of linear model: significance = 0.587" [1] "Test of linear model: significance = 0.409" [1] "Test of linear model: significance = 0.302" [1] "Test of linear model: significance = 0.238" [1] "Test of linear model: significance = 0.197" [1] "Test of linear model: significance = 0.173" [1] "Test of linear model: significance = 0.16" [1] "Test of linear model: significance = 0.155" [1] "Test of linear model: significance = 0.154" > > > > cleanEx(); ..nameEx <- "sj" > > ### * sj > > flush(stderr()); flush(stdout()) > > ### Name: sj > ### Title: Sheather-Jones criterion for nonparametric density estimation > ### Aliases: sj > ### Keywords: nonparametric smooth > > ### ** Examples > > x <- rnorm(50) > hgrid <- seq(0.1, 1, length = 10) > sjgrid <- vector("numeric", length = length(hgrid)) > for (i in 1:10) sjgrid[i] <- sj(x, hgrid[i]) > plot(hgrid, sjgrid, type="l") > abline(0, 0, lty=2) > > > > cleanEx(); ..nameEx <- "sm.ancova" > > ### * sm.ancova > > flush(stderr()); flush(stdout()) > > ### Name: sm.ancova > ### Title: Nonparametric analysis of covariance > ### Aliases: sm.ancova > ### Keywords: nonparametric smooth > > ### ** Examples > > x <- runif(50, 0, 1) > y <- 4*sin(6*x) + rnorm(50) > g <- rbinom(50, 1, 0.5) > sm.ancova(x, y, g, h = 0.15, model = "equal") Test of equal lines: h = 0.15 p-value = 0.11 > > > > cleanEx(); ..nameEx <- "sm.autoregression" > > ### * sm.autoregression > > flush(stderr()); flush(stdout()) > > ### Name: sm.autoregression > ### Title: Nonparametric estimation of the autoregression function > ### Aliases: sm.autoregression > ### Keywords: nonparametric smooth ts > > ### ** Examples > > library(stats) > data(lynx) > sm.autoregression(log(lynx), maxlag=3, se=TRUE) Pause. Press to continue...sm.autoregression(log(lynx), lags=cbind(2:3,4:5)) Pause. Press to continue... > > > cleanEx(); ..nameEx <- "sm.binomial" > > ### * sm.binomial > > flush(stderr()); flush(stdout()) > > ### Name: sm.binomial > ### Title: Nonparametric logistic regression > ### Aliases: sm.binomial > ### Keywords: nonparametric smooth models > > ### ** Examples > ## Not run: > ##D # the next example assumes that all binomial denominators are 1's > ##D sm.binomial(dose, failure, h=0.5) > ##D # in the next example, (some of) the dose levels are replicated > ##D sm.binomial(dose, failure, n.trials, h=0.5) > ## End(Not run) > > > cleanEx(); ..nameEx <- "sm.binomial.bootstrap" > > ### * sm.binomial.bootstrap > > flush(stderr()); flush(stdout()) > > ### Name: sm.binomial.bootstrap > ### Title: Bootstrap goodness-of-fit test for a logistic regression model. > ### Aliases: sm.binomial.bootstrap > ### Keywords: nonparametric smooth htest models > > ### ** Examples > > ## Not run: sm.binomial.bootstrap(concentration, dead, N, 0.5, nboot=50) > > > > cleanEx(); ..nameEx <- "sm.density" > > ### * sm.density > > flush(stderr()); flush(stdout()) > > ### Name: sm.density > ### Title: Nonparametric density estimation in one, two or three > ### dimensions. > ### Aliases: sm.density sm.density.1d sm.density.2d sm.density.3d > ### sm.density.eval.1d sm.density.eval.2d sm.density.positive.1d > ### sm.density.positive.2d sm.density.positive.grid > ### Keywords: nonparametric smooth > > ### ** Examples > > # A one-dimensional example > y <- rnorm(50) > sm.density(y, model = "Normal") > > # A two-dimensional example > y <- cbind(rnorm(50), rnorm(50)) > sm.density(y, display = "image") > > # A three-dimensional example > y <- cbind(rnorm(50), rnorm(50), rnorm(50)) > sm.density(y) > > > > cleanEx(); ..nameEx <- "sm.density.compare" > > ### * sm.density.compare > > flush(stderr()); flush(stdout()) > > ### Name: sm.density.compare > ### Title: Comparison of univariate density estimates > ### Aliases: sm.density.compare > ### Keywords: nonparametric smooth > > ### ** Examples > > y <- rnorm(100) > g <- rep(1:2, rep(50,2)) > sm.density.compare(y, g, model="equal") 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 Test of equal densities: p-value = 0.43 > > > > cleanEx(); ..nameEx <- "sm.options" > > ### * sm.options > > flush(stderr()); flush(stdout()) > > ### Name: sm.options > ### Title: Set or return options of sm library > ### Aliases: sm.options > ### Keywords: nonparametric smooth > > ### ** Examples > > ## Not run: > ##D sm.options(poly.index = 0) > ##D # subsequent regression estimations will be performed using local means > ##D # instead of local regression > ##D # > ##D sm.options(describe = FALSE) > ##D # turns off typing documentation files of data loaded by `sm.script' > ##D # (works from command-line) > ##D # > ##D setHook(packageEvent("sm", "onLoad"), > ##D function(...) sm.options(describe = FALSE))) > ##D # this line can be inserted in `.Rprofile' for permanent customisation > ## End(Not run) > > > cleanEx(); ..nameEx <- "sm.poisson" > > ### * sm.poisson > > flush(stderr()); flush(stdout()) > > ### Name: sm.poisson > ### Title: Nonparametric Poisson regression > ### Aliases: sm.poisson > ### Keywords: nonparametric smooth > > ### ** Examples > > ## Not run: sm.poisson(exposure.time, N.events, 0.5, display="se") > > > > cleanEx(); ..nameEx <- "sm.poisson.bootstrap" > > ### * sm.poisson.bootstrap > > flush(stderr()); flush(stdout()) > > ### Name: sm.poisson.bootstrap > ### Title: Bootstrap goodness-of-fit test for a Poisson regression model > ### Aliases: sm.poisson.bootstrap > ### Keywords: nonparametric smooth htest models > > ### ** Examples > > ## takes a while: extend sm.script(muscle) > provide.data(muscle, options=list(describe=FALSE)) Data file being loaded > TypeI <- TypeI.P + TypeI.R + TypeI.B > sm.poisson.bootstrap(log(TypeI), TypeII, h = 0.5) Cycles per point: 4 3 2 2 2 2 2 2 2 2 2 2 3 2 2 2 2 3 3 3 3 3 3 3 3 Cycles per point: 4 3 3 1 3 1 3 2 1 2 1 1 2 1 2 1 2 1 3 1 1 3 3 2 2 Dipersion parameter = 0.7875154 Test statistic = 1.622347 1 Cycles per point: 4 3 3 1 3 1 2 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 2 Cycles per point: 4 3 3 1 3 1 3 2 1 2 1 1 2 1 2 1 2 1 2 1 1 3 3 2 2 3 Cycles per point: 5 3 3 1 3 1 3 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 4 Cycles per point: 4 3 3 1 3 1 2 2 1 2 1 1 2 1 2 1 2 1 2 1 1 2 2 2 2 5 Cycles per point: 4 3 3 1 3 1 3 3 1 3 1 1 3 1 3 1 3 1 3 1 1 3 2 2 2 6 Cycles per point: 4 3 3 1 3 1 3 3 1 3 1 1 3 1 3 1 3 1 3 1 1 3 3 2 2 7 Cycles per point: 4 3 3 1 3 1 2 2 1 2 1 1 2 1 3 1 2 1 2 1 1 3 3 2 2 8 Cycles per point: 4 2 3 1 3 1 2 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 9 Cycles per point: 4 3 3 1 4 1 3 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 10 Cycles per point: 5 3 3 1 3 1 2 2 1 2 1 1 2 1 3 1 2 1 3 1 1 3 3 1 2 11 Cycles per point: 4 3 3 1 3 1 2 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 12 Cycles per point: 4 2 2 1 3 1 3 2 1 2 1 1 2 1 2 1 3 1 3 1 1 3 3 2 2 13 Cycles per point: 4 3 3 1 3 1 3 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 14 Cycles per point: 4 3 3 1 3 1 3 3 1 3 1 1 3 1 3 1 3 1 3 1 1 3 3 2 2 15 Cycles per point: 4 3 3 1 3 1 3 3 1 3 1 1 2 1 2 1 2 1 3 1 1 3 3 2 2 16 Cycles per point: 4 3 3 1 3 1 3 3 1 3 1 1 3 1 3 1 2 1 2 1 1 2 3 2 2 17 Cycles per point: 4 3 3 1 3 1 3 3 1 3 1 1 3 1 3 1 2 1 2 1 1 3 3 2 2 18 Cycles per point: 4 3 3 1 3 1 3 3 1 3 1 1 3 1 3 1 3 1 3 1 1 3 3 2 2 19 Cycles per point: 4 3 3 1 3 1 3 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 20 Cycles per point: 4 3 3 1 3 1 3 3 1 3 1 1 3 1 3 1 3 1 3 1 1 3 2 2 2 21 Cycles per point: 5 3 2 1 3 1 3 2 1 2 1 1 2 1 3 1 2 1 2 1 1 3 3 2 2 22 Cycles per point: 4 3 3 1 3 1 3 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 1 23 Cycles per point: 4 3 3 1 3 1 3 2 1 2 1 1 2 1 2 1 2 1 3 1 1 3 3 2 2 24 Cycles per point: 4 3 3 1 3 1 3 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 25 Cycles per point: 4 3 3 1 3 1 3 3 1 3 1 1 3 1 3 1 2 1 2 1 1 2 3 2 2 26 Cycles per point: 5 3 3 1 3 1 3 3 1 2 1 1 2 1 2 1 2 1 3 1 1 3 3 2 2 27 Cycles per point: 4 3 3 1 2 1 2 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 28 Cycles per point: 4 2 3 1 3 1 3 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 1 29 Cycles per point: 4 3 3 1 3 1 2 2 1 2 1 1 2 1 3 1 2 1 2 1 1 2 3 2 2 30 Cycles per point: 4 3 3 1 2 1 2 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 31 Cycles per point: 4 3 3 1 3 1 3 2 1 2 1 1 2 1 2 1 2 1 2 1 1 2 2 2 2 32 Cycles per point: 4 3 3 1 3 1 3 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 33 Cycles per point: 4 3 3 1 3 1 3 3 1 3 1 1 3 1 3 1 3 1 3 1 1 2 2 2 2 34 Cycles per point: 4 3 3 1 3 1 2 2 1 2 1 1 2 1 2 1 2 1 2 1 1 2 2 2 2 35 Cycles per point: 4 3 3 1 3 1 2 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 36 Cycles per point: 4 3 3 1 3 1 2 2 1 2 1 1 2 1 2 1 2 1 2 1 1 3 3 2 2 37 Cycles per point: 4 2 3 1 3 1 3 3 1 3 1 1 3 1 3 1 3 1 3 1 1 3 2 2 2 38 Cycles per point: 4 3 3 1 3 1 2 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 39 Cycles per point: 4 3 3 1 2 1 3 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 40 Cycles per point: 5 3 3 1 3 1 3 3 1 3 1 1 2 1 3 1 2 1 2 1 1 2 2 2 2 41 Cycles per point: 4 3 2 1 3 1 3 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 42 Cycles per point: 4 3 3 1 3 1 3 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 43 Cycles per point: 5 3 3 1 3 1 3 2 1 2 1 1 2 1 2 1 2 1 2 1 1 2 2 2 2 44 Cycles per point: 4 2 3 1 3 1 2 2 1 2 1 1 2 1 2 1 2 1 2 1 1 3 3 2 2 45 Cycles per point: 4 3 3 1 3 1 3 3 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 46 Cycles per point: 4 2 3 1 3 1 3 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 47 Cycles per point: 4 3 3 1 3 1 3 3 1 3 1 1 3 1 3 1 3 1 3 1 1 3 3 2 2 48 Cycles per point: 4 2 3 1 3 1 2 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 1 2 49 Cycles per point: 4 3 3 1 3 1 2 2 1 2 1 1 2 1 2 1 2 1 2 1 1 3 3 2 2 50 Cycles per point: 4 3 3 1 2 1 3 3 1 3 1 1 3 1 3 1 3 1 3 1 1 3 3 2 2 51 Cycles per point: 4 3 3 1 3 1 2 2 1 3 1 1 3 1 3 1 3 1 3 1 1 3 3 2 2 52 Cycles per point: 4 3 3 1 3 1 3 3 1 3 1 1 2 1 3 1 2 1 2 1 1 3 3 2 2 53 Cycles per point: 4 3 3 1 3 1 2 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 54 Cycles per point: 4 3 3 1 3 1 2 2 1 2 1 1 2 1 2 1 2 1 2 1 1 2 2 2 2 55 Cycles per point: 4 3 2 1 3 1 3 2 1 2 1 1 2 1 2 1 2 1 3 1 1 3 3 2 2 56 Cycles per point: 4 3 3 1 3 1 2 2 1 2 1 1 2 1 2 1 2 1 2 1 1 2 3 2 2 57 Cycles per point: 4 3 3 1 3 1 3 3 1 3 1 1 2 1 3 1 2 1 2 1 1 3 3 2 2 58 Cycles per point: 4 3 3 1 2 1 3 2 1 2 1 1 2 1 2 1 2 1 2 1 1 2 2 2 2 59 Cycles per point: 5 3 3 1 3 1 2 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 60 Cycles per point: 4 3 3 1 3 1 3 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 61 Cycles per point: 4 4 4 1 4 1 3 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 62 Cycles per point: 5 3 3 1 3 1 3 2 1 2 1 1 2 1 2 1 2 1 3 1 1 3 3 2 2 63 Cycles per point: 4 3 3 1 3 1 3 3 1 3 1 1 3 1 3 1 3 1 3 1 1 3 3 1 2 64 Cycles per point: 4 3 3 1 3 1 2 2 1 2 1 1 2 1 3 1 2 1 3 1 1 3 3 2 2 65 Cycles per point: 4 3 3 1 3 1 3 3 1 3 1 1 3 1 3 1 3 1 3 1 1 3 3 2 2 66 Cycles per point: 4 3 3 1 3 1 3 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 67 Cycles per point: 4 2 3 1 3 1 3 2 1 2 1 1 2 1 2 1 2 1 2 1 1 2 3 2 2 68 Cycles per point: 5 3 3 1 3 1 3 3 1 3 1 1 3 1 3 1 3 1 3 1 1 2 3 2 2 69 Cycles per point: 4 3 3 1 3 1 3 3 1 3 1 1 2 1 3 1 2 1 3 1 1 3 3 2 2 70 Cycles per point: 4 3 3 1 3 1 3 2 1 2 1 1 2 1 3 1 2 1 3 1 1 3 3 2 2 71 Cycles per point: 4 3 3 1 3 1 2 2 1 2 1 1 2 1 2 1 2 1 3 1 1 3 3 2 2 72 Cycles per point: 4 3 3 1 4 1 3 3 1 3 1 1 3 1 3 1 2 1 3 1 1 3 3 2 2 73 Cycles per point: 4 3 3 1 3 1 2 2 1 2 1 1 2 1 2 1 2 1 2 1 1 2 3 2 2 74 Cycles per point: 4 3 3 1 3 1 3 3 1 3 1 1 3 1 3 1 3 1 3 1 1 2 3 2 2 75 Cycles per point: 4 3 3 1 3 1 3 3 1 3 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 76 Cycles per point: 4 3 3 1 3 1 2 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 77 Cycles per point: 5 3 3 1 2 1 2 2 1 2 1 1 2 1 2 1 2 1 2 1 1 3 3 2 2 78 Cycles per point: 4 3 3 1 3 1 3 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 79 Cycles per point: 4 3 3 1 3 1 3 2 1 2 1 1 2 1 2 1 2 1 2 1 1 3 3 2 2 80 Cycles per point: 4 3 3 1 3 1 2 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 81 Cycles per point: 4 3 2 1 3 1 3 2 1 2 1 1 2 1 2 1 3 1 3 1 1 3 3 2 2 82 Cycles per point: 4 3 3 1 2 1 3 3 1 2 1 1 2 1 3 1 2 1 2 1 1 3 3 2 2 83 Cycles per point: 4 3 2 1 3 1 3 3 1 3 1 1 2 1 3 1 3 1 3 1 1 2 3 2 2 84 Cycles per point: 4 3 3 1 3 1 3 2 1 2 1 1 2 1 2 1 2 1 3 1 1 3 3 2 2 85 Cycles per point: 4 3 3 1 2 1 3 2 1 2 1 1 2 1 2 1 3 1 3 1 1 3 3 2 2 86 Cycles per point: 4 3 3 1 3 1 2 2 1 2 1 1 2 1 2 1 2 1 2 1 1 2 3 2 2 87 Cycles per point: 4 3 3 1 3 1 3 3 1 2 1 1 2 1 3 1 2 1 2 1 1 2 3 2 2 88 Cycles per point: 4 3 3 1 3 1 3 2 1 2 1 1 2 1 2 1 2 1 2 1 1 2 2 2 2 89 Cycles per point: 4 3 3 1 3 1 3 2 1 2 1 1 2 1 2 1 2 1 2 1 1 3 2 2 2 90 Cycles per point: 4 3 3 1 3 1 2 2 1 2 1 1 2 1 2 1 1 1 2 1 1 3 3 2 2 91 Cycles per point: 4 2 3 1 3 1 3 2 1 2 1 1 2 1 2 1 2 1 2 1 1 2 2 2 2 92 Cycles per point: 4 3 3 1 3 1 2 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 93 Cycles per point: 4 3 3 1 3 1 3 3 1 3 1 1 3 1 3 1 3 1 3 1 1 3 3 2 2 94 Cycles per point: 4 3 3 1 3 1 3 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 95 Cycles per point: 4 3 3 1 3 1 3 3 1 2 1 1 2 1 2 1 2 1 2 1 1 2 2 2 2 96 Cycles per point: 4 3 3 1 3 1 3 2 1 2 1 1 2 1 3 1 3 1 3 1 1 3 3 2 2 97 Cycles per point: 4 2 3 1 3 1 2 3 1 3 1 1 3 1 3 1 3 1 3 1 1 3 3 2 2 98 Cycles per point: 4 2 2 1 3 1 3 3 1 3 1 1 3 1 3 1 3 1 3 1 1 3 2 2 2 99 Cycles per point: 4 3 3 1 3 1 3 3 1 3 1 1 2 1 3 1 2 1 2 1 1 2 2 2 2 Observed significance = 0.87 > > > > cleanEx(); ..nameEx <- "sm.regression" > > ### * sm.regression > > flush(stderr()); flush(stdout()) > > ### Name: sm.regression > ### Title: Nonparametric regression with one or two covariates. > ### Aliases: sm.regression > ### Keywords: nonparametric regression smooth > > ### ** Examples > > # An example with one covariate > x <- runif(100,-2, 2) > y <- x^2 + rnorm(50) > sm.regression(x, y, h=0.5) > > # An example with one covariate > x <- cbind(runif(100,-2, 2), runif(100,-2, 2)) > y <- x[,1]^2 + x[,2]^2 + rnorm(50) > sm.regression(x, y, h=c(1,1)) > > > > cleanEx(); ..nameEx <- "sm.rm" > > ### * sm.rm > > flush(stderr()); flush(stdout()) > > ### Name: sm.rm > ### Title: Nonparametric analysis of repeated measurements data > ### Aliases: sm.rm > ### Keywords: nonparametric smooth > > ### ** Examples > > provide.data(citrate, options=list(describe=FALSE)) Data file being loaded > provide.data(dogs, options=list(describe=FALSE)) Data file being loaded > a <- sm.rm(y=citrate, display.rice=TRUE) Autocovariances & autocorrelations: auto-cov auto-corr 0 360.623571 1.00000000 1 244.287143 0.67740204 2 204.040714 0.56579972 3 175.807857 0.48751072 4 151.130000 0.41907965 5 128.680714 0.35682835 6 120.196429 0.33330164 7 103.723571 0.28762283 8 91.565000 0.25390742 9 87.847857 0.24359988 10 53.901429 0.14946729 11 22.932143 0.06359025 12 13.760714 0.03815811 13 9.732143 0.02698698 Rice's criterion: h indept. depend. [1] 0.100000 6.005194 6.005194 [1] 0.200000 6.005156 6.005182 [1] 0.300000 5.965648 5.992517 [1] 0.400000 5.583011 5.878175 [1] 0.500000 4.855846 5.702201 [1] 0.600000 4.131101 5.579386 [1] 0.700000 3.535247 5.519406 [1] 0.800000 3.072755 5.506906 [1] 0.900000 2.735846 5.530976 [1] 1.000000 2.516341 5.582579 [1] 1.100000 2.400934 5.653475 [1] 1.200000 2.370399 5.736703 [1] 1.300000 2.402966 5.826924 [1] 1.400000 2.478570 5.920349 [1] 1.500000 2.581237 6.014418 [1] 1.600000 2.699336 6.107412 [1] 1.700000 2.824778 6.198149 [1] 1.800000 2.952046 6.285777 [1] 1.900000 3.077424 6.369671 [1] 2.000000 3.198465 6.449387 h: 0.8 > # > Time <- seq(1,13,by=2) > gr1 <- as.matrix(dogs[dogs$Group==1,2:8]) > plot(c(1,13), c(3,6),xlab="time", ylab="potassium", type="n") > sm1 <- sm.rm(Time, gr1, display="se", add=TRUE) Autocovariances & autocorrelations: auto-cov auto-corr 0 0.35064732 1.00000000 1 0.21689732 0.61856261 2 0.09939732 0.28346808 3 0.03595982 0.10255268 4 0.03254464 0.09281304 5 0.04558036 0.12998918 6 0.02562500 0.07307913 Rice's criterion: h indept. depend. [1] 0.1000000 0.2093583 0.2093583 [1] 0.2000000 0.2093583 0.2093583 [1] 0.3000000 0.2093583 0.2093583 [1] 0.4000000 0.2093572 0.2093579 [1] 0.5000000 0.2092581 0.2093201 [1] 0.6000000 0.2082104 0.2089228 [1] 0.7000000 0.2044647 0.2075348 [1] 0.8000000 0.1972148 0.2049937 [1] 0.9000000 0.1874796 0.2018886 [1] 1.0000000 0.1769501 0.1989313 [1] 1.1000000 0.1668513 0.1964876 [1] 1.2000000 0.1577303 0.1946119 [1] 1.3000000 0.1497093 0.1932320 [1] 1.4000000 0.1427437 0.1922618 [1] 1.5000000 0.1367548 0.1916355 [1] 1.6000000 0.1316702 0.1913057 [1] 1.7000000 0.1274243 0.1912359 [1] 1.8000000 0.1239532 0.1913952 [1] 1.9000000 0.1211923 0.1917559 [1] 2.0000000 0.1190767 0.1922931 h: 1.7 > > > > cleanEx(); ..nameEx <- "sm.script" > > ### * sm.script > > flush(stderr()); flush(stdout()) Index of scripts for the sm library ----------------------------------- To run a script called "sname", give the command sm.script(sname) Script Illus. Fig. Description ------ ------ ---- ----------- sp_hist 1.1 1.1 Density estimate from the aircraft span data sp_build 1.2 Construction of a density estimate sp_alter 1.2 1.3 Changing the bandwidth in a density estimate sp_comp 1.3 1.4 Comparing density estimates from the span data air_scat 1.5 Scatterplots of the airpc data air_dens 1.4 1.6 Density estimates from the airpc data air_imag 1.5 1.7 Imageplot and sliceplot from the airpc data air_cont 1.6 1.8 Sliceplots for the three groups of airpc data geys3d 1.7 1.9 Three-dimensional contour from the geyser data mag_scat 1.8 1.10 Spherical plot of the magnetic remanence data mag_dens 1.9 1.11 Density estimate from the magnetic remanence data speed 1.10 1.12 Density estimate from the aircraft speed data speedvar 1.11 1.13 Modified estimates from the aircraft speed data edfgrad 1.14 The gradient of an empirical distribution function te_var 2.1 2.1 Variable bandwidths with the tephra data air_band 2.2 2.2 A variability band from the aircraft span data te_hcvsj 2.3 2.3 Bandwidth choices for the tephra data air_hcv 2.4 2.4 Bandwidth choices for the aircraft data te_norm 2.5 2.5 Assessing normality for the tephra data te_band 2.6 2.6 Reference bands for normality with the tephra data air_ind 2.7 2.7 Exploring independence in the aircraft data air_inds Testing independence in the aircraft data air_boot 2.8 2.8 Bootstrapping density estimates rc_plot 3.1 3.1 Nonparametric regression with the radiocarbon data rc_alter 3.2 Changing the bandwidth in a nonparametric regression trwlplot 3.2 3.3 Nonparametric regressions with the reef data birth1 3.3 3.4 Standard smoothing with the birthweight data birth2 3.4 3.5 Local logistic regression with the birthweight data muscle 3.5 3.6 Nonparametric regression with the rat muscle data stanplot 3.6 3.7 Percentile curves for the Stanford data follicle 3.7 3.8 Variable bandwidths with the follicle data stananim Animation of percentile curves (Exercise 3.5) sin_prop 4.1 Mean and s.d. of a nonparametric regression rc_vband 4.1 4.2 A variability band with the radiocarbon data sin_cv 4.2 4.3 Cross-validation for bandwidth choice trwlboot 4.3 4.4 A reference band for no effect in the reef data noeff A bootstrap test of no effect in the reef data rc_boot 4.4 4.5 A bootstrap band from the radiocarbon data trw_nesg 5.1 5.1 A significance trace for no effect in the reef data trw_nebd 5.2 5.2 A reference band for no effect in the reef data trw_lf 5.3 A linear model for the reef data trw_lfsg 5.3 5.4 Assessing a linear model for the reef data mildew 5.4 5.5 Assessing spatial trend in the mildew data trees 5.5 5.6 Assessing linearity in the cherry trees data trout1 5.7 Local logistic regression with the trout data trout2 5.6 5.8 Assessing a logistic model for the trout data bissell1 5.9 A parametric prediction band from Bissell's data bissell2 5.7 5.10 A nonparametric prediction band from Bissell's data bissell3 5.11 A reference band for linearity with Bissell's data (execute bissell3 immediately after bissell2) sp_comp2 6.1 6.1 Comparing density estimates for the span data sp_test1 6.2 Assessing equality of densities for the span data sp_test2 6.2 6.3 Assessing equality for the standardised span data lc_dens 6.3 6.4 Density estimates from the laryngeal cancer data lc_rr 6.5 Comparing case and control cancer groups lc_comp A bootstrap test of equality for bivariate densities trwlcomp 6.4 6.6 Nonparametric regression curves for the reef data trwlband 6.5 6.7 A reference band for equality with the reef data trwlcmp2 6.8 Comparing regression surfaces from the reef data wormcomp 6.6 6.9 A reference band for equality with the worm data onionplt 6.7 6.10 Nonparametric regression curves for the onions data onionbnd 6.8 6.11 A reference band for parallelism geys_ts 7.1 7.1-3 Density estimates from the geyser data lynx 7.2 7.4 Analysis of the Canadian lynx data citrate 7.3 7.5-7 Analysis of plasma citrate concentration data dogs 7.4 7.8-9 Analysis of coronary sinus potassium data nyc 7.5 7.10-13 Analysis of New York city air temperature data trwlgam1 8.1 8.1 An additive model for the reef data trwlgam2 8.2 Model comparison for the reef data mackmap 8.3 8.2 Sampling points for the mackerel data mackplot 8.4 8.3 Plots of the mackerel data mackgam 8.5 8.4 Additive models for the mackerel data trwlgam3 8.6 8.5 Semiparametric and varying coefficient models smackplt 8.7 8.6 Plots for the Spanish survey data smackgam 8.8 8.7 An additive model for the Spanish survey data > > ### Name: sm.script > ### Title: Running a script associated to the sm library > ### Aliases: sm.script > ### Keywords: utilities > > ### ** Examples > > sm.script() > sm.script(speed) Data file being loaded Aircraft data These data record six characteristics of aircraft designs which appeared during the twentieth century. The variables are: Yr: year of first manufacture Period: a code to indicate one of three broad time periods Power: total engine power (kW) Span: wing span (m) Length: length (m) Weight: maximum take-off weight (kg) Speed: maximum speed (km/h) Range: range (km) Source: The data were collected by P. Saviotti and are described in detail in Saviotti (1996), "Technological Evolution, Variety and Economy", Edward Elgar: Cheltenham. > > > > cleanEx(); ..nameEx <- "sm.sphere" > > ### * sm.sphere > > flush(stderr()); flush(stdout()) > > ### Name: sm.sphere > ### Title: Nonparametric density estimation for spherical data. > ### Aliases: sm.sphere > ### Keywords: nonparametric smooth > > ### ** Examples > > lat <- rnorm(50, 10, 15) > long <- c(rnorm(25, 300, 15), rnorm(25, 240, 15)) > par(mfrow=c(1,2)) > sm.sphere(lat, long) > sm.sphere(lat, long, sphim=TRUE, kappa=15) > par(mfrow=c(1,1)) > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > cleanEx(); ..nameEx <- "sm.survival" > > ### * sm.survival > > flush(stderr()); flush(stdout()) > > ### Name: sm.survival > ### Title: Nonparametric regression with survival data. > ### Aliases: sm.survival > ### Keywords: nonparametric smooth survival > > ### ** Examples > > x <- runif(50, 0, 10) > y <- rexp(50, 2) > z <- rexp(50, 1) > status <- rep(1, 50) > status[z y <- pmin(z, y) > sm.survival(x, y, status, h=2) > > > > cleanEx(); ..nameEx <- "sm.ts.pdf" > > ### * sm.ts.pdf > > flush(stderr()); flush(stdout()) > > ### Name: sm.ts.pdf > ### Title: Nonparametric density estimation of stationary time series data > ### Aliases: sm.ts.pdf > ### Keywords: nonparametric smooth ts > > ### ** Examples > > data(geyser) > a <- sm.ts.pdf(geyser$duration, lags=1:2) Pause. Press to continue... Pause. Press to continue... > > ### *