tests/testthat/test_mean.R

context("Mean") 

test_that("Mean dimensions", { 
  T = 100
  N = 25
  set.seed(123)
  rets  = matrix(rnorm(T * N), nrow = T, ncol = N)
  
  mu = meanEstimation(rets)
  expect_equal(length(mu), N)
  
  mu = meanEstimation(rets, control = list(type = 'naive'))
  expect_equal(length(mu), N)
  
  mu = meanEstimation(rets, control = list(type = 'ewma'))
  expect_equal(length(mu), N)
  
  mu = meanEstimation(rets, control = list(type = 'ewma', lambda = 0.9))
  expect_equal(length(mu), N)
  
  mu = meanEstimation(rets, control = list(type = 'mart'))
  expect_equal(length(mu), N)
  
  mu = meanEstimation(rets, control = list(type = 'bs'))
  expect_equal(length(mu), N)
})

Try the RiskPortfolios package in your browser

Any scripts or data that you put into this service are public.

RiskPortfolios documentation built on May 17, 2021, 1:10 a.m.