Continuing to look at the PerformanceAnalytic package and this time the 
function UpsidePotentialRatio

The code in the package is:

> UpsidePotentialRatio
function (Ra, MAR = 0) 
{
    Ra = checkData(Ra, method = "vector")
    r = subset(Ra, Ra > MAR)
    return((sum(r - MAR)/(length(Ra)))/DownsideDeviation(Ra, MAR))
}

I believe there are two problems with this calculation according to my 
understanding of the ratio.

- I think the numerator should be the average return of the observations 
in excess of the MAR, so the lenght(Ra) should be lenght(r).

        (sum(r - MAR)/(length(r)))

- Second the denominator should the the deviation below the MAR, but again 
only for the observations below the MAR. The DownsideDeviation function 
looks to again be using all observations:

> DownsideDeviation
function (Ra, MAR = 0) 
{
    Ra = checkDataVector(Ra)
    r = subset(Ra, Ra < MAR)
    return(sqrt(sum((r - MAR)^2)/(length(Ra))))
}

In here the final "length(Ra)" should be "length(r)"


Thanks for taking a look. The package is very impressive.
	[[alternative HTML version deleted]]

