[R] Error in dimnames in R

PIKAL Petr petr.pikal at precheza.cz
Thu Dec 28 08:10:46 CET 2017


Hi

Without knowing much about the functions you use I would suggest few hints.

Do not use HTML format, your message could be scrambled.
Does frontier conform to data expected by function tailoredFrontierPlot?
Your best option could be to contact directly the maintainer. You could get his address by

maintainer("fPortfolio")

Instead of your whole code you should post the minimum reproducible example, with data preferably copied from

dput(frontier)

directly to your mail.

Cheers
Petr

> -----Original Message-----
> From: R-help [mailto:r-help-bounces at r-project.org] On Behalf Of Yury Bobr
> Sent: Wednesday, December 27, 2017 6:26 PM
> To: r-help at r-project.org
> Subject: [R] Error in dimnames in R
>
> Could anyone help me with some little problem? When I plot the frontier I get
> the following message: *"Error in dimnames(x) <- dn : length of 'dimnames' [1]
> not equal to array extent"*(see below for detail). How could I solve this. Thanks
> a lot.
>
> ##---------------------------- Portfolio construction &
> Optimisation------------------------
>
> #Assets: LUTAX,
> PFODX,BRGAX,GFAFX,NMSAX,EGINX,IPOYX,SCWFX,FGLDX,PAGEX
>
> #Getting monthly returns of the assets
> library(quantmod)
> library(tseries)
> library(timeSeries)
>
> LUTAX <- monthlyReturn((getSymbols("LUTAX",auto.assign=FALSE)[,4]),type =
> "arithmetic")
> colnames(LUTAX) <- c("LUTAX")
> PFODX <- monthlyReturn((getSymbols("PFODX",auto.assign=FALSE)[,4]),type =
> "arithmetic")
> colnames(PFODX) <- c("PFODX")
> BRGAX <- monthlyReturn((getSymbols("BRGAX",auto.assign=FALSE)[,4]),type =
> "arithmetic")
> colnames(BRGAX) <- c("BRGAX")
> GFAFX <- monthlyReturn((getSymbols("GFAFX",auto.assign=FALSE)[,4]),type =
> "arithmetic")
> colnames(GFAFX) <- c("GFAFX")
> NMSAX <- monthlyReturn((getSymbols("NMSAX",auto.assign=FALSE)[,4]),type =
> "arithmetic")
> colnames(NMSAX) <- c("NMSAX")
> EGINX <- monthlyReturn((getSymbols("EGINX",auto.assign=FALSE)[,4]),type =
> "arithmetic")
> colnames(EGINX) <- c("EGINX")
> IPOYX <- monthlyReturn((getSymbols("IPOYX",auto.assign=FALSE)[,4]),type =
> "arithmetic")
> colnames(IPOYX) <- c("IPOYX")
> SCWFX <- monthlyReturn((getSymbols("SCWFX",auto.assign=FALSE)[,4]),type =
> "arithmetic")
> colnames(SCWFX) <- c("SCWFX")
> FGLDX <- monthlyReturn((getSymbols("FGLDX",auto.assign=FALSE)[,4]),type =
> "arithmetic")
> colnames(FGLDX) <- c("FGLDX")
> PAGEX <- monthlyReturn((getSymbols("PAGEX",auto.assign=FALSE)[,4]),type =
> "arithmetic")
> colnames(PAGEX) <- c("PAGEX")
>
> # Merging returns of the assets (excluding NA's) portfolio_returns <-
> merge(LUTAX,
> PFODX,BRGAX,GFAFX,NMSAX,EGINX,IPOYX,SCWFX,FGLDX,PAGEX,all=F)
> data <- as.timeSeries(portfolio_returns)
>
> #Optimisation portfolio
> library(fPortfolio)
>
> spec <- portfolioSpec()
> setNFrontierPoints <- 25
> setSolver(spec) <- "solveRquadprog"
> constraints <-
> c("minW[1:1]=0.12","maxW[1:1]=0.18","minW[2:2]=0.12","maxW[2:2]=0.18",
>
> "minW[3:3]=0.10","maxW[3:3]=0.15","minW[4:4]=0.08","maxW[4:4]=0.12",
>
> "minW[5:5]=0.08","maxW[5:5]=0.12","minW[6:6]=0.05","maxW[6:6]=0.10",
>
> "minW[7:7]=0.05","maxW[7:7]=0.10","minW[8:8]=0.08","maxW[8:8]=0.12",
>
> "minW[9:9]=0.05","maxW[9:9]=0.10","minW[10:10]=0.08","maxW[10:10]=0.1
> 2",
>                  "minsumW[c(1:1,2:2)]=0.27","maxsumW[c(1:1,2:2)]=0.33",
>
> "minsumW[c(3:3,4:4,6:6,10:10)]=0.37","maxsumW[c(3:3,4:4,6:6,10:10)]=0.43"
> ,
>
> "minsumW[c(5:5,7:7,8:8,9:9)]=0.27","maxsumW[c(5:5,7:7,8:8,9:9)]=0.33",
>                  "maxsumW[c(1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,10:10)]=1")
>
> portfolioConstraints(data,spec,constraints)
>
> frontier<- portfolioFrontier(data,spec,constraints)
> print(frontier)
>
> tailoredFrontierPlot( frontier)
>
> After running the last command above I get the following message:* "Error in
> dimnames(x) <- dn : length of 'dimnames' [1] not equal to array extent"*
>
>
>
> <https://www.avast.com/sig-
> email?utm_medium=email&utm_source=link&utm_campaign=sig-
> email&utm_content=webmail>
> Без
> вирусов. www.avast.ru
> <https://www.avast.com/sig-
> email?utm_medium=email&utm_source=link&utm_campaign=sig-
> email&utm_content=webmail>
> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
>       [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

________________________________
Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a jsou určeny pouze jeho adresátům.
Jestliže jste obdržel(a) tento e-mail omylem, informujte laskavě neprodleně jeho odesílatele. Obsah tohoto emailu i s přílohami a jeho kopie vymažte ze svého systému.
Nejste-li zamýšleným adresátem tohoto emailu, nejste oprávněni tento email jakkoliv užívat, rozšiřovat, kopírovat či zveřejňovat.
Odesílatel e-mailu neodpovídá za eventuální škodu způsobenou modifikacemi či zpožděním přenosu e-mailu.

V případě, že je tento e-mail součástí obchodního jednání:
- vyhrazuje si odesílatel právo ukončit kdykoliv jednání o uzavření smlouvy, a to z jakéhokoliv důvodu i bez uvedení důvodu.
- a obsahuje-li nabídku, je adresát oprávněn nabídku bezodkladně přijmout; Odesílatel tohoto e-mailu (nabídky) vylučuje přijetí nabídky ze strany příjemce s dodatkem či odchylkou.
- trvá odesílatel na tom, že příslušná smlouva je uzavřena teprve výslovným dosažením shody na všech jejích náležitostech.
- odesílatel tohoto emailu informuje, že není oprávněn uzavírat za společnost žádné smlouvy s výjimkou případů, kdy k tomu byl písemně zmocněn nebo písemně pověřen a takové pověření nebo plná moc byly adresátovi tohoto emailu případně osobě, kterou adresát zastupuje, předloženy nebo jejich existence je adresátovi či osobě jím zastoupené známá.

This e-mail and any documents attached to it may be confidential and are intended only for its intended recipients.
If you received this e-mail by mistake, please immediately inform its sender. Delete the contents of this e-mail with all attachments and its copies from your system.
If you are not the intended recipient of this e-mail, you are not authorized to use, disseminate, copy or disclose this e-mail in any manner.
The sender of this e-mail shall not be liable for any possible damage caused by modifications of the e-mail or by delay with transfer of the email.

In case that this e-mail forms part of business dealings:
- the sender reserves the right to end negotiations about entering into a contract in any time, for any reason, and without stating any reasoning.
- if the e-mail contains an offer, the recipient is entitled to immediately accept such offer; The sender of this e-mail (offer) excludes any acceptance of the offer on the part of the recipient containing any amendment or variation.
- the sender insists on that the respective contract is concluded only upon an express mutual agreement on all its aspects.
- the sender of this e-mail informs that he/she is not authorized to enter into any contracts on behalf of the company except for cases in which he/she is expressly authorized to do so in writing, and such authorization or power of attorney is submitted to the recipient or the person represented by the recipient, or the existence of such authorization is known to the recipient of the person represented by the recipient.


More information about the R-help mailing list