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("VaR-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('VaR') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "DJIA" > > ### * DJIA > > flush(stderr()); flush(stdout()) > > ### Name: DJIA > ### Title: Daily Closing Prices of Stocks in The Dow Jones 30 Industrial > ### Index > ### Aliases: DJIA > ### Keywords: datasets > > ### ** Examples > > data(DJIA) > attach(DJIA) > plot(Date,IBM, xlab = "Time", ylab = "Close Price", main = "Stock Close Prices vs. Day", type = "l") > axis.POSIXct(1, Date) > detach(DJIA) > > > > cleanEx(); ..nameEx <- "VaR.backtest" > > ### * VaR.backtest > > flush(stderr()); flush(stdout()) > > ### Name: VaR.backtest > ### Title: Backtest of VaR Estimation > ### Aliases: VaR.backtest > ### Keywords: htest > > ### ** Examples > > data(exchange.rates) > attach(exchange.rates) > y <- USDJPY[!is.na(USDJPY)] > z <- VaR.norm(y) > VaR.backtest(z$cdata, z$VaR, p = 0.01) [1] 0.004052988 > detach(exchange.rates) > > > > cleanEx(); ..nameEx <- "VaR.gpd" > > ### * VaR.gpd > > flush(stderr()); flush(stdout()) > > ### Name: VaR.gpd > ### Title: Value at Risk Calculation from Log-Likelihood Fit of General > ### Pareto Distribution (GPD) > ### Aliases: VaR.gpd > ### Keywords: ts > > ### ** Examples > > data(exchange.rates) > attach(exchange.rates) > y <- USDJPY[!is.na(USDJPY)] > z <- VaR.gpd(y) Warning in log(x) : NaNs produced Warning in log(x) : NaNs produced Warning in log(x) : NaNs produced Warning in log(x) : NaNs produced Warning in log(x) : NaNs produced Warning in log(x) : NaNs produced Warning in log(x) : NaNs produced Warning in log(x) : NaNs produced > z$VaR [1] 1.636566 > z$VaR.interval [1] 1.485103 1.882315 > z$ES [1] 2.112686 > z$ES.interval [1] 1.812828 2.599206 > detach(exchange.rates) > > > > cleanEx(); ..nameEx <- "VaR.gpd.plots" > > ### * VaR.gpd.plots > > flush(stderr()); flush(stdout()) > > ### Name: VaR.gpd.plots > ### Title: Diagnostic Plots for VaR Calculation from GPD Approximation > ### Aliases: VaR.gpd.plots > ### Keywords: aplot > > ### ** Examples > > data(exchange.rates) > attach(exchange.rates) > y <- USDJPY[!is.na(USDJPY)] > z <- VaR.gpd(y) Warning in log(x) : NaNs produced Warning in log(x) : NaNs produced Warning in log(x) : NaNs produced Warning in log(x) : NaNs produced Warning in log(x) : NaNs produced Warning in log(x) : NaNs produced Warning in log(x) : NaNs produced Warning in log(x) : NaNs produced > VaR.gpd.plots(z) > detach(exchange.rates) > > > > cleanEx(); ..nameEx <- "VaR.norm" > > ### * VaR.norm > > flush(stderr()); flush(stdout()) > > ### Name: VaR.norm > ### Title: Value at Risk Calculation in Lognormal Approximation > ### Aliases: VaR.norm > ### Keywords: ts > > ### ** Examples > > data(exchange.rates) > attach(exchange.rates) > y <- USDJPY[!is.na(USDJPY)] > z <- VaR.norm(y) > z$VaR [1] 1.674734 > detach(exchange.rates) > > > > cleanEx(); ..nameEx <- "VaR.norm.plots" > > ### * VaR.norm.plots > > flush(stderr()); flush(stdout()) > > ### Name: VaR.norm.plots > ### Title: Diagnostic Plots for VaR Calculation in Lognormal Approximation > ### Aliases: VaR.norm.plots > ### Keywords: aplot > > ### ** Examples > > data(exchange.rates) > attach(exchange.rates) > y <- USDJPY[!is.na(USDJPY)] > z <- VaR.norm(y) > VaR.norm.plots(z) > detach(exchange.rates) > > > > cleanEx(); ..nameEx <- "exchange.rates" > > ### * exchange.rates > > flush(stderr()); flush(stdout()) > > ### Name: exchange.rates > ### Title: EUR/USD, USD/JPY, USD/CHF and GPD/USD Exchange Rates > ### Aliases: exchange.rates > ### Keywords: datasets > > ### ** Examples > > data(exchange.rates) > attach(exchange.rates) > plot(date, USDJPY, xlab = "Time", ylab = "Exchange Rate", main = "USD/JPY Exchange Rate", type = "l") > axis.POSIXct(1, date) > detach(exchange.rates) > > > > ### *