Running ‘test-sst-example.R’
  Running ‘test-standalone.R’
  Running ‘testthat.R’ [15s/15s]
Running the tests in ‘tests/test-sst-example.R’ failed.
Complete output:
  > # this is a complete example on how to simulate the target capital from the
  > # Swiss solvency test with the standalone sstModel package
  > 
  > # load package
  > library(sstModel)
  sstModel 1.0.0 
  
  Copyright (c) 2018 Swiss Financial Market Supervisory Authority FINMA
  
  Swiss Financial Market Supervisory Authority FINMA
  Laupenstrasse 27
  CH-3003 Bern
  
  info@finma.ch
  
  This program comes with ABSOLUTELY NO WARRANTY.
  This is free software, and you are welcome to redistribute it
  under certain conditions. 
  
  Type launchDashboard() and go to the 'Legal Notices' Tab for more details about the license. 
  
  Type sstModel_news() to see new features/changes/fixes.
  
  Type sstModel_check() to scan your package library for potential issues.
  > 
  > 
  > # first step: define the market risks
  > 
  > ## define the names of the base risk factors (Risiko Treiber).
  > name <- c("EURCHF", "USDCHF",                        # the fx rate risks
  +           "equityCHF", "equityEUR", "equityUSD",     # the equity risks
  +           "kYCHF", "mYCHF",                          # the interest rate risks
  +           "kYEUR", "mYEUR",
  +           "PC1RateUSD", "PC2RateUSD",                # here we use two PCA components
  +           "AAACHF", "AAAEUR", "AAAUSD")              # the spread risks
  > 
  > ## then we need to define an appropriate correlation matrix
  > corr.mat <- diag(rep(1, 14))
  > colnames(corr.mat) <- name
  > rownames(corr.mat) <- name
  > 
  > ## and the respective volatilities
  > volatility <- rep(0.05, 14)
  > 
  > # create cov mat
  > cov.mat <- diag(volatility, length(volatility), length(volatility)) %*%
  +            corr.mat  %*%  diag(volatility, length(volatility), length(volatility))
  > 
  > colnames(cov.mat) <- rownames(cov.mat) <- colnames(corr.mat)
  > attr(cov.mat, "base.currency") <- "CHF"
  > 
  > ## we should then build the mapping table of market risks
  > mapping.table <- mappingTable(currency(name = "EURCHF",
  +                                        from = "EUR",
  +                                        to   = "CHF"),
  +                               currency(name = "USDCHF",
  +                                        from = "USD",
  +                                        to   = "CHF"),
  + 
  +                               equity(name     = "equityCHF",
  +                                      type     = "equity",
  +                                      currency = "CHF"),
  +                               equity(name     = "equityEUR",
  +                                      type     = "equity",
  +                                      currency = "EUR"),
  +                               equity(name     = "equityEUR",
  +                                      type     = "equity",
  +                                      currency = "USD",
  +                                      scale    = 0.4694625),
  + 
  +                               pcRate(name   = c("PC1RateUSD"),
  +                                      currency = "USD"),
  +                               pcRate(name   = c("PC2RateUSD"),
  +                                      currency = "USD"),
  +                               pcRate(name   = c("PC1RateUSD"),
  +                                      currency = "EUR",
  +                                      scale = 1),
  +                               pcRate(name   = c("PC2RateUSD"),
  +                                      currency = "EUR",
  +                                      scale = 1),
  + 
  +                               rate(name     = "kYCHF",
  +                                    currency = "CHF",
  +                                    horizon  = "k"),
  + 
  +                               rate(name     = c("PC1RateUSD",
  +                                                 "PC2RateUSD"),
  +                                    currency = "EUR",
  +                                    horizon  = "k",
  +                                    scale    = c(0.1,
  +                                                 0.7)),
  + 
  +                               rate(name     = c("PC1RateUSD",
  +                                                 "PC2RateUSD"),
  +                                    currency = "USD",
  +                                    horizon  = "k",
  +                                    scale    = c(0.2,
  +                                                 0.5)),
  + 
  +                               rate(name     = "mYCHF",
  +                                    currency = "CHF",
  +                                    horizon  = "m"),
  + 
  +                               rate(name     = c("PC1RateUSD",
  +                                                 "PC2RateUSD"),
  +                                    currency = "EUR",
  +                                    horizon  = "m",
  +                                    scale    = c(0.05,
  +                                                 0.6)),
  +                               rate(name     = c("PC1RateUSD",
  +                                                 "PC2RateUSD"),
  +                                    currency = "USD",
  +                                    horizon  = "m",
  +                                    scale    = c(0.1,
  +                                                 0.9)),
  + 
  +                               spread(name     = "AAACHF",
  +                                      currency = "CHF",
  +                                      rating   = "AAA"),
  +                               spread(name     = "AAAEUR",
  +                                      currency = "EUR",
  +                                      rating   = "AAA"),
  +                               spread(name     = "AAAUSD",
  +                                      currency = "USD",
  +                                      rating   = "AAA"))
  > 
  > ## and provide the initial values for the risks factors
  > initial.values <- list()
  > 
  > ## initial fx
  > initial.values$initial.fx <- data.frame(from             = c("EUR", "USD"),
  +                                         to               = c("CHF", "CHF"),
  +                                         fx               = c(1.05,1.02),
  +                                         stringsAsFactors = F)
  > 
  > ## initial rates
  > initial.values$initial.rate <- data.frame(time             = c(2L, 2L, 2L, 10L, 10L, 10L),
  +                                           currency         = c("CHF", "EUR", "USD"),
  +                                           rate             = c(0.01, 0.01, 0.01, 0.03, 0.03, 0.03),
  +                                           stringsAsFactors = F)
  > 
  > 
  > # define the mapped times for rates
  > mapping.time <- data.frame(time = c(2L, 10L), mapping = c("k","m"), stringsAsFactors = F)
  > 
  > ## we are finally in shape to build the full market risk
  > mr <- marketRisk(cov.mat        = cov.mat,
  +                  mapping.table  = mapping.table,
  +                  base.currency  = "CHF",
  +                  initial.values = initial.values,
  +                  mapping.time   = mapping.time)
  > 
  > 
  > # second step: define the health and life risks
  > M <- matrix(c(1, 1, 1, 1), 2)
  > colnames(M) <- c("storno", "invalidity")
  > rownames(M) <- colnames(M)
  > 
  > lr <- lifeRisk(corr.mat  = M,
  +                quantile = c(0.995, 0.995))
  > 
  > hr <- healthRisk(corr.mat  = M)
  > 
  > 
  > 
  > # third step: build the portfolio
  > 
  > list.assets <- list(asset(type = "equity", currency = "CHF", value = 30000000),
  +                     asset(type = "equity", currency = "EUR", value = 20000000),
  +                     asset(type = "equity", currency = "USD", value = 5000000))
  > 
  > list.liabilities <- list(liability(time = 2L, currency = "CHF", value = 400000),
  +                          liability(time = 2L, currency = "EUR", value = 700000),
  +                          liability(time = 2L, currency = "USD", value = 340000),
  +                          liability(time = 10L, currency = "CHF", value = 500000),
  +                          liability(time = 10L, currency = "EUR", value = 100000),
  +                          liability(time = 10L, currency = "USD", value = 240000))
  > 
  > list.asset.forward <- list(assetForward(type = "equity",
  +                                         currency = "CHF",
  +                                         time = 10L,
  +                                         exposure = 10000,
  +                                         price = 45000,
  +                                         position = "long"))
  > 
  > 
  > list.marketItems <- append(append(append(append(list(), list.assets), list.liabilities),list.asset.forward),
  +                            list(delta(name = "EURCHF", currency = "CHF", sensitivity = 1000)))
  > 
  > valid.param <- list(mvm = list(mvm.life = 2, mvm.health = 4, mvm.nonlife = 3),
  +                     rtkr = 0,
  +                     rtkg = 0,
  +                     correction.term = 2,
  +                     credit.risk = 3,
  +                     expected.insurance.result =  10^6,
  +                     expected.financial.result =  10^5)
  > 
  > 
  > p <- portfolio(market.items = list.marketItems,
  +                participation.item = participation(currency = "CHF", value = 3000),
  +                life.item = life(name = c("storno", "invalidity"), currency = c("CHF", "CHF"), sensitivity = c(100, 2000)),
  +                health.item = health(name = c("storno", "invalidity"), currency = c("CHF", "CHF"), sensitivity = c(230, 500)),
  +                base.currency = "CHF",
  +                portfolio.parameters = valid.param)
  Error in names(mvm) %in% c("mvm.life", "mvm.health", "mvm.nonlife") ||  : 
    'length = 3' in coercion to 'logical(1)'
  Calls: portfolio -> with -> with.default -> eval -> eval
  Execution halted
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > library(testthat)
  > library(sstModel)
  sstModel 1.0.0 
  
  Copyright (c) 2018 Swiss Financial Market Supervisory Authority FINMA
  
  Swiss Financial Market Supervisory Authority FINMA
  Laupenstrasse 27
  CH-3003 Bern
  
  info@finma.ch
  
  This program comes with ABSOLUTELY NO WARRANTY.
  This is free software, and you are welcome to redistribute it
  under certain conditions. 
  
  Type launchDashboard() and go to the 'Legal Notices' Tab for more details about the license. 
  
  Type sstModel_news() to see new features/changes/fixes.
  
  Type sstModel_check() to scan your package library for potential issues.
  > 
  > test_check("sstModel")
   asset     
   ---------  
   type:      equity 
   currency:  CHF 
   value:     10 
   
   asset forward 
   ------------- 
   type:      equity 
   currency:  EUR 
   time:      1 
   exposure:  10 
   price:     100 
   position:  long 
   
   cashflow 
   --------- 
   time:      1 
   currency:  CHF 
   rating:    AAA 
   spread:    0.2 
   value:     10 
   
   delta term 
   --------------- 
   name:           2YCHF, EURCHF 
   currency:       CHF, CHF 
   sensitivity:    12, 25 
   
   fx forward 
   -------------- 
   domestic:      CHF 
   foreign:       EUR 
   time:          1 
   nominal:       10 
   rate:          1.1 
   position:      long 
   
   health         
   --------------- 
   name:           Sstorno, invalidity 
   currency:       CHF, EUR 
   sensitivity:    12, 25 
   
   healthRisk 
   ------------------- 
   correlation matrix: 2  x  2 
   
   liability 
   ---------- 
   time:      1 
   currency:  CHF 
   value:     -10 
   
   life           
   --------------- 
   name:           Sstorno, invalidity 
   currency:       CHF, CHF 
   sensitivity:    12, 25 
   
   lifeRisk 
   --------------------- 
   correlation matrix:   2  x  2 
   quantiles of length:  2 
   marketRisk 
   ------------------- 
   covariance matrix:         4  x  4 
   mapping table:             4 risk-factors 
   base currency:             CHF 
   
   nonLifeRisk 
   ------------------- 
   a vector of simulations of length:  5 
   
   nonLifeRisk 
   ------------------- 
   simulations from empirical cumulative distribution function. 
   
   nonLifeRisk 
   ------------------- 
   centered log-normal simulations.  
   
   participation 
   ------------------- 
   a participation with total value:  10 
   
   participationRisk 
   ------------------- 
   volatility:  3 
   
   scenarioRisk 
   ------------- 
   name:         terrorism 
   probability:  0.1 
   currency:     CHF 
   effect:       -100 
    scenarioRisk 
   ------------- 
   name:         market crash 
   probability:  0.2 
   currency:     CHF 
   effect:       -50 
   
  [ FAIL 15 | WARN 0 | SKIP 10 | PASS 1158 ]
  
  ══ Skipped tests ═══════════════════════════════════════════════════════════════
  • check-market-items.xlsx: isn't available (dev only test) (1)
  • copula.xlsx: isn't available (dev only test) (1)
  • duplicated-mapping.table.xlsx: isn't available (dev only test) (1)
  • errorSheetNames.xlsx: isn't available (dev only test) (1)
  • health.xlsx: isn't available (dev only test) (1)
  • invalidExtension.xyz: isn't available (dev only test) (1)
  • life.xlsx: isn't available (dev only test) (1)
  • macro-economic-scenarios.xlsx: isn't available (dev only test) (1)
  • scenario.xlsx: isn't available (dev only test) (1)
  • withScenarioNoError.xlsx: isn't available (dev only test) (1)
  
  ══ Failed tests ════════════════════════════════════════════════════════════════
  ── Error (test-macroEconomicScenarios.R:124:3): macroEconomicScenarios: compute method is OK ──
  Error in `names(mvm) %in% c("mvm.life", "mvm.health", "mvm.nonlife") || 
      !all(c("mvm.life", "mvm.health", "mvm.nonlife") %in% names(mvm))`: 'length = 3' in coercion to 'logical(1)'
  Backtrace:
      ▆
   1. └─sstModel::portfolio(...) at test-macroEconomicScenarios.R:124:2
   2.   ├─base::with(...)
   3.   └─base::with.default(...)
   4.     └─base::eval(substitute(expr), data, enclos = parent.frame())
   5.       └─base::eval(substitute(expr), data, enclos = parent.frame())
  ── Failure (test-portfolio.R:35:3): constructor of portfolio is ok ─────────────
  `portfolio(...)` threw an error with unexpected message.
  Expected match: "Invalid types"
  Actual message: "'length = 3' in coercion to 'logical(1)'"
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-portfolio.R:35:2
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─sstModel::portfolio(...)
    7.   ├─base::with(...)
    8.   └─base::with.default(...)
    9.     └─base::eval(substitute(expr), data, enclos = parent.frame())
   10.       └─base::eval(substitute(expr), data, enclos = parent.frame())
  ── Failure (test-portfolio.R:42:3): constructor of portfolio is ok ─────────────
  `portfolio(...)` threw an error with unexpected message.
  Expected match: "Invalid dimensions"
  Actual message: "'length = 3' in coercion to 'logical(1)'"
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-portfolio.R:42:2
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─sstModel::portfolio(...)
    7.   ├─base::with(...)
    8.   └─base::with.default(...)
    9.     └─base::eval(substitute(expr), data, enclos = parent.frame())
   10.       └─base::eval(substitute(expr), data, enclos = parent.frame())
  ── Failure (test-portfolio.R:49:3): constructor of portfolio is ok ─────────────
  `portfolio(...)` threw an error with unexpected message.
  Expected match: "Invalid type"
  Actual message: "'length = 3' in coercion to 'logical(1)'"
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-portfolio.R:49:2
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─sstModel::portfolio(...)
    7.   ├─base::with(...)
    8.   └─base::with.default(...)
    9.     └─base::eval(substitute(expr), data, enclos = parent.frame())
   10.       └─base::eval(substitute(expr), data, enclos = parent.frame())
  ── Failure (test-portfolio.R:64:3): constructor of portfolio is ok ─────────────
  `portfolio(...)` threw an error with unexpected message.
  Expected match: "Invalid types"
  Actual message: "'length = 3' in coercion to 'logical(1)'"
  Backtrace:
       ▆
    1. ├─testthat::expect_error(...) at test-portfolio.R:64:2
    2. │ └─testthat:::quasi_capture(...)
    3. │   ├─testthat .capture(...)
    4. │   │ └─base::withCallingHandlers(...)
    5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
    6. └─sstModel::portfolio(...)
    7.   ├─base::with(...)
    8.   └─base::with.default(...)
    9.     └─base::eval(substitute(expr), data, enclos = parent.frame())
   10.       └─base::eval(substitute(expr), data, enclos = parent.frame())
  ── Error (test-portfolio.R:126:3): constructor of portfolio is ok ──────────────
  Error in `names(mvm) %in% c("mvm.life", "mvm.health", "mvm.nonlife") || 
      !all(c("mvm.life", "mvm.health", "mvm.nonlife") %in% names(mvm))`: 'length = 3' in coercion to 'logical(1)'
  Backtrace:
      ▆
   1. └─sstModel::portfolio(...) at test-portfolio.R:126:2
   2.   ├─base::with(...)
   3.   └─base::with.default(...)
   4.     └─base::eval(substitute(expr), data, enclos = parent.frame())
   5.       └─base::eval(substitute(expr), data, enclos = parent.frame())
  ── Error (test-portfolio.R:168:3): portfolio: standard methods are ok ──────────
  Error in `names(mvm) %in% c("mvm.life", "mvm.health", "mvm.nonlife") || 
      !all(c("mvm.life", "mvm.health", "mvm.nonlife") %in% names(mvm))`: 'length = 3' in coercion to 'logical(1)'
  Backtrace:
      ▆
   1. ├─testthat::expect_equal(...) at test-portfolio.R:168:2
   2. │ └─testthat::quasi_label(enquo(object), label, arg = "object")
   3. │   └─rlang::eval_bare(expr, quo_get_env(quo))
   4. ├─base::format(...)
   5. └─sstModel::portfolio(...)
   6.   ├─base::with(...)
   7.   └─base::with.default(...)
   8.     └─base::eval(substitute(expr), data, enclos = parent.frame())
   9.       └─base::eval(substitute(expr), data, enclos = parent.frame())
  ── Error (test-portfolio.R:245:3): portfolio: generateExpression and generateFunction are ok ──
  Error in `names(mvm) %in% c("mvm.life", "mvm.health", "mvm.nonlife") || 
      !all(c("mvm.life", "mvm.health", "mvm.nonlife") %in% names(mvm))`: 'length = 3' in coercion to 'logical(1)'
  Backtrace:
      ▆
   1. └─sstModel::portfolio(...) at test-portfolio.R:245:2
   2.   ├─base::with(...)
   3.   └─base::with.default(...)
   4.     └─base::eval(substitute(expr), data, enclos = parent.frame())
   5.       └─base::eval(substitute(expr), data, enclos = parent.frame())
  ── Failure (test-reordering.R:33:3): conditionalReordering is ok ───────────────
  `conditionalReordering(...)` threw an error with unexpected message.
  Expected match: "types"
  Actual message: "'length = 4' in coercion to 'logical(1)'"
  Backtrace:
      ▆
   1. ├─testthat::expect_error(...) at test-reordering.R:33:2
   2. │ └─testthat:::quasi_capture(...)
   3. │   ├─testthat .capture(...)
   4. │   │ └─base::withCallingHandlers(...)
   5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
   6. └─sstModel:::conditionalReordering(...)
  ── Failure (test-reordering.R:58:3): conditionalReordering is ok ───────────────
  `conditionalReordering(...)` threw an error with unexpected message.
  Expected match: "square"
  Actual message: "'length = 4' in coercion to 'logical(1)'"
  Backtrace:
      ▆
   1. ├─testthat::expect_error(...) at test-reordering.R:58:2
   2. │ └─testthat:::quasi_capture(...)
   3. │   ├─testthat .capture(...)
   4. │   │ └─base::withCallingHandlers(...)
   5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
   6. └─sstModel:::conditionalReordering(...)
  ── Failure (test-reordering.R:79:3): conditionalReordering is ok ───────────────
  `conditionalReordering(...)` threw an error with unexpected message.
  Expected match: "dimension"
  Actual message: "'length = 4' in coercion to 'logical(1)'"
  Backtrace:
      ▆
   1. ├─testthat::expect_error(...) at test-reordering.R:79:2
   2. │ └─testthat:::quasi_capture(...)
   3. │   ├─testthat .capture(...)
   4. │   │ └─base::withCallingHandlers(...)
   5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
   6. └─sstModel:::conditionalReordering(...)
  ── Failure (test-reordering.R:104:3): conditionalReordering is ok ──────────────
  `conditionalReordering(...)` threw an error with unexpected message.
  Expected match: "definite"
  Actual message: "'length = 4' in coercion to 'logical(1)'"
  Backtrace:
      ▆
   1. ├─testthat::expect_error(...) at test-reordering.R:104:2
   2. │ └─testthat:::quasi_capture(...)
   3. │   ├─testthat .capture(...)
   4. │   │ └─base::withCallingHandlers(...)
   5. │   └─rlang::eval_bare(quo_get_expr(.quo), quo_get_env(.quo))
   6. └─sstModel:::conditionalReordering(...)
  ── Error (test-reordering.R:150:6): conditionalReordering is ok ────────────────
  Error in `!is.character(name) || duplicated(name)`: 'length = 4' in coercion to 'logical(1)'
  Backtrace:
      ▆
   1. └─sstModel:::conditionalReordering(...) at test-reordering.R:150:5
  ── Error (test-sstModel.R:84:3): sstModel is ok ────────────────────────────────
  Error in `names(mvm) %in% c("mvm.life", "mvm.health", "mvm.nonlife") || 
      !all(c("mvm.life", "mvm.health", "mvm.nonlife") %in% names(mvm))`: 'length = 3' in coercion to 'logical(1)'
  Backtrace:
      ▆
   1. └─sstModel::portfolio(...) at test-sstModel.R:84:2
   2.   ├─base::with(...)
   3.   └─base::with.default(...)
   4.     └─base::eval(substitute(expr), data, enclos = parent.frame())
   5.       └─base::eval(substitute(expr), data, enclos = parent.frame())
  ── Error (test-sstOutput.R:84:3): sstOutput figures are ok ─────────────────────
  Error in `names(mvm) %in% c("mvm.life", "mvm.health", "mvm.nonlife") || 
      !all(c("mvm.life", "mvm.health", "mvm.nonlife") %in% names(mvm))`: 'length = 3' in coercion to 'logical(1)'
  Backtrace:
      ▆
   1. └─sstModel::portfolio(...) at test-sstOutput.R:84:2
   2.   ├─base::with(...)
   3.   └─base::with.default(...)
   4.     └─base::eval(substitute(expr), data, enclos = parent.frame())
   5.       └─base::eval(substitute(expr), data, enclos = parent.frame())
  
  [ FAIL 15 | WARN 0 | SKIP 10 | PASS 1158 ]
  Error: Test failures
  Execution halted