[Eventstudies-commits] r88 - in pkg: . inst inst/tests tests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jul 16 12:33:54 CEST 2013


Author: chiraganand
Date: 2013-07-16 12:33:53 +0200 (Tue, 16 Jul 2013)
New Revision: 88

Added:
   pkg/inst/tests/
   pkg/inst/tests/test_AMM.R
   pkg/inst/tests/test_eventstudy.R
   pkg/inst/tests/test_inr_inference.R
   pkg/tests/test-all.R
Removed:
   pkg/tests/test_AMM.R
   pkg/tests/test_eventstudy.R
   pkg/tests/test_inr_inference.R
   pkg/tests/unit_tests.R
Modified:
   pkg/DESCRIPTION
Log:
Removed RUnit test cases, using testthat now. All tests running now.


Modified: pkg/DESCRIPTION
===================================================================
--- pkg/DESCRIPTION	2013-07-16 08:10:16 UTC (rev 87)
+++ pkg/DESCRIPTION	2013-07-16 10:33:53 UTC (rev 88)
@@ -4,7 +4,7 @@
 Version: 1.1
 Author: Ajay Shah, Vimal Balasubramaniam, Vikram Bahure
 Maintainer: Vikram Bahure <economics.vikram at gmail.com>
-Depends: R (>= 2.12.0), zoo, xts, boot 
+Depends: R (>= 2.12.0), zoo, xts, boot, testthat (<= 0.7.1)
 Description: Implementation of short and long term event study methodology
 License: GPL-2
 LazyLoad: yes

Copied: pkg/inst/tests/test_AMM.R (from rev 86, pkg/tests/test_AMM.R)
===================================================================
--- pkg/inst/tests/test_AMM.R	                        (rev 0)
+++ pkg/inst/tests/test_AMM.R	2013-07-16 10:33:53 UTC (rev 88)
@@ -0,0 +1,127 @@
+context("Models")
+
+test_that("test.AMM", {
+  library(sandwich)
+  
+  load(system.file("data", "firmExposures.rda", package = "eventstudies"))
+
+  rj  <- firmExposures$Company_A
+  rM1 <- firmExposures$NIFTY_INDEX
+  rM2 <- firmExposures$usdinr
+  rM3 <- firmExposures$baa
+
+  cat("Doing Testcase P2:\n")
+  X <- makeX(rM1, others=rM2,
+             switch.to.innov=FALSE, rM1purge=FALSE, verbose=FALSE)
+  a <- firmExposures(rj, 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("rM1", "z", "rM1", "z")), tolerance=1e-1))
+
+  cat("Doing Testcase P3:\n")
+  X <- makeX(rM1, others=rM2,
+             switch.to.innov=TRUE, rM1purge=FALSE, verbose=FALSE)
+  a <- firmExposures(rj, 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("rM1", "z", "rM1", "z")), tolerance=1e-1))
+  
+  cat("Doing Testcase P4:\n")
+  a <- firmExposures(rj, 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("rM1","z", "rM1", "z")),tolerance=1e-1))
+
+  
+  cat("Doing Testcase P5:\n")
+  X <- makeX(rM1, others=rM2,
+             switch.to.innov=TRUE, rM1purge=TRUE, nlags=1, verbose=FALSE)
+  a <- firmExposures(rj, 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("rM1", "z", "rM1", "z")),tolerance=1e-1))
+  
+  cat("Doing Testcase P6:\n")
+  X <- makeX(rM1, others=cbind(rM2, rM3),
+             switch.to.innov=c(FALSE, FALSE), rM1purge=FALSE, verbose=FALSE)
+  a <- firmExposures(rj, 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("rM1", "rM2", "rM3", "rM1", "rM2", "rM3")),tolerance=1e-1))
+
+  cat("Doing Testcase P7:\n")
+  X <- makeX(rM1, others=cbind(rM2, rM3),
+             switch.to.innov=c(TRUE, TRUE), rM1purge=TRUE, nlags=1, verbose=FALSE)
+  a <- firmExposures(rj, 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("rM1", "rM2", "rM3", "rM1", "rM2", "rM3")),tolerance=1e-1))
+
+################################################################################
+                                        #                                                                              #
+                                        # THE NEXT CASES TESTS THE FUNCTION FOR THREE COMPANIES FOR THREE YEARS        #
+                                        #                                                                              #
+################################################################################
+
+
+  cat("Doing Testcases P8:\n")
+  load(system.file("data", "y3c3.rda", package = "eventstudies"))
+
+  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, rM1purge=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 <- manyfirmsAMM(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(rM1.P1 = c(0.756294904326272, 0.359467326140834,0.914021428042946),
+                                    z.P1 = c(-2.23264294525560, -1.05654919420689,0.296635483126946),
+                                    rM1.P2 = c(1.02094561445355, 0.988758963378838,0.879236409569888),
+                                    z.P2 = c(-4.72831391695047, -2.0508684999854,-1.02215809586573),
+                                    rM1.P3 = c(1.20585808099744, 0.676388278572118,0.530718379431386),
+                                    z.P3 = c(-1.32677083522489, -2.74055730512260, -1.50032216697694),
+                                    rM1.P4 = c(1.11331096371784, 0.437117737120777,0.663182186702262),
+                                    z.P4 = c(-2.05336868436562, -1.60350865767951,-0.466253391408585),
+                                    rM1.P1 = c(0.143617135793294, 0.263130891045529,0.154272220123111),
+                                    z.P1 = c(1.20226371286803, 1.22122136357895,1.02442932195400),
+                                    rM1.P2 = c(0.203037609116444, 0.123122376136099,0.121880488983820),
+                                    z.P2 = c(1.118400430819, 0.798694545623495,1.29755067543957),
+                                    rM1.P3 = c(0.230304109532112, 0.289262660515515,0.164866239494693),
+                                    z.P3 = c(1.17618117392934, 0.795008683829453,0.650736332270758),
+                                    rM1.P4 = c(0.231338818884745, 0.213858364836974,0.207154237634752),
+                                    z.P4 = c(0.771450066857429, 0.415931231130697,0.696448914066602),
+                                    rM1.P1 = c(5.26604920888266, 1.36611602200152,5.9247311493511),
+                                    z.P1 = c(-1.85703263049467, -0.865157804896683,0.289561687438957),
+                                    rM1.P2 = c(5.02835715460001, 8.0307007906172,7.21392256382075),
+                                    z.P2 = c(-4.2277468665565, -2.56777576762391,-0.787759673062059),
+                                    rM1.P3 = c(5.23593818385294, 2.33831866638673,3.21908464133114),
+                                    z.P3 = c(-1.12803270842405, -3.44720423923131,-2.30557614900882),
+                                    rM1.P4 = c(4.81246929972659, 2.04395903547657,3.20139329165723),
+                                    z.P4 = c(-2.66170005367969, -3.85522542589652,-0.669472493949494)),
+                               .Names = c("rM1.P1", "z.P1", "rM1.P2","z.P2", "rM1.P3", "z.P3",
+                                 "rM1.P4", "z.P4", "rM1.P1", "z.P1","rM1.P2", "z.P2", "rM1.P3", "z.P3",
+                                 "rM1.P4", "z.P4", "rM1.P1", "z.P1", "rM1.P2", "z.P2", "rM1.P3",
+                                 "z.P3", "rM1.P4", "z.P4"),
+                               row.names = c("Company_A","Company_B", "Company_C"), class = "data.frame"),
+                     check.attributes=FALSE))
+})

Copied: pkg/inst/tests/test_eventstudy.R (from rev 86, pkg/tests/test_eventstudy.R)
===================================================================
--- pkg/inst/tests/test_eventstudy.R	                        (rev 0)
+++ pkg/inst/tests/test_eventstudy.R	2013-07-16 10:33:53 UTC (rev 88)
@@ -0,0 +1,59 @@
+context("Event study")
+
+test_that("test.eventstudy", {
+
+# 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(unit=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$unit <- as.character(eventslist$unit)
+
+# 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"))
+
+# Check without the width handling --
+a <- phys2eventtime(p, eventslist,width=0)
+expect_that(a, equals(rawres))
+
+# Check 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.
+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" ))))
+})

Copied: pkg/inst/tests/test_inr_inference.R (from rev 86, pkg/tests/test_inr_inference.R)
===================================================================
--- pkg/inst/tests/test_inr_inference.R	                        (rev 0)
+++ pkg/inst/tests/test_inr_inference.R	2013-07-16 10:33:53 UTC (rev 88)
@@ -0,0 +1,31 @@
+context("Event study")
+
+test_that("test.inr.inference", {
+library(eventstudies)
+
+load(system.file("data", "inr.rda", package = "eventstudies"))
+
+inr_returns <- diff(log(inr))[-1]
+
+eventslist <- data.frame(unit=rep("inr",10),
+                         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")
+                           )
+                         )
+
+event_time_data <- phys2eventtime(inr_returns,eventslist,width=10)
+w <- window(event_time_data$z.e,start=-10,end=10)
+
+expect_that(inference.Ecar(w)[,2],
+                         equals(c(-0.00215361156303362, -0.00040191670837042, 0.00171845148444985, 
+                           0.00143799970419951, 0.00149260146357282, -0.00284892904228684, 
+                           0.0013220811191847, -0.000634983205805195, 0.00115930378269389, 
+                           -0.000508755768685365, -0.00190621828611177, 0.000128303517790052, 
+                           -0.000547070723466092, 0.000463708708964017, -0.00108666428087325, 
+                           -0.00121321855159642, 0.00216769754166339, -0.000166340225607797, 
+                           0.00117626759805196, 0.000207307545758795, 0.000602629204764948
+                           )))
+})

Added: pkg/tests/test-all.R
===================================================================
--- pkg/tests/test-all.R	                        (rev 0)
+++ pkg/tests/test-all.R	2013-07-16 10:33:53 UTC (rev 88)
@@ -0,0 +1,3 @@
+library(testthat)
+library(eventstudies)
+test_package("eventstudies")

Deleted: pkg/tests/test_AMM.R
===================================================================
--- pkg/tests/test_AMM.R	2013-07-16 08:10:16 UTC (rev 87)
+++ pkg/tests/test_AMM.R	2013-07-16 10:33:53 UTC (rev 88)
@@ -1,102 +0,0 @@
-test.AMM <- function() {
-  library(eventstudies)
-  library(sandwich)
-
-  data("firmExposures",package="eventstudies")
-
-  rj  <- firmExposures$Company_A
-  rM1 <- firmExposures$NIFTY_INDEX
-  rM2 <- firmExposures$usdinr
-  rM3 <- firmExposures$baa
-
-  cat("Doing Testcase P2:\n")
-  X <- makeX(rM1, others=rM2,
-             switch.to.innov=FALSE, rM1purge=FALSE, verbose=FALSE)
-  a <- firmExposures(rj, X, nlags=0, verbose=FALSE)
-  test.result <- all.equal(c(a$exposures, a$s.exposures),
-            structure(c(0.716160223601197,-0.673093436292401,
-                        0.152101606133946,1.02143820457251),
-                      .Names = c("rM1", "z", "rM1", "z")), tolerance=1e-1)
-  checkTrue(isTRUE(test.result))
-
-  cat("Doing Testcase P3:\n")
-  X <- makeX(rM1, others=rM2,
-             switch.to.innov=TRUE, rM1purge=FALSE, verbose=FALSE)
-  a <- firmExposures(rj, X, nlags=0, verbose=FALSE)
-  test.result <- all.equal(c(a$exposures, a$s.exposures),
-            structure(c(0.716160223601197,-0.673093436292401,
-                        0.152100337597009,1.02146106755333),
-                      .Names = c("rM1", "z", "rM1", "z")), tolerance=1e-1)
-  checkTrue(isTRUE(test.result))
-  
-  cat("Doing Testcase P4:\n")
-  a <- firmExposures(rj, X, nlags=1, verbose=FALSE)
-  test.result <- all.equal(c(a$exposures, a$s.exposures),
-            structure(c( 0.736264286484902, -1.450805,
-                        0.177929844631439, 1.646730),
-                      .Names = c("rM1","z", "rM1", "z")),tolerance=1e-1)
-  checkTrue(isTRUE(test.result))
-  
-  cat("Doing Testcase P5:\n")
-  X <- makeX(rM1, others=rM2,
-             switch.to.innov=TRUE, rM1purge=TRUE, nlags=1, verbose=FALSE)
-  a <- firmExposures(rj, X, nlags=1, verbose=FALSE)
-  test.result <- all.equal(c(a$exposures, a$s.exposures),
-            structure(c(0.7365566,-2.340171,
-                        0.1653025, 1.1436666),
-                      .Names = c("rM1", "z", "rM1", "z")),tolerance=1e-1)
-  checkTrue(isTRUE(test.result))
-  
-  cat("Doing Testcase P6:\n")
-  X <- makeX(rM1, others=cbind(rM2, rM3),
-             switch.to.innov=c(FALSE, FALSE), rM1purge=FALSE, verbose=FALSE)
-  a <- firmExposures(rj, X, nlags=0, verbose=FALSE)
-  test.result <-   all.equal(c(a$exposures, a$s.exposures),
-            structure(c(0.7230599,-0.7642377,
-                        0.207374104922771,0.173380799334299,
-                        1.01806122963342,0.467821650129292),
-                      .Names = c("rM1", "rM2", "rM3", "rM1", "rM2", "rM3")),tolerance=1e-1)
-  checkTrue(isTRUE(test.result))
-  
-  cat("Doing Testcase P7:\n")
-  X <- makeX(rM1, others=cbind(rM2, rM3),
-             switch.to.innov=c(TRUE, TRUE), rM1purge=TRUE, nlags=1, verbose=FALSE)
-  a <- firmExposures(rj, X, nlags=1, verbose=FALSE)
-  test.result <- all.equal(c(a$exposures, a$s.exposures),
-            structure(c(0.7482719,-1.9468851,-0.4802211,
-                        0.1740678,1.2455112,0.6146619),
-                      .Names = c("rM1", "rM2", "rM3", "rM1", "rM2", "rM3")),tolerance=1e-1)
-  checkTrue(isTRUE(test.result))
-
-################################################################################
-                                        #                                                                              #
-                                        # THE NEXT CASES TESTS THE FUNCTION FOR THREE COMPANIES FOR THREE YEARS        #
-                                        #                                                                              #
-################################################################################
-
-
-  cat("Doing Testcases P8:\n")
-  data("y3c3", package="eventstudies")
-
-  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, rM1purge=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 <- manyfirmsAMM(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)
-
-  test.result <- all.equal(as.data.frame(res),structure(list(rM1.P1 = c(0.756294904326272, 0.359467326140834,0.914021428042946), z.P1 = c(-2.23264294525560, -1.05654919420689,0.296635483126946), rM1.P2 = c(1.02094561445355, 0.988758963378838,0.879236409569888), z.P2 = c(-4.72831391695047, -2.0508684999854,-1.02215809586573), rM1.P3 = c(1.20585808099744, 0.676388278572118,0.530718379431386), z.P3 = c(-1.32677083522489, -2.74055730512260, -1.50032216697694), rM1.P4 = c(1.11331096371784, 0.437117737120777,0.663182186702262), z.P4 = c(-2.05336868436562, -1.60350865767951,-0.466253391408585), rM1.P1 = c(0.143617135793294, 0.263130891045529,0.154272220123111), z.P1 = c(1.20226371286803, 1.22122136357895,1.02442932195400), rM1.P2 = c(0.203037609116444, 0.123122376136099,0.121880488983820), z.P2 = c(1.118400430819, 0.798694545623495,1.29755067543957), rM1.P3 = c(0.230304109532112, 0.289262660515515,0.164866239494693), z.P3 = c(1.17618117392934, 0.795008683829453,0.650736332270758), rM1.P4 = c(0.231338818884745, 0.213858364836974,0.207154237634752), z.P4 = c(0.771450066857429, 0.415931231130697,0.696448914066602), rM1.P1 = c(5.26604920888266, 1.36611602200152,5.9247311493511), z.P1 = c(-1.85703263049467, -0.865157804896683,0.289561687438957), rM1.P2 = c(5.02835715460001, 8.0307007906172,7.21392256382075), z.P2 = c(-4.2277468665565, -2.56777576762391,-0.787759673062059), rM1.P3 = c(5.23593818385294, 2.33831866638673,3.21908464133114), z.P3 = c(-1.12803270842405, -3.44720423923131,-2.30557614900882), rM1.P4 = c(4.81246929972659, 2.04395903547657,3.20139329165723), z.P4 = c(-2.66170005367969, -3.85522542589652,-0.669472493949494)), .Names = c("rM1.P1", "z.P1", "rM1.P2","z.P2", "rM1.P3", "z.P3", "rM1.P4", "z.P4", "rM1.P1", "z.P1","rM1.P2", "z.P2", "rM1.P3", "z.P3", "rM1.P4", "z.P4", "rM1.P1", "z.P1", "rM1.P2", "z.P2", "rM1.P3", "z.P3", "rM1.P4", "z.P4"),row.names = c("Company_A","Company_B", "Company_C"), class = "data.frame"),check.attributes=FALSE)
-
-  checkTrue(isTRUE(test.result))
-}

Deleted: pkg/tests/test_eventstudy.R
===================================================================
--- pkg/tests/test_eventstudy.R	2013-07-16 08:10:16 UTC (rev 87)
+++ pkg/tests/test_eventstudy.R	2013-07-16 10:33:53 UTC (rev 88)
@@ -1,66 +0,0 @@
-library(eventstudies)
-
-test.eventstudy <- function() {
-# 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(unit=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$unit <- as.character(eventslist$unit)
-
-# 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"))
-
-# Check without the width handling --
-a <- phys2eventtime(p, eventslist,width=0)
-all.equal(a, rawres)
-# Check with width of 1 --
-a <- phys2eventtime(p, eventslist,width=1)
-all.equal(a, 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.
-a <- phys2eventtime(p, eventslist,width=2)
-test.result <- all.equal(a, 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" )))
-s <- 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" ))
-
-checkTrue(isTRUE(test.result))
-}

Deleted: pkg/tests/test_inr_inference.R
===================================================================
--- pkg/tests/test_inr_inference.R	2013-07-16 08:10:16 UTC (rev 87)
+++ pkg/tests/test_inr_inference.R	2013-07-16 10:33:53 UTC (rev 88)
@@ -1,31 +0,0 @@
-library(eventstudies)
-
-test.inr.inference <- function() {
-data(inr)
-
-inr_returns <- diff(log(inr))[-1]
-
-eventslist <- data.frame(unit=rep("inr",10),
-                         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")
-                           )
-                         )
-
-event_time_data <- phys2eventtime(inr_returns,eventslist,width=10)
-w <- window(event_time_data$z.e,start=-10,end=10)
-
-test.result <- all.equal(inference.Ecar(w)[,2],
-                         c(-0.00215361156303362, -0.00040191670837042, 0.00171845148444985, 
-                           0.00143799970419951, 0.00149260146357282, -0.00284892904228684, 
-                           0.0013220811191847, -0.000634983205805195, 0.00115930378269389, 
-                           -0.000508755768685365, -0.00190621828611177, 0.000128303517790052, 
-                           -0.000547070723466092, 0.000463708708964017, -0.00108666428087325, 
-                           -0.00121321855159642, 0.00216769754166339, -0.000166340225607797, 
-                           0.00117626759805196, 0.000207307545758795, 0.000602629204764948
-                           ))
-
-checkTrue(isTRUE(test.result))
-}

Deleted: pkg/tests/unit_tests.R
===================================================================
--- pkg/tests/unit_tests.R	2013-07-16 08:10:16 UTC (rev 87)
+++ pkg/tests/unit_tests.R	2013-07-16 10:33:53 UTC (rev 88)
@@ -1,9 +0,0 @@
-library(RUnit)
-
-testsuite <- defineTestSuite("Event Studies Test Suite",
-                             dirs = ".",
-                             testFileRegexp = "^test_.*\\.R$",
-                             testFuncRegexp = "^.*$"
-                             )
-
-testresult <- runTestSuite(testsuite)



More information about the Eventstudies-commits mailing list