* using log directory ‘/data/gannet/ripley/R/packages/tests-LENGTH1/sstModel.Rcheck’ * using R Under development (unstable) (2022-04-26 r82260) * using platform: x86_64-pc-linux-gnu (64-bit) * using session charset: UTF-8 * using option ‘--no-stop-on-test-error’ * checking for file ‘sstModel/DESCRIPTION’ ... OK * this is package ‘sstModel’ version ‘1.0.0’ * package encoding: UTF-8 * checking package namespace information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK * checking if there is a namespace ... OK * checking for executable files ... OK * checking for hidden files and directories ... OK * checking for portable file names ... OK * checking for sufficient/correct file permissions ... OK * checking whether package ‘sstModel’ can be installed ... [23s/77s] OK * checking package directory ... OK * checking ‘build’ directory ... OK * checking DESCRIPTION meta-information ... OK * checking top-level files ... OK * checking for left-over files ... OK * checking index information ... OK * checking package subdirectories ... OK * checking R files for non-ASCII characters ... OK * checking R files for syntax errors ... OK * checking whether the package can be loaded ... OK * checking whether the package can be loaded with stated dependencies ... OK * checking whether the package can be unloaded cleanly ... OK * checking whether the namespace can be loaded with stated dependencies ... OK * checking whether the namespace can be unloaded cleanly ... OK * checking loading without being on the library search path ... OK * checking use of S3 registration ... OK * checking dependencies in R code ... NOTE Namespace in Imports field not imported from: ‘shinydashboard’ All declared Imports should be used. * checking S3 generic/method consistency ... OK * checking replacement functions ... OK * checking foreign function calls ... OK * checking R code for possible problems ... [38s/74s] OK * checking Rd files ... OK * checking Rd metadata ... OK * checking Rd line widths ... OK * checking Rd cross-references ... OK * checking for missing documentation entries ... OK * checking for code/documentation mismatches ... OK * checking Rd \usage sections ... OK * checking Rd contents ... OK * checking for unstated dependencies in examples ... OK * checking LazyData ... NOTE 'LazyData' is specified without a 'data' directory * checking installed files from ‘inst/doc’ ... OK * checking files in ‘vignettes’ ... OK * checking examples ... ERROR Running examples in ‘sstModel-Ex.R’ failed The error most likely occurred in: > ### Name: portfolio > ### Title: Constructing a SST Portfolio > ### Aliases: portfolio > > ### ** Examples > > # Creating a portofolio. > asset1 <- asset("equity", "USD", 1000) > asset2 <- asset("hedge fund", "EUR", 2000) > life1 <- life(name = c("pandemy", "longetivity", "storno"), + currency = c("CHF", "CHF", "CHF"), + sensitivity = c(-100, -150, -130)) > health1 <- health(name = c("pandemy", "longetivity", "storno"), + currency = c("CHF", "CHF", "CHF"), + sensitivity = c(100, 150, 130)) > participation1 <- participation("CHF", 1000) > # valid portfolio parameters > 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) > pf <- portfolio(market.items = list(asset1, asset2), + participation.item = participation1, + life.item = life1, + health.item = health1, + base.currency = "CHF", + portfolio.parameters = valid.param) ----------- FAILURE REPORT -------------- --- failure: length > 1 in coercion to logical --- --- srcref --- : --- package (from environment) --- sstModel --- call from context --- eval(substitute(expr), data, enclos = parent.frame()) --- call from argument --- names(mvm) %in% c("mvm.life", "mvm.health", "mvm.nonlife") || !all(c("mvm.life", "mvm.health", "mvm.nonlife") %in% names(mvm)) --- R stacktrace --- where 1: eval(substitute(expr), data, enclos = parent.frame()) where 2: eval(substitute(expr), data, enclos = parent.frame()) where 3: with.default(portfolio.parameters, { if (!is.list(mvm) && !is.numeric(rtkg) && !is.numeric(rtkr) && !is.numeric(correction.term) && !is.numeric(credit.risk) && !is.numeric(expected.insurance.result) && !is.numeric(expected.financial.result)) { stop("Invalid types, see ?portfolio.") } if (!all(sapply(list(rtkr, rtkg, correction.term, credit.risk, expected.insurance.result, expected.financial.result), function(x) is.null(x) || (length(unlist(x))) == 1))) { stop("Invalid dimensions, see ?portfolio.") } if (length(mvm) != 3) { stop("Invalid dimensions, see ?portfolio.") } if (is.null(names(mvm)) || !all(names(mvm) %in% c("mvm.life", "mvm.health", "mvm.nonlife") || !all(c("mvm.life", "mvm.health", "mvm.nonlife") %in% names(mvm)) || any(duplicated(names(mvm))))) { stop("Invalid names for mvm parameter, see ?portfolio.") } if (any(is.infinite(unlist(mvm))) || is.infinite(rtkr) || is.infinite(rtkg) || is.infinite(correction.term) || is.infinite(credit.risk) || is.infinite(expected.insurance.result) || is.infinite(expected.financial.result)) { stop("Infinite values, see ?portfolio.") } if (any(is.na(unlist(mvm))) || is.na(rtkr) || is.na(rtkg) || is.na(correction.term) || is.na(credit.risk) || is.na(expected.insurance.result) || is.na(expected.financial.result)) { stop("Missing values, see ?portfolio.") } }) where 4: with(portfolio.parameters, { if (!is.list(mvm) && !is.numeric(rtkg) && !is.numeric(rtkr) && !is.numeric(correction.term) && !is.numeric(credit.risk) && !is.numeric(expected.insurance.result) && !is.numeric(expected.financial.result)) { stop("Invalid types, see ?portfolio.") } if (!all(sapply(list(rtkr, rtkg, correction.term, credit.risk, expected.insurance.result, expected.financial.result), function(x) is.null(x) || (length(unlist(x))) == 1))) { stop("Invalid dimensions, see ?portfolio.") } if (length(mvm) != 3) { stop("Invalid dimensions, see ?portfolio.") } if (is.null(names(mvm)) || !all(names(mvm) %in% c("mvm.life", "mvm.health", "mvm.nonlife") || !all(c("mvm.life", "mvm.health", "mvm.nonlife") %in% names(mvm)) || any(duplicated(names(mvm))))) { stop("Invalid names for mvm parameter, see ?portfolio.") } if (any(is.infinite(unlist(mvm))) || is.infinite(rtkr) || is.infinite(rtkg) || is.infinite(correction.term) || is.infinite(credit.risk) || is.infinite(expected.insurance.result) || is.infinite(expected.financial.result)) { stop("Infinite values, see ?portfolio.") } if (any(is.na(unlist(mvm))) || is.na(rtkr) || is.na(rtkg) || is.na(correction.term) || is.na(credit.risk) || is.na(expected.insurance.result) || is.na(expected.financial.result)) { stop("Missing values, see ?portfolio.") } }) where 5: portfolio(market.items = list(asset1, asset2), participation.item = participation1, life.item = life1, health.item = health1, base.currency = "CHF", portfolio.parameters = valid.param) --- value of length: 3 type: logical --- [1] TRUE TRUE TRUE --- function from context --- --- function search by body --- ----------- END OF FAILURE REPORT -------------- Fatal error: length > 1 in coercion to logical * checking for unstated dependencies in ‘tests’ ... OK * checking tests ... Running ‘test-sst-example.R’ Running ‘test-standalone.R’ Running ‘testthat.R’ [11s/16s] [13s/20s] ERROR 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) ----------- FAILURE REPORT -------------- --- failure: length > 1 in coercion to logical --- --- srcref --- : --- package (from environment) --- sstModel --- call from context --- eval(substitute(expr), data, enclos = parent.frame()) --- call from argument --- names(mvm) %in% c("mvm.life", "mvm.health", "mvm.nonlife") || !all(c("mvm.life", "mvm.health", "mvm.nonlife") %in% names(mvm)) --- R stacktrace --- where 1: eval(substitute(expr), data, enclos = parent.frame()) where 2: eval(substitute(expr), data, enclos = parent.frame()) where 3: with.default(portfolio.parameters, { if (!is.list(mvm) && !is.numeric(rtkg) && !is.numeric(rtkr) && !is.numeric(correction.term) && !is.numeric(credit.risk) && !is.numeric(expected.insurance.result) && !is.numeric(expected.financial.result)) { stop("Invalid types, see ?portfolio.") } if (!all(sapply(list(rtkr, rtkg, correction.term, credit.risk, expected.insurance.result, expected.financial.result), function(x) is.null(x) || (length(unlist(x))) == 1))) { stop("Invalid dimensions, see ?portfolio.") } if (length(mvm) != 3) { stop("Invalid dimensions, see ?portfolio.") } if (is.null(names(mvm)) || !all(names(mvm) %in% c("mvm.life", "mvm.health", "mvm.nonlife") || !all(c("mvm.life", "mvm.health", "mvm.nonlife") %in% names(mvm)) || any(duplicated(names(mvm))))) { stop("Invalid names for mvm parameter, see ?portfolio.") } if (any(is.infinite(unlist(mvm))) || is.infinite(rtkr) || is.infinite(rtkg) || is.infinite(correction.term) || is.infinite(credit.risk) || is.infinite(expected.insurance.result) || is.infinite(expected.financial.result)) { stop("Infinite values, see ?portfolio.") } if (any(is.na(unlist(mvm))) || is.na(rtkr) || is.na(rtkg) || is.na(correction.term) || is.na(credit.risk) || is.na(expected.insurance.result) || is.na(expected.financial.result)) { stop("Missing values, see ?portfolio.") } }) where 4: with(portfolio.parameters, { if (!is.list(mvm) && !is.numeric(rtkg) && !is.numeric(rtkr) && !is.numeric(correction.term) && !is.numeric(credit.risk) && !is.numeric(expected.insurance.result) && !is.numeric(expected.financial.result)) { stop("Invalid types, see ?portfolio.") } if (!all(sapply(list(rtkr, rtkg, correction.term, credit.risk, expected.insurance.result, expected.financial.result), function(x) is.null(x) || (length(unlist(x))) == 1))) { stop("Invalid dimensions, see ?portfolio.") } if (length(mvm) != 3) { stop("Invalid dimensions, see ?portfolio.") } if (is.null(names(mvm)) || !all(names(mvm) %in% c("mvm.life", "mvm.health", "mvm.nonlife") || !all(c("mvm.life", "mvm.health", "mvm.nonlife") %in% names(mvm)) || any(duplicated(names(mvm))))) { stop("Invalid names for mvm parameter, see ?portfolio.") } if (any(is.infinite(unlist(mvm))) || is.infinite(rtkr) || is.infinite(rtkg) || is.infinite(correction.term) || is.infinite(credit.risk) || is.infinite(expected.insurance.result) || is.infinite(expected.financial.result)) { stop("Infinite values, see ?portfolio.") } if (any(is.na(unlist(mvm))) || is.na(rtkr) || is.na(rtkg) || is.na(correction.term) || is.na(credit.risk) || is.na(expected.insurance.result) || is.na(expected.financial.result)) { stop("Missing values, see ?portfolio.") } }) where 5: 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) --- value of length: 3 type: logical --- [1] TRUE TRUE TRUE --- function from context --- --- function search by body --- ----------- END OF FAILURE REPORT -------------- Fatal error: length > 1 in coercion to logical 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 ----------- FAILURE REPORT -------------- --- failure: length > 1 in coercion to logical --- --- srcref --- : --- package (from environment) --- sstModel --- call from context --- eval(substitute(expr), data, enclos = parent.frame()) --- call from argument --- names(mvm) %in% c("mvm.life", "mvm.health", "mvm.nonlife") || !all(c("mvm.life", "mvm.health", "mvm.nonlife") %in% names(mvm)) --- R stacktrace --- where 1: eval(substitute(expr), data, enclos = parent.frame()) where 2: eval(substitute(expr), data, enclos = parent.frame()) where 3: with.default(portfolio.parameters, { if (!is.list(mvm) && !is.numeric(rtkg) && !is.numeric(rtkr) && !is.numeric(correction.term) && !is.numeric(credit.risk) && !is.numeric(expected.insurance.result) && !is.numeric(expected.financial.result)) { stop("Invalid types, see ?portfolio.") } if (!all(sapply(list(rtkr, rtkg, correction.term, credit.risk, expected.insurance.result, expected.financial.result), function(x) is.null(x) || (length(unlist(x))) == 1))) { stop("Invalid dimensions, see ?portfolio.") } if (length(mvm) != 3) { stop("Invalid dimensions, see ?portfolio.") } if (is.null(names(mvm)) || !all(names(mvm) %in% c("mvm.life", "mvm.health", "mvm.nonlife") || !all(c("mvm.life", "mvm.health", "mvm.nonlife") %in% names(mvm)) || any(duplicated(names(mvm))))) { stop("Invalid names for mvm parameter, see ?portfolio.") } if (any(is.infinite(unlist(mvm))) || is.infinite(rtkr) || is.infinite(rtkg) || is.infinite(correction.term) || is.infinite(credit.risk) || is.infinite(expected.insurance.result) || is.infinite(expected.financial.result)) { stop("Infinite values, see ?portfolio.") } if (any(is.na(unlist(mvm))) || is.na(rtkr) || is.na(rtkg) || is.na(correction.term) || is.na(credit.risk) || is.na(expected.insurance.result) || is.na(expected.financial.result)) { stop("Missing values, see ?portfolio.") } }) where 4: with(portfolio.parameters, { if (!is.list(mvm) && !is.numeric(rtkg) && !is.numeric(rtkr) && !is.numeric(correction.term) && !is.numeric(credit.risk) && !is.numeric(expected.insurance.result) && !is.numeric(expected.financial.result)) { stop("Invalid types, see ?portfolio.") } if (!all(sapply(list(rtkr, rtkg, correction.term, credit.risk, expected.insurance.result, expected.financial.result), function(x) is.null(x) || (length(unlist(x))) == 1))) { stop("Invalid dimensions, see ?portfolio.") } if (length(mvm) != 3) { stop("Invalid dimensions, see ?portfolio.") } if (is.null(names(mvm)) || !all(names(mvm) %in% c("mvm.life", "mvm.health", "mvm.nonlife") || !all(c("mvm.life", "mvm.health", "mvm.nonlife") %in% names(mvm)) || any(duplicated(names(mvm))))) { stop("Invalid names for mvm parameter, see ?portfolio.") } if (any(is.infinite(unlist(mvm))) || is.infinite(rtkr) || is.infinite(rtkg) || is.infinite(correction.term) || is.infinite(credit.risk) || is.infinite(expected.insurance.result) || is.infinite(expected.financial.result)) { stop("Infinite values, see ?portfolio.") } if (any(is.na(unlist(mvm))) || is.na(rtkr) || is.na(rtkg) || is.na(correction.term) || is.na(credit.risk) || is.na(expected.insurance.result) || is.na(expected.financial.result)) { stop("Missing values, see ?portfolio.") } }) where 5 at test-macroEconomicScenarios.R#124: portfolio(market.items = list(asset(type = "equity", currency = "CHF", value = 1000), assetForward(type = "equity", currency = "CHF", time = 1L, exposure = 1000, price = 600, position = "short"), fxForward(domestic = "CHF", foreign = "EUR", time = 1L, nominal = 100, rate = 1.05, position = "short"), liability(time = 1L, currency = "EUR", value = -400), cashflow(time = 1L, currency = "CHF", rating = "AAA", 0.06, value = 500), delta(name = "EURCHF", currency = "CHF", sensitivity = 30)), participation.item = participation(currency = "CHF", value = 200), life.item = NULL, health.item = NULL, base.currency = "CHF", portfolio.parameters = valid.param) where 6: eval(code, test_env) where 7: eval(code, test_env) where 8: withCallingHandlers({ eval(code, test_env) if (!handled && !is.null(test)) { skip_empty() } }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, message = handle_message, error = handle_error) where 9: doTryCatch(return(expr), name, parentenv, handler) where 10: tryCatchOne(expr, names, parentenv, handlers[[1L]]) where 11: tryCatchList(expr, names[-nh], parentenv, handlers[-nh]) where 12: doTryCatch(return(expr), name, parentenv, handler) where 13: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), names[nh], parentenv, handlers[[nh]]) where 14: tryCatchList(expr, classes, parentenv, handlers) where 15: tryCatch(withCallingHandlers({ eval(code, test_env) if (!handled && !is.null(test)) { skip_empty() } }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, message = handle_message, error = handle_error), error = handle_fatal, skip = function(e) { }) where 16: test_code(desc, code, env = parent.frame(), reporter = reporter) where 17 at test-macroEconomicScenarios.R#64: test_that("macroEconomicScenarios: compute method is OK", { cov.mat <- diag(1, 4, 4) %*% diag(rep(1, 4)) %*% diag(1, 4, 4) name <- c("EURCHF", "equityCHF", "2YCHF", "AAACHF") colnames(cov.mat) <- name rownames(cov.mat) <- name attr(cov.mat, "base.currency") <- "CHF" mapping.table <- mappingTable(currency(name = "EURCHF", from = "EUR", to = "CHF"), equity(name = "equityCHF", type = "equity", currency = "CHF"), rate(name = "2YCHF", currency = "CHF", horizon = "k"), spread(name = "AAACHF", currency = "CHF", rating = "AAA"), rate(name = "2YCHF", currency = "EUR", horizon = "k", scale = 0.8)) initial.values <- list() initial.values$initial.fx <- data.frame(from = "EUR", to = "CHF", fx = 1.05, stringsAsFactors = F) initial.values$initial.rate <- data.frame(time = 1L, currency = c("CHF", "EUR"), rate = c(0.01, 0.01), stringsAsFactors = F) mapping.time <- data.frame(time = 1L, mapping = "k", stringsAsFactors = F) eco.table <- matrix(c(1, 1, 1, 1, 2, 2, 1, 4, 2, 3), nrow = 2) colnames(eco.table) <- c(name, "participation") rownames(eco.table) <- c("sc1", "sc2") eco.scenario <- macroEconomicScenarios(macro.economic.scenario.table = eco.table) mr <- marketRisk(cov.mat = cov.mat, mapping.table = mapping.table, initial.values = initial.values, base.currency = "CHF", mapping.time = mapping.time) valid.param <- list(mvm = list(mvm.life = 3, mvm.health = 1, mvm.nonlife = 3), rtkr = 0, rtkg = 0, credit.risk = 3, expected.insurance.result = 10^6, expected.financial.result = 10^5, correction.term = 3) p <- portfolio(market.items = list(asset(type = "equity", currency = "CHF", value = 1000), assetForward(type = "equity", currency = "CHF", time = 1L, exposure = 1000, price = 600, position = "short"), fxForward(domestic = "CHF", foreign = "EUR", time = 1L, nominal = 100, rate = 1.05, position = "short"), liability(time = 1L, currency = "EUR", value = -400), cashflow(time = 1L, currency = "CHF", rating = "AAA", 0.06, value = 500), delta(name = "EURCHF", currency = "CHF", sensitivity = 30)), participation.item = participation(currency = "CHF", value = 200), life.item = NULL, health.item = NULL, base.currency = "CHF", portfolio.parameters = valid.param) expect_equal(as.numeric(compute.macroEconomicScenarios(object = eco.scenario, portfolio = p, market.risk = mr))[1], as.numeric(valFunction(p$market.items[[1]], market.risk = mr, with.constant = F)(eco.scenario$macro.economic.scenario.table[, -5]) + valFunction(p$market.items[[2]], market.risk = mr, with.constant = F)(eco.scenario$macro.economic.scenario.table[, -5]) + valFunction(p$market.items[[3]], market.risk = mr, with.constant = F)(eco.scenario$macro.economic.scenario.table[, -5]) + valFunction(p$market.items[[4]], market.risk = mr, with.constant = F)(eco.scenario$macro.economic.scenario.table[, -5]) + valFunction(p$market.items[[5]], market.risk = mr, with.constant = F)(eco.scenario$macro.economic.scenario.table[, -5]) + valFunction(p$market.items[[6]], market.risk = mr)(eco.scenario$macro.economic.scenario.table[, -5]) + 200 * (exp(eco.scenario$macro.economic.scenario.table[, "participation"]) - 1))[1]) expect_equal(as.numeric(compute.macroEconomicScenarios(object = eco.scenario, portfolio = p, market.risk = mr))[2], as.numeric(valFunction(p$market.items[[1]], market.risk = mr, with.constant = F)(eco.scenario$macro.economic.scenario.table[, -5]) + valFunction(p$market.items[[2]], market.risk = mr, with.constant = F)(eco.scenario$macro.economic.scenario.table[, -5]) + valFunction(p$market.items[[3]], market.risk = mr, with.constant = F)(eco.scenario$macro.economic.scenario.table[, -5]) + valFunction(p$market.items[[4]], market.risk = mr, with.constant = F)(eco.scenario$macro.economic.scenario.table[, -5]) + valFunction(p$market.items[[5]], market.risk = mr, with.constant = F)(eco.scenario$macro.economic.scenario.table[, -5]) + valFunction(p$market.items[[6]], market.risk = mr)(eco.scenario$macro.economic.scenario.table[, -5]) + 200 * (exp(eco.scenario$macro.economic.scenario.table[, "participation"]) - 1))[2]) eco.table <- matrix(c(1, 1, 1, 1, 2, 2, 1, 4), nrow = 2) colnames(eco.table) <- name rownames(eco.table) <- c("sc1", "sc2") eco.scenario <- macroEconomicScenarios(macro.economic.scenario.table = eco.table) p <- portfolio(market.items = list(asset(type = "equity", currency = "CHF", value = 1000), assetForward(type = "equity", currency = "CHF", time = 1L, exposure = 1000, price = 600, position = "short"), fxForward(domestic = "CHF", foreign = "EUR", time = 1L, nominal = 100, rate = 1.05, position = "short"), liability(time = 1L, currency = "EUR", value = -400), cashflow(time = 1L, currency = "CHF", rating = "AAA", 0.06, value = 500), delta(name = "EURCHF", currency = "CHF", sensitivity = 30)), participation.item = NULL, life.item = NULL, health.item = NULL, base.currency = "CHF", portfolio.parameters = valid.param) expect_equal(as.numeric(compute.macroEconomicScenarios(object = eco.scenario, portfolio = p, market.risk = mr))[1], as.numeric(valFunction(p$market.items[[1]], market.risk = mr, with.constant = F)(eco.scenario$macro.economic.scenario.table[, -5]) + valFunction(p$market.items[[2]], market.risk = mr, with.constant = F)(eco.scenario$macro.economic.scenario.table[, -5]) + valFunction(p$market.items[[3]], market.risk = mr, with.constant = F)(eco.scenario$macro.economic.scenario.table[, -5]) + valFunction(p$market.items[[4]], market.risk = mr, with.constant = F)(eco.scenario$macro.economic.scenario.table[, -5]) + valFunction(p$market.items[[5]], market.risk = mr, with.constant = F)(eco.scenario$macro.economic.scenario.table[, -5]) + valFunction(p$market.items[[6]], market.risk = mr)(eco.scenario$macro.economic.scenario.table[, -5]))[1]) expect_equal(as.numeric(compute.macroEconomicScenarios(object = eco.scenario, portfolio = p, market.risk = mr))[2], as.numeric(valFunction(p$market.items[[1]], market.risk = mr, with.constant = F)(eco.scenario$macro.economic.scenario.table[, -5]) + valFunction(p$market.items[[2]], market.risk = mr, with.constant = F)(eco.scenario$macro.economic.scenario.table[, -5]) + valFunction(p$market.items[[3]], market.risk = mr, with.constant = F)(eco.scenario$macro.economic.scenario.table[, -5]) + valFunction(p$market.items[[4]], market.risk = mr, with.constant = F)(eco.scenario$macro.economic.scenario.table[, -5]) + valFunction(p$market.items[[5]], market.risk = mr, with.constant = F)(eco.scenario$macro.economic.scenario.table[, -5]) + valFunction(p$market.items[[6]], market.risk = mr)(eco.scenario$macro.economic.scenario.table[, -5]))[2]) eco.table <- matrix(c(1, 1, 1, 1, 2, 2, 1, 4, 2, 3), nrow = 2) colnames(eco.table) <- c(name, "participation") rownames(eco.table) <- c("sc1", "sc2") eco.scenario <- macroEconomicScenarios(macro.economic.scenario.table = eco.table) expect_error(compute(eco.scenario, market.risk = mr, portfolio = p), "marketRisk") }) where 18: eval(code, test_env) where 19: eval(code, test_env) where 20: withCallingHandlers({ eval(code, test_env) if (!handled && !is.null(test)) { skip_empty() } }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, message = handle_message, error = handle_error) where 21: doTryCatch(return(expr), name, parentenv, handler) where 22: tryCatchOne(expr, names, parentenv, handlers[[1L]]) where 23: tryCatchList(expr, names[-nh], parentenv, handlers[-nh]) where 24: doTryCatch(return(expr), name, parentenv, handler) where 25: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), names[nh], parentenv, handlers[[nh]]) where 26: tryCatchList(expr, classes, parentenv, handlers) where 27: tryCatch(withCallingHandlers({ eval(code, test_env) if (!handled && !is.null(test)) { skip_empty() } }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, message = handle_message, error = handle_error), error = handle_fatal, skip = function(e) { }) where 28: test_code(NULL, exprs, env) where 29: source_file(path, child_env(env), wrap = wrap) where 30: FUN(X[[i]], ...) where 31: lapply(test_paths, test_one_file, env = env, wrap = wrap) where 32: doTryCatch(return(expr), name, parentenv, handler) where 33: tryCatchOne(expr, names, parentenv, handlers[[1L]]) where 34: tryCatchList(expr, classes, parentenv, handlers) where 35: tryCatch(code, testthat_abort_reporter = function(cnd) { cat(conditionMessage(cnd), "\n") NULL }) where 36: with_reporter(reporters$multi, lapply(test_paths, test_one_file, env = env, wrap = wrap)) where 37: test_files(test_dir = test_dir, test_package = test_package, test_paths = test_paths, load_helpers = load_helpers, reporter = reporter, env = env, stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning, wrap = wrap, load_package = load_package) where 38: test_files(test_dir = path, test_paths = test_paths, test_package = package, reporter = reporter, load_helpers = load_helpers, env = env, stop_on_failure = stop_on_failure, stop_on_warning = stop_on_warning, wrap = wrap, load_package = load_package, parallel = parallel) where 39: test_dir("testthat", package = package, reporter = reporter, ..., load_package = "installed") where 40: test_check("sstModel") --- value of length: 3 type: logical --- [1] TRUE TRUE TRUE --- function from context --- --- function search by body --- ----------- END OF FAILURE REPORT -------------- Fatal error: length > 1 in coercion to logical * checking for unstated dependencies in vignettes ... OK * checking package vignettes in ‘inst/doc’ ... OK * checking re-building of vignette outputs ... ERROR Error(s) in re-building vignettes: --- re-building ‘packageAPI.Rmd’ using rmarkdown ----------- FAILURE REPORT -------------- --- failure: length > 1 in coercion to logical --- --- srcref --- : --- package (from environment) --- sstModel --- call from context --- eval(substitute(expr), data, enclos = parent.frame()) --- call from argument --- names(mvm) %in% c("mvm.life", "mvm.health", "mvm.nonlife") || !all(c("mvm.life", "mvm.health", "mvm.nonlife") %in% names(mvm)) --- R stacktrace --- where 1: eval(substitute(expr), data, enclos = parent.frame()) where 2: eval(substitute(expr), data, enclos = parent.frame()) where 3: with.default(portfolio.parameters, { if (!is.list(mvm) && !is.numeric(rtkg) && !is.numeric(rtkr) && !is.numeric(correction.term) && !is.numeric(credit.risk) && !is.numeric(expected.insurance.result) && !is.numeric(expected.financial.result)) { stop("Invalid types, see ?portfolio.") } if (!all(sapply(list(rtkr, rtkg, correction.term, credit.risk, expected.insurance.result, expected.financial.result), function(x) is.null(x) || (length(unlist(x))) == 1))) { stop("Invalid dimensions, see ?portfolio.") } if (length(mvm) != 3) { stop("Invalid dimensions, see ?portfolio.") } if (is.null(names(mvm)) || !all(names(mvm) %in% c("mvm.life", "mvm.health", "mvm.nonlife") || !all(c("mvm.life", "mvm.health", "mvm.nonlife") %in% names(mvm)) || any(duplicated(names(mvm))))) { stop("Invalid names for mvm parameter, see ?portfolio.") } if (any(is.infinite(unlist(mvm))) || is.infinite(rtkr) || is.infinite(rtkg) || is.infinite(correction.term) || is.infinite(credit.risk) || is.infinite(expected.insurance.result) || is.infinite(expected.financial.result)) { stop("Infinite values, see ?portfolio.") } if (any(is.na(unlist(mvm))) || is.na(rtkr) || is.na(rtkg) || is.na(correction.term) || is.na(credit.risk) || is.na(expected.insurance.result) || is.na(expected.financial.result)) { stop("Missing values, see ?portfolio.") } }) where 4: with(portfolio.parameters, { if (!is.list(mvm) && !is.numeric(rtkg) && !is.numeric(rtkr) && !is.numeric(correction.term) && !is.numeric(credit.risk) && !is.numeric(expected.insurance.result) && !is.numeric(expected.financial.result)) { stop("Invalid types, see ?portfolio.") } if (!all(sapply(list(rtkr, rtkg, correction.term, credit.risk, expected.insurance.result, expected.financial.result), function(x) is.null(x) || (length(unlist(x))) == 1))) { stop("Invalid dimensions, see ?portfolio.") } if (length(mvm) != 3) { stop("Invalid dimensions, see ?portfolio.") } if (is.null(names(mvm)) || !all(names(mvm) %in% c("mvm.life", "mvm.health", "mvm.nonlife") || !all(c("mvm.life", "mvm.health", "mvm.nonlife") %in% names(mvm)) || any(duplicated(names(mvm))))) { stop("Invalid names for mvm parameter, see ?portfolio.") } if (any(is.infinite(unlist(mvm))) || is.infinite(rtkr) || is.infinite(rtkg) || is.infinite(correction.term) || is.infinite(credit.risk) || is.infinite(expected.insurance.result) || is.infinite(expected.financial.result)) { stop("Infinite values, see ?portfolio.") } if (any(is.na(unlist(mvm))) || is.na(rtkr) || is.na(rtkg) || is.na(correction.term) || is.na(credit.risk) || is.na(expected.insurance.result) || is.na(expected.financial.result)) { stop("Missing values, see ?portfolio.") } }) where 5: portfolio(market.items = c(list.fixed.income, list.assets, list.forwards, list.delta), base.currency = "CHF", life.item = life.item, health.item = health.item, participation.item = participation.item, portfolio.parameters = list(mvm = list(mvm.life = 10^5, mvm.health = 10^5, mvm.nonlife = 10^5), credit.risk = 10^5, correction.term = 10^4, expected.financial.result = 3 * 10^6, expected.insurance.result = 2 * 10^6, rtkg = 20 * 10^6, rtkr = 18 * 10^6)) where 6: eval(expr, envir, enclos) where 7: eval(expr, envir, enclos) where 8: eval_with_user_handlers(expr, envir, enclos, user_handlers) where 9: withVisible(eval_with_user_handlers(expr, envir, enclos, user_handlers)) where 10: withCallingHandlers(withVisible(eval_with_user_handlers(expr, envir, enclos, user_handlers)), warning = wHandler, error = eHandler, message = mHandler) where 11: handle(ev <- withCallingHandlers(withVisible(eval_with_user_handlers(expr, envir, enclos, user_handlers)), warning = wHandler, error = eHandler, message = mHandler)) where 12: timing_fn(handle(ev <- withCallingHandlers(withVisible(eval_with_user_handlers(expr, envir, enclos, user_handlers)), warning = wHandler, error = eHandler, message = mHandler))) where 13: evaluate_call(expr, parsed$src[[i]], envir = envir, enclos = enclos, debug = debug, last = i == length(out), use_try = stop_on_error != 2L, keep_warning = keep_warning, keep_message = keep_message, output_handler = output_handler, include_timing = include_timing) where 14: evaluate::evaluate(...) where 15: evaluate(code, envir = env, new_device = FALSE, keep_warning = !isFALSE(options$warning), keep_message = !isFALSE(options$message), stop_on_error = if (is.numeric(options$error)) options$error else { if (options$error && options$include) 0L else 2L }, output_handler = knit_handlers(options$render, options)) where 16: in_dir(input_dir(), expr) where 17: in_input_dir(evaluate(code, envir = env, new_device = FALSE, keep_warning = !isFALSE(options$warning), keep_message = !isFALSE(options$message), stop_on_error = if (is.numeric(options$error)) options$error else { if (options$error && options$include) 0L else 2L }, output_handler = knit_handlers(options$render, options))) where 18: eng_r(options) where 19: block_exec(params) where 20: call_block(x) where 21: process_group.block(group) where 22: process_group(group) where 23: withCallingHandlers(if (tangle) process_tangle(group) else process_group(group), error = function(e) { setwd(wd) cat(res, sep = "\n", file = output %n% "") message("Quitting from lines ", paste(current_lines(i), collapse = "-"), " (", knit_concord$get("infile"), ") ") }) where 24: process_file(text, output) where 25: knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet) where 26: rmarkdown::render(file, encoding = encoding, quiet = quiet, envir = globalenv(), output_dir = getwd(), ...) where 27: vweave_rmarkdown(...) where 28: engine$weave(file, quiet = quiet, encoding = enc) where 29: doTryCatch(return(expr), name, parentenv, handler) where 30: tryCatchOne(expr, names, parentenv, handlers[[1L]]) where 31: tryCatchList(expr, classes, parentenv, handlers) where 32: tryCatch({ engine$weave(file, quiet = quiet, encoding = enc) setwd(startdir) output <- find_vignette_product(name, by = "weave", engine = engine) if (!have.makefile && vignette_is_tex(output)) { texi2pdf(file = output, clean = FALSE, quiet = quiet) output <- find_vignette_product(name, by = "texi2pdf", engine = engine) } outputs <- c(outputs, output) }, error = function(e) { thisOK <<- FALSE fails <<- c(fails, file) message(gettextf("Error: processing vignette '%s' failed with diagnostics:\n%s", file, conditionMessage(e))) }) where 33: tools:::buildVignettes(dir = "/data/gannet/ripley/R/packages/tests-LENGTH1/sstModel.Rcheck/vign_test/sstModel") --- value of length: 3 type: logical --- [1] TRUE TRUE TRUE --- function from context --- --- function search by body --- ----------- END OF FAILURE REPORT -------------- Fatal error: length > 1 in coercion to logical * checking PDF version of manual ... OK * checking for non-standard things in the check directory ... OK * checking for detritus in the temp directory ... OK * DONE Status: 3 ERRORs, 2 NOTEs See ‘/data/gannet/ripley/R/packages/tests-LENGTH1/sstModel.Rcheck/00check.log’ for details. Command exited with non-zero status 1 Time 5:13.48, 138.56 + 9.21