<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"><channel><title>Gilgamath</title><link>https://www.gilgamath.com/</link><description></description><lastBuildDate>Sun, 19 Sep 2021 21:50:52 -0700</lastBuildDate><item><title>Antichess Elo Problems</title><link>https://www.gilgamath.com/antichess-two.html</link><description>&lt;p&gt;Antichess Elo on lichess are miscalibrated.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Steven</dc:creator><pubDate>Sun, 19 Sep 2021 21:50:52 -0700</pubDate><guid isPermaLink="false">tag:www.gilgamath.com,2021-09-19:/antichess-two.html</guid><category>analysis</category><category>data</category><category>chess</category><category>antichess</category></item><item><title>Antichess Piece Values</title><link>https://www.gilgamath.com/antichess-one.html</link><description>&lt;p&gt;In a &lt;a href="atomic-three"&gt;previous blog post&lt;/a&gt; I used logistic regression on games
played data to estimate the piece value of pieces in Atomic chess.
Since then I have been playing less Atomic and more 
&lt;a href="https://en.wikipedia.org/wiki/Losing_chess"&gt;Antichess&lt;/a&gt;.
In Antichess, you win by losing all your pieces. To facilitate this,
capturing is compulsory when possible; when multiple captures
are possible you may select among them. There is no castling, and a pawn
may promote to a king, but otherwise it is like traditional chess.
(For more on antichess, 
I highly recommend Andrejić's book, &lt;a href="http://perpetualcheck.com/antichess/"&gt;&lt;em&gt;The Ultimate Guide to Antichess&lt;/em&gt;&lt;/a&gt;.)&lt;/p&gt;
&lt;p&gt;A king is a relatively powerful piece in Antichess: it can not as easily
be turned into a "loose cannon", yet it can move in any direction.
In general you want to keep your king on the board and remove your
opponent's king. In that spirit, I wanted to estimate piece values
in Antichess. I will use logistic regression for the analysis,
as I did in my analysis of &lt;a href="atomic-one"&gt;atomic chess&lt;/a&gt;.&lt;/p&gt;
&lt;!-- PELICAN_END_SUMMARY --&gt;

&lt;p&gt;For the analysis I pulled &lt;a href="https://database.lichess.org/#variant_games"&gt;rated games data&lt;/a&gt;
from Lichess.
I wrote some &lt;a href="https://github.com/shabbychef/lichess-data"&gt;code&lt;/a&gt;
that will download and parse this data, turning it into a CSV file.
I am sharing &lt;a href="https://drive.google.com/file/d/15lTi5PAtnkeGIvuSP2vT_nSi1u06oHg_/view?usp=sharing"&gt;v1 of this file&lt;/a&gt;,
but please remember that Lichess is the ultimate copyright holder.&lt;/p&gt;
&lt;p&gt;The games in the dataset end in one of three conditions: Normal, Time forfeit, 
and Abandoned (game terminated before it began). 
The last category is very rare, and I omit these from my processing.
The majority of games end in the Normal way, and I will consider only those.
Also, games are played at various time controls, and players can make
suboptimal moves when pressed for time, so I will restrict to games played
with at least two minutes per side.&lt;/p&gt;
&lt;p&gt;The game data includes Elo scores (well, Glicko scores, but …&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Steven E. Pav</dc:creator><pubDate>Fri, 10 Sep 2021 21:24:59 -0700</pubDate><guid isPermaLink="false">tag:www.gilgamath.com,2021-09-10:/antichess-one.html</guid><category>analysis</category><category>data</category><category>chess</category><category>antichess</category></item><item><title>Atomic Piece Values, Again</title><link>https://www.gilgamath.com/atomic-three.html</link><description>&lt;p&gt;In a &lt;a href="atomic-two"&gt;previous blog post&lt;/a&gt; I used logistic regression to estimate
the values of pieces in Atomic chess. In that study I computed material
differences between the two players using a snapshot 8 plies before the end
of the match. (A "ply" is a move by a single player.) That choice of snapshot
was arbitrary, but it is typically late enough in the match so there is some
material difference to measure, and also near enough to the end to estimate the "power"
of each piece to bring victory.
However, this valuation is rather late in the game, and is probably not
representative of the average value of the pieces.
That is, a knight advantage early in the game could be parlayed into a queen
advantage later, which could then prove decisive. &lt;/p&gt;
&lt;!-- PELICAN_END_SUMMARY --&gt;

&lt;p&gt;To fix that issue, I will re-perform that analysis on other snapshots.
Recall that I am working from 9 million rated Atomic games that I downloaded from Lichess.
For each match I selected a pseudo-random ply after the second and before the
last ply of each game, uniformly. (There is no material difference before the third ply.) 
I also selected pseudo-random snapshots in
the first third, the second third, and the last third of each match. I
compute the difference in material as well as differences in passed pawn counts
for each snapshot.
You can download &lt;a href="https://drive.google.com/file/d/1RPMJZ4MvCf1VqkZUNpqcR85isK0cgDdU/view?usp=sharing"&gt;v2 of the data&lt;/a&gt;,
and the &lt;a href="https://github.com/shabbychef/lichess-data"&gt;code&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Recall that I am using logistic regression to estimate coefficients in the
model
&lt;/p&gt;
&lt;div class="math"&gt;$$
\operatorname{log}\left(\frac{p}{1-p}\right) = \frac{\operatorname{log}(10)}{400}\left[\Delta e + 
c_P \Delta P + 
c_K \Delta K + 
c_B \Delta B + 
c_R \Delta R + 
c_Q \Delta Q
\right],
$$&lt;/div&gt;
&lt;p&gt;
where &lt;span class="math"&gt;\(\Delta e\)&lt;/span&gt; is the difference in Elo, and 
&lt;span class="math"&gt;\(\Delta P, \Delta K, \Delta B, \Delta R, \Delta Q\)&lt;/span&gt; are the …&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Steven E. Pav</dc:creator><pubDate>Mon, 31 May 2021 21:46:54 -0700</pubDate><guid isPermaLink="false">tag:www.gilgamath.com,2021-05-31:/atomic-three.html</guid><category>analysis</category><category>data</category><category>chess</category><category>atomic</category></item><item><title>Atomic Piece Values</title><link>https://www.gilgamath.com/atomic-two.html</link><description>&lt;p&gt;Most chess playing computer programs use forward search over the tree of possible moves.
Because such a search cannot examine every branch to termination of the game,
usually "static" evaluation of leaf nodes in the tree is via the combination of
a bunch of scoring rules.
These typically include a term for the material balance of the position.&lt;br&gt;
In traditional chess the pieces are usually assigned scores of 1 point for pawns,
around 3 points for knights and bishops, 5 for rooks, and 9 for queens.
Human players often use this heuristic when considering exchanges.&lt;/p&gt;
&lt;p&gt;I recently started playing a chess variant called &lt;a href="https://en.wikipedia.org/wiki/Atomic_chess"&gt;Atomic chess&lt;/a&gt;. 
In Atomic, when a piece captures another, both are removed from the board,
along with all non-pawn pieces in the up to eight adjacent squares.
The idea is that a capture causes an 'explosion'. 
Lichess plays a delightful explosion noise when this happens.&lt;/p&gt;
&lt;p&gt;The traditional scoring heuristic is apparently based on mobility of the pieces.
While movement of pieces is the same in the Atomic variant,
I suspect that traditional scoring is not well calibrated for Atomic:
A piece can capture only once in Atomic;
a piece can remove multiple pieces from the board in one capture;
pieces have value as protective 'chaff';
Kings cannot capture pieces, so solo mates are possible;
pawns on the seventh rank can trap high-value pieces by threatening promotion;
there are numerous fools' mates involving knights, &lt;em&gt;etc.&lt;/em&gt;
Can we create a scoring heuristic calibrated for Atomic?&lt;/p&gt;
&lt;!-- PELICAN_END_SUMMARY --&gt;

&lt;p&gt;The problem would seem intractable from first principles,
because piece value is so different from average piece mobility.
Instead, perhaps we can infer a kind of average value for pieces.
In a &lt;a href="atomic-one"&gt;previous blog post&lt;/a&gt; I performed a quick analysis of Atomic
openings on a database of around 9 million games played on Lichess …&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Steven E. Pav</dc:creator><pubDate>Mon, 10 May 2021 21:53:59 -0700</pubDate><guid isPermaLink="false">tag:www.gilgamath.com,2021-05-10:/atomic-two.html</guid><category>analysis</category><category>data</category><category>chess</category><category>atomic</category></item><item><title>Atomic Openings</title><link>https://www.gilgamath.com/atomic-one.html</link><description>&lt;p&gt;I've started playing a variant of chess called
&lt;a href="https://en.wikipedia.org/wiki/Atomic_chess"&gt;Atomic&lt;/a&gt;. 
The pieces move like traditional chess, and start in the same position.
In this variant, however, when a piece takes another piece, &lt;em&gt;both&lt;/em&gt; are 
removed from the board, as well as any non-pawn pieces on the (up to eight)
adjacent squares. As a consequence of this one change, the game can
end if your King is 'blown up' by your opponent's capture. As another
consequence, Kings cannot capture, and may occupy adjacent squares.&lt;/p&gt;
&lt;p&gt;For example, from the following position White's Knight can
blow up the pawns at either d7 or f7, blowing up the Black King 
and ending the game.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://www.gilgamath.com/figure/atomic_one_blowup-1.png" title="plot of chunk blowup" alt="plot of chunk blowup" width="700px" height="560px" /&gt;&lt;/p&gt;
&lt;!-- PELICAN_END_SUMMARY --&gt;

&lt;p&gt;I looked around for some resources on Atomic chess, but have never
had luck with traditional chess studies.
Instead I decided to learn about Atomic statistically.&lt;/p&gt;
&lt;p&gt;As it happens, Lichess (which is truly a great site) 
&lt;a href="https://database.lichess.org/#variant_games"&gt;publishes their game data&lt;/a&gt;
which includes over 9 million Atomic games played.
I wrote some &lt;a href="https://github.com/shabbychef/lichess-data"&gt;code&lt;/a&gt;
that will download and parse this data, turning it into a CSV file.
You can &lt;a href="https://drive.google.com/file/d/1YqOFKZlCQoWJBUT9B3HI7q0i6DHvT9or/view?usp=sharing"&gt;download&lt;/a&gt;
v1 of this file, but Lichess is the ultimate copyright holder.&lt;/p&gt;
&lt;h2&gt;First steps&lt;/h2&gt;
&lt;p&gt;The games in the dataset end in one of three conditions: Normal (checkmate or
what passes for it in Atomic), Time forfeit, and Abandoned (game terminated
before it began). The last category is very rare, and I omit these from my processing.
The majority of games end in the Normal way, as tabulated here:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th align="left"&gt;termination&lt;/th&gt;
&lt;th align="right"&gt;n&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td align="left"&gt;Normal&lt;/td&gt;
&lt;td align="right"&gt;8426052&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td align="left"&gt;Time forfeit&lt;/td&gt;
&lt;td align="right"&gt;1257295&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The game data includes Elo scores for players, as computed prior to the game.
As a first check, I wanted to see if Elo is properly calibrated.
To do this, I compute the empirical win rate of White over Black,
grouped by bins of the difference in their Elo …&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Steven E. Pav</dc:creator><pubDate>Fri, 07 May 2021 21:51:52 -0700</pubDate><guid isPermaLink="false">tag:www.gilgamath.com,2021-05-07:/atomic-one.html</guid><category>analysis</category><category>data</category><category>chess</category><category>atomic</category></item><item><title>Nonparametric Market Timing</title><link>https://www.gilgamath.com/nonparametric_market_timing.html</link><description>&lt;p&gt;Market timing a single instrument with a single feature&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Steven</dc:creator><pubDate>Sat, 04 Jan 2020 21:07:06 -0800</pubDate><guid isPermaLink="false">tag:www.gilgamath.com,2020-01-04:/nonparametric_market_timing.html</guid><category>quant-finance</category><category>R</category><category>analysis</category><category>statistics</category><category>Markowitz</category><category>portfolio</category><category>tactical-asset-allocation</category></item><item><title>ohenery!</title><link>https://www.gilgamath.com/ohenery.html</link><description>&lt;p&gt;ohenery package to CRAN&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Steven</dc:creator><pubDate>Wed, 25 Sep 2019 21:32:52 -0700</pubDate><guid isPermaLink="false">tag:www.gilgamath.com,2019-09-25:/ohenery.html</guid><category>R</category><category>package</category></item><item><title>Discrete State Market Timing</title><link>https://www.gilgamath.com/market-timing.html</link><description>&lt;p&gt;Market timing with a discrete feature&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Steven</dc:creator><pubDate>Sun, 30 Jun 2019 10:22:58 -0700</pubDate><guid isPermaLink="false">tag:www.gilgamath.com,2019-06-30:/market-timing.html</guid><category>quant-finance</category><category>R</category><category>analysis</category><category>statistics</category><category>Markowitz</category><category>portfolio</category><category>tactical-asset-allocation</category></item><item><title>Conditional Portfolios with Feature Flattening</title><link>https://www.gilgamath.com/portfolio-flattening.html</link><description>&lt;h2&gt;Conditional Portfolios&lt;/h2&gt;
&lt;p&gt;When I first started working at a quant fund I tried to read
about portfolio theory. (Beyond, you know, "&lt;em&gt;Hedge Funds for Dummies&lt;/em&gt;.")
I learned about various objectives and portfolio constraints,
including the Markowitz portfolio, which felt very natural.
Markowitz solves the mean-variance optimization problem, as
well as the Sharpe maximization problem, namely
&lt;/p&gt;
&lt;div class="math"&gt;$$
\operatorname{argmax}_w \frac{w^{\top}\mu}{\sqrt{w^{\top} \Sigma w}}.
$$&lt;/div&gt;
&lt;p&gt;
This is solved, up to scaling, by the Markowitz portfolio &lt;span class="math"&gt;\(\Sigma^{-1}\mu\)&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;When I first read about the theory behind Markowitz, I 
did not read anything about where &lt;span class="math"&gt;\(\mu\)&lt;/span&gt; and &lt;span class="math"&gt;\(\Sigma\)&lt;/span&gt; come from.
I assumed the authors I was reading were talking about the
vanilla sample estimates of the mean and covariance,
though the theory does not require this.&lt;/p&gt;
&lt;p&gt;There are some problems with the Markowitz portfolio.
For us, as a small quant fund, the most pressing issue
was that holding the Markowitz portfolio based on the
historical mean and covariance was not a good look.
You don't get paid "2 and twenty" for computing some
long term averages.&lt;/p&gt;
&lt;!-- PELICAN_END_SUMMARY --&gt;

&lt;p&gt;Rather than holding an &lt;em&gt;unconditional&lt;/em&gt; portfolio, 
we sought to construct a &lt;em&gt;conditional&lt;/em&gt; one,
conditional on some "features". 
(I now believe this topic falls under the rubric of "Tactical Asset
Allocation".)
We stumbled on two simple methods for adapting
Markowitz theory to accept conditioning information:
Conditional Markowitz, and "Flattening".&lt;/p&gt;
&lt;h2&gt;Conditional Markowitz&lt;/h2&gt;
&lt;p&gt;Suppose you observe some &lt;span class="math"&gt;\(l\)&lt;/span&gt; vector of features, &lt;span class="math"&gt;\(f_i\)&lt;/span&gt; prior
to the time you have to allocate into &lt;span class="math"&gt;\(p\)&lt;/span&gt; assets to enjoy
returns &lt;span class="math"&gt;\(x_i\)&lt;/span&gt;. Assume that the returns are linear in the features,
but the covariance is a long term average. That is
&lt;/p&gt;
&lt;div class="math"&gt;$$
E\left[x_i \left|f_i\right.\right] = B f_i,\quad\mbox{Var}\left(x_i \left|f_i\right.\right) = \Sigma.
$$&lt;/div&gt;
&lt;p&gt;Note that Markowitz theory never really said how to estimate
mean …&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Steven E. Pav</dc:creator><pubDate>Wed, 19 Jun 2019 21:04:21 -0700</pubDate><guid isPermaLink="false">tag:www.gilgamath.com,2019-06-19:/portfolio-flattening.html</guid><category>quant-finance</category><category>analysis</category><category>statistics</category><category>Markowitz</category><category>portfolio</category><category>tactical-asset-allocation</category></item><item><title>No Parity like a Risk Parity.</title><link>https://www.gilgamath.com/risk-parity.html</link><description>&lt;h2&gt;Portfolio Selection and Exchangeability&lt;/h2&gt;
&lt;p&gt;Consider the problem of &lt;em&gt;portfolio selection&lt;/em&gt;, where you observe
some historical data on &lt;span class="math"&gt;\(p\)&lt;/span&gt; assets, say &lt;span class="math"&gt;\(n\)&lt;/span&gt; days worth in an &lt;span class="math"&gt;\(n\times p\)&lt;/span&gt;
matrix, &lt;span class="math"&gt;\(X\)&lt;/span&gt;, and then are required to construct a (dollarwise)
portfolio &lt;span class="math"&gt;\(w\)&lt;/span&gt;. 
You can view this task as a function &lt;span class="math"&gt;\(w\left(X\right)\)&lt;/span&gt;.
There are a few different kinds of &lt;span class="math"&gt;\(w\)&lt;/span&gt; function: Markowitz,
equal dollar, Minimum Variance, Equal Risk Contribution ('Risk Parity'), 
and so on.&lt;/p&gt;
&lt;p&gt;How are we to choose among these competing approaches?
Their supporters can point to theoretical underpinnings,
but these often seem a bit shaky even from a distance.
Usually evidence is provided in the form of backtests
on the historical returns of some universe of assets.
It can be hard to generalize from a single history,
and these backtests rarely offer theoretical justification
for the differential performance in methods.&lt;/p&gt;
&lt;!-- PELICAN_END_SUMMARY --&gt;

&lt;p&gt;One way to consider these different methods of portfolio
construction is via the lens of &lt;em&gt;exchangeability&lt;/em&gt;.
Roughly speaking, how does the function &lt;span class="math"&gt;\(w\left(X\right)\)&lt;/span&gt; react
under certain systematic changes in &lt;span class="math"&gt;\(X\)&lt;/span&gt; that "shouldn't" matter.
For example, suppose that the ticker changed on
one stock in your universe. Suppose you order the columns of
&lt;span class="math"&gt;\(X\)&lt;/span&gt; alphabetically, so now you must reorder your &lt;span class="math"&gt;\(X\)&lt;/span&gt;.
Assuming no new data has been observed, shouldn't
&lt;span class="math"&gt;\(w\left(X\right)\)&lt;/span&gt; simply reorder its output in the same way?&lt;/p&gt;
&lt;p&gt;Put another way, suppose a method &lt;span class="math"&gt;\(w\)&lt;/span&gt; systematically
overweights the first element of the universe
(This seems more like a bug than a feature),
and you observe backtests over the 2000's on 
U.S. equities where &lt;code&gt;AAPL&lt;/code&gt; happened to be the
first stock in the universe.  Your &lt;span class="math"&gt;\(w\)&lt;/span&gt; might
seem to outperform other methods for no good reason.&lt;/p&gt;
&lt;p&gt;Equivariance to order is a kind of exchangeability condition. 
The 'right' kind of &lt;span class="math"&gt;\(w\)&lt;/span&gt; is 'order …&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Steven E. Pav</dc:creator><pubDate>Sun, 09 Jun 2019 22:53:04 -0700</pubDate><guid isPermaLink="false">tag:www.gilgamath.com,2019-06-09:/risk-parity.html</guid><category>quant-finance</category><category>analysis</category><category>statistics</category><category>Markowitz</category><category>portfolio</category><category>R</category></item></channel></rss>