[R-SIG-Finance] the package nmof

Pedro Garcia peg@rc|@m76 @end|ng |rom gm@||@com
Sat Jan 26 05:02:36 CET 2019


Ok, it may be that 'x' is a data structure, need to turn it into an array,
also you need to transpose it 'x' when multiplying.

Good luck,

Pedro

<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Fri, 25 Jan 2019 at 21:26, mmm ammm <mmmammm1900 using gmail.com> wrote:

> Dear all,
> i'm hoping that one of you can help me in the following code that is
> used for asset selection based on nmof package and please guide me
> where is the mistake:
>
> the error message is: "Error in colSums(x) : 'x' must be an array of
> at least two dimensions".
>
> The entire code is below (it works with DEopt) but does not with PSO;
> it is for asset selection exaclty from the package nmof.
>
> require("NMOF")
> na<-31
>
> nn<- read.table("n.txt") # n is the a 31*31 matrix.
> Sigma <- data.matrix(nn)
>
> OF2 <- function(x, data) {
> #  res <- colSums (data$Sigma %*% x * x)
> res <- colSums (Sigma %*% x * x)
> #z<-c(x,x)
> n <- colSums (x); res <- res / n^2
> }
> #######  pso  #############
> data <- list(
> na = na,
> max = rep( 0.05, na),
> min = rep(-0.05, na)
> )
> algo <- list(nP = 31L,
> nG = 1000L,
> c1 = 0.5,
> c2 = 1.5,
> #min = data$min, max = data$max,
> max = rep( 0.05, na), min = rep(-0.05, na),
> #repair = repair, pen = penalty,
> iner = 0.7, initV = 1, maxV = 0.2
> #printBar = FALSE, printDetail = TRUE
> )
> #x<-array(x, c(2,2))
>
> system.time(sol <- PSopt(OF = OF2,algo = algo, data))
>
> _______________________________________________
> R-SIG-Finance using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions
> should go.
>

	[[alternative HTML version deleted]]



More information about the R-SIG-Finance mailing list