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("CDNmoney-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('CDNmoney') > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "CanadianCreditData" > > ### * CanadianCreditData > > flush(stderr()); flush(stdout()) > > ### Name: CanadianCreditData > ### Title: Canadian Credit Aggregates > ### Aliases: CanadianCreditData CanadianCreditData.asof.28Jan2005 > ### TotalCredit ConsumerCredit ResidentialMortgage > ### ShortTermBusinessCredit OtherBusinessCredit > ### Keywords: datasets > > ### ** Examples > > require("tframe") Loading required package: tframe [1] TRUE > data("CanadianCreditData", package="CDNmoney") > > tfplot(TotalCredit, ConsumerCredit, ResidentialMortgage, + ShortTermBusinessCredit, OtherBusinessCredit) > tfplot(tbind(TotalCredit, ConsumerCredit, ResidentialMortgage, + ShortTermBusinessCredit, OtherBusinessCredit), graphs.per.page=3 ) > > tfplot(diff(tbind(TotalCredit, ConsumerCredit, ResidentialMortgage, + ShortTermBusinessCredit, OtherBusinessCredit)), graphs.per.page=3 ) > > tfplot(tbind(TotalCredit, ConsumerCredit, ResidentialMortgage, + ShortTermBusinessCredit, OtherBusinessCredit), graphs.per.page=3, + start=c(1990,6), end=c(1991,6)) > > > > cleanEx(); ..nameEx <- "CanadianMoneyData" > > ### * CanadianMoneyData > > flush(stderr()); flush(stdout()) > > ### Name: CanadianMoneyData > ### Title: Continuity Adjusted Component Data for Canadian Monetary > ### Aggregates > ### Aliases: CanadianMoneyData CanadianMoneyData.asof.28Jan2005 > ### CanadianMoneyData.asof.6Feb2004 CanadianMoneyData.asof.26Aug2002 > ### MB2001 MB486 MB487p MB452 MB453 MB454 MB472 NonbankCheq MB473 > ### NonbankNonCheq NonbankTerm MB2046 MB2047 MB2048 MB2057 MB2058 MB475 > ### MB482 M1total M1real M1PerCapita float TMLinterbank MB452adj MB473adj > ### CUadj > ### Keywords: datasets > > ### ** Examples > > require("tframe") Loading required package: tframe [1] TRUE > data("CanadianMoneyData", package="CDNmoney") > ########### Calculations to get monetary aggregates ###### > > M1gross <- tframed(MB2001 + MB486 + MB487p + TMLinterbank, names="gross M1 (B2054)") > M1p <- tframed(MB2001 + MB486 + MB487p + MB452 + MB452adj + MB472 + + NonbankCheq, names="M1+ (B2060)") > M1pp <- tframed(CUadj + M1p + MB453 + MB473 + MB473adj + NonbankNonCheq, + names="M1++ (B2061)") > M2 <- tframed(M1total + MB472 + MB473 + MB452 + MB453 + MB454, names="M2 (B2031)") > M2p <- tframed(M2 + NonbankCheq + NonbankNonCheq + NonbankTerm + + MB2046 + MB2047 + MB2048, names="M2+ (B2037)") > M2pp <- tframed(M2p + MB2057 + MB2058, names="M2++ (B2059)") > M3 <- tframed(M2 + MB475 + MB482, names="M3 (B2030)") > > ######### Calculations of cpi and pop ###### > > # M1real = M1total * 100/p100000 (CPI - p20 Bank of Canada Weekly Financial > # Statistics, June 1992=100) > # M1PerCapita = M1total * 100 /(pop * p100000) # using a quarterly population > # series converted to monthly using spline. > > cpi <- 100 * M1total / M1real > seriesNames(cpi) <- "CPI" > > popm <- M1total / M1PerCapita > seriesNames(popm) <- "Population of Canada" > > ######### Plot aggregates ##### > > tfplot(tbind(M1total, M1gross, M1p, M1pp)) > tfplot(tbind(M1PerCapita, M1real)) > tfplot(tbind(M2, M2p, M2pp)) > tfplot(M3) > > #### Calculations to get components as used in Gilbert and Pichette #### > > z <-tfwindow(tframed(tbind( + MB2001, + MB486 + MB452 , + NonbankCheq, + MB472 + MB473 + MB487p, + MB475, + NonbankNonCheq + MB454 + NonbankTerm + MB2046 + MB2047 + MB2048 + + MB2057 + MB2058 + MB482 + MB453), + names=c("currency", "personal cheq.", "NonbankCheq", + "N-P demand & notice", "N-P term", "Investment") + ), start=c(1986,1), end=c(2002,4)) > > MBcomponents <- 1e8 * z /matrix(tfwindow(popm * cpi, start=c(1986,1), + end=c(2002,4)),196, 6) > # 1e8 * gives real $ per person > #(MB numbers in millions, CPI in fraction*100, popm in persons.) > > tfplot(MBcomponents, graphs.per.page=3) > > > > ### *