Student’s t: location-scale
Motivation
Often when we examine financial data, we find that logarithmic returns exhibit fatter tails than the normal distribution. Hence, we need a distribution with more probability mass in the tails, and – coming from traditional financial mathematics with normally distributed log-returns – the natural first choice is the student’s -distribution.
However, the standard student’s -distribution has zero mean, and a variance determined through its degrees of freedom parameter. This is usually too restrictive, since one major characteristic of financial data is changing volatility, which ideally should be captured without further changes of the shape of the distribution. To gain such extended flexibility, the student’s -distribution can be extended through linear transformation, so that mean, standard deviation and tails can be adapted flexibly.
Standard student’s t-distribution
For the variance depends on the degrees of freedom parameter :
## set parameter nu <- 8 ## number of samples n <- 10000 ## simulate t <- rt(n,nu) ## analytically calculated variance variance <- nu/(nu-2) sprintf("True variance: %f",variance) ## get sample variance sprintf( "Sample variance: %f",var(t))
: [1] “True variance: 1.333333” : [1] “Sample variance: 1.291841”
Location-scale transformation
Through application of a linear transformation, we can easily shift the center of the distribution and affect the divergence from its mean.
Note, that the standard deviation of the new random variable does not equal the scaling factor , but is a composition of scaling factor and original standard deviation determined by .
The cumulative distribution function after the transformation can easily be obtained through:
Taking this result, we can derive the inverse cdf:
Getting the density of is slightly more demanding, since we need an additional rescaling in order to guarantee that integration of the density function still yields an area of 1. Hence, we need to apply the transformation theorem:
with given by .
Calculating requires exchanging and and solving for :
Taking the derivative:
Putting the parts together, we get:
Implementation
The functions now can be implemented in R. We use the code provided by wikipedia:
dt_ls <- function(x, df, mu, a) 1/a * dt((x - mu)/a, df) pt_ls <- function(x, df, mu, a) pt((x - mu)/a, df) qt_ls <- function(prob, df, mu, a) qt(prob, df)*a + mu rt_ls <- function(n, df, mu, a) rt(n,df)*a + mu
We can now try to fit the t-location-scale distribution to simulated data.
library(MASS) ## set parameters n <- 10000 mu <- 0.4 a <- 1.2 nu <- 4 ## simulate values simVals <- rt_ls(n, nu,mu,a) fit <- fitdistr(simVals,"t") print(fit)
There were 12 warnings (use warnings() to see them) m s df 0.40849216 1.20630991 4.00772609 (0.01427656) (0.01498895) (0.16515696)
Posted on 2013/04/30, in financial econometrics, R and tagged fat_tails, location-scale, Rbloggers, Student's_t, t. Bookmark the permalink. 2 Comments.
Pingback: Model Checking: Posterior Predictive Checks – Laplace Bayes
Pingback: Model Checking: Posterior Predictive Checks – DataCATz