Running 'build.matches.test.R' [165s]
  Running 'classes.test.R' [1s]
  Running 'df.category.mean.test.R' [154s]
  Running 'matchit.test.R' [1s]
  Running 'nearest.multiple.test.R' [175s]
  Running 'next.treatment.test.R' [155s]
  Running 'portfolio.Arith.test.R' [158s]
  Running 'portfolio.all.equal.test.R' [1s]
  Running 'portfolio.calcShares.test.R' [1s]
  Running 'portfolio.calcWeights.test.R' [1s]
  Running 'portfolio.create.test.R' [1s]
  Running 'portfolio.expandData.test.R' [168s]
  Running 'portfolio.expose.test.R' [1s]
  Running 'portfolio.matching.test.R' [1s]
  Running 'portfolio.mvLong.test.R' [205s]
  Running 'portfolio.mvShort.test.R' [1s]
  Running 'portfolio.performance.test.R' [1s]
  Running 'portfolio.updatePrices.test.R' [162s]
  Running 'portfolioBasic.Arith.test.R' [157s]
  Running 'portfolioBasic.all.equal.test.R' [173s]
  Running 'portfolioBasic.contribution.test.R' [0s]
  Running 'portfolioBasic.exposure.test.R' [1s]
  Running 'portfolioBasic.performance.test.R' [1s]
  Running 'portfolioBasic.test.R' [1s]
  Running 'prob.matrix.test.R' [168s]
  Running 'sample.matrix.test.R' [0s]
  Running 'tradelist.calcActual.test.R' [150s]
  Running 'tradelist.calcCandidates.test.R' [1s]
  Running 'tradelist.calcChunks.test.R' [1s]
  Running 'tradelist.calcChunksActual.test.R' [159s]
  Running 'tradelist.calcRanks.test.R' [162s]
  Running 'tradelist.calcSwaps.test.R' [155s]
  Running 'tradelist.calcSwapsActual.test.R' [1s]
  Running 'trades.test.R' [0s]
  Running 'weight.test.R' [1s]
Running the tests in 'tests/build.matches.test.R' failed.
Complete output:
  > ################################################################################
  > ##
  > ## $Id: build.matches.test.R 346 2006-10-01 05:08:55Z enos $
  > ##
  > ## tests the .build.matches private function
  > ##
  > ################################################################################
  > 
  > library(portfolio)
  Loading required package: grid
  Loading required package: lattice
  > 
  > universe  <- c("IBM", "AAPL", "MSFT", "GOOG", "DELL", "HPQ", "PFE",
  +               "MRK", "DOW", "HAL")
  > 
  > id.matrix <- matrix(rep("HPQ", 25),
  +                     nrow = 5,
  +                     ncol = 5,
  +                     dimnames = list(universe[1:5], 1:5)
  +                     )
  > 
  > weights <- rep(0.1, 5)
  > 
  > matches <- portfolio:::.build.matches(universe, id.matrix, weights)
  > 
  > truth <- matrix(0,
  +                 nrow = 10,
  +                 ncol = 5,
  +                 dimnames = list(universe, 1:5)
  +                 )
  > 
  > truth["HPQ",] <- 0.5
  >   
  > stopifnot(
  +           all.equal(matches, truth)
  +           )
  > 
  > proc.time()
     user  system elapsed 
     0.35    0.06    0.39 
Running the tests in 'tests/df.category.mean.test.R' failed.
Complete output:
  > ################################################################################
  > ##
  > ## $Id: df.category.mean.test.R 1625 2010-02-18 19:44:29Z enos $
  > ##
  > ## Tests df.category.mean function
  > ##
  > ################################################################################
  > 
  > library(portfolio)
  Loading required package: grid
  Loading required package: lattice
  > 
  > load("df.category.mean.test.RData")
  > 
  > ## save(truth, file = "df.category.mean.test.RData", compress = TRUE)
  > 
  > ## Corner cases: data.frame with 0 rows and a data.frame with 1 row
  > 
  > trial.0 <- try(
  +                portfolio:::.df.category.mean(data.frame(), by.var = "by.var"),
  +                silent = TRUE
  +                )
  > 
  > trial.1 <- try(
  +                portfolio:::.df.category.mean(data.frame(c("foo"),
  +                                              by.var = "by.var")),
  +                silent = TRUE
  +                )
  > 
  > if(class(trial.0) == "try-error" || class(trial.1) == "try-error"){
  +   stop("Fails on corner cases!")
  + }
  > 
  > 
  > 
  > ## Invalid input: list contains non-data.frame objects
  > 
  > trial.2 <- try(
  +                portfolio:::.df.category.mean(matrix(), array(), data.frame(),
  +                                              by.var = "by.var"), silent = TRUE
  +                ) 
  > 
  > if(class(trial.2) == "try-error"){
  +   stopifnot(
  +             isTRUE(as.logical(grep("Error.*is\\.data\\.frame",trial.2[1])))
  +             )
  + }
  > 
  > ## Tests function results against pre-calculated data
  > 
  > stopifnot(
  +           all.equal(truth$mean.1.2,
  +                     portfolio:::.df.category.mean(truth$x.1, truth$x.2,
  +                                                   by.var = "by.var")
  +                     ),
  +           all.equal(truth$mean.1.3,
  +                     portfolio:::.df.category.mean(truth$x.1, truth$x.3,
  +                                                   by.var = "by.var")
  +                     ),
  +           all.equal(truth$mean.1.2.3,
  +                     portfolio:::.df.category.mean(truth$x.1, truth$x.2, truth$x.3,
  +                                                   by.var = "by.var")
  +                     )
  +           )
  > 
  > proc.time()
     user  system elapsed 
     0.37    0.07    0.45 
Running the tests in 'tests/nearest.multiple.test.R' failed.
Complete output:
  > ################################################################################
  > ##
  > ## $Id: nearest.multiple.test.R 346 2006-10-01 05:08:55Z enos $
  > ##
  > ## Tests for the "nearest.multiple" function
  > ##
  > ################################################################################
  > 
  > library(portfolio)
  Loading required package: grid
  Loading required package: lattice
  > 
  > load("nearest.multiple.test.RData")
  > 
  > ## save(truth, file = "nearest.multiple.test.RData", compress = TRUE)
  > 
  > ## Invalid input: complex numbers
  > 
  > trial.0 <- try(
  +                portfolio:::.nearest.multiple(5+0i, 10), silent = TRUE
  +                )
  > 
  > if(class(trial.0) == "try-error"){
  +   stopifnot(
  +             as.logical(grep("Error.*invalid.*complex",trial.0[1]))
  +             )
  + }
  > 
  > stopifnot(
  +           all.equal(truth$result,
  +                     portfolio:::.nearest.multiple(truth$x, truth$y))
  +           )
  > 
  > proc.time()
     user  system elapsed 
     0.34    0.10    0.43 
Running the tests in 'tests/next.treatment.test.R' failed.
Complete output:
  > ################################################################################
  > ##
  > ## $Id: next.treatment.test.R 1313 2008-10-31 19:24:34Z enos $
  > ##
  > ## Tests for the matching method of portfolioBasic
  > ##
  > ################################################################################
  > 
  > library(portfolio)
  Loading required package: grid
  Loading required package: lattice
  > 
  > ## save(truth, file = "next.treatment.test.RData", compress = TRUE)
  > 
  > load("next.treatment.test.RData")
  > 
  > data(assay)
  > 
  > x <- assay
  > x <- assay[assay$country == "USA", c("symbol", "name", "sector", "liq", "on.fl")]
  > 
  > ## universe for test case includes all US stocks, 10 from the focus
  > ## list, 10 identified as good matches by the matchit method, and 10
  > ## other US stocks
  > 
  > all.stocks <- c("76143", "18027", "14730", "6961", "6930", "69571", "71262",
  + "21266", "7308", "11746", "27043", "37495", "74206", "79463", "2923", "8267",
  + "33105", "26322", "68150", "71570", "22101", "19167", "39252", "13776",
  + "83265", "71301", "7631", "29780", "3604", "28225")
  > 
  > x <- x[all.stocks,]
  > x$matches <- NA
  > x$ps <- fitted(glm(on.fl ~ sector + liq, x, family = binomial("logit")))
  > 
  > treatments <- character()
  > 
  > while(any(is.na(x[x[["on.fl"]] == TRUE, "matches"]))){
  +   
  +   current.treatment <- portfolio:::.next.treatment(x, "on.fl")
  +   x[current.treatment, "matches"] <- 1
  +   treatments <- append(treatments, row.names(x[current.treatment,]))
  +   treatments
  +     }
  > 
  > stopifnot(
  +           isTRUE(all.equal(treatments, truth))
  +           )
  > 
  > proc.time()
     user  system elapsed 
     0.39    0.09    0.50 
Running the tests in 'tests/portfolio.Arith.test.R' failed.
Complete output:
  > ################################################################################
  > ##
  > ## $Id: portfolio.Arith.test.R 406 2007-04-19 16:30:22Z enos $
  > ##
  > ## Tests for adding portolios
  > ##
  > ################################################################################
  > 
  > library(portfolio)
  Loading required package: grid
  Loading required package: lattice
  > 
  > load("portfolio.Arith.test.RData")
  > 
  > ## save(p.0, p.1, truth, file = "portfolio.Arith.test.RData", compress = TRUE)
  > 
  > p.sum <- p.0 + p.1
  > 
  > stopifnot(
  +           isTRUE(all.equal(p.sum, truth)),
  +           nrow(p.sum@data) == length(union(p.0@data$id, p.1@data$id))
  +           )
  > 
  > p.pos <- p.0
  > 
  > p.neg <- p.0
  > p.neg@shares$shares <- -1 * p.neg@shares$shares
  > p.neg <- calcWeights(p.neg)
  > 
  > p.sum <- p.pos + p.neg
  > 
  > stopifnot(validObject(p.sum, test = TRUE),
  +           nrow(p.sum@shares) == 0)
  > 
  > proc.time()
     user  system elapsed 
     0.50    0.15    0.64 
Running the tests in 'tests/portfolio.expandData.test.R' failed.
Complete output:
  > ################################################################################
  > ##
  > ## $Id: portfolio.expandData.test.R 346 2006-10-01 05:08:55Z enos $
  > ##
  > ## Tests the expandData method of class portfolio.
  > ##
  > ################################################################################
  > 
  > library(portfolio)
  Loading required package: grid
  Loading required package: lattice
  > 
  > load("portfolio.expandData.test.RData")
  > 
  > ## save(test, truth, file = "portfolio.expandData.test.RData", compress = TRUE)
  > 
  > result <- expandData(test)
  > 
  > stopifnot(
  +           all.equal(truth$id, result@data$id),
  +           all.equal(truth$price, result@data$price),
  +           all.equal(truth$in.var, result@data$in.var)
  +           )
  > 
  > proc.time()
     user  system elapsed 
     0.34    0.14    0.43 
Running the tests in 'tests/portfolio.mvLong.test.R' failed.
Complete output:
  > ################################################################################
  > ##
  > ## $Id: portfolio.mvLong.test.R 410 2007-04-22 00:13:06Z enos $
  > ##
  > ## Tests for method "mvLong".
  > ##
  > ################################################################################
  > 
  > library(portfolio)
  Loading required package: grid
  Loading required package: lattice
  > 
  > price <- rnorm(20, mean = 80, sd = 30)
  > 
  > data.0 <- data.frame(id = 1:20, symbol.var = letters[1:20],
  +                      in.var = price,
  +                      ret.var = rnorm(20, mean = 0, sd = 0.1),
  +                      price.var = price, round.lot = 1)
  > 
  > ## corner case of 0 positions
  > 
  > p <- new("portfolio", id.var = "id", symbol.var = "symbol.var",
  +          in.var = "in.var", ret.var = "ret.var", type = "equal",
  +          size = "quintile", equity = 100000, sides = "long",
  +          price.var = "price.var", data = data.0)
  > 
  > p@shares <- p@shares[0,]
  > 
  > stopifnot(portfolio:::mvLong(p) == 0)
  > 
  > proc.time()
     user  system elapsed 
     0.40    0.10    0.48 
Running the tests in 'tests/portfolio.updatePrices.test.R' failed.
Complete output:
  > ################################################################################
  > ##
  > ## $Id: portfolio.updatePrices.test.R 346 2006-10-01 05:08:55Z enos $
  > ##
  > ## Tests the updatePrices method of class portfolio.
  > ##
  > ################################################################################
  > 
  > library(portfolio)
  Loading required package: grid
  Loading required package: lattice
  > 
  > load("portfolio.updatePrices.test.RData")
  > 
  > ## save(test, test.id, test.price, truth, file = "portfolio.updatePrices.test.RData", compress = TRUE)
  > 
  > result <- updatePrices(test, test.id, test.price)
  > 
  > stopifnot(
  +           all.equal(truth, result@data[[result@price.var]])
  +           )
  > 
  > proc.time()
     user  system elapsed 
     0.34    0.18    0.46 
Running the tests in 'tests/portfolioBasic.Arith.test.R' failed.
Complete output:
  > ################################################################################
  > ##
  > ## $Id: portfolioBasic.Arith.test.R 406 2007-04-19 16:30:22Z enos $
  > ##
  > ## Tests "+" method of "portfolioBasic"
  > ##
  > ################################################################################
  > 
  > library(portfolio)
  Loading required package: grid
  Loading required package: lattice
  > 
  > load("portfolioBasic.Arith.test.RData")
  > 
  > ## save(p.0, p.1, truth, file = "portfolioBasic.Arith.test.RData", compress = TRUE)
  > 
  > ## Constructs data and portfolioBasics that should add ("+") correctly
  > 
  > data.0 <- data.frame(id = as.character(letters[1:20]), in.var = 1:20)
  > data.1 <- data.frame(id = as.character(letters[26:7]), in.var = 20:1)
  > 
  > p.0 <- new("portfolioBasic", id.var = "id", symbol.var = "symbol.var",
  +               in.var = "in.var", ret.var = "ret.var", type = "sigmoid",
  +               size = 10, data = data.0, sides = c("long", "short"))
  > 
  > p.1 <- new("portfolioBasic", id.var = "id", symbol.var = "symbol.var",
  +               in.var = "in.var", ret.var = "ret.var", type = "linear",
  +               size = 8, data = data.1, sides = c("long", "short"))
  > 
  > p.0@data$id <- as.character(p.0@data$id)
  > p.1@data$id <- as.character(p.1@data$id)
  > 
  > p.0@weights$id <- as.character(p.0@weights$id)
  > p.1@weights$id <- as.character(p.1@weights$id)
  > 
  > p.sum <- p.0 + p.1
  > 
  > stopifnot(
  +           isTRUE(all.equal(p.sum, truth)),
  +           nrow(p.sum@data) == length(union(p.0@data$id, p.1@data$id))
  +           )
  > 
  > 
  > p.pos <- p.0
  > 
  > p.neg <- p.0
  > p.neg@weights$weight <- -1 * p.neg@weights$weight
  > 
  > p.sum <- p.pos + p.neg
  > 
  > stopifnot(validObject(p.sum, test = TRUE),
  +           nrow(p.sum@weights) == 0)
  > 
  > proc.time()
     user  system elapsed 
     0.35    0.15    0.48 
Running the tests in 'tests/portfolioBasic.all.equal.test.R' failed.
Complete output:
  > ################################################################################
  > ##
  > ## $Id: portfolioBasic.all.equal.test.R 346 2006-10-01 05:08:55Z enos $
  > ##
  > ## Tests "all.equal" method of "portfolioBasic"
  > ##
  > ################################################################################
  > 
  > library(portfolio)
  Loading required package: grid
  Loading required package: lattice
  > 
  > ## save(current, target, file = "portfolioBasic.all.equal.test.RData", compress = TRUE)
  > 
  > ## loads 2 portfolioBasic objects identical in all regards except
  > ## their weights slots have been ordered differently
  > 
  > load("portfolioBasic.all.equal.test.RData")
  > 
  > stopifnot(
  +           isTRUE(all.equal(current, target))
  +           )
  > 
  > proc.time()
     user  system elapsed 
     0.39    0.06    0.43 
Running the tests in 'tests/prob.matrix.test.R' failed.
Complete output:
  > ################################################################################
  > ##
  > ## $Id: prob.matrix.test.R 346 2006-10-01 05:08:55Z enos $
  > ##
  > ## Tests that ".prob.matrix" correctly forms probabilities from a matrix of
  > ## distances
  > ##
  > ################################################################################
  > 
  > library(portfolio)
  Loading required package: grid
  Loading required package: lattice
  > 
  > ## save(truth, file = "prob.matrix.test.RData", compress = TRUE)
  > 
  > load("prob.matrix.test.RData")
  > 
  > ## tests that the match.matrix matches the values with the highest
  > ## probabilities
  > 
  > ## sets all the values of i to a low probability
  > 
  > set.seed(1)
  > distances <- matrix(abs(rnorm(30, sd = .30)),
  +                     nrow = 5,
  +                     ncol = 6,
  +                     dimnames = list(1:5, letters[1:6])
  +             )
  > 
  > ## sets letter "a" to have a high probability of being chosen
  > 
  > test <- portfolio:::.prob.matrix(distances)
  > 
  > stopifnot(
  +           all.equal(truth, test)
  +           )
  > 
  > proc.time()
     user  system elapsed 
     0.31    0.09    0.39 
Running the tests in 'tests/tradelist.calcActual.test.R' failed.
Complete output:
  > ################################################################################
  > ##
  > ## $Id: tradelist.calcActual.test.R 346 2006-10-01 05:08:55Z enos $
  > ##
  > ## Tests "calcActual" method of "tradelist" class
  > ##
  > ################################################################################
  > 
  > library(portfolio)
  Loading required package: grid
  Loading required package: lattice
  > 
  > load("tradelist.calcActual.test.RData")
  > 
  > ## save(tl, truth.actual, file = "tradelist.calcActual.test.RData", compress = TRUE)
  > 
  > tl <- portfolio:::calcActual(tl)
  > 
  > stopifnot(all.equal(tl@actual, truth.actual))
  > 
  > ## truth.actual <- tl@actual
  > 
  > 
  > 
  > proc.time()
     user  system elapsed 
     0.29    0.14    0.43 
Running the tests in 'tests/tradelist.calcChunksActual.test.R' failed.
Complete output:
  > ################################################################################
  > ##
  > ## $Id: tradelist.calcChunksActual.test.R 346 2006-10-01 05:08:55Z enos $
  > ##
  > ## Tests "calcChunksActual" method of "tradelist" class
  > ##
  > ################################################################################
  > 
  > library(portfolio)
  Loading required package: grid
  Loading required package: lattice
  > 
  > load("tradelist.calcChunksActual.test.RData")
  > 
  > ## save(tl, tl.1,  truth.chunks.actual, truth.row.names, file = "tradelist.calcChunksActual.test.RData", compress = TRUE)
  > 
  > tl <- portfolio:::calcChunksActual(tl)
  > 
  > tl.1 <- portfolio:::calcChunksActual(tl.1)
  > tl.1@chunks.actual <- tl.1@chunks.actual[order(row.names(tl.1@chunks.actual)),]
  > 
  > stopifnot(all.equal(tl@chunks.actual, truth.chunks.actual))
  > stopifnot(all.equal(row.names(tl.1@chunks.actual), truth.row.names))
  > 
  > ## truth.chunks.actual <- tl@chunks.actual
  > 
  > 
  > 
  > proc.time()
     user  system elapsed 
     0.46    0.04    0.46 
Running the tests in 'tests/tradelist.calcRanks.test.R' failed.
Complete output:
  > ################################################################################
  > ##
  > ## $Id: tradelist.calcRanks.test.R 346 2006-10-01 05:08:55Z enos $
  > ##
  > ## Tests "calcRanks" method of "tradelist" class
  > ##
  > ################################################################################
  > 
  > library(portfolio)
  Loading required package: grid
  Loading required package: lattice
  > 
  > load("tradelist.calcRanks.test.RData")
  > 
  > ## save(tl, truth.ranks, truth.rank.sorts, truth.weights,  file = "tradelist.calcRanks.test.RData", compress = TRUE)
  > 
  > ## tests overall behavior of calcRanks method; candidates include
  > ## buys, sells, shorts, and covers.
  > 
  > tl <- portfolio:::calcRanks(tl)
  > 
  > ## truth.ranks <- tl@ranks
  > ## truth.rank.sorts <- tl@rank.sorts
  > 
  > stopifnot(
  +           all.equal(tl@ranks, truth.ranks),
  +           all.equal(tl@rank.sorts, truth.rank.sorts)
  +           )
  > 
  > ## tests weighting scheme and trade-cost adjustment functions by
  > ## assigning different weights to the different sorts.
  > 
  > ## tl@sorts <- list(sort.input.1 = 1, sort.input.2 = 1/2)
  > 
  > tl.1 <- tl
  > tl.1@sorts <- list(sort.input.1 = 1, sort.input.2 = 1/2)
  > 
  > tl.1 <- portfolio:::calcRanks(tl.1)
  > 
  > ## tests that the rank ordering produced by calcRanks is correct
  > 
  > stopifnot(all.equal(tl.1@ranks[order(tl.1@ranks$rank.t, decreasing = TRUE),]$id,
  +                     truth.weights))
  > 
  > ## tests for missing values in sorts
  > 
  > ## tl.2 <- portfolio:::calcRanks(tl.2)
  > ## tl.2@ranks <- tl.2@ranks[order(row.names(tl.2@ranks)),]
  > 
  > ## stopifnot(all.equal(row.names(tl.2@ranks), truth.row.names.2))
  > 
  > proc.time()
     user  system elapsed 
     0.45    0.15    0.59 
Running the tests in 'tests/tradelist.calcSwaps.test.R' failed.
Complete output:
  > ################################################################################
  > ##
  > ## $Id: tradelist.calcSwaps.test.R 346 2006-10-01 05:08:55Z enos $
  > ##
  > ## Tests "calcSwaps" method of "tradelist" class
  > ##
  > ################################################################################
  > 
  > library(portfolio)
  Loading required package: grid
  Loading required package: lattice
  > 
  > load("tradelist.calcSwaps.test.RData")
  > 
  > ## save(tl, tl.1, tl.2, tl.3, truth.swaps, truth.row.names, truth.row.names.2, truth.row.names.3, file = "tradelist.calcSwaps.test.RData", compress = TRUE)
  > 
  > tl  <- portfolio:::calcSwaps(tl)
  > 
  > stopifnot(all.equal(tl@swaps, truth.swaps))
  > 
  > ## tests that dummy sells are created when the portfolio is
  > ## under-invested
  > 
  > tl.1 <- portfolio:::calcSwaps(tl.1)
  > 
  > ## compares generated row names to expected row names
  > 
  > stopifnot(all.equal(row.names(tl.1@swaps), truth.row.names))
  > 
  > ## tests normal creation of swaps (matching buys with sells)
  > 
  > tl.2 <- portfolio:::calcSwaps(tl.2)
  > 
  > stopifnot(all.equal(row.names(tl.2@swaps), truth.row.names.2))
  > 
  > ## tests that dummy buys are created when the portfolio is
  > ## over-invested
  > 
  > tl.3 <- portfolio:::calcSwaps(tl.3)
  > 
  > stopifnot(all.equal(row.names(tl.3@swaps), truth.row.names.3))
  > 
  > proc.time()
     user  system elapsed 
     0.56    0.17    0.67