garchmvbootstrap.rpf

Discussions of ARCH, GARCH, and related models
ac_1
Posts: 467
Joined: Thu Apr 15, 2010 6:30 am

garchmvbootstrap.rpf

Unread post by ac_1 »

Hi Tom,

Univariate
From viewtopic.php?p=19356&hilit=would+give+ ... o+a#p19356 , the univariate case
"
The g10xrate file has all currencies quoted as USD value of a foreign currency unit whether that is the standard quotation or not.

set x = -100.0*log(usxjpn/usxjpn{1})

would give you the return to a long position of $100 US.

set x = +100.0*log(usxjpn/usxjpn{1})

would give you the return to a long position of 100 yen.
"

Multivariate
Here: https://estima.com/webhelp/topics/garch ... aprpf.html

Code: Select all

open data g10xrate.xls
data(format=xls,org=columns) 1 6237 usxjpn usxfra usxsui

set xjpn = +100.0*log(usxjpn/usxjpn{1})
set xfra = +100.0*log(usxfra/usxfra{1})
set xsui = +100.0*log(usxsui/usxsui{1})

ENTRY       USXJPN          USXFRA          USXSUI           XJPN            XFRA            XSUI
      1    0.3317960118   19.5224801359   26.5153523890        NA              NA              NA
      2    0.3317519822   19.4950774929   26.5703050271  -0.013270961698 -0.140463161565  0.207033916140
      3    0.3320053121   19.5099110348   26.5449139945   0.076332091406  0.076059720436 -0.095607379587
      4    0.3318951211   19.5198126098   26.5597195294  -0.033195038142  0.050738638595  0.055759862374
If I proceed with bootstrapping and forecasting VaR and ES in the multivariate case, DVECH, DCC, what is the correct interpretation of the portfolio?

Is it?
Portfolio View: USD-Based Investor
If I'm LONG this portfolio:
• Short USD vs. Long foreign currencies (JPY, FRA, SUI).
• Benefiting when USD depreciates.
If I'm SHORT this portfolio:
• Long USD vs. Short foreign currencies.
• Benefiting when USD appreciates.

So as they are +'s in front of the returns: would give the portfolio return to a LONG position of 100.0*(optimal weights*returns) i.e the realized (actual) return of the portfolio = 100.0*(wjpn*xjpn + wfra*xfra + wsui*xsui). Is that from the point-of-view of a USD-Based investor or Foreign-Based Investor?

Or do I need to put minus signs, then what's the interpretation?

Code: Select all

set xjpn = -100.0*log(usxjpn/usxjpn{1})
set xfra = -100.0*log(usxfra/usxfra{1})
set xsui = -100.0*log(usxsui/usxsui{1})
Univariate
The analysis should ideally be consistent as in the univariate case where I have modelled:

Code: Select all

*My raw data USDJPY = 140.00 (say)

set p = 1.0/USDJPY
set lp = log(p)
diff lp / dlp
set dlp = -dlp; * would give you the return to a long position of $100 US
Which is the return of USDJPY (the raw data)! BUT the reason why I have p = 1.0/USDJPY was to follow your example data g10xrate.xls https://estima.com/webhelp/topics/garchbootrpf.html and for plots.

Thereafter, the extra line above was put in

Code: Select all

set dlp = -dlp; * would give you the return to a long position of $100 US
And then, I have calculated VaR and ES for LONG and SHORT[right-tail], i.e. using that negated dlp.

thanks,
Amarjit
TomDoan
Posts: 7776
Joined: Wed Nov 01, 2006 4:36 pm

Re: garchmv.rpf and garchmvbootstrap.rpf

Unread post by TomDoan »

I'm not sure what you're asking. If there are more than two securities, you would be looking at return statistics to a portfolio---some weighted combination (of which there are an infinite number of distinct possibilities, so it's a much more complicated problem compared with a single security, where there are basically just two: short or long). There's a whole literature on portfolio selection given the means and covariances of returns. While we have examples of how to do calculations using RATS, those assume you understand what the analysis is doing.
ac_1
Posts: 467
Joined: Thu Apr 15, 2010 6:30 am

Re: garchmv.rpf and garchmvbootstrap.rpf

Unread post by ac_1 »

TomDoan wrote: Mon Sep 29, 2025 12:01 pm I'm not sure what you're asking. If there are more than two securities, you would be looking at return statistics to a portfolio---some weighted combination (of which there are an infinite number of distinct possibilities, so it's a much more complicated problem compared with a single security, where there are basically just two: short or long). There's a whole literature on portfolio selection given the means and covariances of returns. While we have examples of how to do calculations using RATS, those assume you understand what the analysis is doing.
My aim is to backtest and forecast VaR and ES in the multivariate (MV) case, as it's similar in structure with univariate (UV) https://estima.com/webhelp/topics/garchbootrpf.html

As I've underlined and emboldened above, at this stage I'm asking about interpretation, and consistency with UV. I need to know what I am getting from MV.

Consistency: I would like consistency with UV analysis. To repeat: I have modelled the data in UV case as:

UNIVARIATE
The MV analysis should ideally be consistent as in the UV where I have modelled:

Code: Select all

My raw data USDJPY = 140.00 (say)

set p = 1.0/USDJPY
set lp = log(p)
diff lp / dlp
set dlp = -dlp; * would give you the return to a long position of $100 US
Which is the return of USDJPY (the raw data)! BUT the reason why I have p = 1.0/USDJPY was to follow your example data g10xrate.xls https://estima.com/webhelp/topics/garchbootrpf.html and for plots.

Thereafter, the extra line above was put in

Code: Select all

set dlp = -dlp; * would give you the return to a long position of $100 US
And then, I have calculated VaR and ES for LONG and SHORT[right-tail], i.e. using that negated dlp.


AND EXPLAINED IN FOUR SCENARIOS:
If you’re a dollar investor, USD is the base currency, you are interested in how much 1 USD buys in JPY i.e. USDJPY, not JPYUSD.
If you’re a yen investor, JPY is the base currency, you care about how much 1 JPY buys in USD i.e. JPYUSD, not USDJPY.

All calculations are as in [1] (below) JPYUSD from the perspective of a dollar investor i.e. USDJPY, as I have calculated SHORT[right-tail] for VaR and ES. Note I have not calculated [3] and [4] as everything stems from [1].

-log(usxjpn(t)/usxjpn(t−1)) = +log(usxjpn(t−1)/usxjpn(t)).

And that’s the log return of USDJPY (because USDJPY = 1/JPYUSD).


[1]. JPYUSD for a dollar investor: USDJPY i.e. LONG USD / SHORT JPY

usxjpn = JPYUSD

set x = -100.0*log(usxjpn/usxjpn{1})

would give you the return to a long position of $100 US.

because log(1/x)=-log(x)


[2]. USDJPY for a dollar investor, SHORT USD / LONG JPY i.e. SHORT[right-tail]


[3]. JPYUSD for a yen investor, SHORT JPY / LONG USD i.e. SAME as [1].

set x = +100.0*log(jpnusx/jpnusx{1})

would give you the return to a long position of 100 yen


[4]. USDJPY for a yen investor, JPYUSD i.e. LONG JPY / SHORT USD i.e. SHORT[right-tail] i.e. SAME as [2].


Is that clear and correct?

MULTIVARIATE
- Interpretation:

set xjpn = 100.0*log(usxjpn/usxjpn{1})
set xfra = 100.0*log(usxfra/usxfra{1})
set xsui = 100.0*log(usxsui/usxsui{1})

Should those be with +'s or with -'s in front?

And the terminology? How to explain? Like I have in UV case: dollar investor, foreign investor, long, short, or otherwise?

Portfolio Strategies
Yes there are a plethora of portfolio strategies i.e. how to best set weights
* id_0 Equal Weights (1/3 each, fixed)
* id_1 GMV, fixed (from first estimation window only)
* id_2 Rolling GMV (rebalance every rebalfreq days)
* id_3 Risk Parity (equal risk contribution, rebalance)
* id_4 Max Sharpe Ratio (tangency portfolio, rebalance)
etc etc

Practically, weights should NOT be changing on a daily basis. And then there's including transaction costs w.r.t. rebalancing.

Correct me if I'm wrong, RATS is specifically designed for REGRESSION ANALYSIS OF TIME SERIES methodologies, where it excels! It is not necessarily about backtesting technical trading models or portfolio strategies, which obviously RATS can do, but there are specifically designed software for those tasks e.g. AmiBroker, MetaTrder, TradeStation, etc etc.

Lastly, is the g10xrate.xls available with DATE stamps?
TomDoan
Posts: 7776
Joined: Wed Nov 01, 2006 4:36 pm

Re: garchmv.rpf and garchmvbootstrap.rpf

Unread post by TomDoan »

In doing a multivariate GARCH model, you should have all the series set to be returns to a positive investment in a standard currency. (This is true whether you are doing currency markets or equity markets). Otherwise, you end up with a mess if you try to do any non-trivial portfolio calculations. If you restrict yourself to "portfolios" which are just +/-1 on a currency I, then the mean return will be +/-1 x the estimated mean for I in the model and the variance will be H(I,I) regardless of the sign of your investment. That's usually assumed to be Normal, but can also be t if you used that in the estimation.

I've attached an XLSX version which includes dates.
Attachments
g10xrate.xlsx
File with dates
(627.71 KiB) Downloaded 126 times
ac_1
Posts: 467
Joined: Thu Apr 15, 2010 6:30 am

Re: garchmv.rpf and garchmvbootstrap.rpf

Unread post by ac_1 »

Thanks!

I'll assume the UV 4 Scenario's explanation is correct.

In GARCHMVBOOTSTRAP.RPF, with

set xjpn = +100.0*log(usxjpn/usxjpn{1})
set xfra = +100.0*log(usxfra/usxfra{1})
set xsui = +100.0*log(usxsui/usxsui{1})

presupposing positive weights, the portfolio (FX-Portfolio-Manager) is Short USD and Long a basket of foreign currencies (JPY, FFR, CHF).

multivariate GARCH with DVECH has

gset portfolio bstart bend = hinv=inv(h),hinv*ones/%qform(hinv,ones)

which results in two positive, one negative weight. The negative weight reverse's the position on CHFUSD i.e. Short CHF, Long USD.

The idea is to backtest, forecasting 1% VaR and ES, h-steps ahead, with:
- options for different portfolio weight methods: equal, GMV, risk-parity, max-sharpe, etc
- options to rebalance: 0 mth, 1 mth, qtrly, semi-annual, yearly
- include transaction costs

What else would be useful to "gather" from the forecast returns distribution on EACH hth-day? Maybe the means and generate a cumulative equity curve - but it's an MVGARCH model, not a technical trading, would that be considered unreasonable or excessive expectation?
TomDoan
Posts: 7776
Joined: Wed Nov 01, 2006 4:36 pm

Re: garchmv.rpf and garchmvbootstrap.rpf

Unread post by TomDoan »

My understanding is that "technical trading" algorithms take moving window statistics (means, variances, percentiles,...) and produce a trading strategy from those. In what way is a (moving window) MV-GARCH model different from that? It's the same idea, just a different set of statistics. The one major difference is that the MV-GARCH model also produces predictions for what type of values will be produced in the near future (thus allowing calculation of a model-based VaR) since it's a time series model .
ac_1
Posts: 467
Joined: Thu Apr 15, 2010 6:30 am

Re: garchmvbootstrap.rpf

Unread post by ac_1 »

Here, using bootstrap, I can generate multi-step ahead variances and covariances as in https://estima.com/webhelp/topics/garch ... aprpf.html, and backtest.

Importantly: presumably the multi-step (cumulative) VaR's can be judged via exceedance plots,
e.g.
- 1 step VaR vs. 1-day actual returns: violation ratios, exceedence plots, Kupiec, Christoffersen
- k-step VaR vs. 1-day actual returns. Or do I need to judge the k-step VaR against the sum of k-day actual returns?

What about the (cumulative) correlations, how to assess their backtest adequacy?

So the questions are:
(a) How to judge multi-step VaR. Against what?
(b) How to judge 1-day and multi-step correlations. Against what?


NB: The regulatory rules for Minimum Capital Requirements For Market Risk appear to have changed in BASEL III (2019) https://www.bis.org/bcbs/publ/d457.pdf .
It seems to be:
- 2.5% ES is the required risk-measure (for capital), liquidity-horizon-adjusted e.g. 10-day. See page 89.
- 1% VaR for backtesting only (not for capital), See page 81.
ac_1
Posts: 467
Joined: Thu Apr 15, 2010 6:30 am

Re: garchmvbootstrap.rpf

Unread post by ac_1 »

So I propose

1 step VaR vs. 1-day actual returns: violation ratios, exceedance plots, Kupiec, Christoffersen.

2 step VaR vs. sum of 2-day actual returns: violation ratios (vr), exceedance plot showing the sum of 2-day returns vs. 2 step VaR

Code: Select all

set csdlp1000_2 %allocend()-999 %allocend()+2 = dlp + dlp{1}; * sum of 2-day actual returns
The k-day analogue of Kupiec, or similar test statistic

H0: vr==1,
HA: vr<>1; reject H0 p<0.05.

but adjusting the test statistic for clustering (serially dependence) in violations due to the 'overlapping' sum of k-day returns.

If so, how to adjust Kupiec/test statistic?
TomDoan
Posts: 7776
Joined: Wed Nov 01, 2006 4:36 pm

Re: garchmvbootstrap.rpf

Unread post by TomDoan »

Are you asking me how to adjust those tests for clustering? Isn't that covered in the literature (somewhere)?
ac_1
Posts: 467
Joined: Thu Apr 15, 2010 6:30 am

Re: garchmvbootstrap.rpf

Unread post by ac_1 »

TomDoan wrote: Fri Nov 07, 2025 11:01 am Are you asking me how to adjust those tests for clustering? Isn't that covered in the literature (somewhere)?
I'll assume, unless otherwise stated

k step VaR vs. sum of k-day actual returns: violation ratios (vr), exceedance plot showing the sum of k-day returns vs. k step VaR

Code: Select all

set csdlp1000_2 %allocend()-999 %allocend()+2 = dlp + dlp{1}; * sum of 2-day actual returns
set csdlp1000_3 %allocend()-999 %allocend()+3 = dlp + dlp{1} + dlp{2}; * sum of 3-day actual returns
* etc
is how to judge the multi-step VaR forecasts.

Thereafter, regarding test-statistic for vr's, the k-day analogue of Kupiec HAC adjusted (Newey-West) is probably the way forward.

So, how to adjust Kupiec?

Code: Select all

sstats(mean) tstart tend trigger>>alphahat
compute pof=2*%nobs*((1-alphahat)*log((1-alphahat)/(1-alpha))+$
     alphahat*log(alphahat/alpha))
disp "POF measure" pof
Unless there's a simpler, more powerful test for clustering (serial dependence).
TomDoan
Posts: 7776
Joined: Wed Nov 01, 2006 4:36 pm

Re: garchmvbootstrap.rpf

Unread post by TomDoan »

I think you're missing the point. Yes, if you use overlapping ranges there will be serial correlation induced. (You're not "testing" for clustering. The serial correlation is there by construction). No, the fix for that is not likely to be simple as these are not statistics that fall into the standard regression/GMM structure. I assume if it's important, someone in the literature has addressed it. It's your job to check into that.
ac_1
Posts: 467
Joined: Thu Apr 15, 2010 6:30 am

Re: garchmvbootstrap.rpf

Unread post by ac_1 »

Numerical examples of the coverage tests
- Kupiec (1995) (unconditional coverage)
- Christoffersen (1998) (independence of exceedance)
- Joint test (conditional coverage) unconditional coverage and independence of exceedance

are in: CAROL ALEXANDER (2009) Market Risk Analysis VOL II Practical Financial Econometrics, Wiley, pp358-360.

Those tests are not designed for use with overlapping ranges, and problems thereafter with assessing multi-step forecasts -- I'm not certain analysis exist in the literature.

So, for k-step (k>=2) multi-step:
- raw violation count only, not violation ratio's (number of violations/(0.01 * OOS data length)) -- what's the expected number of exceedances (denominator) with overlapping returns?
- exceedance plots (visual assessment) k step VaR vs. sum of k-day returns i.e. overlapping returns

Backtesting various GARCH models, I'm seeing similar-ish numbers of violation's (comparing against overlapping returns) for k days ahead, as with the 1-day.
Post Reply