R Under development (unstable) (2024-07-28 r86931 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > require(CLA) Loading required package: CLA > > b64 <- .Machine$sizeof.pointer == 8 > cat(sprintf("%d bit platform type '%s'\n", if(b64) 64 else 32, .Platform$OS.type)) 64 bit platform type 'windows' > (nonWindows <- .Platform$OS.type != "windows") [1] FALSE > arch <- Sys.info()[["machine"]] > .M <- .Machine; str(.M[grep("^sizeof", names(.M))]) ## differentiate long-double.. List of 5 $ sizeof.long : int 4 $ sizeof.longlong : int 8 $ sizeof.longdouble: int 16 $ sizeof.pointer : int 8 $ sizeof.time_t : int 8 > ## Do we have 64bit but no-long-double ? > b64nLD <- (arch == "x86_64" && .M$sizeof.longdouble != 16) > if(b64nLD) arch <- paste0(arch, "--no-long-double") > arch [1] "x86-64" > > data(muS.sp500)## <<-- working from this data --------------------- > > ##--> ../man/findMu.Rd -- has this example -- > set.seed(2016) > iS <- sample.int(length(muS.sp500$mu), 17) > cov17 <- muS.sp500$covar[iS, iS] > CLsp.17 <- CLA(muS.sp500$mu[iS], covar=cov17, lB=0, uB = 1/2) > CLsp.17 # 16 turning points Call: CLA(mu = muS.sp500$mu[iS], covar = cov17, lB = 0, uB = 1/2) Critical Line Algorithm for n = 17 assets, resulting in 16 turning points Overview of result parts: List of 5 $ weights_set : num [1:17, 1:16] 0 0 0 0 0 ... $ free_indices:List of 16 $ gammas : num [1:16] -0.01915 -0.01915 -0.01018 -0.00242 -0.00141 ... $ lambdas : num [1:16] 3.242 3.242 1.884 0.519 0.334 ... $ emptyLambdas: list() > tpS <- CLsp.17$MS_weights[,"Sig"] > str(s0 <- c(min(tpS), seq(0.0188, 0.039, by = 0.0001), max(tpS))) num [1:205] 0.0167 0.0188 0.0189 0.019 0.0191 ... > mu.. <- findMu(s0, result=CLsp.17, covar=cov17) > str(mu..) List of 2 $ Mu : num [1:205] 0.00323 0.00522 0.00525 0.00527 0.0053 ... $ weight: num [1:17, 1:205] 0 0.0342 0.0384 0.2228 0.0896 ... ..- attr(*, "dimnames")=List of 2 .. ..$ : chr [1:17] "AN" "EMC" "RX" "BAX" ... .. ..$ : NULL > stopifnot(dim(mu..$weight) == c(17, length(s0))) > ## and then plots > > > ##--> ../man/findSig.Rd -- has this example > set.seed(2018) > iS <- sample.int(length(muS.sp500$mu), 21) > cov21 <- muS.sp500$covar[iS, iS] > CLsp.21 <- CLA(muS.sp500$mu[iS], covar=cov21, lB=0, uB = 1/2) > CLsp.21 # had 14, now (R-devel new sample()) 21 turning points Call: CLA(mu = muS.sp500$mu[iS], covar = cov21, lB = 0, uB = 1/2) Critical Line Algorithm for n = 21 assets, resulting in 17 turning points Overview of result parts: List of 5 $ weights_set : num [1:21, 1:17] 0.5 0 0 0 0 0 0 0 0 0 ... $ free_indices:List of 17 $ gammas : num [1:17] -0.060472 -0.001911 -0.001613 -0.000898 -0.00081 ... $ lambdas : num [1:17] 8.084 0.367 0.329 0.233 0.221 ... $ emptyLambdas: list() > tpM <- CLsp.21$MS_weights[,"Mu"] > str(m0 <- c(min(tpM), seq(0.0028, 0.0052, by = 0.00005), max(tpM))) num [1:51] 0.00279 0.0028 0.00285 0.0029 0.00295 ... > sig. <- findSig(m0, result=CLsp.21, covar=cov21) > str(sig.) List of 2 $ Sig : num [1:51] 0.0152 0.0152 0.0152 0.0153 0.0153 ... $ weight: num [1:21, 1:51] 0 0 0.00207 0.07623 0 ... ..- attr(*, "dimnames")=List of 2 .. ..$ : chr [1:21] "ADSK" "GCI" "SLM" "DTE" ... .. ..$ : NULL > stopifnot(dim(sig.$weight) == c(21, length(m0))) > ## and then plots > > proc.time() user system elapsed 0.70 0.12 0.79