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("gld-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('gld') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "GeneralisedLambdaDistribution" > > ### * GeneralisedLambdaDistribution > > flush(stderr()); flush(stdout()) > > ### Name: GeneralisedLambdaDistribution > ### Title: The Generalised Lambda Distribution > ### Aliases: dgl qdgl qdgl.fmkl qdgl.rs pgl qgl qgl.fmkl qgl.rs rgl > ### GeneralizedLambdaDistribution GeneralisedLambdaDistribution gld > ### Keywords: distribution > > ### ** Examples > > qgl(seq(0,1,0.02),0,1,0.123,-4.3) [1] -8.130081e+00 -3.084143e+00 -2.613430e+00 -2.307344e+00 -2.070771e+00 [6] -1.871960e+00 -1.695938e+00 -1.534172e+00 -1.381095e+00 -1.232661e+00 [11] -1.085627e+00 -9.371516e-01 -7.845475e-01 -6.250917e-01 -4.558740e-01 [16] -2.736478e-01 -7.467189e-02 1.454739e-01 3.921148e-01 6.717672e-01 [21] 9.925117e-01 1.364486e+00 1.800545e+00 2.317166e+00 2.935684e+00 [26] 3.684023e+00 4.599143e+00 5.730540e+00 7.145340e+00 8.935826e+00 [31] 1.123075e+01 1.421265e+01 1.814500e+01 2.341553e+01 3.060746e+01 [36] 4.061970e+01 5.487640e+01 7.570540e+01 1.070508e+02 1.558785e+02 [41] 2.351079e+02 3.701324e+02 6.145107e+02 1.091513e+03 2.118256e+03 [46] 4.639808e+03 1.211249e+04 4.173286e+04 2.386015e+05 4.700051e+06 [51] Inf > pgl(seq(-2,2,0.2),0,1,-.1,-.2,param="fmkl",inverse.eps=.Machine$double.eps) [1] 0.1419931 0.1639120 0.1888526 0.2170072 0.2484826 0.2832626 0.3211723 [8] 0.3618524 0.4047522 0.4491492 0.4941974 0.5389997 0.5826900 0.6245082 [15] 0.6638550 0.7003169 0.7336649 0.7638316 0.7908780 0.8149566 0.8362783 > # calculate the probabilities more accurately than normal > > > > cleanEx(); ..nameEx <- "gl.check.lambda" > > ### * gl.check.lambda > > flush(stderr()); flush(stdout()) > > ### Name: gl.check.lambda > ### Title: Function to check the validity of parameters of the generalized > ### lambda distribution > ### Aliases: gl.check.lambda > ### Keywords: distribution > > ### ** Examples > > gl.check.lambda(0,1,.23,4.5) ## TRUE [1] TRUE > gl.check.lambda(0,-1,.23,4.5) ## FALSE [1] FALSE > gl.check.lambda(0,1,0.5,-0.5,"rs") ## FALSE [1] FALSE > > > > cleanEx(); ..nameEx <- "plotgl" > > ### * plotgl > > flush(stderr()); flush(stdout()) > > ### Name: plotgl > ### Title: Plots of density and distribution function for the generalised > ### lambda distribution > ### Aliases: plotgl plotglc plotgld > ### Keywords: distribution hplot aplot > > ### ** Examples > > plotgld(0,1.4640474,.1349,.1349,main="Approximation to Standard Normal", + sub="But you can see this isn't on infinite support") 0% 25% 50% 75% 100% -5.063291 -0.670889 0.000000 0.670889 5.063291 > > plotgld(1.42857143,1,.7,.3,main="The whale") 0% 25% 50% 75% 100% 1.428571e-09 8.169448e-01 1.505214e+00 2.302159e+00 4.761905e+00 > plotglc(1.42857143,1,.7,.3) > plotgld(0,-1,5,-0.3,param="rs") 0% 25% 50% 75% 100% 1.000000 1.089162 1.199894 1.278412 Inf > plotgld(0,-1,5,-0.3,param="rs",xlim=c(1,2)) 0% 25% 50% 75% 100% 1.000000 1.089162 1.199894 1.278412 Inf > # A bizarre shape from the RS paramterisation > plotgld(0,1,5,-0.3,param="fmkl") 0% 25% 50% 75% 100% -0.2000000 0.1006565 0.5767314 1.5665162 Inf > plotgld(10/3,,.3,-1,truncate=1e-3) 0% 25% 50% 75% 100% 0.000000 2.532513 3.707508 6.057716 Inf > > plotgld(0,1,.0742,.0742,col.or.type=2,param="rs", + main="All distributions have the same moments", + sub="The full Range of all distributions is shown") 0% 25% 50% 75% 100% -1.00000000 -0.07662967 0.00000000 0.07662967 1.00000000 > plotgld(0,1,6.026,6.026,col.or.type=3,new.plot=FALSE,param="rs") 0% 25% 50% 75% 100% -1.0000000 -0.1764168 0.0000000 0.1764168 1.0000000 > plotgld(0,1,35.498,2.297,col.or.type=4,new.plot=FALSE,param="rs") 0% 25% 50% 75% 100% -1.00000000 -0.51643506 -0.20348580 -0.04136975 1.00000000 > legend(0.25,3.5,lty=1,col=c(2,3,4),legend=c("(0,1,.0742,.0742)", + "(0,1,6.026,6.026)","(0,1,35.498,2.297)"),cex=0.9) > # An illustration of problems with moments as a method of characterising shape > > > > > cleanEx(); ..nameEx <- "qqgl" > > ### * qqgl > > flush(stderr()); flush(stdout()) > > ### Name: qqgl > ### Title: Quantile-Quantile plot against the generalised lambda > ### distribution > ### Aliases: qqgl > ### Keywords: distribution hplot aplot > > ### ** Examples > > qqgl(rgl(100,0,1,0,-.1),0,1,0,-.1) > > > > cleanEx(); ..nameEx <- "starship" > > ### * starship > > flush(stderr()); flush(stdout()) > > ### Name: starship > ### Title: Carry out the ``starship'' estimation method for the generalised > ### lambda distribution > ### Aliases: starship > ### Keywords: distribution > > ### ** Examples > > data <- rgl(100,0,1,.2,.2) > starship(data,optim.method="Nelder-Mead",initgrid=list(lcvect=(0:4)/10, + ldvect=(0:4)/10)) Warning in starship(data, optim.method = "Nelder-Mead", initgrid = list(lcvect = (0:4)/10, : No checks for grids implemented $lambda [1] 0.1058156 1.1115780 0.1959718 0.2533017 $grid.results $grid.results$response [1] 0.2258877 $grid.results$lambda [1] 0.1325427 1.0898225 0.2000000 0.3000000 $optim.results $optim.results$par [1] 0.1058156 1.1115780 0.1959718 0.2533017 $optim.results$value [1] 0.1933497 $optim.results$counts function gradient 169 NA $optim.results$convergence [1] 0 $optim.results$message NULL > > > > cleanEx(); ..nameEx <- "starship.adaptivegrid" > > ### * starship.adaptivegrid > > flush(stderr()); flush(stdout()) > > ### Name: starship.adaptivegrid > ### Title: Carry out the ``starship'' estimation method for the generalised > ### lambda distribution using a grid-based search > ### Aliases: starship.adaptivegrid > ### Keywords: distribution > > ### ** Examples > > data <- rgl(100,0,1,.2,.2) > starship.adaptivegrid(data,lcvect=(0:4)/10,ldvect=(0:4)/10) $response [1] 0.2258877 $lambda [1] 0.1325427 1.0898225 0.2000000 0.3000000 > > > > cleanEx(); ..nameEx <- "starship.obj" > > ### * starship.obj > > flush(stderr()); flush(stdout()) > > ### Name: starship.obj > ### Title: Objective function that is minimised in starship estimation > ### method > ### Aliases: starship.obj > ### Keywords: distribution > > ### ** Examples > > data <- rgl(100,0,1,.2,.2) > starship.obj(c(0,1,.2,.2),data,"fmkl") [1] 0.8548376 > > > > ### *