Learn R Programming

SharpeR (version 1.4.0)

sr_test: test for Sharpe ratio

Description

Performs one and two sample tests of Sharpe ratio on vectors of data.

Usage

sr_test(
  x,
  y = NULL,
  alternative = c("two.sided", "less", "greater"),
  zeta = 0,
  ope = 1,
  paired = FALSE,
  conf.level = 0.95,
  type = c("exact", "t", "Z", "Mertens", "Bao"),
  ...
)

Value

A list with class "htest" containing the following components:

statistic

the value of the t- or Z-statistic.

parameter

the degrees of freedom for the statistic.

p.value

the p-value for the test.

conf.int

a confidence interval appropriate to the specified alternative hypothesis. NYI for some cases.

estimate

the estimated Sharpe or difference in Sharpes depending on whether it was a one-sample test or a two-sample test. Annualized

null.value

the specified hypothesized value of the Sharpe or difference of Sharpes depending on whether it was a one-sample test or a two-sample test.

alternative

a character string describing the alternative hypothesis.

method

a character string indicating what type of test was performed.

data.name

a character string giving the name(s) of the data.

Arguments

x

a (non-empty) numeric vector of data values, or an object of class sr, containing a scalar sample Sharpe estimate.

y

an optional (non-empty) numeric vector of data values, or an object of class sr, containing a scalar sample Sharpe estimate. Only an unpaired test can be performed when at least one of x and y are of class sr

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less". You can specify just the initial letter.

zeta

a number indicating the null hypothesis offset value, the \(S\) value.

ope

the number of observations per 'epoch'. For convenience of interpretation, The Sharpe ratio is typically quoted in 'annualized' units for some epoch, that is, 'per square root epoch', though returns are observed at a frequency of ope per epoch. The default value is 1, meaning the code will not attempt to guess what the observation frequency is, and no annualization adjustments will be made.

paired

a logical indicating whether you want a paired test.

conf.level

confidence level of the interval.

type

which method to apply.

...

further arguments to be passed to or from methods.

Author

Steven E. Pav shabbychef@gmail.com

Details

Given \(n\) observations \(x_i\) from a normal random variable, with mean \(\mu\) and standard deviation \(\sigma\), tests $$H_0: \frac{\mu}{\sigma} = S$$ against two or one sided alternatives.

Can also perform two sample tests of Sharpe ratio. For paired observations \(x_i\) and \(y_i\), tests $$H_0: \frac{\mu_x}{\sigma_x} = \frac{\mu_u}{\sigma_y}$$ against two or one sided alternative, via sr_equality_test.

For unpaired (and independent) observations, tests $$H_0: \frac{\mu_x}{\sigma_x} - \frac{\mu_u}{\sigma_y} = S$$ against two or one-sided alternatives via an asymptotic approximation.

The one sample test admits a number of different methods:

exact

The default, which is only exact when returns are normal, based on inverting the non-central t distribution.

t

Uses the Johnson Welch approximation to the standard error, centered around the sample value.

Z

Uses the Johnson Welch approximation to the standard error, performing a simple correction for the bias of the Sharpe ratio based on Miller and Gehr formula.

Mertens

Uses the Mertens higher order approximation to the standard error, centered around the sample value.

Bao

Uses the Bao higher order approximation to the standard error, performing a higher order correction for the bias of the Sharpe ratio.

See confint.sr for more information on these types

See ‘The Sharpe Ratio: Statistics and Applications’, section 3.2.1, 3.2.2, and 3.3.1.

References

Sharpe, William F. "Mutual fund performance." Journal of business (1966): 119-138. https://ideas.repec.org/a/ucp/jnlbus/v39y1965p119.html

Pav, S. E. "The Sharpe Ratio: Statistics and Applications." CRC Press, 2021.

See Also

reannualize

sr_equality_test, sr_unpaired_test, t.test.

Other sr: as.sr(), confint.sr(), dsr(), is.sr(), plambdap(), power.sr_test(), predint(), print.sr(), reannualize(), se(), sr, sr_equality_test(), sr_unpaired_test(), sr_vcov(), summary.sr

Examples

Run this code
# should reject null
x <- sr_test(rnorm(1000,mean=0.5,sd=0.1),zeta=2,ope=1,alternative="greater")
x <- sr_test(rnorm(1000,mean=0.5,sd=0.1),zeta=2,ope=1,alternative="two.sided")
# should not reject null
x <- sr_test(rnorm(1000,mean=0.5,sd=0.1),zeta=2,ope=1,alternative="less")

# test for uniformity
pvs <- replicate(128,{ x <- sr_test(rnorm(1000),ope=253,alternative="two.sided")
                        x$p.value })
plot(ecdf(pvs))
abline(0,1,col='red') 
# testing an object of class sr
asr <- as.sr(rnorm(1000,1 / sqrt(253)),ope=253)
checkit <- sr_test(asr,zeta=0)

Run the code above in your browser using DataLab