Qu

Uncategorised

qu_twin_axis_reference

A two-panel figure of the shape journals actually print: a distribution with its two summary statistics called out, and a dual-axis panel whose axes are colour-bound to their own series.

catalog/qu_twin_axis_reference.qu

Kept as a catalogue case because it is the hardest ordinary figure to make well -- a bar series and a line series on independent y axes, each axis tinted to say which numbers belong to it, categorical x labels, and real mathematics in every title and axis label.

Run: qu run catalog/qu_twin_axis_reference.qu

Results

0 50 100 150 200 250 300 350 -0.1 0 0.1 0.2 0.3 x=-0.111, y=120 x=-0.104, y=0 x=-0.097, y=0 x=-0.089, y=2 x=-0.082, y=2 x=-0.074, y=2 x=-0.067, y=4 x=-0.06, y=5 x=-0.052, y=12 x=-0.045, y=19 x=-0.037, y=30 x=-0.03, y=53 x=-0.023, y=50 x=-0.015, y=64 x=-0.008, y=84 x=$-5.9\times10^{-4}$, y=106 x=0.007, y=145 x=0.014, y=193 x=0.022, y=212 x=0.029, y=214 x=0.036, y=256 x=0.044, y=270 x=0.051, y=293 x=0.058, y=272 x=0.066, y=346 x=0.073, y=316 x=0.081, y=321 x=0.088, y=289 x=0.095, y=279 x=0.103, y=291 x=0.11, y=234 x=0.118, y=221 x=0.125, y=198 x=0.132, y=172 x=0.14, y=153 x=0.147, y=130 x=0.154, y=116 x=0.162, y=80 x=0.169, y=86 x=0.177, y=65 x=0.184, y=59 x=0.191, y=45 x=0.199, y=42 x=0.206, y=27 x=0.213, y=22 x=0.221, y=10 x=0.228, y=9 x=0.236, y=15 x=0.243, y=5 x=0.25, y=9 x=0.258, y=10 x=0.265, y=4 x=0.273, y=1 x=0.28, y=0 x=0.287, y=4 x=0.295, y=1 x=0.302, y=1 x=0.309, y=0 x=0.317, y=0 x=0.324, y=31 (a) what trees actually buy over ridge gain: trees R2 − fitted ridge R2 households realised, median +0.075 ΔNL predicted, median +0.043 0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 ×10−2 0.025 0.03 0.035 0.04 0.045 0.05 0.055 0.06 ≤ 0.3 0.3-0.4 0.4-0.5 0.5-0.6 0.6-0.7 > 0.7 x=0, y=0.076 x=1, y=0.082 x=2, y=0.081 x=3, y=0.077 x=4, y=0.076 x=5, y=0.073 x=0, y=0.061 x=1, y=0.058 x=2, y=0.051 x=3, y=0.044 x=4, y=0.036 x=5, y=0.025 (b) the (1 − Πlin) scaling, cross-estimator: flat once de-artefacted linear ceiling Πlin* (test window) relative dividend gain/(1 − Πlin) absolute gain (median)
Drawn by running the program above.

The whole program

Runnable as it stands: qu run catalog/qu_twin_axis_reference.qu

# A two-panel figure of the shape journals actually print: a distribution

# with its two summary statistics called out, and a dual-axis panel whose

# axes are colour-bound to their own series.

#

# Kept as a catalogue case because it is the hardest ordinary figure to

# make well -- a bar series and a line series on independent y axes, each

# axis tinted to say which numbers belong to it, categorical x labels, and

# real mathematics in every title and axis label.

#

# Run:  qu run catalog/qu_twin_axis_reference.qu


theme("publication")
figure_size(7.16, 2.9, unit = "in")

# ----------------------------------------------------------- (a) the gain

# A right-skewed distribution with a small spike of zeros at each end --

# households where the flexible model bought nothing, and where it bought

# a great deal.

n = 6000
seed(11)
gain = 0.055 + 0.045 * randn(n)
gain = gain + 0.06 * max(0, randn(n))
gain[0:119] = -0.115
gain[5970:5999] = 0.325

subplot(1, 2, 1)
hist(gain, bins = 60, color = "#8f57b5", alpha = 0.95)
vline(0, color = "#555555", width = 1.2)
vline(median(gain), color = "#c0392b", dash = true, width = 1.6,
      label = "realised, median +{median(gain):.3f}")
vline(0.043, color = "#2f6fb5", dot = true, width = 1.6,
      label = "$\widehat{\Delta}_{\mathrm{NL}}$ predicted, median +0.043")
xlabel("gain: trees $R^2$ $-$ fitted ridge $R^2$")
ylabel("households")
title("(a) what trees actually buy over ridge")
legend top right

# ------------------------------------------------ (b) the twin-axis panel

subplot(1, 2, 2)

ceiling  = ("$\leq$ 0.3", "0.3-0.4", "0.4-0.5", "0.5-0.6", "0.6-0.7", "> 0.7")
relative = [0.0755, 0.0820, 0.0810, 0.0772, 0.0763, 0.0733]
absolute = [0.0608, 0.0580, 0.0513, 0.0443, 0.0355, 0.0245]

C_bar  = "#e07b1a"
C_line = "#1f6fb4"

bar(relative, color = C_bar, width = 0.62)
xticklabels(ceiling)
ylabel("relative dividend  gain/(1 $-$ $\widehat{\Pi}^{\mathrm{lin}}$)")
ylim(0, 0.088)

yyaxis right
plot(absolute, color = C_line, marker = "o-", fill = true,
     ms = pt(3.2), lw = pt(1.6))
ylabel("absolute gain (median)")
yyaxis left

xlabel("linear ceiling  $\Pi^{\mathrm{lin}*}$ (test window)")
title("(b) the $(1-\Pi^{\mathrm{lin}})$ scaling, cross-estimator: flat once de-artefacted")

savefig("qu_twin_axis_reference.svg")