Repository navigation
nns_copula: independence anchors from the empirical marginals (book ch12) - #171
Closed
gitRasheed wants to merge 1 commit into
Closed
gitRasheed wants to merge 1 commit into
gitRasheed wants to merge 1 commit into
Conversation
gitRasheed
force-pushed
the
rasheed/book-copula-anchor
branch
from
November 2, 2026 04:12
cf3233e to
dc59d8c
Compare
gitRasheed
force-pushed
the
rasheed/book-seas-all-phases
branch
from
November 2, 2026 04:12
fb469dd to
b392514
Compare
…chor)
Mirrors R's copula-marginal-anchor branch (NNS.copula), including its
round-2 fixes. The copula compared its co-moments with fixed anchors,
0.25 * (n^2 - n) for the pairwise sum and 1 - 2 * 0.5^n for the nD
divergent share, which hold only when every target is the median. The
default target is the column means, so independent skewed data read
about 0.2.
Each term now uses its own independence value from each margin's lower
share p_j at its target: pairs sum p_i p_j + (1 - p_i)(1 - p_j), and the
divergent share is 1 - prod(p) - prod(1 - p). Degree-0 terms use
p_j = LPM(0, t_j, x_j), degree-1 terms LPM.ratio(1, t_j, x_j) (degree 0
for both with continuous=False). The nD terms are clamped to 1 like the
pairwise ones. Constant margins are dropped first (fewer than two
varying margins give 0), and a moment equal to a zero anchor scores 0.
Both copula._copula and the native copula_nd change; nns_reg's default
order and dependence inherit it.
Before -> after (= R):
independent Exp(1), 3 columns, n = 2e4 0.1910 -> 0.0604
continuous=False 0.2591 -> 0.0382
independent normals, 3 columns 0.0663 (unchanged)
[x, 1], x = -2..2 0.7746 -> 0
three -10/0.1 rows, target 0 0.7053 -> 0.8507
interior-pair-sum integer matrix 0.5837 -> 0.5780
test_Copula.R B C D E 0.2554 0.2 0.2470 0.2
-> 0.2543 0.1970 0.2506 0.2088
The adopted test_Copula.R fixture takes R's updated values. 26 entries
(14 NNS.copula, 5 NNS.reg, 5 dy.dx.numeric, 2 NNS.boost.numeric) predate
the R change and were refilled; 10 are added for the new test.
gitRasheed
force-pushed
the
rasheed/book-copula-anchor
branch
from
November 2, 2026 23:09
dc59d8c to
f01e08b
Compare
Contributor
|
Incorporated through NNS R 14.0 integration #192, merged as |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
nns_copulacompares its co-moments with fixed anchors, 0.25 * (n^2 - n) for the pairwise sum and 1 - 2 * 0.5^n for the nD divergent share. They hold only when every target is the median, and the default target is the column means, so independent skewed data read about 0.2. Book ch12 defines the copula through the marginals, CoLPM_00 = C(F_X(t_X), F_Y(t_Y)) (ch12:130-133). We mirror OVVO-Financial/NNS#86, which makes R follow the book, including its round-2 fixes. That PR changes the method, so the R author may close it; if so, this slice should be dropped too.Stacked on #170; merge with a merge commit.
Changes
continuous=False. Independent Exp(1) data with 3 columns at n = 2e4 go from 0.1910 to 0.0604; independent normals stay at 0.0663.[x, 1]for x = -2..2 goes from 0.7746 to 0. A moment equal to a zero anchor scores 0.copula._copulaand the nativecopula_ndboth change, andnns_reg's default order and dependence inherit it.Tests
New parity cases for the anchors, constant margins and boundary targets. The
test_Copula.Rfixture takes R's updated values: B, C, D and E go from 0.2554, 0.2, 0.2470, 0.2 to 0.2543, 0.1970, 0.2506, 0.2088. 26 entries that predate the R change are refilled (14NNS.copula, 5NNS.reg, 5dy.dx.numeric, 2NNS.boost.numeric), one of them the boost balance case whose structure-only test had let a stale value pass. The parity cache encodes R 13.3 plus the fixes in OVVO-Financial/NNS#73-#92. The nineNNS.VARstrict xfails from #170 stay until #174.Mirrors OVVO-Financial/NNS#86
Part of OVVO-Financial/NNS#70
Review
GPT-6.1 Sol reviewed this slice and found nothing. It compared 400 cases against R on both paths.