Skip to content

Error with MAR if it is a vector of returns #191

@XanderDes

Description

@XanderDes

Description

When using SortinoRatio(Stats_Data$EQ, MAR = Stats_Data$RF), I got the following error:

Error in DownsideDeviation(R, MAR) :
dims [product 71] do not match the length of object [197]
In addition: Warning message:
In MAR - r :
longer object length is not a multiple of shorter object length

Stats_Data is a grouped tibble and EQ and RF are columns with equity and risk-free returns, resp. They are numerical, of equal length and without any NAs.
The same error occurs with randomly generated data (see below).

Expected behavior

I would have expected an output as the one returned for MAR = 0:

SortinoRatio(Stats_Data$EQ, MAR = 0)
                              [,1]
Sortino Ratio (MAR = 0%) 0.6913074

Minimal, reproducible example

On randomly generated data:

Rand_EQ <- rnorm(100)  # Random returns
Rand_RF <- rnorm(100, mean = 0.01)  # Random benchmark returns

DownsideDeviation(Rand_EQ, MAR = 0)  # Results in 0.5808906
DownsideDeviation(Rand_EQ, MAR = Rand_RF)  # Results in error

Session Info

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions