Now, going back to other characteristics, essentially what I'm, what I'm doing is I'm mirroring with sample statistics, the kinds of things we did in probability theory. Alright. So an important thing for us is a quantile of the distribution. So, when we did value at risk we found, you know, if you want to know with five percent probability, how much money we could loose, we compute the five percent quantile of the return distribution. Now, we have, we, if we have a probability distribution, we can determine the quantile from the inverse of the CDF. But with data, we can also estimate or compute a sample quantile, right? And the sample quantile is often called the empirical quantile or the percentile. So, for some alpha and 01, we can get the hundred times alpha percentile that is, like, the fifth percentile of the data. The fifth percentile of the data is just the data points such that or, sorry, the alpha percentile is the data points such that alpha percent of the data is less than that value, okay? And so essentially, how do you find these empirical quantiles in this ordered data from largest to smallest and the five%, the, the, the fifth percentile is just that point in the data such that five percent is to the left, okay? And, and then, we also have these things called quartiles, the, you know, the first quartile is the twenty-fifth percentile, the second quartile is the median, the third quartile is the seventy-fifth percentile and, and so on. There's something called the interquartile range which is a measure of the, the, you know, the bulk of the distribution. It's just the difference between the third quartile and the first quartile. Now, let's look at actual data. So, if we're looking at the Microsoft data, there's a function of R called the quantile. The quantile function computes the empirical quantiles of the data. And if you just use the quantile function by itself, it gives you the minimum, so the minimum return is -42%. It gives you the first quartile, so it's the twenty-fifth percentile, so -5.3%. 25 percent of the returns are smaller than this value, okay? The, this is the median, the, and the median return is one%, okay? So, and then, the on the right side of the distribution so 75 percent of the returns are less than six percent or 25 percent of the returns are bigger than six%. And then, this is the largest return, it's 34%, okay? Now, for value at risk calculations, we're often interested in the one percent and the five percent empirical quantiles. So, if we look at Microsoft, we use the quantile function, we say, prod is equal, you know, we combine 0.01 and 0.05. Then, we get the one percent quantile and the five percent quantile. So here the one percent empirical quantile is -26%. So , one percent of the returns are less than 26 percent and the five percent empirical quantile is -fourteen percent so five percent of the returns are smaller than -fourteen%, okay? Now again, we can compare, so here are quantiles. These are from the actual data, right? Now, what about quantiles from a normal distribution? So, if I take a normal distribution that has the same mean and standard deviation as the data, then I get these quantiles. So, the one percent is, is -24 percent where as in the data it is -26%. So, the one percent quantile in the data is smaller than the one%t normal quantile, okay? And if we look at the five percent quantile, it's kind of interesting that the normal five percent quantile is actually bigger than, in the empirical data, right? So, that's kind of like saying that data distribution is kind of squished with fat tails relative to the normal, okay? Now, when we're doing value at risk we use quantiles to do the value at risk calculations. So, we can do value at risk with the empirical quantiles, or we can do value at risk from the normal quantiles that use the mean and standard deviation from the actual data. Okay, so, those are two different types of assumptions for doing for doing VAR. Now, if we look at the S and P 500, we can do the same comparison. So, the empirical quantiles for the S and P 500 data, the one percent quantiles minus eleven percent and the five percent quantiles minus 7.5%. Now, it's interesting to compare this to Microsoft. So, with the S and P 500 with say, one percent probability, you could lose eleven percent or more. But with Microsoft, with one percent probability, you could lose 26 percent or more, right? So, that's almost three times as much as what you can lose in the S and P 500. So again, if we think about risk as being the probability of loss, then there's a higher probability of loss associated with Microsoft than there is with the S and P 500. Okay, so okay, so here is the empirical quantiles. And R functions there are lot of functions you can sort data, you can take the minimum and the maximum, you can compute range which is the difference between the minimum and the max, compute your quantiles, the median, you can compute interquartile ranges. So, you have all these, you know, nice functions you know, that, you can work with, the homework assignment, you know, takes you through many things. I want to make a comment about value at risk using empirical quantiles. So, there's something known in, in the finance literature as historical value at risk. When you, when you hear the term historical value at risk, you're computing value at risk using the empirical quantiles, not the quantiles from a normal distribution or something like that, you're just using the empirical quantiles from the data. So, what is actually being computed? So, we have our simple returns and the historical value at risk is your initial investment times the empirical quantile of your simple returns, you know, at the alpha level, okay? So, this is just the, the data point that we use from the quantile function, okay? And, and so, this, this could be an estimate of, of our loss, okay? If we have continuously compounded returns, remember the value at risk then would be e to the continuously compounded quantile -one times your initial investment. So, this would be your value at risk with continuously compounded data. And the key thing is, again, we're using the, just the empirical quantile, we're not using the quantile from, say, a normal distribution, alright? Now so, here's the histogram that gives us the general shape of the distribution. Now, what about shape characteristics? If we want to know the sensor, then we compute the sample average. The sample average is a, is a measure of the center of the distribution and that's just an equally-weighted average of the data points, okay? If we want to know the spread about the average for the histogram, we compute the sample variance. The sample variance, we take one over the sample size minus one, and then we sum all of the observations, we subtract the mean value, we square it. So this is, this is called the sample average. Notice we divide by t - one and not t, okay? We'll come back to this a little bit later on. The reason for dividing by t - one is to make the estimates slightly, a little bit better. We, we have what's called an unbiased estimate of spread when you divide by t minus one. The sample standard deviation is the square root of the sample variance. Again, that's the an estimate of the spread about the average in the same units as the data. One of the things I want to point out about notation you know, the sample average is often denoted as x bar, and sometime as just mu hat. So, the Greek letter represents the probably, the expected value of a random variable, and when you put a hat on top of it, that means we're estimating that expected value. And here, we're estimating the expected value using the sample average. This is known as the plug in principle in Statistics. So, we plug in a sample statistic for a population expectation. And for sample variance, we often, you often see little s ^two for sample variance and sometimes we also call it sigma hat squared. So, again that's just terminology. And then, similarly, we can compute a sample skewness. Sample skewness, we take the average of the observations minus the mean cube divided by the standard deviation cube and again, we divide by t - one to make this an unbiased estimate. And then, sample kurtosis, this is measuring the thickness in the tails. We sum up the observations, we subtract the mean, we raise it to the power of four, we divide by the standard deviation to a fourth. Okay, that's the estimated kurtosis and estimated axis kurtosis would be this kurtosis -three, okay. And again we, axis kurtosis gives us a measure of tail thickness relative to a normal distribution, okay? So, we have sample statistics that give us the shape characteristics of the histograms. So, in R, we have set of functions. So, the mean function computes the sample mean. The bar function can be the variance, SD compute standard deviation. Core R actually doesn't have functions for skewness and kurtosis. So, I like to use the skewness and kurtosis functions from the performance analytics package. This performance analytics package in general, is a very nice collection of functions that are useful in Finance. They are very nice charting functions and they have a number of utility functions that are, that are quite useful. In our, in our labs we are going to be using the performance analytics functions quite a lot. So, you should become familiar with, with this package, okay? Now, one of the things I wanted to say about R and I'll come back to this here when you calculate, when you use the mean function, you only work on either a vector of data or one column of data at a time. If you have many return series, say, in a matrix, often, very often you want to compute the mean for each column, alright? The mean function doesn't work column wise. And so, in R, when you want to apply a function to the columns of data, there's a function called apply. And, and so this, the apply function essentially implement a loop. You loop over the columns and then you apply the function to the column itself. I'll illustrate how this works. These apply functions are very, very, very useful particularly, say, if you have a thousand assets and you want to compute the means for each of the thousand assets, you can do it in one command by, by using the apply function. Alright. So, let's look at some of the sample statistics. So, for the mean return for Microsoft is 0.006. So, this is the monthly mean and it's about it's a little less, a little less than one percent per month, okay. The variance is 0.01, now that's in squared returns, the standard deviation is in returns. The typical spread about the average is ten%, okay? Remember, this is a monthly return. So remember mean plus and minus the standard deviation for bell-shaped data gives you roughly two-thirds of the observations. So, two-thirds of the observations on Microsoft are between -ten percent and ten%, okay? So, losing ten percent in a month is, is quite a lot actually. The sample skewness is negative. So in the picture, we saw a long left tail and when you use the skewness function for Microsoft, you do get a negative skewness number. And the kurtosis function, actually gives you axis kurtosis. So don't, don't be fooled by this. The fact that it's kurtosis, when you look at the help and performance analytics, you find that what's actually been computed as sample kurtosis -three. So, axis kurtosis is 1.8 so the actual kurtosis is 4.8. So, the Microsoft data have fatter tails than the normal distribution. So, we're seeing a mean return of, you know, 0.6 percent per month, a standard deviation of ten percent per month, a negative skewness, and an axis kurtosis, okay? Now, suppose we had a matrix of data that contains, the first column contains the data from Microsoft and the second column contains the date for the S and P 500. And I want to compute the means of each of the columns of this, this matrix. This is where we use the apply function. So you, say, apply your data matrix and then this parameter two means apply to the columns. If this parameter was one then you would apply the function to the rows, okay? So, this means apply to the columns and what are you applying? You're applying the mean function. And so, what do you get? You get the mean for the first column, the mean for the second column, okay? So here, we can compare Microsoft and the S and P 500. The average return for Microsoft is 0.6%. The average return for the S and P 500 is 0.3%. So, on average, we get about twice as much per month on Microsoft than we do for the S and P 500, okay? Now, what about the standard deviations? So, the standard deviation for Microsoft is ten%, actually it's, it's about eleven%, and the standard deviation for the S and P 500 is only four%, right? So here, the spread about the average for Microsoft is, is about 2-1/2 times bigger than that for the S and P 500. Notice that the mean for Microsoft is higher than the mean for the S and P 500, and the standard deviation for Microsoft is bigger than the standard deviation for the S and P 500. So, we're seeing assets that have higher volatility, has, has a higher mean, the asset with a lower volatility has a lower mean, okay? If you were using daily data instead of monthly data, data, we would get a better analysis of the tail. And in general, the answer is yes, because we have more daily data than monthly data. And so, we have more information in the tail with daily data than we do with monthly data. Okay. So and then we have the skewness for Microsoft, S and P 500, both have negative skewness, and the skewness for S and P 500 is quite a bit bigger, is a bigger negative number than for Microsoft. And the axis kurtosis is bigger for Microsoft than it is for the S and P 500. So, again, just some comparisons.