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("logspline-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('logspline') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "dlogspline" > > ### * dlogspline > > flush(stderr()); flush(stdout()) > > ### Name: dlogspline > ### Title: Logspline Density Estimation > ### Aliases: dlogspline plogspline qlogspline rlogspline > ### Keywords: distribution smooth > > ### ** Examples > > x <- rnorm(100) > fit <- logspline(x) > qq <- qlogspline((1:99)/100, fit) > plot(qnorm((1:99)/100), qq) # qq plot of the fitted density > pp <- plogspline((-250:250)/100, fit) > plot((-250:250)/100, pp, type = "l") > lines((-250:250)/100,pnorm((-250:250)/100)) # asses the fit of the distribution > dd <- dlogspline((-250:250)/100, fit) > plot((-250:250)/100, dd, type = "l") > lines((-250:250)/100, dnorm((-250:250)/100)) # asses the fit of the density > rr <- rlogspline(100, fit) # random sample from fit > > > > cleanEx(); ..nameEx <- "doldlogspline" > > ### * doldlogspline > > flush(stderr()); flush(stdout()) > > ### Name: doldlogspline > ### Title: Logspline Density Estimation - 1992 version > ### Aliases: doldlogspline poldlogspline qoldlogspline roldlogspline > ### Keywords: distribution smooth > > ### ** Examples > > x <- rnorm(100) > fit <- oldlogspline(x) > qq <- qoldlogspline((1:99)/100, fit) > plot(qnorm((1:99)/100), qq) # qq plot of the fitted density > pp <- poldlogspline((-250:250)/100, fit) > plot((-250:250)/100, pp, type = "l") > lines((-250:250)/100, pnorm((-250:250)/100)) # asses the fit of the distribution > dd <- doldlogspline((-250:250)/100, fit) > plot((-250:250)/100, dd, type = "l") > lines((-250:250)/100, dnorm((-250:250)/100)) # asses the fit of the density > rr <- roldlogspline(100, fit) # random sample from fit > > > > cleanEx(); ..nameEx <- "logspline" > > ### * logspline > > flush(stderr()); flush(stdout()) > > ### Name: logspline > ### Title: Logspline Density Estimation > ### Aliases: logspline > ### Keywords: distribution smooth > > ### ** Examples > > y <- rnorm(100) > fit <- logspline(y) > plot(fit) > # as (4 == length(-2, -1, 0, 1, 2) -1), this forces these initial knots, > # and does no knot selection > fit <- logspline(y, knots = c(-2, -1, 0, 1, 2), maxknots = 4, penalty = 0) > > > > cleanEx(); ..nameEx <- "oldlogspline" > > ### * oldlogspline > > flush(stderr()); flush(stdout()) > > ### Name: oldlogspline > ### Title: Logspline Density Estimation - 1992 version > ### Aliases: oldlogspline > ### Keywords: distribution smooth > > ### ** Examples > > # A simple example > y <- rnorm(100) > fit <- oldlogspline(y) > plot(fit) > # An example involving censoring and a lower bound > y <- rlnorm(1000) > censoring <- rexp(1000) * 4 > delta <- 1 * (y <= censoring) > y[delta == 0] <- censoring[delta == 0] > fit <- oldlogspline(y[delta == 1], y[delta == 0], lbound = 0) > > > > cleanEx(); ..nameEx <- "plot.logspline" > > ### * plot.logspline > > flush(stderr()); flush(stdout()) > > ### Name: plot.logspline > ### Title: Logspline Density Estimation > ### Aliases: plot.logspline > ### Keywords: distribution smooth > > ### ** Examples > > y <- rnorm(100) > fit <- logspline(y) > plot(fit) > > > > cleanEx(); ..nameEx <- "plot.oldlogspline" > > ### * plot.oldlogspline > > flush(stderr()); flush(stdout()) > > ### Name: plot.oldlogspline > ### Title: Logspline Density Estimation - 1992 version > ### Aliases: plot.oldlogspline > ### Keywords: distribution smooth > > ### ** Examples > > y <- rnorm(100) > fit <- oldlogspline(y) > plot(fit) > > > > cleanEx(); ..nameEx <- "summary.logspline" > > ### * summary.logspline > > flush(stderr()); flush(stdout()) > > ### Name: summary.logspline > ### Title: Logspline Density Estimation > ### Aliases: summary.logspline print.logspline > ### Keywords: distribution smooth > > ### ** Examples > > y <- rnorm(100) > fit <- logspline(y) > summary(fit) knots A(1)/D(2) loglik AIC minimum penalty maximum penalty 3 2 -132.83 274.87 2.11 Inf 4 2 -132.63 279.08 NA NA 5 2 -130.72 279.85 1.21 2.11 6 2 -130.54 284.11 NA NA 7 2 -129.68 286.99 NA NA 8 2 -129.58 291.40 NA NA 9 2 -128.30 293.44 0.47 1.21 10 2 -128.25 297.94 NA NA 11 2 -127.82 301.70 0.06 0.47 12 1 -127.80 306.25 0.00 0.06 the present optimal number of knots is 3 penalty(AIC) was the default: BIC=log(samplesize): log( 100 )= 4.61 > > > > cleanEx(); ..nameEx <- "summary.oldlogspline" > > ### * summary.oldlogspline > > flush(stderr()); flush(stdout()) > > ### Name: summary.oldlogspline > ### Title: Logspline Density Estimation - 1992 version > ### Aliases: summary.oldlogspline print.oldlogspline > ### Keywords: distribution smooth > > ### ** Examples > > y <- rnorm(100) > fit <- oldlogspline(y) > summary(fit) knots loglik AIC minimum penalty maximum penalty 3 -130.97 275.76 0.37 Inf 4 -130.97 280.35 NA NA 5 -130.70 284.43 NA NA 6 -130.51 288.65 NA NA 7 -130.23 292.69 0.31 0.37 8 -130.14 297.12 NA NA 9 -129.92 301.28 0.03 0.31 10 -129.90 305.86 0.01 0.03 11 -129.90 310.45 0.00 0.01 the present optimal number of knots is 3 penalty(AIC) was the default: BIC=log(samplesize): log( 100 )= 4.61 > > > > cleanEx(); ..nameEx <- "unstrip" > > ### * unstrip > > flush(stderr()); flush(stdout()) > > ### Name: unstrip > ### Title: Reformat data as vector or matrix > ### Aliases: unstrip > ### Keywords: utilities classes > > ### ** Examples > > data(co2) > unstrip(co2) [1] 315.42 316.31 316.50 317.56 318.13 318.00 316.39 314.65 313.68 313.18 [11] 314.66 315.43 316.27 316.81 317.42 318.87 319.87 319.43 318.01 315.74 [21] 314.00 313.68 314.84 316.03 316.73 317.54 318.38 319.31 320.42 319.61 [31] 318.42 316.63 314.83 315.16 315.94 316.85 317.78 318.40 319.53 320.42 [41] 320.85 320.45 319.45 317.25 316.11 315.27 316.53 317.53 318.58 318.92 [51] 319.70 321.22 322.08 321.31 319.58 317.61 316.05 315.83 316.91 318.20 [61] 319.41 320.07 320.74 321.40 322.06 321.73 320.27 318.54 316.54 316.71 [71] 317.53 318.55 319.27 320.28 320.73 321.97 322.00 321.71 321.05 318.71 [81] 317.66 317.14 318.70 319.25 320.46 321.43 322.23 323.54 323.91 323.59 [91] 322.24 320.20 318.48 317.94 319.63 320.87 322.17 322.34 322.88 324.25 [101] 324.83 323.93 322.38 320.76 319.10 319.24 320.56 321.80 322.40 322.99 [111] 323.73 324.86 325.40 325.20 323.98 321.95 320.18 320.09 321.16 322.74 [121] 323.83 324.26 325.47 326.50 327.21 326.54 325.72 323.50 322.22 321.62 [131] 322.69 323.95 324.89 325.82 326.77 327.97 327.91 327.50 326.18 324.53 [141] 322.93 322.90 323.85 324.96 326.01 326.51 327.01 327.62 328.76 328.40 [151] 327.20 325.27 323.20 323.40 324.63 325.85 326.60 327.47 327.58 329.56 [161] 329.90 328.92 327.88 326.16 324.68 325.04 326.34 327.39 328.37 329.40 [171] 330.14 331.33 332.31 331.90 330.70 329.15 327.35 327.02 327.99 328.48 [181] 329.18 330.55 331.32 332.48 332.92 332.08 331.01 329.23 327.27 327.21 [191] 328.29 329.41 330.23 331.25 331.87 333.14 333.80 333.43 331.73 329.90 [201] 328.40 328.17 329.32 330.59 331.58 332.39 333.33 334.41 334.71 334.17 [211] 332.89 330.77 329.14 328.78 330.14 331.52 332.75 333.24 334.53 335.90 [221] 336.57 336.10 334.76 332.59 331.42 330.98 332.24 333.68 334.80 335.22 [231] 336.47 337.59 337.84 337.72 336.37 334.51 332.60 332.38 333.75 334.78 [241] 336.05 336.59 337.79 338.71 339.30 339.12 337.56 335.92 333.75 333.70 [251] 335.12 336.56 337.84 338.19 339.91 340.60 341.29 341.00 339.39 337.43 [261] 335.72 335.84 336.93 338.04 339.06 340.30 341.21 342.33 342.74 342.08 [271] 340.32 338.26 336.52 336.68 338.19 339.44 340.57 341.44 342.53 343.39 [281] 343.96 343.18 341.88 339.65 337.81 337.69 339.09 340.32 341.20 342.35 [291] 342.93 344.77 345.58 345.14 343.81 342.21 339.69 339.82 340.98 342.82 [301] 343.52 344.33 345.11 346.88 347.25 346.62 345.22 343.11 340.90 341.18 [311] 342.80 344.04 344.79 345.82 347.25 348.17 348.74 348.07 346.38 344.51 [321] 342.92 342.62 344.06 345.38 346.11 346.78 347.68 349.37 350.03 349.37 [331] 347.76 345.73 344.68 343.99 345.48 346.72 347.84 348.29 349.23 350.80 [341] 351.66 351.07 349.33 347.92 346.27 346.18 347.64 348.78 350.25 351.54 [351] 352.05 353.41 354.04 353.62 352.22 350.27 348.55 348.72 349.91 351.18 [361] 352.60 352.92 353.53 355.26 355.52 354.97 353.75 351.52 349.64 349.83 [371] 351.14 352.37 353.50 354.55 355.23 356.04 357.00 356.07 354.67 352.76 [381] 350.82 351.04 352.69 354.07 354.59 355.63 357.03 358.48 359.22 358.12 [391] 356.06 353.92 352.05 352.11 353.64 354.89 355.88 356.63 357.72 359.07 [401] 359.58 359.17 356.94 354.92 352.94 353.23 354.09 355.33 356.63 357.10 [411] 358.32 359.41 360.23 359.55 357.53 355.48 353.67 353.95 355.30 356.78 [421] 358.34 358.89 359.95 361.25 361.67 360.94 359.55 357.49 355.84 356.00 [431] 357.59 359.05 359.98 361.03 361.66 363.48 363.82 363.30 361.94 359.50 [441] 358.11 357.80 359.61 360.74 362.09 363.29 364.06 364.76 365.45 365.01 [451] 363.70 361.54 359.51 359.65 360.80 362.38 363.23 364.06 364.61 366.40 [461] 366.84 365.68 364.52 362.57 360.24 360.83 362.49 364.34 > data(iris) > unstrip(iris) [,1] [,2] [,3] [,4] [,5] [1,] 5.1 3.5 1.4 0.2 1 [2,] 4.9 3.0 1.4 0.2 1 [3,] 4.7 3.2 1.3 0.2 1 [4,] 4.6 3.1 1.5 0.2 1 [5,] 5.0 3.6 1.4 0.2 1 [6,] 5.4 3.9 1.7 0.4 1 [7,] 4.6 3.4 1.4 0.3 1 [8,] 5.0 3.4 1.5 0.2 1 [9,] 4.4 2.9 1.4 0.2 1 [10,] 4.9 3.1 1.5 0.1 1 [11,] 5.4 3.7 1.5 0.2 1 [12,] 4.8 3.4 1.6 0.2 1 [13,] 4.8 3.0 1.4 0.1 1 [14,] 4.3 3.0 1.1 0.1 1 [15,] 5.8 4.0 1.2 0.2 1 [16,] 5.7 4.4 1.5 0.4 1 [17,] 5.4 3.9 1.3 0.4 1 [18,] 5.1 3.5 1.4 0.3 1 [19,] 5.7 3.8 1.7 0.3 1 [20,] 5.1 3.8 1.5 0.3 1 [21,] 5.4 3.4 1.7 0.2 1 [22,] 5.1 3.7 1.5 0.4 1 [23,] 4.6 3.6 1.0 0.2 1 [24,] 5.1 3.3 1.7 0.5 1 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