SlideShare a Scribd company logo
PERFORMANCE
ANALYSIS WITH (I)
Jérémy Morvan
Assistant professor
January 2018
Université de Bretagne Occidentale
INTRODUCTION
2
Introduction
• Financial performance assessment is an important issue
• An economic issue
• Financialization of the economy has led financial markets to drive
economic coordination
• A methodological issue
• How assessing portfolio performance?
• A theoretical issue
• How do financial markets work?
3
Introduction
• This course is an introduction to financial performance
analysis by using the programming language R
• What is performance in finance?
• What are the expected results according to modern portfolio
theory?
• What are the measures of performance?
4
Introduction
• Contents (I)
1. Performance in finance
2. Descriptive statistics
3. Histogram and Normality tests
4. Mean-variance analysis
5
I. WHAT IS PERFORMANCE IN
FINANCE?
6
Performance in finance
• Historical
• Performance analysis is one of the basic issues that built the
modern portfolio theory
• Bachelier (1900) highlights that the rise and the fall of prices are
equiprobable at any time
• Prices fluctuate randomly
• Cowles (1933, 1944) highlights that investment advices from financial
analysts do not allow to outperform the market
• It is impossible to predict future prices
7
Performance in finance
• Efficient market hypothesis
• Definition
8
[…] the ideal is a market in which prices provide accurate signal for ressource
allocation: that is, a market in which firms can make production-Investment decisions,
and investors can choose among the securities that represent ownership of firms’
activities under the assumption that security prices at any time "fully reflect" all
available information. A market in which prices always "fully reflect" available
information is called "efficient". (Fama E., 1970)
[the market efficiency hypothesis is] the simple statement that security prices fully
reflect allavailable information. A precondition for this strong version of the hypothesis
is that information and tranding costs, the costs of getting prices to reflect information,
are always 0 (Grossman and Stiglitz (1980). A weaker and enconomically more
sensible version of the efficiency hypothesis says that prices reflect information to the
point where the marginal benefits of acting on information (the profits to be made) do
not exceed the marginal costs (Jensen (1978). (Fama E., 1991)
Performance in finance
• Efficient market hypothesis
• Definition
• The definition of efficient markets varies according to the informational
set considered (Fama, 1970)
9
Present information
(semi-strong form
efficiency)
Past information
(weak-form
efficiency)
All information sets,
including private
information (strong-
form efficiency)
Performance in finance
• Efficient market hypothesis
• Consequences
• Price is an unbiased estimate of the intrinsic value of a security
• There is no better financial analyst than the market
• Future variations are independent of past variations
• Random walk theory
• Investors cannot forecast prices successully
• The theory assumes that managers do not add value (a) to the portfolio
10
Performance in finance
• Efficient frontier (Markowitz, 1952)
• The efficient frontier is the set of optimal portfolios that offers the
highest expected return for a given level of risk or the lowest risk for
a defined level of expected return
• Two stochastic dominance decision rules
• An efficient portfolio optimizes the risk/reward ratio
• A diversified portfolio should have at least 50 investments (see Euro
Stoxx 50)
11
At a given level of return,
investors choose the less
risky asset
At a given level of risk,
investors choose the asset
with highest returns
Performance in finance
• Efficient frontier (Markowitz, 1952)
• Well-diversified portfolios tend to have similar return (given account
the risk) and rare extreme returns
12
Asset 1
Asset 2
Rf
0,00%
2,00%
4,00%
6,00%
8,00%
10,00%
12,00%
14,00%
0,00% 5,00% 10,00% 15,00% 20,00% 25,00%
Return (Ri)
Volatility (si)
Portfolio of two risky assets Portfolio with one risky asset and the risk free asset
Performance in finance
• Expected results
• Financial performance integrates return and risk
• There are several measures of return (max, mean…) and risk (min, s,
VaR…)
• Returns are random
• The most common representation of randomness is the Gaussian
distribution
• A skilled manager shows a similar performance to the market given
the risk
• Outperformance is impossible
• Underperformance is possible
13
A great number of causes Causes are independant
Each cause has
a small effect
Performance in finance
• Critics
• Behavioral Finance
• Many behavioral biases impact investment decisions
• Market anomalies
• Calendar anomalies
• "January effect" is an abnormal increase in stock prices in January
• "Weekend effect": stock returns on Monday are often significantly lower
• Other anomalies
• Small firms tend to outperfom
• There is a negative relation between PER and returns and between market to
book ratio and returns
• The Gaussian distribution imperfectly represents return ditribution
• … by underestimating risk
14
2. DATA ANALYSIS
15
Data analysis
• Definition
• Statistical procedure to determine the main characteristics of a
dataset
• We use the programming language
16
#install packages (collections of functions which allow more
statistical techniques, and graphical devices)
install.packages("quantmode")
install.packages("fBasics")
install.packages("moments")
install.packages("PerformanceAnalytics")
install.packages("normtest")
install.packages("tseries")
install.packages("roll")
install.packages("xts")
Data are available in the data.csv file with
- Pi are daily closing prices of the stock i
- Pm are daily closing prices of the market index m
- RFR are daily closing rates of a 10-year constant maturity fictitious sovereign bond
• Calculation of daily returns
• Logarithmic returns are a better measure
17
#read data
data<-read.csv2(file= file.choose(),header = TRUE,sep = ";",dec = ",")
#Compute daily returns
library(quantmode)
data$Ri<-Delt(x1 = data$Pi,x2 = NULL,k = 1,type = "log")
data$Rm<-Delt(x1 = data$Pm,x2 = NULL,k = 1,type = "log")
data$Rf<-log(1+data$RFR/250)
#Clean up data object
#suppress 1st row
data<-data[-1,]
#suppress colums 2,3,4 (we only keep colums 1, 5 to 7)
data<-data[,c(1,5:7)]









1,
,
, ln
ti
ti
ti
R
R
R
Data analysis
If the package “quantmode” doesn’t
work (it happens !), we can compute
daily returns as follows data$Ri[2:774]<-log(data$Pi[2:774]/data$Pi[1:773])
data$Ri[2:774]<-diff(log(data$Pi))
• Descriptive statistics
• Main measures
18
Ri Rm Rf
nobs 773.000000 773.000000 774.000000
NAs 0.000000 0.000000 0.000000
Minimum -0.035737 -0.032272 0.000093
Maximum 0.035524 0.025047 0.000156
I. Quartile -0.004088 -0.004349 0.000114
3. Quartile 0.005653 0.005855 0.000142
Mean 0.000491 0.000529 0.000127
Median 0.000639 0.000844 0.000130
Sum 0.379467 0.409023 0.097973
SE Mean 0.000298 0.000299 0.000001
LCL Mean -0.000094 -0.000057 0.000125
UCL Mean 0.001075 0.001115 0.000128
Variance 0.000069 0.000069 0.000000
Stdev 0.008278 0.008300 0.000017
Skewness -0.369131 -0.391430 -0.352644
Kurtosis I.794045 I.091768 -1.073065
 



n
t
itii RR
n 1
2
,
2
1
1
s
  

n
t
tiii R
n
RRE
1
,
1
library(fBasics)
basicStats(data[,2:4])















 

3
i
ii
i
RR
ESk
s















 

4
i
ii
i
RR
EK
s
Data analysis
• Descriptive statistics
• Main measures
19
Measures Definition
Mean
In finance, mean is a performance measure
The average is calculated on daily data. It must be annualized (n = 252 days)
Variance
In finance, the variance is a risk measure
The variance is calculated on daily data. It must be annualized
The variance is expressed in the square of the unit of measure ("%²"). The
standard deviation is the square root of the variance.
yMean.Ri<-mean(data$Ri)*252
yMean.Rm<-mean(data$Rm)*252
ySD.Ri<-sd(data$Ri)*sqrt(252)
ySD.Rm<-sd(data$Rm)*sqrt(252)
Data analysis
• Descriptive statistics
• Main measures
20
Measures Definition
Skewness
(Sk)
Skewness is a measure of asymmetry of the probability distribution
• If > 0, the most part of the distribution is concentrated on the left of the figure (the right tail
is longer)
• If < 0, the most part of the distribution is concentrated on the right of the figure (the left tail
is longer)
Kurtosis
(K)
Kurtosis is a measure of of the probability distribution (1 < K < ∞)
• If > 3, leptokurtic distribution (the data are heavy-tailed: extreme returns are more frequent
than predicted by the gaussian distribution)
• If < 3, platykurtic distribution (the data are light-tailed: extreme returns are less frequent
than predicted by the gaussian distribution)
Data analysis
Data analysis
• Descriptive statistics
• Main measures
• Some measures of kurtosis
• Kurtosis is sometimes calculated in excess of 3
21
[1] 1.794045
attr(,"method")
[1] "excess“
[1] 4.794045
[1] 1.806473
[1] 4.806473
library(moments)
kurtosis(data$Ri)
mean(((data$Ri-mean(data$Ri))/sd(data$Ri))^4)
library(PerformanceAnalytics)
kurtosis(data$Ri, na.rm = FALSE, method = "excess")
kurtosis(data$Ri, na.rm = FALSE, method = "moment")
Most explicit
command!
Data analysis
• Descriptive statistics
• Main measures
• Some measures of skewness
22
library(moments)
skewness(data$Ri)
mean(((data$Ri-mean(data$Ri))/sd(data$Ri))^3)
library(PerformanceAnalytics)
skewness(data$Ri, na.rm = FALSE)
Delt.1.log
-0.3698488
[1] -0.3691314
[1] -0.3698488
There are sometimes
(small) differences in
the results
3. NORMALITY TESTS
23
Normality tests
• Histogram of returns
• For financial theory, markets evolve randomly
• A common representation of randomness is the Gaussian distribution
• The Gaussian distribution has a causal structure that defines a relatively
stable world
• ... consistent with the EMH (and perfect competition)
• Extreme returns are rare
• Returns around mean are the most frequent
24
Brownian motion Stochastic process Random walk
Normality tests
• Histogram of returns
• Definition
• Graphic that represents the distribution of numerical data
• It is a graphical way to compare empirical and theoretical distributions
25
hist(data$Ri,main = "Histograms of Ri and Rm", breaks = 100, freq =
FALSE, xlab = "Ri", xlim = c(min(data$Ri,data$Rm),
max(data$Ri,data$Rm)), col = "green",axes = F)
axis(1, pos = 0, cex.axis = 0.8)
axis(2,pos = 0,cex.axis = 0.8,las = 2)
hist(data$Rm,breaks = 50, freq = FALSE, xlim =
c(min(data$Ri,data$Rm), max(data$Ri,data$Rm)), col = "red",,axes =
F,add = TRUE)
curve(dnorm(x, mean(data$Ri), sd(data$Ri)), xlim = c(min(data$Ri),
max(data$Ri)), lwd = 2,col = "grey", add = TRUE)
curve(dnorm(x, mean(data$Rm), sd(data$Rm)), xlim = c(min(data$Rm),
max(data$Rm)), lwd = 2,col = "red", add = TRUE)
legend("topleft",c("Histogram of Ri","Histogram of Rm"),lty =
c(1,1),col = c("green","red"),bty = "n")
Normality tests
• Histogram of returns
26
Sharper
distribution
Less returns
than expected
on both sides
"fat" tails
Normality tests
• Histogram of returns
• The Gaussian distribution poorly approximates the return
distribution
• It underestimates the probability of extreme returns
27
(min(data$Ri)-mean(data$Ri))/sd(data$Ri)
pnorm(q = (min(data$Ri)-mean(data$Ri))/sd(data$Ri),mean = 0,sd =
1, lower.tail = TRUE, log.p = FALSE)
format(x = pnorm(q = -4.376432,mean = 0,sd = 1, lower.tail =
TRUE,log.p = FALSE),scientific = FALSE, digits = 10)
format(x = 1/(pnorm(q = -4.376432, mean = 0, sd = 1,TRUE,
FALSE)*nrow(data$Ri)), scientific = FALSE, digits = 10)
[1] -4.376432
[1] 6.03189e-06
[1] "0.000006031890184"
[1] "214.4702608"
the worst return occurred 1 time
out of 773 or 214 times too
often…
• Normality test of distributions
• Jarque-Bera non-parametric test (1980) (for n >> 0)
• H0: Sk = 0 and K = 3 (the data follows a Gaussian distribution)
• H1: Sk ≠ 0 or K ≠ 3 (the data do not follow a Gaussian distribution)
28
Jarque-Bera test for normality
data: data$Ri
JB = 122.73, p-value < 2.2e-16
Title:
Jarque - Bera Normalality Test
Test Results:
STATISTIC:
X-squared: 122.7298
P VALUE:
Asymptotic p Value: < 2.2e-16
Jarque Bera Test
data: data$Ri
X-squared = 122.73, df = 2, p-value < 2.2e-16
  






22
3
4
1
6
ii
i
i KSk
n
JB
Normality tests
library(normtest)
jb.norm.test(data$Ri)
library(fBasics)
jarqueberaTest(data$Ri)
library(tseries)
jarque.bera.test(data$Ri)
Normality tests
• Normality test of distributions
• Non-parametric test of Kolgomorov-Smirnov
• H0: D = D0 (the data follow the Gaussian distribution)
• H1: D ≠ D0 (the data do not follow the Gaussian distribution)
29
Title: One-sample Kolmogorov-Smirnov test
Test Results:
STATISTIC:
D: 0.4878
P VALUE:
Alternative Two-Sided: < 2.2e-16
Alternative Less: < 2.2e-16
Alternative Greater: < 2.2e-16
library(fBasics)
ksnormTest(data$Ri)
At a = 10%, criticial value = 1,223/√n
At a = 5%, criticial value = 1,358/ √n
At a = 1%, criticial value = 1,629/ √n
If oberved value D > criticial value, H0 is rejected
3. MEAN-VARIANCE ANALYSIS
30
• Definition
• Combination of statistical hypothesis tests
• Parametric tests assume that sample data follow a probability
distribution based on a given set of parameters
• Two risks of error
• The type I error rate is the probability of rejecting the null hypothesis
given that it is true
• The type I error is the p-value (or significance level) a = 1%, 5% or 10%
• The type II error occurs when the null hypothesis is false, but is not
rejected
• The rate of the type II error (b is linked to the power of the test (1− b)
31
Mean-variance analysis
F-test of equality of
variances
Student t-test
Parameter
Null hypothesis
(H0)
Alternative
hypothesis (H1)
• Definition
• Combination of two statistical hypothesis tests on variance and
mean
32
21 mm 
21 mm 
22
1 2
ss 
22
1 2
ss 
1
1
2
2
22
1
2
11
1;1 21



n
Sn
n
Sn
F nn
   
 
2
11
21
21
2
22
2
11
2121
221









 nn
nn
SnSn
mmXX
T nn
When n1 = n2, 2
2
2
1
1;1 21
S
S
F nn 
Mean-variance analysis
• Parametric tests
• Decision rule
• F-test of equality of variances
• Student t-test
33
0
H0 is valid H0 is rejected
1 Critical value
at 10%
Critical value
at 5%
Critical value
at 1%
The value is more and more frequently calculated
• If p value < 1%, H0 is rejected at 1% (***)
• If p value < 5%, H0 is rejected at 5% (**)
• If p value < 10%, H0 is rejected at 10% (*)
Mean-variance analysis
H0 is valid H0 is rejected
Critical value
at 10%
Critical value
at 5%
Critical value
at 1%
• Parametric tests
• F-test of equality of variances
• Is the variance of Ri different from the variance of Rm?
34
F test to compare two variances
data: data$Ri and data$Rm
F = 0.99478, num df = 772, denom df = 772, p-value = 0.9421
alternative hypothesis: true ratio of variances is not equal to 1
95 percent confidence interval:
0.8637999 1.1456325
sample estimates:
ratio of variances
0.994785
var.test(x = data$Ri,y = data$Rm)
The test
doesn’t follow
the convention
2
2
2
1 ss 
Mean-variance analysis
ifelse(var(data$Ri) > var(data$Rm), var(data$Ri) / var(data$Rm),
var(data$Rm) / var(data$Ri))
• Parametric tests
• Student t-test
• Is the mean of Ri different from the mean of Rm?
35
Paired t-test
data: data$Ri and data$Rm
t = -0.13619, df = 772, p-value = 0.8917
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.0005893457 0.0005128742
sample estimates:
mean of the differences
-3.823577e-05
t.test(x = data$Ri,y = data$Rm,paired = TRUE)
Mean-variance analysis
• Critics
36
Strenghts Weaknesses
Mean-variance analysis
The criticisms are
especially of
financial nature
• Critics
• Volatility is not stable over time
• Calculation of 20 day rolling volatility
37
#Computing 20 day rolling Std dev
library(roll)
data$SD_Ri<-roll_sd(data$Ri,width = 20)*sqrt(252)
data$SD_Rm<-roll_sd(data$Rm,width = 20)*sqrt(252)
#Converting date data to date format
date<-as.Date(data$Date,format = "%d/%m/%Y")
data<-cbind(date,data[,-1])
library(xts)
data<-xts(data[,2:6],order.by = data[,1])
#Drawing plot
windows()
plot(data$SD_Ri[23:773], xlab = "Date", ylab = "Annualized Std
Dev",type = "l", col = "green")
lines(data$SD_Rm,col = "red")
legend("topleft",c("Std dev of Ri","Std dev of Rm"),lty =
c(1,1),col = c("green","red"),bty = "n")
title(main = "20 day rolling std dev of Ri and Rm")
Mean-variance analysis
38
Mean-variance analysis
• Critics
• Volatility is not stable over time
Mean-variance analysis
• Critics
• Volatility is not stable over time
data<-read.csv2(file.choose(),header=T,sep=";",dec=",")
data$Ri[2:774]<-diff(log(data$Pi))
data<-data[-1,]
library(roll)
data$Ri<-as.matrix(data$Ri)
data$SD_Ri<-roll_sd(data$Ri,width = 20)*sqrt(252)
windows()
par(mfrow=c(2,1))
plot(data[,2],type="h",col="grey",xlab="Date",ylab="Price
(€)",ylim=c(round(min(data[,2])-5),round(max(data[,2])+5)),axes=F)
axis(1,pos=40)
axis(2,pos=0)
title(main="Price of i")
plot(data[,6],type="h",col="grey",xlab="Date",ylab="20 day rolling
volatility (%)",ylim=c(0,0.35),axes=F)
axis(1,pos=0)
axis(2,pos=0)
title(main="20 day rolling volatility of i")
Mean-variance analysis
• Critics
• Volatility is
not stable
over time
CONCLUSION
41
Conclusion
• Statistics is “the science of collecting, analyzing,
presenting, and interpreting data”
• Descriptive statistics summarize the population data
• The histogram and the normality test make it possible to evaluate
the adequacy between a variable and the statistical law of
reference
• The expectation variance analysis allows a comparison of the
variables
42
Conclusion
• Financial modelling seeks to improve the mathematical
representation of the behavior of securities
• Monofactorial models are the precursors
• Market model (Sharpe, 1963)
• Capital Asset Pricing Model (Lintner, 1965)
• Multifactor models try to integrate more variables
• Market timing (Treynor-Mazuy, 1966)
• Arbitrage pricing theory (Ross, 1976)
• Fama-French three factor model (1993)
• Carhart four factor model (1997)
43
References
Finance
• Bachelier L. (1900), Théorie de la spéculation, Annales scientifiques de l’ENS, (17)3, 21-86
• Carthart M. (1997), “On persistence of Mutual Fund Performance”, Journal of Finance, (52), 57-82
• Cowles A. (1933), “Can Stock Market Forecasters Forecast?”, Econometrica, (1)3, 309-324
• Cowles A. (1944), “Stock Market Forecasting”, Econometrica, (12)3-4, 206-214
• Fama E. (1970), “Efficient Capital Markets: A review of Theory and Empirical Work”, Journal of Finance,
(25)2, 383-417
• Fama E. (1991), “Efficient Capital Markets”, Journal of Finance, (46)5, 1575-1617
• Fama E., K. French (1993), “Common Risk Factors in the Returns on Stocks and Bonds”, Journal of
Financial Economics, (33), 3-56.
• Lintner J. (1965), “The valuation of risk assets and the selection of risky investments in stock portfolios and
capital budgets”, Review of Economics and Statistics, 47(1), 13–37
• Markowitz H. (1952), “Portfolio Selection”, Journal of Finance, (7)1, 77-91
• Ross S. (1976), "The Arbitrage Theory of Capital Asset Pricing". Journal of Economic Theory, (13)3, 341-
360
• Sharpe W. (1963), “A Simplified Model for Portfolio Analysis”, Management Science, (9)2, 277-293
• Treynor, J., Mazuy, K. (1966), “Can Mutual Funds Outguess the Market?” Harvard Business Review, (44),
131-136
Statistics
• Jarque C., Bera A. (1980). “Efficient tests for normality, homoscedasticity and serial independence of
regression residuals”, Economics Letters. (6) 3, 255–259
44
References
• Programming with R
45

More Related Content

PPT
PPTX
henry fayol principles business studies class 12th
PPT
Random Portfolio using R to create investment strategy for Hedge Fund
PPTX
1.1.Introduction Econometrics.pptx
PPT
PPT
The Process of Portfolio Management
PPT
The Process Of Portfolio Management
PDF
BlueBookAcademy.com - Risk, Return & Diversification Techniques
henry fayol principles business studies class 12th
Random Portfolio using R to create investment strategy for Hedge Fund
1.1.Introduction Econometrics.pptx
The Process of Portfolio Management
The Process Of Portfolio Management
BlueBookAcademy.com - Risk, Return & Diversification Techniques

Similar to Performance analysis with R (20)

PPT
RISK+AND+RETURN+I.ppt
PDF
Unit_2_IAPM_PPT.pdf
PDF
CFA 2024 SCH L2 QS for exam preparations
PPT
Value at risk powerpoint presentation with its methods
PPT
WhatisVaRYouKnowThatLetItGoorLetItBe.ppt
PPT
CompleteTrainingofValueAtRiskTypeofRisk.ppt
PPTX
Statistical analysis
PPTX
capmandaptmodels presentation and its details
PPTX
Business Finance Chapter 11 Risk and return
PPT
Portpolio mgt.ch01
PPT
Portfolio management
PPT
Perfmeasure.ppt
PPT
Chap013 Return, Risk, and the Security Market Line.ppt
PPT
Hidden Treasure of High Frequency Dynamics
PPT
HTHFD
PDF
An Introduction to high frequency finance and market microestructure
PPTX
The process of portfolio management
PPT
Portfolio Construction.ppt kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPT
EVALUATION OF PORTFOLIO OUTLINES, PRACTICES
RISK+AND+RETURN+I.ppt
Unit_2_IAPM_PPT.pdf
CFA 2024 SCH L2 QS for exam preparations
Value at risk powerpoint presentation with its methods
WhatisVaRYouKnowThatLetItGoorLetItBe.ppt
CompleteTrainingofValueAtRiskTypeofRisk.ppt
Statistical analysis
capmandaptmodels presentation and its details
Business Finance Chapter 11 Risk and return
Portpolio mgt.ch01
Portfolio management
Perfmeasure.ppt
Chap013 Return, Risk, and the Security Market Line.ppt
Hidden Treasure of High Frequency Dynamics
HTHFD
An Introduction to high frequency finance and market microestructure
The process of portfolio management
Portfolio Construction.ppt kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
EVALUATION OF PORTFOLIO OUTLINES, PRACTICES
Ad

More from Jérémy Morvan (15)

PDF
III Gestion risque obligataire
PDF
IV Gestion risque de change
PDF
Introduction gestion des risques
PDF
Financial markets: Theoretical Perspectives
PDF
Analyse de la performance financière avec R
PDF
Socially Responsible Investment (SRI)
PDF
Presentation investissement socialement responsable
PDF
Monetary policy: monetary orthodoxy or quantitative easing?
PDF
Politique monétaire
PDF
Un siècle d'évolution des marchés financiers (1914 2015)
PDF
R for research in finance
PDF
Partie II - Strategie et gouvernance universitaires
PDF
Partie I - L'université et sa gouvernance
PDF
Partie III - Gestion opérationnelle universitaire
PDF
La direction d'une composante universitaire en France
III Gestion risque obligataire
IV Gestion risque de change
Introduction gestion des risques
Financial markets: Theoretical Perspectives
Analyse de la performance financière avec R
Socially Responsible Investment (SRI)
Presentation investissement socialement responsable
Monetary policy: monetary orthodoxy or quantitative easing?
Politique monétaire
Un siècle d'évolution des marchés financiers (1914 2015)
R for research in finance
Partie II - Strategie et gouvernance universitaires
Partie I - L'université et sa gouvernance
Partie III - Gestion opérationnelle universitaire
La direction d'une composante universitaire en France
Ad

Recently uploaded (20)

PPTX
Session 14-16. Capital Structure Theories.pptx
PPTX
Introduction to Managemeng Chapter 1..pptx
PDF
Understanding University Research Expenditures (1)_compressed.pdf
PPT
E commerce busin and some important issues
PDF
6a Transition Through Old Age in a Dynamic Retirement Distribution Model JFP ...
PPTX
Antihypertensive_Drugs_Presentation_Poonam_Painkra.pptx
PPTX
Introduction to Customs (June 2025) v1.pptx
PPTX
How best to drive Metrics, Ratios, and Key Performance Indicators
PPTX
social-studies-subject-for-high-school-globalization.pptx
PPTX
OAT_ORI_Fed Independence_August 2025.pptx
PDF
ECONOMICS AND ENTREPRENEURS LESSONSS AND
PDF
Dialnet-DynamicHedgingOfPricesOfNaturalGasInMexico-8788871.pdf
PPTX
kyc aml guideline a detailed pt onthat.pptx
PDF
ECONOMICS AND ENTREPRENEURS LESSONSS AND
PPTX
introuction to banking- Types of Payment Methods
PDF
HCWM AND HAI FOR BHCM STUDENTS(1).Pdf and ptts
PDF
Mathematical Economics 23lec03slides.pdf
PDF
Q2 2025 :Lundin Gold Conference Call Presentation_Final.pdf
PDF
THE EFFECT OF FOREIGN AID ON ECONOMIC GROWTH IN ETHIOPIA
PPT
KPMG FA Benefits Report_FINAL_Jan 27_2010.ppt
Session 14-16. Capital Structure Theories.pptx
Introduction to Managemeng Chapter 1..pptx
Understanding University Research Expenditures (1)_compressed.pdf
E commerce busin and some important issues
6a Transition Through Old Age in a Dynamic Retirement Distribution Model JFP ...
Antihypertensive_Drugs_Presentation_Poonam_Painkra.pptx
Introduction to Customs (June 2025) v1.pptx
How best to drive Metrics, Ratios, and Key Performance Indicators
social-studies-subject-for-high-school-globalization.pptx
OAT_ORI_Fed Independence_August 2025.pptx
ECONOMICS AND ENTREPRENEURS LESSONSS AND
Dialnet-DynamicHedgingOfPricesOfNaturalGasInMexico-8788871.pdf
kyc aml guideline a detailed pt onthat.pptx
ECONOMICS AND ENTREPRENEURS LESSONSS AND
introuction to banking- Types of Payment Methods
HCWM AND HAI FOR BHCM STUDENTS(1).Pdf and ptts
Mathematical Economics 23lec03slides.pdf
Q2 2025 :Lundin Gold Conference Call Presentation_Final.pdf
THE EFFECT OF FOREIGN AID ON ECONOMIC GROWTH IN ETHIOPIA
KPMG FA Benefits Report_FINAL_Jan 27_2010.ppt

Performance analysis with R

  • 1. PERFORMANCE ANALYSIS WITH (I) Jérémy Morvan Assistant professor January 2018 Université de Bretagne Occidentale
  • 3. Introduction • Financial performance assessment is an important issue • An economic issue • Financialization of the economy has led financial markets to drive economic coordination • A methodological issue • How assessing portfolio performance? • A theoretical issue • How do financial markets work? 3
  • 4. Introduction • This course is an introduction to financial performance analysis by using the programming language R • What is performance in finance? • What are the expected results according to modern portfolio theory? • What are the measures of performance? 4
  • 5. Introduction • Contents (I) 1. Performance in finance 2. Descriptive statistics 3. Histogram and Normality tests 4. Mean-variance analysis 5
  • 6. I. WHAT IS PERFORMANCE IN FINANCE? 6
  • 7. Performance in finance • Historical • Performance analysis is one of the basic issues that built the modern portfolio theory • Bachelier (1900) highlights that the rise and the fall of prices are equiprobable at any time • Prices fluctuate randomly • Cowles (1933, 1944) highlights that investment advices from financial analysts do not allow to outperform the market • It is impossible to predict future prices 7
  • 8. Performance in finance • Efficient market hypothesis • Definition 8 […] the ideal is a market in which prices provide accurate signal for ressource allocation: that is, a market in which firms can make production-Investment decisions, and investors can choose among the securities that represent ownership of firms’ activities under the assumption that security prices at any time "fully reflect" all available information. A market in which prices always "fully reflect" available information is called "efficient". (Fama E., 1970) [the market efficiency hypothesis is] the simple statement that security prices fully reflect allavailable information. A precondition for this strong version of the hypothesis is that information and tranding costs, the costs of getting prices to reflect information, are always 0 (Grossman and Stiglitz (1980). A weaker and enconomically more sensible version of the efficiency hypothesis says that prices reflect information to the point where the marginal benefits of acting on information (the profits to be made) do not exceed the marginal costs (Jensen (1978). (Fama E., 1991)
  • 9. Performance in finance • Efficient market hypothesis • Definition • The definition of efficient markets varies according to the informational set considered (Fama, 1970) 9 Present information (semi-strong form efficiency) Past information (weak-form efficiency) All information sets, including private information (strong- form efficiency)
  • 10. Performance in finance • Efficient market hypothesis • Consequences • Price is an unbiased estimate of the intrinsic value of a security • There is no better financial analyst than the market • Future variations are independent of past variations • Random walk theory • Investors cannot forecast prices successully • The theory assumes that managers do not add value (a) to the portfolio 10
  • 11. Performance in finance • Efficient frontier (Markowitz, 1952) • The efficient frontier is the set of optimal portfolios that offers the highest expected return for a given level of risk or the lowest risk for a defined level of expected return • Two stochastic dominance decision rules • An efficient portfolio optimizes the risk/reward ratio • A diversified portfolio should have at least 50 investments (see Euro Stoxx 50) 11 At a given level of return, investors choose the less risky asset At a given level of risk, investors choose the asset with highest returns
  • 12. Performance in finance • Efficient frontier (Markowitz, 1952) • Well-diversified portfolios tend to have similar return (given account the risk) and rare extreme returns 12 Asset 1 Asset 2 Rf 0,00% 2,00% 4,00% 6,00% 8,00% 10,00% 12,00% 14,00% 0,00% 5,00% 10,00% 15,00% 20,00% 25,00% Return (Ri) Volatility (si) Portfolio of two risky assets Portfolio with one risky asset and the risk free asset
  • 13. Performance in finance • Expected results • Financial performance integrates return and risk • There are several measures of return (max, mean…) and risk (min, s, VaR…) • Returns are random • The most common representation of randomness is the Gaussian distribution • A skilled manager shows a similar performance to the market given the risk • Outperformance is impossible • Underperformance is possible 13 A great number of causes Causes are independant Each cause has a small effect
  • 14. Performance in finance • Critics • Behavioral Finance • Many behavioral biases impact investment decisions • Market anomalies • Calendar anomalies • "January effect" is an abnormal increase in stock prices in January • "Weekend effect": stock returns on Monday are often significantly lower • Other anomalies • Small firms tend to outperfom • There is a negative relation between PER and returns and between market to book ratio and returns • The Gaussian distribution imperfectly represents return ditribution • … by underestimating risk 14
  • 16. Data analysis • Definition • Statistical procedure to determine the main characteristics of a dataset • We use the programming language 16 #install packages (collections of functions which allow more statistical techniques, and graphical devices) install.packages("quantmode") install.packages("fBasics") install.packages("moments") install.packages("PerformanceAnalytics") install.packages("normtest") install.packages("tseries") install.packages("roll") install.packages("xts") Data are available in the data.csv file with - Pi are daily closing prices of the stock i - Pm are daily closing prices of the market index m - RFR are daily closing rates of a 10-year constant maturity fictitious sovereign bond
  • 17. • Calculation of daily returns • Logarithmic returns are a better measure 17 #read data data<-read.csv2(file= file.choose(),header = TRUE,sep = ";",dec = ",") #Compute daily returns library(quantmode) data$Ri<-Delt(x1 = data$Pi,x2 = NULL,k = 1,type = "log") data$Rm<-Delt(x1 = data$Pm,x2 = NULL,k = 1,type = "log") data$Rf<-log(1+data$RFR/250) #Clean up data object #suppress 1st row data<-data[-1,] #suppress colums 2,3,4 (we only keep colums 1, 5 to 7) data<-data[,c(1,5:7)]          1, , , ln ti ti ti R R R Data analysis If the package “quantmode” doesn’t work (it happens !), we can compute daily returns as follows data$Ri[2:774]<-log(data$Pi[2:774]/data$Pi[1:773]) data$Ri[2:774]<-diff(log(data$Pi))
  • 18. • Descriptive statistics • Main measures 18 Ri Rm Rf nobs 773.000000 773.000000 774.000000 NAs 0.000000 0.000000 0.000000 Minimum -0.035737 -0.032272 0.000093 Maximum 0.035524 0.025047 0.000156 I. Quartile -0.004088 -0.004349 0.000114 3. Quartile 0.005653 0.005855 0.000142 Mean 0.000491 0.000529 0.000127 Median 0.000639 0.000844 0.000130 Sum 0.379467 0.409023 0.097973 SE Mean 0.000298 0.000299 0.000001 LCL Mean -0.000094 -0.000057 0.000125 UCL Mean 0.001075 0.001115 0.000128 Variance 0.000069 0.000069 0.000000 Stdev 0.008278 0.008300 0.000017 Skewness -0.369131 -0.391430 -0.352644 Kurtosis I.794045 I.091768 -1.073065      n t itii RR n 1 2 , 2 1 1 s     n t tiii R n RRE 1 , 1 library(fBasics) basicStats(data[,2:4])                   3 i ii i RR ESk s                   4 i ii i RR EK s Data analysis
  • 19. • Descriptive statistics • Main measures 19 Measures Definition Mean In finance, mean is a performance measure The average is calculated on daily data. It must be annualized (n = 252 days) Variance In finance, the variance is a risk measure The variance is calculated on daily data. It must be annualized The variance is expressed in the square of the unit of measure ("%²"). The standard deviation is the square root of the variance. yMean.Ri<-mean(data$Ri)*252 yMean.Rm<-mean(data$Rm)*252 ySD.Ri<-sd(data$Ri)*sqrt(252) ySD.Rm<-sd(data$Rm)*sqrt(252) Data analysis
  • 20. • Descriptive statistics • Main measures 20 Measures Definition Skewness (Sk) Skewness is a measure of asymmetry of the probability distribution • If > 0, the most part of the distribution is concentrated on the left of the figure (the right tail is longer) • If < 0, the most part of the distribution is concentrated on the right of the figure (the left tail is longer) Kurtosis (K) Kurtosis is a measure of of the probability distribution (1 < K < ∞) • If > 3, leptokurtic distribution (the data are heavy-tailed: extreme returns are more frequent than predicted by the gaussian distribution) • If < 3, platykurtic distribution (the data are light-tailed: extreme returns are less frequent than predicted by the gaussian distribution) Data analysis
  • 21. Data analysis • Descriptive statistics • Main measures • Some measures of kurtosis • Kurtosis is sometimes calculated in excess of 3 21 [1] 1.794045 attr(,"method") [1] "excess“ [1] 4.794045 [1] 1.806473 [1] 4.806473 library(moments) kurtosis(data$Ri) mean(((data$Ri-mean(data$Ri))/sd(data$Ri))^4) library(PerformanceAnalytics) kurtosis(data$Ri, na.rm = FALSE, method = "excess") kurtosis(data$Ri, na.rm = FALSE, method = "moment") Most explicit command!
  • 22. Data analysis • Descriptive statistics • Main measures • Some measures of skewness 22 library(moments) skewness(data$Ri) mean(((data$Ri-mean(data$Ri))/sd(data$Ri))^3) library(PerformanceAnalytics) skewness(data$Ri, na.rm = FALSE) Delt.1.log -0.3698488 [1] -0.3691314 [1] -0.3698488 There are sometimes (small) differences in the results
  • 24. Normality tests • Histogram of returns • For financial theory, markets evolve randomly • A common representation of randomness is the Gaussian distribution • The Gaussian distribution has a causal structure that defines a relatively stable world • ... consistent with the EMH (and perfect competition) • Extreme returns are rare • Returns around mean are the most frequent 24 Brownian motion Stochastic process Random walk
  • 25. Normality tests • Histogram of returns • Definition • Graphic that represents the distribution of numerical data • It is a graphical way to compare empirical and theoretical distributions 25 hist(data$Ri,main = "Histograms of Ri and Rm", breaks = 100, freq = FALSE, xlab = "Ri", xlim = c(min(data$Ri,data$Rm), max(data$Ri,data$Rm)), col = "green",axes = F) axis(1, pos = 0, cex.axis = 0.8) axis(2,pos = 0,cex.axis = 0.8,las = 2) hist(data$Rm,breaks = 50, freq = FALSE, xlim = c(min(data$Ri,data$Rm), max(data$Ri,data$Rm)), col = "red",,axes = F,add = TRUE) curve(dnorm(x, mean(data$Ri), sd(data$Ri)), xlim = c(min(data$Ri), max(data$Ri)), lwd = 2,col = "grey", add = TRUE) curve(dnorm(x, mean(data$Rm), sd(data$Rm)), xlim = c(min(data$Rm), max(data$Rm)), lwd = 2,col = "red", add = TRUE) legend("topleft",c("Histogram of Ri","Histogram of Rm"),lty = c(1,1),col = c("green","red"),bty = "n")
  • 26. Normality tests • Histogram of returns 26 Sharper distribution Less returns than expected on both sides "fat" tails
  • 27. Normality tests • Histogram of returns • The Gaussian distribution poorly approximates the return distribution • It underestimates the probability of extreme returns 27 (min(data$Ri)-mean(data$Ri))/sd(data$Ri) pnorm(q = (min(data$Ri)-mean(data$Ri))/sd(data$Ri),mean = 0,sd = 1, lower.tail = TRUE, log.p = FALSE) format(x = pnorm(q = -4.376432,mean = 0,sd = 1, lower.tail = TRUE,log.p = FALSE),scientific = FALSE, digits = 10) format(x = 1/(pnorm(q = -4.376432, mean = 0, sd = 1,TRUE, FALSE)*nrow(data$Ri)), scientific = FALSE, digits = 10) [1] -4.376432 [1] 6.03189e-06 [1] "0.000006031890184" [1] "214.4702608" the worst return occurred 1 time out of 773 or 214 times too often…
  • 28. • Normality test of distributions • Jarque-Bera non-parametric test (1980) (for n >> 0) • H0: Sk = 0 and K = 3 (the data follows a Gaussian distribution) • H1: Sk ≠ 0 or K ≠ 3 (the data do not follow a Gaussian distribution) 28 Jarque-Bera test for normality data: data$Ri JB = 122.73, p-value < 2.2e-16 Title: Jarque - Bera Normalality Test Test Results: STATISTIC: X-squared: 122.7298 P VALUE: Asymptotic p Value: < 2.2e-16 Jarque Bera Test data: data$Ri X-squared = 122.73, df = 2, p-value < 2.2e-16          22 3 4 1 6 ii i i KSk n JB Normality tests library(normtest) jb.norm.test(data$Ri) library(fBasics) jarqueberaTest(data$Ri) library(tseries) jarque.bera.test(data$Ri)
  • 29. Normality tests • Normality test of distributions • Non-parametric test of Kolgomorov-Smirnov • H0: D = D0 (the data follow the Gaussian distribution) • H1: D ≠ D0 (the data do not follow the Gaussian distribution) 29 Title: One-sample Kolmogorov-Smirnov test Test Results: STATISTIC: D: 0.4878 P VALUE: Alternative Two-Sided: < 2.2e-16 Alternative Less: < 2.2e-16 Alternative Greater: < 2.2e-16 library(fBasics) ksnormTest(data$Ri) At a = 10%, criticial value = 1,223/√n At a = 5%, criticial value = 1,358/ √n At a = 1%, criticial value = 1,629/ √n If oberved value D > criticial value, H0 is rejected
  • 31. • Definition • Combination of statistical hypothesis tests • Parametric tests assume that sample data follow a probability distribution based on a given set of parameters • Two risks of error • The type I error rate is the probability of rejecting the null hypothesis given that it is true • The type I error is the p-value (or significance level) a = 1%, 5% or 10% • The type II error occurs when the null hypothesis is false, but is not rejected • The rate of the type II error (b is linked to the power of the test (1− b) 31 Mean-variance analysis
  • 32. F-test of equality of variances Student t-test Parameter Null hypothesis (H0) Alternative hypothesis (H1) • Definition • Combination of two statistical hypothesis tests on variance and mean 32 21 mm  21 mm  22 1 2 ss  22 1 2 ss  1 1 2 2 22 1 2 11 1;1 21    n Sn n Sn F nn       2 11 21 21 2 22 2 11 2121 221           nn nn SnSn mmXX T nn When n1 = n2, 2 2 2 1 1;1 21 S S F nn  Mean-variance analysis
  • 33. • Parametric tests • Decision rule • F-test of equality of variances • Student t-test 33 0 H0 is valid H0 is rejected 1 Critical value at 10% Critical value at 5% Critical value at 1% The value is more and more frequently calculated • If p value < 1%, H0 is rejected at 1% (***) • If p value < 5%, H0 is rejected at 5% (**) • If p value < 10%, H0 is rejected at 10% (*) Mean-variance analysis H0 is valid H0 is rejected Critical value at 10% Critical value at 5% Critical value at 1%
  • 34. • Parametric tests • F-test of equality of variances • Is the variance of Ri different from the variance of Rm? 34 F test to compare two variances data: data$Ri and data$Rm F = 0.99478, num df = 772, denom df = 772, p-value = 0.9421 alternative hypothesis: true ratio of variances is not equal to 1 95 percent confidence interval: 0.8637999 1.1456325 sample estimates: ratio of variances 0.994785 var.test(x = data$Ri,y = data$Rm) The test doesn’t follow the convention 2 2 2 1 ss  Mean-variance analysis ifelse(var(data$Ri) > var(data$Rm), var(data$Ri) / var(data$Rm), var(data$Rm) / var(data$Ri))
  • 35. • Parametric tests • Student t-test • Is the mean of Ri different from the mean of Rm? 35 Paired t-test data: data$Ri and data$Rm t = -0.13619, df = 772, p-value = 0.8917 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -0.0005893457 0.0005128742 sample estimates: mean of the differences -3.823577e-05 t.test(x = data$Ri,y = data$Rm,paired = TRUE) Mean-variance analysis
  • 36. • Critics 36 Strenghts Weaknesses Mean-variance analysis The criticisms are especially of financial nature
  • 37. • Critics • Volatility is not stable over time • Calculation of 20 day rolling volatility 37 #Computing 20 day rolling Std dev library(roll) data$SD_Ri<-roll_sd(data$Ri,width = 20)*sqrt(252) data$SD_Rm<-roll_sd(data$Rm,width = 20)*sqrt(252) #Converting date data to date format date<-as.Date(data$Date,format = "%d/%m/%Y") data<-cbind(date,data[,-1]) library(xts) data<-xts(data[,2:6],order.by = data[,1]) #Drawing plot windows() plot(data$SD_Ri[23:773], xlab = "Date", ylab = "Annualized Std Dev",type = "l", col = "green") lines(data$SD_Rm,col = "red") legend("topleft",c("Std dev of Ri","Std dev of Rm"),lty = c(1,1),col = c("green","red"),bty = "n") title(main = "20 day rolling std dev of Ri and Rm") Mean-variance analysis
  • 38. 38 Mean-variance analysis • Critics • Volatility is not stable over time
  • 39. Mean-variance analysis • Critics • Volatility is not stable over time data<-read.csv2(file.choose(),header=T,sep=";",dec=",") data$Ri[2:774]<-diff(log(data$Pi)) data<-data[-1,] library(roll) data$Ri<-as.matrix(data$Ri) data$SD_Ri<-roll_sd(data$Ri,width = 20)*sqrt(252) windows() par(mfrow=c(2,1)) plot(data[,2],type="h",col="grey",xlab="Date",ylab="Price (€)",ylim=c(round(min(data[,2])-5),round(max(data[,2])+5)),axes=F) axis(1,pos=40) axis(2,pos=0) title(main="Price of i") plot(data[,6],type="h",col="grey",xlab="Date",ylab="20 day rolling volatility (%)",ylim=c(0,0.35),axes=F) axis(1,pos=0) axis(2,pos=0) title(main="20 day rolling volatility of i")
  • 40. Mean-variance analysis • Critics • Volatility is not stable over time
  • 42. Conclusion • Statistics is “the science of collecting, analyzing, presenting, and interpreting data” • Descriptive statistics summarize the population data • The histogram and the normality test make it possible to evaluate the adequacy between a variable and the statistical law of reference • The expectation variance analysis allows a comparison of the variables 42
  • 43. Conclusion • Financial modelling seeks to improve the mathematical representation of the behavior of securities • Monofactorial models are the precursors • Market model (Sharpe, 1963) • Capital Asset Pricing Model (Lintner, 1965) • Multifactor models try to integrate more variables • Market timing (Treynor-Mazuy, 1966) • Arbitrage pricing theory (Ross, 1976) • Fama-French three factor model (1993) • Carhart four factor model (1997) 43
  • 44. References Finance • Bachelier L. (1900), Théorie de la spéculation, Annales scientifiques de l’ENS, (17)3, 21-86 • Carthart M. (1997), “On persistence of Mutual Fund Performance”, Journal of Finance, (52), 57-82 • Cowles A. (1933), “Can Stock Market Forecasters Forecast?”, Econometrica, (1)3, 309-324 • Cowles A. (1944), “Stock Market Forecasting”, Econometrica, (12)3-4, 206-214 • Fama E. (1970), “Efficient Capital Markets: A review of Theory and Empirical Work”, Journal of Finance, (25)2, 383-417 • Fama E. (1991), “Efficient Capital Markets”, Journal of Finance, (46)5, 1575-1617 • Fama E., K. French (1993), “Common Risk Factors in the Returns on Stocks and Bonds”, Journal of Financial Economics, (33), 3-56. • Lintner J. (1965), “The valuation of risk assets and the selection of risky investments in stock portfolios and capital budgets”, Review of Economics and Statistics, 47(1), 13–37 • Markowitz H. (1952), “Portfolio Selection”, Journal of Finance, (7)1, 77-91 • Ross S. (1976), "The Arbitrage Theory of Capital Asset Pricing". Journal of Economic Theory, (13)3, 341- 360 • Sharpe W. (1963), “A Simplified Model for Portfolio Analysis”, Management Science, (9)2, 277-293 • Treynor, J., Mazuy, K. (1966), “Can Mutual Funds Outguess the Market?” Harvard Business Review, (44), 131-136 Statistics • Jarque C., Bera A. (1980). “Efficient tests for normality, homoscedasticity and serial independence of regression residuals”, Economics Letters. (6) 3, 255–259 44