This page contains some of the Matlab code I've
written during the course of my research. If you
find any mistakes or bugs in the code please let me know.
This code is being released under a
BSD license, which means that you can do pretty much
what ever you want with it, including make money by selling it.
Most of my functions use code
contained in the econometrics
toolbox for Matlab by James P. LeSage. This toolbox contains many useful
programs for econometricians. It must be installed before my code will work.
This toolbox contains many useful
functions relating to estimating and simulating both univariate and
multivariate GARCH models. Some of my programs call some of Kevin's functions,
so this also needs to be installed. The GARCH toolbox can be found
here.
This zip file contains 5 functions: the pdf,
cdf, log-likelihood, inverse cdf and a function to generate random draws from
the skewed t distribution.
Hansen, Bruce E., 1994,
Autoregressive Conditional Density Estimation, International Economic
Review, 35(3), 705-730.
This Matlab
m-file (saved as a “txt” file) returns an estimate of the
optimal block size for bootstrap methods (stationary or circular) of estimating
the asymptotic variance of the mean of dependent data, given a sample from a
univariate time series.
R code for this procedure, written by Jeff Racine and Chris Parmeter is available here, and a PDF help file is here. Alternatively, if you install R and the “np” package you will have access to the function “b.star”.
Bug
fixes and updates:
26aug03: updated with suggestions from Kevin Sheppard.
16dec07: major
revision: estimate of optimal block length for the stationary bootstrap
corrected using recent paper by Nordman (Annals of Statistics, forthcoming). Details in a “correction” paper
available here.
9dec08: fixed small bug in choice of
“KN”, thanks to Jeff
Racine for spotting this.
28oct09: Here is “mlag.m”
(saved as a “txt” file) which is called in my code. (This
function is part of the econometrics toolbox for Matlab
by James P. LeSage.)
Politis, Dimitris N., and White, Halbert, 2004, Automatic Block-Length Selection for the
Dependent Bootstrap, Econometric
Reviews, 23(1), 53-70.
Politis,
Dimitris N., White, Halbert,
and Patton,
Andrew J., 2009, Correction:
Automatic Block-Length Selection for the Dependent Bootstrap, Econometric
Reviews, 28(4), 372-375.
This zip file
contains code to compute the exceedence correlations used by Longin and Solnik
(2001) and Ang and Chen (2002). Code for the test that the exceedence
correlation plot is symmetric recently proposed by Hong, Tu and Zhou (2003) is
also included.
Longin, Francois, and Solnik,
Bruno, 2001, Extreme Correlation of International Equity Markets, Journal of Finance, 56, 649-676.
Ang, Andrew, and Chen, Joseph, 2002, Asymmetric
Correlations of Equity Portfolios, Journal
of Financial Economics, 63(3), 443-494.
Hong, Yongmiao,
Tu, Jun, and Zhou, Guofu,
2007, Asymmetries
in Stock Returns: Statistical Tests and Economic Evaluation, Review of Financial Studies, 20, 1547-1581.
This zip file contains Matlab code to
replicate the empirical section in Patton (2008), on volatility
forecast comparison using imperfect volatility proxies. The main program is
called "robust_example_code.m", which generates the figures and does
the calculations. The data used in the paper is included. The function
"robust_loss_1.m" is a function for the parametric family of
"robust" loss functions proposed in the paper. Some helper functions
are also included.
This zip file
contains a collection of Matlab functions that I wrote for my research on copulas for financial time series (Patton 2006a, Patton 2006b, Patton 2004, Granger et al. 2006, Patton 2007). Some simple example
code is given in "copula_example_code.m". A table of contents is
given in "contents.xls". Briefly, the toolbox contains CDFs, PDFs,
log-likelihoods and random number generators for many common bivariate copulas,
including the Clayton, Gumbel, Normal, Student's t, Frank, Plackett and symmetrised
Joe-Clayton (SJC) copulas. Basic code for time-varying Normal, Gumbel and SJC
copulas is included. Some helper functions are also included. If you find any
bugs in this code please let me know: andrew.patton@economics.ox.ac.uk.
Bug fixes:
22aug06: Fixed two small bugs in clayton_pdf.m and tCopula_cdf.m
1aug07: Fixed big bug in sym_jc_rnd.m
19aug07: Fixed small bug in copula_example_code.m
2feb07: Fixed small bug in copula_example_code.m
5feb07: Fixed small bug in
copula_example_code.m
This
zip file contains Matlab code to replicate the empirical results presented
in Patton and Timmermann (2009),
on tests of monotonicity in asset returns. The main program is called
"sorts_example_code_100.m", which loads the data, computes the t-test
and MR test statistics and p-values, and returns the tables and the figure. The
data used in the paper is included, as are some helper functions. Also included
is a file made for Matlab beginners, “MR_test_for_dummies_100.m”,
which goes through each step with explicit instructions. If you have any problems using the functions in this toolbox please
feel free to email me: andrew.patton@duke.edu
.
Updates:
23may08: Updated toolbox to compute the Wolak test (Journal of
Econometrics 1989) for comparison, and to allow for two-way sorted returns.
15jun08:
Updated toolbox to include a “MR test for dummies” function,
which goes through the implementation of the MR test step-by-step –
designed for Matlab beginners.
2may09:
Large update, to go with the revision of the paper. Main MR test
function was updated, example code to replicate all of the empirical results
was extended to reflect the broader selection of empirical applications
considered in the paper. Code for the “up” and “down”
bootstrap tests was added.
__________________________________________
Andrew Patton
Department of Economics
213 Social Sciences Building
Durham
NC 27708-0097
USA
Email:
andrew.patton@duke.edu
Phone: +1 919 660 1849
Fax: +1 919 684
8974
Web: . http://econ.duke.edu/~ap172
__________________________________________
Last Updated: February 2010.
Go to Andrew's main page.