Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Error using using tsbootstrap function from resamplr package

$
0
0

I am trying to run the following code to obtain bootstrapped time series by using tsbootstrap function from resamplr package

library(quantmod)
library(resamplr)
# get prices
symbols <- c("SPY","IEF")
getSymbols(symbols, from = as.Date("2000-02-01") ,adjusted=TRUE)
prices <- list()
for(i in 1:length(symbols)) {
  tmp <- Ad(get(symbols[[i]]))
  prices[[i]] <- tmp
}
prices <- do.call(cbind, prices)
names(prices)<-symbols
# get returns
returns<-diff(log(prices))
# bootstrap
ns<-tsbootstrap((returns), R = 10, size = 500, m = nrow(returns),type = "geom")

I get the following error:

Error in UseMethod("tsbootstrap") : 
  no applicable method for 'tsbootstrap' applied to an object of class "c('xts', 'zoo')"

Information on my system:

R version 3.6.2 (2019-12-12)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18362)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252   
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] PerformanceAnalytics_1.5.3 resamplr_0.0.1             quantmod_0.4-15            TTR_0.23-6                
[5] xts_0.12-0                 zoo_1.8-7                 

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.3       rstudioapi_0.11  magrittr_1.5     tidyselect_1.0.0 lattice_0.20-38  R6_2.4.1        
 [7] quadprog_1.5-8   rlang_0.4.4      dplyr_0.8.4      tools_3.6.2      grid_3.6.2       broom_0.5.4     
[13] nlme_3.1-142     modelr_0.1.5     assertthat_0.2.1 lifecycle_0.1.0  tibble_2.1.3     crayon_1.3.4    
[19] purrr_0.3.3      tidyr_1.0.2      vctrs_0.2.2      curl_4.3         glue_1.3.1       compiler_3.6.2  
[25] pillar_1.4.3     backports_1.1.5  generics_0.0.2   pkgconfig_2.0.3 

Does anybody have already solved this error?

Many thanks


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>