[R-SIG-Finance] RES: [Fwd: Re: problem with fPortfolio]

Julio Ferreira julio.ferreira at reliance.com.br
Fri Jul 20 22:28:07 CEST 2007


Checking the code for assetsMeanCov, I found out that when method="mcd"
the code does this:

else if (method == "mve") {
        ans = MASS::cov.rob(x, method = "mve")
        mu = ans$mu
        Sigma = ans$Omega
    else if (method == "mcd") {
        ans = MASS::cov.rob(x, method = "mcd")
        mu = ans$mu
        Sigma = ans$Omega

When the correct should be this:

else if (method == "mve") {
        ans = MASS::cov.rob(x, method = "mve")
        mu = ans$center
        Sigma = ans$cov
    else if (method == "mcd") {
        ans = MASS::cov.rob(x, method = "mcd")
        mu = ans$center
        Sigma = ans$cov

As the cov.rob function (package MASS) returns $center(instead of $mu) and $cov (instead of $Omega), the objects mu and Omega were NULL, and then the error message makes sense ("trying to attribute to a NULL")
In the case of the other methods choices, the code is correct.
I am a newcomer to R, so would you pls indicate how should I warn the mantainer to get this code fixed on the package??

-----Mensagem original-----
De: Brian G. Peterson [mailto:brian at braverock.com] 
Enviada em: sexta-feira, 20 de julho de 2007 16:04
Para: R-SIG-Finance
Cc: Julio Ferreira
Assunto: [Fwd: Re: [R-SIG-Finance] problem with fPortfolio]

Please address responses to the list

-------- Original Message --------
From: Julio Ferreira <julio.ferreira at reliance.com.br>
To: Brian G. Peterson <brian at braverock.com>


Yes, I did after I sent the message calling for help. Actually I found 
out that "isPositiveDefinite" is part of fEcofin, which apparently 
should have been downloaded (I used "dependencies=TRUE", when downloaded 
fPortfolio). I tried to download fEcofin from another mirror and it 
solved the problem. Maybe the first downloaded was (somehow) 
"corrupted"????Is it possible ?? the checks seemed to be ok....

Now i´m getting another strange problem: when calling


I´m getting error message:

Erro em names(mu) = colnames(x) : tentativa de especificar um atributo 
em um NULL

translation: "attempted to specify an attribute to a  NULL"

The problem is that I am just reproducing what was on the fPortfolio 
documentation. Any guess what was going on?

I thank you for your reply, and apologize for "abusing" from you 
"goodwill", but I am learning R by myself, so don´t have no one else to 
ask for help...

-------- End Original Message --------


Try with a different data set, or check to make sure that there are no 
NA's in the data you're using to test the functions.  Rmetrics is a set 
of functions and data which have accumulated over several years, and 
fEcofin is a relative newcomer to the package set.  In some cases, this 
means that examples in documentation, which are not automatically 
checked on package build, may no longer work properly.

In the specific case you cite above, it looks like your input data may 
not have had named columns.

I'm not sure that's the case though, because when I try with a different 
data set which I know is named and symetric in length of all columns, I 
get a similar error to the one you describe:

 > data(edhec)
 > assetsMeanCov(edhec,method="mcd")

Error in `names<-.default`(`*tmp*`, value = c("Convertible.Arbitrage", 
:        attempt to set an attribute on NULL

When I try with a different data set with timeseries of differing 
lengths, I get a different error:

 > data(managers)
 > assetsMeanCov(managers,method="mcd")
Error in MASS::cov.rob(x, method = "mcd") :
         missing or infinite values are not allowed

When I try with a different method parameter, I get the error you 
reported initially.

 > assetsMeanCov(edhec,method="cov")
Error in assetsMeanCov(edhec, method = "cov") :
         could not find function "isPositiveDefinite"

So, I'm suspecting that there may be a bug in the naming section (or 
elsewhere) in the assetsMeanCov function.

Perhaps you should try the more primitive functions mean() and cov() 
before working with wrapper functions.


   - Brian

More information about the R-SIG-Finance mailing list