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("ifs-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('ifs') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "ifs.FT" > > ### * ifs.FT > > flush(stderr()); flush(stdout()) > > ### Name: ifs.FT > ### Title: IFS estimator > ### Aliases: ifs.FT ifs.setup.FT ifs.pf.FT ifs.df.FT IFS.pf.FT IFS.df.FT > ### Keywords: distribution > > ### ** Examples > > library(ifs) > > nobs <- 100 > y<-rbeta(nobs,2,4) > > # uncomment if you want to test the normal distribution > # y<-sort(rnorm(nobs,3,1))/6 > > IFS.est <- IFS(y) Warning in if (maps == "quantile") { : the condition has length > 1 and only the first element will be used Warning in if (maps == "wl1") { : the condition has length > 1 and only the first element will be used Warning in if (maps == "wl2") { : the condition has length > 1 and only the first element will be used Warning in if (maps != "quantile") nm <- 10 : the condition has length > 1 and only the first element will be used Warning in if (maps != "quantile") { : the condition has length > 1 and only the first element will be used > xx <- IFS.est$x > tt <- IFS.est$y > > ss <- pbeta(xx,2,4) > > # uncomment if you want to test the normal distribution > # ss <- pnorm(6*xx-3) > > par(mfrow=c(3,1)) > > plot(ecdf(y),xlim=c(0,1),main="IFS estimator versus EDF") > lines(xx,ss,col="blue") > lines(IFS.est,col="red") > IFS.FT.est <- IFS.pf.FT(y) Warning in if (maps == "quantile") { : the condition has length > 1 and only the first element will be used Warning in if (maps == "wl1") { : the condition has length > 1 and only the first element will be used Warning in if (maps == "wl2") { : the condition has length > 1 and only the first element will be used > xxx <- IFS.FT.est$x > uuu <- IFS.FT.est$y > sss <- pbeta(xxx,2,4) > # uncomment if you want to test the normal distribution > # sss <- pnorm(6*xxx-3) > > lines(IFS.FT.est,col="green") > > # calculates MSE > > ww <- ecdf(y)(xx) > mean((ww-ss)^2) [1] 0.001218602 > mean((tt-ss)^2) [1] 0.001009437 > mean((uuu-sss)^2) [1] 0.001346715 > > plot(xx,(ww-ss)^2,main="MSE",type="l",xlab="x",ylab="MSE(x)") > lines(xx,(tt-ss)^2,col="red") > lines(xxx,(uuu-sss)^2,col="green") > > plot(IFS.df.FT(y),type="l",col="green",ylim=c(0,3),main="IFS vs Kernel") Warning in if (maps == "quantile") { : the condition has length > 1 and only the first element will be used Warning in if (maps == "wl1") { : the condition has length > 1 and only the first element will be used Warning in if (maps == "wl2") { : the condition has length > 1 and only the first element will be used > lines(density(y),col="blue") > curve(dbeta(x,2,4),0,1,add=TRUE) > # uncomment if you want to test the normal distribution > # curve(6*dnorm(x*6-3,0,1),0,1,add=TRUE) > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > cleanEx(); ..nameEx <- "ifs" > > ### * ifs > > flush(stderr()); flush(stdout()) > > ### Name: ifs > ### Title: IFS estimator > ### Aliases: ifs ifs.flex IFS > ### Keywords: nonparametric > > ### ** Examples > > library(ifs) > > y<-rbeta(50,.5,.1) > > # uncomment if you want to test the normal distribution > # y<-sort(rnorm(50,3,1))/6 > > IFS.est <- IFS(y) Warning in if (maps == "quantile") { : the condition has length > 1 and only the first element will be used Warning in if (maps == "wl1") { : the condition has length > 1 and only the first element will be used Warning in if (maps == "wl2") { : the condition has length > 1 and only the first element will be used Warning in if (maps != "quantile") nm <- 10 : the condition has length > 1 and only the first element will be used Warning in if (maps != "quantile") { : the condition has length > 1 and only the first element will be used > xx <- IFS.est$x > tt <- IFS.est$y > > ss <- pbeta(xx,.5,.1) > > # uncomment if you want to test the normal distribution > # ss <- pnorm(6*xx-3) > > par(mfrow=c(2,1)) > > plot(ecdf(y),xlim=c(0,1),main="IFS estimator versus EDF") > lines(xx,ss,col="blue") > lines(xx,tt,col="red") > > # calculates MSE > > ww <- ecdf(y)(xx) > mean((ww-ss)^2) [1] 0.002377201 > mean((tt-ss)^2) [1] 0.002236732 > > plot(xx,(ww-ss)^2,main="MSE",type="l",xlab="x",ylab="MSE(x)") > lines(xx,(tt-ss)^2,col="red") > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > ### *