Repository navigation
Mirror the R fixes to moments, CDF, dependence and partitions - #158
Closed
gitRasheed wants to merge 25 commits into
Closed
gitRasheed wants to merge 25 commits into
gitRasheed wants to merge 25 commits into
Conversation
gitRasheed
force-pushed
the
rasheed/native-core
branch
from
November 2, 2026 04:12
e8c62df to
a0536f1
Compare
gitRasheed
force-pushed
the
rasheed/r-fixes-moments-dependence
branch
from
November 2, 2026 04:12
eac3a7b to
be46bb3
Compare
…f the R fix)
The univariate hazard uses the finite-difference density proxy
(F[hi] - F[lo]) / (x[hi] - x[lo]) over a +-5 window of sorted x. When
the window lies inside a run of tied values the width is 0, the proxy
is NaN and nns_reg stopped with "[y] must contain finite values."
Discrete, rounded or return data with zero-return runs hit this. As in
the patched R, such windows are widened to the neighbouring distinct
values; windows of positive width are untouched. A constant variable now
raises "type = 'hazard' requires at least two distinct values of
variable".
Before -> after (A/B against the patched R):
NVDA daily returns [1:1000] error -> finite hazard, equal to R
(max abs diff 1.4e-14 over 1001 values)
Poisson(3), n = 200 error -> equal to R (2.2e-16)
rep(2, 5) "[y] must contain finite values."
-> the R message
Untied data are unchanged (rnorm(300): equal to R to 1.1e-16). The 37
NNS.CDF.custom cache entries the tests read were regenerated from the
patched R and are unchanged; four entries for the new tie-run tests are
added.
The parity tests for this slice's fixes read 31 entries that were still from unpatched R 13.3 or from before the degree-0 tie, NNS.copula perfect-dependence and NNS.dep sign patches: NNS.dep (17), NNS.reg (4), Co.UPM_nD (2), the positional multi-factor NNS.boost case (2), NNS.caus (1) and five label/level entries. Re-record them from R 13.3 + the patch series, like the rest of the cache.
Python's NNS.VAR here has the integer-x centroid fix but not the forecast-row and stack fixes, so neither unpatched nor patched R matches these eight cases. Mark them xfail(strict=False) until those fixes are mirrored.
The NNS.dep entries are now recorded from the patched R and the native kernels carry the core fixes, so neither listed exception holds any more.
nns_moments(population=False) computed the skewness as n/((n-1)(n-2)) * n*mean(z^3) / v^(3/2) with v the population variance, copying NNS.moments. The adjusted Fisher-Pearson estimator G1 (Excel SKEW, scipy skew(bias=False)) divides by s^3 with s the (n-1) sample sd, which the kurtosis branch already does; the old value was inflated by (n/(n-1))^1.5. R fixed this. Before -> after (population=False): x = [1, 2, 4, 8, 16] 1.852184 -> 1.325315 (= fixed R, G1) x = [-2, -1, 0.5, 1.5, 3, 8] 1.612817 -> 1.226911 (= fixed R) Population statistics, mean, variance and kurtosis are unchanged. The NNS.moments cache shard is regenerated from the patched R.
…R fix)
The multivariate survival, hazard and cumulative hazard used the 2-D
formula 1 - sum(marginals) + joint CDF for any number of columns, which
is not P(X_1 > t_1, ..., X_d > t_d) for d >= 3. Only the first two
target coordinates were bounds-checked, and the hazard / cumulative
hazard target.value used 1 - CDF(target) (the hazard one regressed the
already transformed values), so it disagreed with the returned function
even for d = 2. R fixed all of this.
Compute the joint survival by inclusion-exclusion over all column
subsets (Co.LPM_nD batch on each subset), evaluate target.value with
the same formula (one hazard fit with point_est = target, as R), and
check every target coordinate plus the target length.
Before -> after:
40 x 3 correlated normals, degree 0 survival: max |S - P(all X > t)|
0.275 -> 3e-16 (now equal to the patched R for all three types)
2 x 3 matrix [[1,2],[2,1],[3,3]], hazard, target (2, 2):
target.value 3.0 -> 1.0 (= patched R, = the function at that row)
target (0, 0, 1e6) on 3 columns: 0.34 -> ValueError (out of bounds)
The d = 2 Function output is unchanged. The NNS.CDF.custom shard is
regenerated from the patched R; four univariate entries keep their
13.3 values until the LPM.ratio NaN and NNS.part rounding mirrors
land.
For degree > 0, lpm_ratio/upm_ratio are LPM / (LPM + UPM), which is 0/0 when every observation equals the target, so nns_cdf([2, 2, 2, 2], 1) and nns_cdf([2], 1) were all NaN (as in R 13.3). R now returns the degree-0 ratio there (the degree -> 0 limit and the ECDF convention x <= target): LPM ratio 1, UPM ratio 0. Do the same in both the native and the NumPy path of lpm_ratio/upm_ratio. Before -> after (= patched R): lpm_ratio(1, 3, [3, 3, 3, 3]) NaN -> 1 upm_ratio(1, 3, [3, 3, 3, 3]) NaN -> 0 nns_cdf([5] * 5, 1)["Function"] NaN x 5 -> 1 x 5 nns_anova(ones(100), ones(100)) Certainty NaN -> 0 (also robust) Only targets with zero total deviation change. The LPM.ratio shard is regenerated (no existing entry changes), a UPM.ratio shard is added, and the point-mass NNS.CDF.custom entry is refreshed from the patched R.
…of the R fix)
R's LPM.ratio/UPM.ratio/Co.*/D.*/PM.matrix did no validation and
counted NA observations in n, so NNS.CDF of double data with NA topped
out below 1; nns_cdf copied that on purpose. R now stops on
non-finite input in those wrappers ("`<arg>` must be finite.") and
NNS.CDF drops missing observations (complete rows for a matrix) first.
Python:
- lpm_ratio/upm_ratio reject a non-finite target (x was already checked);
- co_lpm/co_upm/d_lpm/d_upm reject non-finite x, y and targets, and
pm_matrix a non-finite variable or target (they returned NaN);
- nns_cdf drops NaN (complete rows for a matrix) and raises on Inf; the
emulation of R's NA-in-denominator quirk is removed.
Before -> after (= patched R):
nns_cdf([1, 2, 3, NaN, 5])["CDF"] 0.2 0.4 0.6 0.8 -> 0.25 0.5 0.75 1
nns_cdf([1, 2, 3, NaN, 5], target=2) ValueError -> target.value 0.5
nns_cdf([[1,2],[2,NaN],[3,1],[4,4]]) ValueError -> CDF 1/3 1/3 1 (3 rows)
nns_cdf([1, inf, 2]) 0.33 0.67 0.67 -> ValueError
co_lpm(0, [1,2,3,NaN,5], ..., 6, 6) NaN -> ValueError
Finite inputs are unaffected. The Co.LPM, Co.UPM, D.LPM, D.UPM,
PM.matrix, LPM.ratio and UPM.ratio shards are regenerated from the
patched R: no entry value changes; the four co-moment shards drop 120
stale keys each and gain the 120 entries the current tests request.
The co-moment parity tests drew correlated pairs with Generator.multivariate_normal, which factorises the covariance with LAPACK; its last bits differ across NumPy/BLAS builds, so the inputs, and with them the R cache keys, changed from one environment to the next (120 cache misses per run under NumPy 2.5, a hard failure under NNS_R_CACHE_ONLY). Build the pair from standard normals with an explicit Cholesky factor, re-record the entries from R, and drop the entries no test reads any more.
R's LPM/UPM take excess_ret = TRUE for element-wise targets (one target per observation, or a single target) returning mean(max(target_i - x_i, 0)^degree); Python had no such option (lpm(..., excess_ret=True) raised TypeError). R's excess branch also used a strict diff > 0 test at degree 0, so a tie counted in neither tail; R fixed that. Add excess_ret: bool = False to lpm and upm with the patched R semantics (degree-0 LPM counts x_i <= target_i, target length 1 or len(x), else ValueError). lpm(0, 2, [1, 2, 3], excess_ret=True) 0.6667 (= patched R; 13.3 0.3333) lpm(0, ...) + upm(0, ...) with excess_ret=True 1.0 upm(1.5, [2, 1, 5], [1, 2, 3], excess_ret=True) 0.3333 (= R) The default (excess_ret=False) is unchanged. The LPM and UPM shards are regenerated from the patched R (no existing entry changes; 8 excess_ret entries each are added).
copula_signed returned an unsigned +1 both when every point of a partition cell was concordant and when every point was discordant, skipping the slope sign, so NNS.dep(x, -x) reported Correlation +1. R now returns -1 for a fully discordant cell. Apply the same change to the NumPy path of nns_dep (_copula_signed). Before -> after on that path (= patched R): nns_dep(x, -x), x = 300 normals 1 / 1 -> -1 / 1 nns_dep(1:100, -(1:100)) 0.370 / 0.990 -> -0.990 / 0.990 nns_dep([1, 2], [2, 1]) 1 / 1 -> -1 / 1 (asym=True likewise). Dependence is unchanged. The native nns_dep_pair kernel (src/nns/_nnscore_bindings.cpp dep_copula_signed, and extern/NNS-core dependence.cpp copula_signed) has the same early return and cannot be rebuilt here, so the default path still gives the 13.3 numbers until the native core is updated. The NNS.dep shard is regenerated from the patched R, except that the seven entries whose tests run on the native path (quadratic/noise cases and the matrix form, which contain fully discordant cells) keep their 13.3 values for now.
nns_causation truncated tau = 1.5 to 1, accepted tau = "3" and tau >= n (then failed with "x must be non-empty"), and returned 0/0/0 for a constant variable. R now validates the bivariate path: non-constant x and y, and tau must be "cs", "ts" or a single non-negative integer smaller than length(x) - 2; tau = "ts" without a qualifying period stops with a message asking for a numeric tau. Do the same in nns_causation (and so causal_matrix, which calls it per pair, as R's NNS.caus.matrix calls NNS.caus): tau = 1.5 / -1 / "3" / "foo" / True / NaN / >= n - 2 -> ValueError constant x or y 0/0/0 -> ValueError tau = 3, 3.0, numpy integers, "cs", 0 unchanged (= R) The NNS.caus shard is regenerated from the patched R (no entry changes; the new integer-tau entries are added).
…of the R fix)
When x was integer-valued, NNS.part rounded the x coordinate of every
regression point half-up to an integer but kept the cell's y centroid,
so the point no longer lay on the cell centroid. That biases every
NNS.reg with integer predictors (counts, years, ages), and NNS.ARMA's
nonlinear method, which regresses each component on its integer time
index. R removed the rounding.
Python rounded in the same places: nns_part's NumPy path, the native
nns_part_off kernel and the native nns_reg_mv fast path (both in
_nnscore_bindings.cpp, which cannot be rebuilt here). Drop the NumPy
rounding; for the native partition recompute the x centroids from the
returned prior quadrants when x is integer-valued; and skip the native
nns_reg_mv fast path for integer-valued x (the NumPy path is not slower
on the ARMA component sizes: nns_arma(AirPassengers, h=12, sf=c(12,24,36))
0.051 s -> 0.028 s).
Before -> after (= patched R):
nns_reg(1:1000, 2*(1:1000)): max |y.hat - y| 1 -> 0; regression points
x 1, 2, 4 -> 1, 1.5, 4.25
nns_reg(1:10, 3*(1:10) + 1) R2 0.99375 -> 1
nns_part(1:20, (1:20)^2, order=2) points x 15, 5 -> 14.593, 4.625
nns_arma(AirPassengers, h=3) 317.5 392.25 422.25 -> 333 421 458
nns_arma(AirPassengers, h=3, sf=12) 450.25 421.52 446.10 -> 450.05 421.33 445.93
Continuous x is unchanged; the native kernels need the same change when
the native core is rebuilt.
Shards regenerated from the patched R: NNS.part, NNS.reg,
NNS.reg.factor_predictor.v2, NNS.ARMA, NNS.ARMA.pred_int,
NNS.ARMA.optim.custom, NNS.boost.factor_predictor,
NNS.boost.multi_factor_predictor.positional.v1, NNS.CDF.custom,
NNS.stack.factor_predictor.v2, NNS.VAR, NNS.VAR.custom. Entries whose
tests also depend on the NNS.ARMA/NNS.VAR fixes mirrored next keep their
13.3 values for now; eight NNS.VAR parity tests (and the live practical
VAR example) only pass again once those land.
After the mirror commits every shard in tests/_r_cache was regenerated
from R 13.3 plus the local R bug-fix series (the local
branch fix/combined) by running the whole suite with that build;
untouched functions reproduced byte for byte apart from one
last-digit change in NNS.reg.factor_dimred (committed here). Seven
NNS.dep entries keep their 13.3 values because the native nns_dep_pair
kernel still has the sign bug R fixed.
Document this in docs/parity.md ("Cache provenance: R 13.3 + patches")
and in sync/nns_source.json "notes".
Re-vendor extern/NNS-core from NNS-core with
scripts/sync_nns_core_snapshot.py. The new core commits
mirror the R patches already in the parity cache's R build:
- Degree-0 Co.UPM_nD counts rows strictly above the
target and DPM_nD / the bivariate discordant count are "neither
co-lower (<=) nor co-upper (>)", so the three counts partition the
sample.
- mreg_setup's "mode" reducer is NNS.mode (not bound
in the extension, so no Python result depends on it).
- copula_signed returns -1 for a fully
discordant cell and compares the concordant count with n exactly.
Native extension, before -> after (R 13.3 + patches in brackets):
nns_dep(x, -x), x ~ N(0,1), n = 100: Correlation 1 -> -1 [-1]
native cupm_nd / dpm_nd, x = (1,2,3,3,4,5), y = (3,3,1,5,3,2),
target (3, 3), degree 0: 0.333 / 1 -> 0 / 0.5 [0 / 0.5]
nns_dep(u, v), u, v independent permutations of 100 x {-1, 0, 1}:
Dependence 0.2872 -> 0.1414 (the fallback still gives 0.2872;
the next commit aligns it)
sync/nns_source.json records the new core commit and the fixes it
carries.
The NumPy code paths that run without the extension (and, for the nD
co-moments and NNS.caus, always) still used the old R rules:
- _copula_moments counted a point tied with the cell mean as co-lower
AND discordant (discordant was "not strictly co-lower or co-upper").
Discordant is now "neither co-lower (<=) nor co-upper (>)", i.e.
n - concordant (R patch "NNS.dep: degree-0 discordant count
uses the same split as the co-counts", as in NNS-core).
- _copula_signed compared the concordant share count * (1/n) with 1,
which fails for n = 49, 98, 103 and more. It now compares the
count with n (+1) and with 0 (-1, the sign fix it already had),
as NNS-core does.
- co_upm_nd / dpm_nd at degree 0 counted ties with the target as upper
and as discordant. Co.UPM_nD now counts rows strictly above the target
in every coordinate and DPM_nD rows that are neither all <= nor all >,
so CLPM + CUPM + DPM = 1 (R patch "Co.UPM_nD/DPM_nD: degree-0 counts
partition the sample"). These functions have no native binding, so
this changes public results on tied data. Degree > 0 is unchanged (a
tied coordinate contributes a zero factor either way).
The multivariate NNS.reg "mode" reducer (_reduce_value) already used
nns_mode with discrete = FALSE, multi = FALSE for numeric cells and the
exact-frequency mode for class responses; the arguments are
now spelled out so a change of nns_mode's defaults cannot move it.
Fallback (NNS_DISABLE_NATIVE=1), before -> after [R 13.3 + patches]:
nns_dep(b, b), b = 51 zeros + 49 ones: 0.51 / 0.755 -> 1 / 1 [1 / 1]
nns_dep(u, v), independent permutations of 100 x {-1, 0, 1}:
Dependence 0.2872 -> 0.1414 [0.1414]
co_lpm_nd / co_upm_nd / dpm_nd, x = (1,2,3,3,4,5), y = (3,3,1,5,3,2),
target (3, 3), degree 0: 0.5 / 0.333 / 1 -> 0.5 / 0 / 0.5 [0.5 / 0 / 0.5];
500 x 3 draws from {-1, 0, 1}, target 0: sum 1.528 -> 1.
New invariant tests: the dep fallback equals the native kernel on 63
tie-heavy pairs (both asym settings) and the degree-0 nD fallbacks equal
the native clpm_nd/cupm_nd/dpm_nd and sum to 1. Both fail on the old
fallback.
NNS.copula returned 1 whenever the sum of the degree-0 co-partial
moments over the column pairs was exactly 1 or 0. That is the bivariate
rule: with d >= 3 columns "every pair fully concordant" is a sum of
d(d-1)/2, and a sum of 1 is an interior value. Mirror the R patch
"NNS.copula: dimension-generic perfect-dependence early return" in
copula._copula and in the binding's copula_nd: return 1 only when the
sum equals d(d-1)/2, or 0 for two variables, with a 1e-9 tolerance (far
below one observation's 1 / nrow).
The binding's copula_nd also kept its own degree-0 DPM_nD, which still
counted a row tied with the target as discordant; it now uses the
degree-0 tie split (not all <= target and not all > target), like R's
DPM_nD and the NumPy fallback. Degree 1 is unchanged (a tied coordinate
contributes a zero factor).
Before -> after (native and fallback agree; R 13.3 + patches in brackets):
3000 random 10 x 3 integer matrices (values 1..5, numpy seed 1):
copula == 1 in 170 -> 0 [0]; mean 0.4389 -> 0.4141
[0.4141, max |diff| 1.7e-16]; the tie split alone gives 0.4378
draws 6 / 14 / 24 (pair sum exactly 1): 1 -> 0.5766 / 0.6117 / 0.5988
300 x 2 independent permutations of {-1, 0, 1} (means exactly 0):
0.4062 -> 0.2000 [0.2000]
cbind(x, x, x), cbind(x, 2x, x + 1), cbind(x, -x): 1 (unchanged)
New parity tests (native and fallback, continuous TRUE/FALSE) with
their R cache entries from R 13.3 + patches.
Lag 0 failed the new len(x) - 2 check, so two cross-sectional observations raised ValueError; they now give the zero matrix R's NNS.caus.matrix returns.
The native kernel now scores fully discordant cells -1 as well (nns_dep([1, 2], [2, 1]) gives Correlation -1.0 natively).
They point at notes that don't live in this repo.
The binding's regression_points_from_prior still rounded every
regression-point x half-up when x was integer-valued, which R removed
("NNS.part: do not round regression-point x for integer-valued x").
nns_part worked around it by recomputing the x centroids from the
returned prior quadrants (_prior_group_gravity). Drop the rounding in
the kernel and the workaround in part.py.
NNS-core needs no change: its partition.cpp ports R's NNS_part.cpp,
which never rounded (the rounding was in R's Partition_Map.R), and the
nns_reg_mv kernel that also rounded was already removed from the
binding. No other kernel in the binding rounds x.
Native kernel, NNS.part(1:20, (1:20)^2, order = 2) points x:
15, 5 -> 14.593, 4.625 (= R 13.3 + patches). Public nns_part / nns_reg
results are unchanged (the workaround produced the same centroids; the
cached part/reg/ARMA parity tests give identical results with and
without the workaround). nns_part on 1e5 integer x: 0.106 s -> 0.090 s;
nns_reg(1:144, sin) 1.2 ms -> 0.8 ms.
New parity test: integer-x partitions (quadrant and XONLY) through the
native kernel and the NumPy path against R 13.3 + patches; the native
cases fail on the old extension.
a = 1:5, b = (1,2,1,4,3), cc = (2,1,3,5,4): every column pair of
cbind(a, b, cc) is fully concordant about the column means, so the
degree-0 pair sum is 3 = choose(3, 2). R 13.3 compared the sum with 1
and returned 0.9660918 (continuous) / 0.9309493 (discrete); R 13.3 +
patches ("NNS.copula: dimension-generic perfect-dependence early
return") and nns_copula since the perfect-dependence commit return 1 for
both. The bivariate expectations (1, 1) are unchanged.
gitRasheed
force-pushed
the
rasheed/r-fixes-moments-dependence
branch
from
November 2, 2026 23:09
be46bb3 to
93aa01e
Compare
gitRasheed
force-pushed
the
rasheed/native-core
branch
from
November 2, 2026 23:09
a0536f1 to
31f85d0
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.
The audit fixed a set of bugs in R that NNS-python had copied for parity: the inflated sample skewness, multivariate survival for d >= 3, the 0/0 ratio, NA counted in n, the lost sign of
NNS.dep(x, -x), the bivariate copula shortcut in any dimension, degree-0 tie counting, and the rounded regression-point x for integer x. We mirror each R fix, vendor the matching NNS-core changes from OVVO-Financial/NNS-core#33, and regenerate the parity cache from the patched R.Stacked on #157; merge with a merge commit.
Changes
nns_moments(population=False)skewness divides by the sample sd cubed (G1), as the kurtosis already did. [1, 2, 4, 8, 16] goes from 1.852184 to 1.325315.nns_cdfsurvival, hazard and cumulative hazard use inclusion-exclusion over all column subsets, check every target coordinate, and computetarget.valuethe same way as the rows. On 40 x 3 correlated normals the max survival error goes from 0.275 to 3e-16.lpm_ratio(1, 3, [3, 3, 3, 3])goes from NaN to 1, andnns_anovaof two constant groups from NaN to 0.pm_matrixfunctions reject non-finite input, andnns_cdfdrops NaN rows first.nns_cdf([1, 2, 3, NaN, 5])tops out at 1 instead of 0.8.lpmandupmgainexcess_ret, with degree-0 ties counted as lower:lpm(0, 2, [1, 2, 3], excess_ret=True)is 0.6667, where 13.3 gives 0.3333.nns_dep(x, -x)gives Correlation -1 instead of 1. The concordant count is compared with n exactly.Co.UPM_nDcounts rows strictly above the target andDPM_nDrows that are neither all <= nor all >, so CLPM + CUPM + DPM = 1; on 500 x 3 draws from {-1, 0, 1} the sum was 1.528.nns_depon independent {-1, 0, 1} permutations goes from 0.2872 to 0.1414.nns_copulareturns 1 only when the pair sum equals d(d-1)/2, instead of the bivariate test for any d. On 3000 random 10 x 3 integer matrices it returned 1 in 170 cases, now 0.nns_causationvalidates tau and rejects constant input, as the patchedNNS.causdoes. tau = 1.5 was truncated to 1, and a constant variable returned 0/0/0.nns_partkeeps the cell's x centroid for integer x.nns_reg(1:10, 3*(1:10) + 1)R2 goes from 0.99375 to 1, andnns_arma(AirPassengers, h=3)from 317.5 392.25 422.25 to 333 421 458. The nativenns_part_offkernel drops its rounding too.Tests
Parity tests for each fix, against R 13.3 with the audit's R patches. The whole cache is regenerated from that build; untouched functions reproduce byte for byte apart from one last-digit change in
NNS.reg.factor_dimred, and 31 entries that predated the patches (17NNS.dep, 4NNS.reg, 2Co.UPM_nD, 2 positional boost, 1NNS.caus, 5 labels) are re-recorded. The co-moment parity inputs come from an explicit Cholesky factor, so their cache keys no longer depend on the LAPACK build. docs/parity.md records the provenance. New invariants check the dependence and degree-0 nD fallbacks against native.Eight
NNS.VARparity cases are markedxfail(strict=False). This slice has the integer-x centroid fix but not the forecast-row or stack fixes, so no R build matches them. #159 clears all eight.Vendors OVVO-Financial/NNS-core#33
Mirrors OVVO-Financial/NNS#74, OVVO-Financial/NNS#75, OVVO-Financial/NNS#76, OVVO-Financial/NNS#84 and OVVO-Financial/NNS#85
Part of OVVO-Financial/NNS#61
Update
This push adds the excess-return case to the constant-sample target test from #154.
Review
GPT-6.1 Sol reviewed this slice and raised two findings. We took both.
causal_matrixturned tau="cs" into 0 before forwarding it, so the new validation rejected two-observation cross-sectional input. R returns a zero matrix. "cs" is forwarded unchanged and returns R's zero matrix, with a test.The fix commits have not been re-reviewed.