[Eventstudies-commits] r405 - pkg/inst/tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Feb 26 09:07:05 CET 2015


Author: sargam_jain
Date: 2015-02-26 09:07:05 +0100 (Thu, 26 Feb 2015)
New Revision: 405

Added:
   pkg/inst/tests/test_compilation.txt
Removed:
   pkg/inst/tests/test_INR.rda
   pkg/inst/tests/test_NiftyIndex.rda
   pkg/inst/tests/test_SplitDates.rda
   pkg/inst/tests/test_StockPriceReturns.rda
   pkg/inst/tests/test_USDINR.rda
   pkg/inst/tests/test_eventstudy.R
   pkg/inst/tests/test_firmExposuresData.rda
   pkg/inst/tests/test_inr_inference.R
   pkg/inst/tests/test_interfaces.R
   pkg/inst/tests/test_lmAMM.R
   pkg/inst/tests/test_marketresiduals.R
   pkg/inst/tests/test_y3c3.rda
Log:
Removed old test cases. Added the draft for new test cases to test for.

Deleted: pkg/inst/tests/test_INR.rda
===================================================================
(Binary files differ)

Deleted: pkg/inst/tests/test_NiftyIndex.rda
===================================================================
(Binary files differ)

Deleted: pkg/inst/tests/test_SplitDates.rda
===================================================================
(Binary files differ)

Deleted: pkg/inst/tests/test_StockPriceReturns.rda
===================================================================
(Binary files differ)

Deleted: pkg/inst/tests/test_USDINR.rda
===================================================================
(Binary files differ)

Added: pkg/inst/tests/test_compilation.txt
===================================================================
--- pkg/inst/tests/test_compilation.txt	                        (rev 0)
+++ pkg/inst/tests/test_compilation.txt	2015-02-26 08:07:05 UTC (rev 405)
@@ -0,0 +1,209 @@
+###### Testing functions in eventstudies package #####
+
+Tests are categorized as follows:
+I.   Tests for argument inputs (context: user input)
+II.  Tests for functionality (context: functionality)
+III. Tests for aggregate function (context: aggregate) 
+IV.  Example from book as test case (context: example)
+
+I. TESTS FOR ARGUMENT INPUTS
+
+1. Function phys2eventime 
+   a) Check for following values for width:
+      # Normal values:
+      	* 10
+	* 1
+      # Extreme values:
+      	* zero
+	* +Inf
+      	* -Inf
+	* Values greater than the no. of rows in dataframe StockPriceReturns
+   b) Check for following when zoo object with firm data and dates as index is a univariate series:
+      # If univariate series is input as vector (not matrix), then the function fails.
+   c) Check for following values for z (zoo object):
+       # Normal values:
+ 	* ?
+	* ?
+      # Extreme values:
+      	* ?
+	* ?
+   d) Check for following values for event.list:
+       # Normal values:
+      	* ?
+	* ?
+      # Extreme values:
+      	* ?
+	* ?
+
+****************** Models ********************
+
+2. Function marketModel
+   a) Check whether: # of rows in df(firm returns) = # of rows in df(market returns) 
+   b) Check for extreme values of no. of rows and columns i.e. 1 row or 1 col in dataset
+   c) Check for residuals = TRUE (whether data is in returns or price format)
+   d) Check for class of arguments 
+
+3. Function excessReturn
+   a) Check whether: # of rows in df(firm returns) = # of rows in df(market returns)
+   b) Check for extreme values of no. of rows and columns i.e. 1 row or 1 col in dataset   
+   c) Check for class of arguments   
+ 
+4. Function lmAMM
+   a) Check for whether X is the output of makeX or not (read makeX manual)
+   b) Check for other logical arguments (those with TRUE/FALSE)
+
+5. Function None
+   a) Check that no model arguments should be specified
+
+
+************** Remap functions **************
+
+6. Function remap.cumsum
+   a) Check for is.pc = TRUE (whether data is in percentage)
+   b) Check for following values of base:
+      # Normal values:
+        * 0
+        * 100
+      # Extreme values:
+	* -Inf
+	* Inf  
+7. Function remap.cumprod
+   a) Check for is.pc = TRUE (whether data is in percentage)
+   b) Check for is.pc = TRUE (whether data is in returns or price format)
+   c) Check for following values of base:
+      # Normal values:
+        * 0
+        * 100
+      # Extreme values:
+	* -Inf
+	* Inf  
+
+************* Inference procedures ***********
+
+8. Function inference.bootstrap
+   a) Check for following values of boot.run:
+      # Normal values:
+        * 1000
+	* 10  
+      # Extreme values:
+	* 0
+	* Inf/ -Inf
+   b) Check for following values of es.w:
+      # Extreme values:
+	* ?
+	* ?
+10. Function inference.wilcox
+   a) Check for following values of prob:
+      # Normal values:
+        * .10
+      # Extreme values:
+	* Any value less than 0 and greater than 1
+   b) Check for following values of es.w:
+      # Extreme values:
+	* ?
+	* ?
+
+
+************************************************************************************************************
+
+II. TESTS FOR FUNCTIONALITY
+
+1. Function phys2eventime 
+   a) Check for list components returned by the function
+   b) Check for firm selected should not have NA in data for defined width
+   c) Check for class of arguments
+   d) Check for if the function handles following data discrepancies in events:
+      * Missing dates in eventlist 
+      * Missing firm in eventlist  
+   e) When zoo object with firm data and dates as index is a univariate series, 
+      function must work if its a matrix of one column.
+
+
+****************** Models ********************
+
+2. Function marketModel
+   a) Check the working and results of regression analysis manually
+
+3. Function excessReturn
+   a) Check with small sample data whether the result is correct or not.
+   
+4. Function lmaMM
+   a) Check for class of arguments
+   b) Check the working and results of regression analysis manually: difficult @leave this for now
+   @ remind to come up with test cases for lmAMM
+
+5. Function None     
+
+************** Remap functions **************
+6. Function remap.cumsum
+   a) Cumulate by summing and tally
+
+7. Function remap.cumprod
+   a) Cumulate by multiplying and tally
+
+************* Inference procedures ***********
+
+8. Function inference.bootstrap @think and read
+
+9. Function inference.wilcox   @think and read
+   
+********************************************************************************
+
+III. TESTS FOR AGGREGATE FUNCTION (eventstudy)
+
+10. Check the following for argument, event.window:
+      # Normal values:
+        * Any value less than no. of rows of firm.returns and greater than zero
+      # Extreme values:
+	* 0
+	* Inf/ -Inf
+	* Any value greater than no. of rows of firm.returns and less than zero
+   b) Check that event.window does not overlap with estimation window (i.e. firm returns 
+      used to estimate market returns through any of the described models.
+
+***************** Models *********************
+
+10. Check the function for all the models using small data sets:
+    a) Check for the argument, type: by default, model type (argument in eventstudy 
+       function) should be market model, else specify the type as any of the following:
+       # none
+       # lmAMM
+       # excessReturn
+
+***************** Remap functions ************
+
+11. Check the function for logical argument to.remap (taking values TRUE/ FALSE):
+    a) for cumsum
+    b) for cumprod
+
+************* Inference procedures ***********
+
+12. Check the function for logical argument inference (taking values TRUE/ FALSE):
+13. Check the function for the argument inference.strategy taking following values:
+    a) bootstrap
+    b) wilcoxin
+
+  
+
+
+
+Function prepare.returns(): for (model != "None") and (number of returns > 1)
+      - Merge all the returns (firm.returns, currency, and/or market)
+        into one 'zoo' object.
+      - Convert the merged object for each event separately to event
+        time.
+      - Store the outcomes as attributes of the event time object.
+      - Return a 'list' of event time objects for each event.
+   2. prepare.returns(): for (model = "None") and (number of returns = 1)
+      - Convert the whole zoo object 'firm.returns' to event time.
+      - Returns this object as a whole.
+   3. Check whether all the outcomes are not "success".
+   4. If model is not "None", run the model program for each object in
+      the returned list, and return the series index only within the
+      event window.
+   5. If model is None, then directly return the series within the
+      event window.
+   6. Check for any NULL values.
+   7. Handle univariate output: convert to a single column zoo object.
+   8. Perform remapping if asked by the user.
+   9. Perform inference if asked by the user.

Deleted: pkg/inst/tests/test_eventstudy.R
===================================================================
--- pkg/inst/tests/test_eventstudy.R	2015-01-26 14:49:09 UTC (rev 404)
+++ pkg/inst/tests/test_eventstudy.R	2015-02-26 08:07:05 UTC (rev 405)
@@ -1,78 +0,0 @@
-context("phys2eventtime")
-
-test_that("test.phys2eventtime", {
-
-# An example dataset, with 3 firms --
-p <- structure(c(33.16, 34.0967, 35.3683, 34.46, 34.17, 35.89, 36.19,
-                 37.1317, 36.7033, 37.7933, 37.8533, 285.325, 292.6,
-                 290.025, 286.2, 290.075, 295.05, 289.325, 285.625,
-                 293.7, 298.5, 289.05, 704.5438, 708.35, 735.8375,
-                 710.625, 711.65, 731.0125, 727.575, 715.0187, 724.2,
-                 713.1875, 695.1812), .Dim = c(11L, 3L), .Dimnames =
-                 list( NULL, c("ITC", "Reliance", "Infosys")), index =
-                 structure(c(12418, 12419, 12422, 12423, 12424, 12425,
-                 12426, 12429, 12430, 12431, 12432), class = "Date"),
-                 class = "zoo")
-# An example events list
-eventslist <- data.frame(name=c("ITC","Reliance","Infosys",
-                           "ITC","Reliance","Junk"),
-                         when=as.Date(c(
-                           "2004-01-02", "2004-01-08", "2004-01-14",
-                           "2005-01-15", "2004-01-01", "2005-01-01")))
-eventslist$name <- as.character(eventslist$name)
-
-# What we expect if we don't worry about width --
-rawres <- structure(list(z.e = structure(c(NA, NA, NA, NA, NA, NA,
-  NA, NA, 33.16, 34.0967, 35.3683, 34.46, 34.17, 35.89, 36.19,
-  37.1317, 36.7033, 37.7933, 37.8533, NA, NA, NA, NA, 285.325, 292.6,
-  290.025, 286.2, 290.075, 295.05, 289.325, 285.625, 293.7, 298.5,
-  289.05, NA, NA, NA, NA, 704.5438, 708.35, 735.8375, 710.625, 711.65,
-  731.0125, 727.575, 715.0187, 724.2, 713.1875, 695.1812, NA, NA, NA,
-  NA, NA, NA, NA, NA), .Dim = c(19L, 3L), .Dimnames = list( NULL,
-  c("1", "2", "3")), index = -9:9, class = "zoo"), outcomes =
-  structure(c(1L, 1L, 1L, 3L, 3L, 2L), .Label = c("success",
-  "unitmissing", "wrongspan" ), class = "factor")), .Names = c("z.e",
-  "outcomes"))
-
-cat("\nCheck without width handling ")
-a <- phys2eventtime(p, eventslist,width=0)
-expect_that(a, equals(rawres))
-
-cat("\nCheck with width of 1 ")
-a <- phys2eventtime(p, eventslist,width=1)
-expect_that(a, equals(rawres))
-
-# But when we go to width=2, column 1 and 3 drop off because they have
-# only 1 obs before & after the event date respectively.
-cat("\nCheck with width of 2 ")
-a <- phys2eventtime(p, eventslist,width=2)
-expect_that(a, equals(structure(list(z.e = structure(c(NA, NA, NA, NA, 285.325,
-                                       292.6, 290.025, 286.2, 290.075, 295.05,
-                                       289.325, 285.625, 293.7, 298.5, 289.05,
-                                       NA, NA, NA, NA),
-                                       index = -9:9,
-                                       class = "zoo"),
-                                     outcomes = structure(c(3L, 1L, 3L, 4L, 4L, 2L),
-                                       .Label = c("success", "unitmissing",
-                                         "wdatamissing", "wrongspan"),
-                                       class = "factor")),
-                                .Names = c("z.e", "outcomes" ))))
-
-## Check the previous date
-cat("\nTesting handling of missing data on event date: ")
-eventdate <- as.Date("2004-01-10")
-eventdate_output <- "2004-01-09"
-eventslist <- data.frame(name = "ITC", when = eventdate,
-                         stringsAsFactors = FALSE)
-a <- phys2eventtime(p, eventslist, width = 2)
-expect_that(as.numeric(a$z.e["0",]),
-            equals(as.numeric(p$ITC[as.Date(eventdate_output), ])))
-
-
-## events$when should be a time-based class
-cat("\nTesting class of events$when: ")
-eventdate <- "2004-01-09"
-eventslist <- data.frame(name = "ITC", when = eventdate,
-                         stringsAsFactors = FALSE)
-expect_error(a <- phys2eventtime(p, eventslist, width = 2), regexp = "events\\$when.*class.*$")
-})

Deleted: pkg/inst/tests/test_firmExposuresData.rda
===================================================================
(Binary files differ)

Deleted: pkg/inst/tests/test_inr_inference.R
===================================================================
--- pkg/inst/tests/test_inr_inference.R	2015-01-26 14:49:09 UTC (rev 404)
+++ pkg/inst/tests/test_inr_inference.R	2015-02-26 08:07:05 UTC (rev 405)
@@ -1,45 +0,0 @@
-context("INR Inference")
-
-test_that("test.inr.inference", {
-library(eventstudies)
-
-load("test_INR.rda")
-
-inr_returns <- diff(log(INR))[-1]
-
-eventslist <- data.frame(when=as.Date(c(
-                           "2010-04-20","2010-07-02","2010-07-27",
-                           "2010-09-16","2010-11-02","2011-01-25",
-                           "2011-03-17","2011-05-03","2011-06-16",
-                           "2011-07-26")
-                           ),
-                         name=rep("inr",10)
-                         )
-
-event_time_data <- phys2eventtime(inr_returns[, , drop = FALSE] , eventslist,width=10)
-w <- window(event_time_data$z.e,start=-10,end=10)
-
-expect_that(inference.bootstrap(w, to.plot=FALSE)[,2],
-            equals(c(-0.000015327455,
-                     -0.002526819039,
-                     0.001190000495,
-                     0.001193534934,
-                     0.001846733711,
-                     -0.000105473215,
-                     -0.001659771669,
-                     0.001644517771,
-                     -0.001325235918,
-                     0.001546368579,
-                     -0.000809734240,
-                     -0.001499191073,
-                     -0.000289413740,
-                     -0.000003273428,
-                     -0.000416661873,
-                     -0.001150000190,
-                     -0.000759748390,
-                     0.002306711019,
-                     -0.0004872993296,
-                     0.001122457470,
-                     0.000635889955)))
-})
-

Deleted: pkg/inst/tests/test_interfaces.R
===================================================================
--- pkg/inst/tests/test_interfaces.R	2015-01-26 14:49:09 UTC (rev 404)
+++ pkg/inst/tests/test_interfaces.R	2015-02-26 08:07:05 UTC (rev 405)
@@ -1,189 +0,0 @@
-context("eventstudy")
-
-test_that("test.interfaces", {
-    load("test_SplitDates.rda")
-    load("test_StockPriceReturns.rda")
-    load("test_NiftyIndex.rda")
-    load("test_USDINR.rda")
-
-### Basic event study with default args (market residuals)
-    cat("\nChecking market residuals interface: ")
-    expected_mean <- c(0, 0.0393985717416213, -0.7458035091065,
-                     0.457817077869512, 0.715714066835461, 2.33986420702835,
-                     2.37333344340029)
-    expected_outcomes <- c("success", "success")
-
-    test_events <- data.frame(name = "ONGC",
-                              when = as.Date(c("2011-08-01", "2010-05-14")),
-                              stringsAsFactors = FALSE)
-    test_returns<- StockPriceReturns[complete.cases(StockPriceReturns$ONGC), "ONGC",
-                                     drop = FALSE]
-    test_es <- eventstudy(firm.returns = test_returns,
-                     event.list = test_events,
-                     event.window = 3,
-                     model.args = list(market.returns = NiftyIndex))
-
-    expect_that(expected_mean, equals(test_es$result[, "Mean"]))
-    expect_that(expected_outcomes, equals(test_es$outcomes))
-    expect_is(test_es, "es")
-
-### None
-    cat("\nChecking no model output: ")
-    expected_mean <- c(0, -0.197406699931557, -0.804299958306487,
-                       0.0135570496689663, -0.418062964428412,
-                       0.904144365357373, -0.806779427723603)
-    expected_outcomes <- c("success", "success")
-
-    test_events <- data.frame(name = "ONGC",
-                              when = as.Date(c("2011-08-01", "2010-05-14")),
-                              stringsAsFactors = FALSE)
-    test_returns<- StockPriceReturns[complete.cases(StockPriceReturns$ONGC), "ONGC",
-                                     drop = FALSE]
-    test_es <- eventstudy(firm.returns = test_returns,
-                          event.list = test_events,
-                          event.window = 3,
-                          type = "None")
-
-    expect_that(expected_mean, equals(test_es$result[, "Mean"]))
-    expect_that(expected_outcomes, equals(test_es$outcomes))
-    expect_is(test_es, "es")
-
-### AMM interface
-    cat("\nChecking AMM interface: ")
-    expected_mean <-  c(0, 0.135927645042554, -0.600457594252805, 0.631525565290171,
-                        0.871423869901684, 2.54741102266723, 2.5989730099384)
-
-    expected_outcomes <- c("success", "success")
-
-    test_events <- data.frame(name = "ONGC",
-                              when = as.Date(c("2011-08-01", "2010-05-14")),
-                              stringsAsFactors = FALSE)
-    test_returns<- StockPriceReturns[complete.cases(StockPriceReturns$ONGC), "ONGC",
-                                     drop = FALSE]
-    test_others <- USDINR
-    test_es <- eventstudy(firm.returns = test_returns,
-                          event.list = test_events,
-                          event.window = 3,
-                          type = "lmAMM",
-                          model.args = list(market.returns = NiftyIndex[index(USDINR)],
-                          others = test_others))
-
-    expect_that(expected_mean, equals(test_es$result[, "Mean"]))
-    expect_that(expected_outcomes, equals(test_es$outcomes))
-    expect_is(test_es, "es")
-
-### Excess return
-    cat("\nChecking excess return interface: ")
-    expected_mean <- c(0, 0.138567158395153, -0.631185954448288, 0.701644918222266,
-                       1.15001275036422, 2.88646832315114, 3.32315429568726)
-    expected_outcomes <- c("success", "success")
-
-    test_events <- data.frame(name = "ONGC",
-                              when = as.Date(c("2011-08-01", "2010-05-14")),
-                              stringsAsFactors = FALSE)
-    test_returns<- StockPriceReturns[complete.cases(StockPriceReturns$ONGC), "ONGC",
-                                     drop = FALSE]
-
-    test_es <- eventstudy(firm.returns = test_returns,
-                          event.list = test_events,
-                          event.window = 3,
-                          type = "excessReturn",
-                          model.args = list(market.returns = NiftyIndex))
-
-    expect_that(expected_mean, equals(test_es$result[, "Mean"]))
-    expect_that(expected_outcomes, equals(test_es$outcomes))
-    expect_is(test_es, "es")
-
-### Remapping
-    cat("\nChecking remapping: ")
-    test_events <- data.frame(name = "ONGC",
-                              when = as.Date(c("2011-08-01", "2010-05-14")),
-                              stringsAsFactors = FALSE)
-    test_returns <- StockPriceReturns[complete.cases(StockPriceReturns$ONGC), "ONGC",
-                                      drop = FALSE]
-
-    ## cumsum
-    test_es <- eventstudy(firm.returns = test_returns,
-                          event.list = test_events,
-                          event.window = 3,
-                          type = "None",
-                          to.remap = FALSE,
-                          remap = "cumsum")
-
-    test_es_remap <- eventstudy(firm.returns = test_returns,
-                          event.list = test_events,
-                          event.window = 3,
-                          type = "None",
-                          to.remap = TRUE,
-                          remap = "cumsum")
-
-    expect_false(isTRUE(all.equal(test_es, test_es_remap)))
-
-    ## cumprod
-    test_es <- eventstudy(firm.returns = test_returns,
-                          event.list = test_events,
-                          event.window = 3,
-                          type = "None",
-                          to.remap = FALSE,
-                          remap = "cumprod")
-
-    test_es_remap <- eventstudy(firm.returns = test_returns,
-                          event.list = test_events,
-                          event.window = 3,
-                          type = "None",
-                          to.remap = TRUE,
-                          remap = "cumprod")
-
-    expect_false(isTRUE(all.equal(test_es, test_es_remap)))
-
-### Inference
-    cat("\nChecking inference interface: ")
-    ## bootstrap
-    test_es_inference <- eventstudy(firm.returns = test_returns,
-                                    event.list = test_events,
-                                    event.window = 3,
-                                    type = "None",
-                                    inference = TRUE,
-                                    inference.strategy = "bootstrap")
-
-    test_es <- eventstudy(firm.returns = test_returns,
-                          event.list = test_events,
-                          event.window = 3,
-                          type = "None",
-                          inference = FALSE,
-                          inference.strategy = "bootstrap")
-
-    expect_false(isTRUE(all.equal(test_es, test_es_inference)))
-
-    ## wilcoxon
-    test_es_inference <- eventstudy(firm.returns = test_returns,
-                                    event.list = test_events,
-                                    event.window = 3,
-                                    type = "None",
-                                    inference = TRUE,
-                                    inference.strategy = "wilcoxon")
-
-    test_es <- eventstudy(firm.returns = test_returns,
-                          event.list = test_events,
-                          event.window = 3,
-                          type = "None",
-                          inference = FALSE,
-                          inference.strategy = "wilcoxon")
-
-    expect_false(isTRUE(all.equal(test_es, test_es_inference)))
-
-})                                       # end test_that()
-
-test_that("test.arguments", {
-    load("test_StockPriceReturns.rda")
-
-    cat("\nChecking single series handling: ")
-    test_events <- data.frame(name = "ONGC",
-                              when = c("2011-08-01", "2010-05-14"),
-                              stringsAsFactors = FALSE)
-    test_returns<- StockPriceReturns$ONGC
-    expect_error(eventstudy(firm.returns = test_returns,
-                            event.list = test_events,
-                            event.window = 3,
-                            type = "None"))
-})

Deleted: pkg/inst/tests/test_lmAMM.R
===================================================================
--- pkg/inst/tests/test_lmAMM.R	2015-01-26 14:49:09 UTC (rev 404)
+++ pkg/inst/tests/test_lmAMM.R	2015-02-26 08:07:05 UTC (rev 405)
@@ -1,126 +0,0 @@
-context("lmAMM")
-
-test_that("test.lmAMM", {
-  load("test_firmExposuresData.rda")
-
-  firm.returns  <- firmExposuresData$Company_A
-  market.returns <- firmExposuresData$NIFTY_INDEX
-  inrusd <- firmExposuresData$usdinr
-  rM3 <- firmExposuresData$baa
-
-  cat("\nDoing Testcase P2")
-  X <- makeX(market.returns, others=inrusd,
-             switch.to.innov=FALSE, market.returns.purge=FALSE, verbose=FALSE)
-  a <- lmAMM(firm.returns, X, nlags=0, verbose=FALSE)
-  expect_that(c(a$exposures, a$s.exposures),
-              equals(structure(c(0.716160223601197,-0.673093436292401,
-                                 0.152101606133946,1.02143820457251),
-                               .Names = c("market.returns", "z", "market.returns", "z")), tolerance=1e-1))
-
-  cat("\nDoing Testcase P3")
-  X <- makeX(market.returns, others=inrusd,
-             switch.to.innov=TRUE, market.returns.purge=FALSE, verbose=FALSE)
-  a <- lmAMM(firm.returns, X, nlags=0, verbose=FALSE)
-  expect_that(c(a$exposures, a$s.exposures),
-              equals(structure(c(0.716160223601197,-0.673093436292401,
-                                 0.152100337597009,1.02146106755333),
-                               .Names = c("market.returns", "z", "market.returns", "z")), tolerance=1e-1))
-  
-  cat("\nDoing Testcase P4")
-  a <- lmAMM(firm.returns, X, nlags=1, verbose=FALSE)
-  expect_that(c(a$exposures, a$s.exposures),
-              equals(structure(c( 0.736264286484902, -1.450805,
-                                 0.177929844631439, 1.646730),
-                               .Names = c("market.returns","z", "market.returns", "z")),tolerance=1e-1))
-
-  
-  cat("\nDoing Testcase P5")
-  X <- makeX(market.returns, others=inrusd,
-             switch.to.innov=TRUE, market.returns.purge=TRUE, nlags=1, verbose=FALSE)
-  a <- lmAMM(firm.returns, X, nlags=1, verbose=FALSE)
-  expect_that(c(a$exposures, a$s.exposures),
-              equals(structure(c(0.7365566,-2.340171,
-                                 0.1653025, 1.1436666),
-                               .Names = c("market.returns", "z", "market.returns", "z")),tolerance=1e-1))
-  
-  cat("\nDoing Testcase P6")
-  X <- makeX(market.returns, others=cbind(inrusd, rM3),
-             switch.to.innov=c(FALSE, FALSE), market.returns.purge=FALSE, verbose=FALSE)
-  a <- lmAMM(firm.returns, X, nlags=0, verbose=FALSE)
-  expect_that(c(a$exposures, a$s.exposures),
-              equals(structure(c(0.7230599,-0.7642377,
-                                 0.207374104922771,0.173380799334299,
-                                 1.01806122963342,0.467821650129292),
-                               .Names = c("market.returns", "inrusd", "rM3", "market.returns", "inrusd", "rM3")),tolerance=1e-1))
-
-  cat("\nDoing Testcase P7")
-  X <- makeX(market.returns, others=cbind(inrusd, rM3),
-             switch.to.innov=c(TRUE, TRUE), market.returns.purge=TRUE, nlags=1, verbose=FALSE)
-  a <- lmAMM(firm.returns, X, nlags=1, verbose=FALSE)
-  
-  expect_that(c(a$exposures, a$s.exposures),
-              equals(structure(c(0.7482719,-1.9468851,-0.4802211,
-                                 0.1740678,1.2455112,0.6146619),
-                               .Names = c("market.returns", "inrusd", "rM3", "market.returns", "inrusd", "rM3")),tolerance=1e-1))
-
-################################################################################
-                                        #                                                                              #
-                                        # THE NEXT CASES TESTS THE FUNCTION FOR THREE COMPANIES FOR THREE YEARS        #
-                                        #                                                                              #
-################################################################################
-
-
-  cat("\nDoing Testcases P8\n")
-  load("test_y3c3.rda")
-
-  NIFTY_INDEX <- y3c3$NIFTY_INDEX
-  INRUSD <- y3c3$INRUSD
-  Company_A <- y3c3$Company_A
-  Company_B <- y3c3$Company_B
-  Company_C <- y3c3$Company_C
-
-  regressors <- makeX(NIFTY_INDEX, others=INRUSD,
-                      switch.to.innov=TRUE, market.returns.purge=TRUE, nlags=1,
-                      dates=as.Date(c("2005-01-15","2006-01-07","2007-01-06",
-                        "2008-01-05","2009-01-03")), verbose=FALSE)
-
-  regressand <- cbind(Company_A,Company_B,Company_C)
-
-  res <- manyfirmssubperiod.lmAMM(regressand,regressors,lags=1,
-                       dates=as.Date(c("2005-01-15","2006-01-07","2007-01-06",
-                         "2008-01-05","2009-01-03")),periodnames=c("P1","P2","P3","P4"),
-                       verbose=FALSE)
-
-  expect_that(as.data.frame(res),
-
-              equals(structure(list(market.returns.P1 = c(0.756294904326272, 0.359467326140834,0.914021428042946),
-                                    z.P1 = c(-2.23264294525560, -1.05654919420689,0.296635483126946),
-                                    market.returns.P2 = c(1.02094561445355, 0.988758963378838,0.879236409569888),
-                                    z.P2 = c(-4.72831391695047, -2.0508684999854,-1.02215809586573),
-                                    market.returns.P3 = c(1.20585808099744, 0.676388278572118,0.530718379431386),
-                                    z.P3 = c(-1.32677083522489, -2.74055730512260, -1.50032216697694),
-                                    market.returns.P4 = c(1.11331096371784, 0.437117737120777,0.663182186702262),
-                                    z.P4 = c(-2.05336868436562, -1.60350865767951,-0.466253391408585),
-                                    market.returns.P1 = c(0.143617135793294, 0.263130891045529,0.154272220123111),
-                                    z.P1 = c(1.20226371286803, 1.22122136357895,1.02442932195400),
-                                    market.returns.P2 = c(0.203037609116444, 0.123122376136099,0.121880488983820),
-                                    z.P2 = c(1.118400430819, 0.798694545623495,1.29755067543957),
-                                    market.returns.P3 = c(0.230304109532112, 0.289262660515515,0.164866239494693),
-                                    z.P3 = c(1.17618117392934, 0.795008683829453,0.650736332270758),
-                                    market.returns.P4 = c(0.231338818884745, 0.213858364836974,0.207154237634752),
-                                    z.P4 = c(0.771450066857429, 0.415931231130697,0.696448914066602),
-                                    market.returns.P1 = c(5.26604920888266, 1.36611602200152,5.9247311493511),
-                                    z.P1 = c(-1.85703263049467, -0.865157804896683,0.289561687438957),
-                                    market.returns.P2 = c(5.02835715460001, 8.0307007906172,7.21392256382075),
-                                    z.P2 = c(-4.2277468665565, -2.56777576762391,-0.787759673062059),
-                                    market.returns.P3 = c(5.23593818385294, 2.33831866638673,3.21908464133114),
-                                    z.P3 = c(-1.12803270842405, -3.44720423923131,-2.30557614900882),
-                                    market.returns.P4 = c(4.81246929972659, 2.04395903547657,3.20139329165723),
-                                    z.P4 = c(-2.66170005367969, -3.85522542589652,-0.669472493949494)),
-                               .Names = c("market.returns.P1", "z.P1", "market.returns.P2","z.P2", "market.returns.P3", "z.P3",
-                                 "market.returns.P4", "z.P4", "market.returns.P1", "z.P1","market.returns.P2", "z.P2", "market.returns.P3", "z.P3",
-                                 "market.returns.P4", "z.P4", "market.returns.P1", "z.P1", "market.returns.P2", "z.P2", "market.returns.P3",
-                                 "z.P3", "market.returns.P4", "z.P4"),
-                               row.names = c("Company_A","Company_B", "Company_C"), class = "data.frame"),
-                     check.attributes=FALSE))
-})

Deleted: pkg/inst/tests/test_marketresiduals.R
===================================================================
--- pkg/inst/tests/test_marketresiduals.R	2015-01-26 14:49:09 UTC (rev 404)
+++ pkg/inst/tests/test_marketresiduals.R	2015-02-26 08:07:05 UTC (rev 405)
@@ -1,25 +0,0 @@
-context("Market residuals")
-
-test_that("test.market.residuals", {
-library(eventstudies)
-
-load("test_StockPriceReturns.rda")
-load("test_NiftyIndex.rda")
-
-alldata <- merge(StockPriceReturns, NiftyIndex, all = TRUE)
-StockPriceReturns <- alldata[,-which(colnames(alldata) %in% "NiftyIndex")]
-NiftyIndex <- alldata$NiftyIndex
-
-mm.result <- marketResidual(firm.returns=StockPriceReturns[,c("BHEL")],
-                            market.returns=NiftyIndex)
-mm.result <- xts(mm.result[complete.cases(mm.result),])
-colnames(mm.result) <- "BHEL"
-
-# Calculating manually
-result <- lm(BHEL ~ NiftyIndex, data=StockPriceReturns)
-resid.res <- xts(result$resid,as.Date(attr(result$resid,"names")))
-colnames(resid.res) <- "BHEL"
-
-expect_that(mm.result,equals(resid.res))
-
-})

Deleted: pkg/inst/tests/test_y3c3.rda
===================================================================
(Binary files differ)



More information about the Eventstudies-commits mailing list