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.