Internal worker that builds a dScoreTest object from a fixed
three-way (or two-way) sample split. Called by dScoreTest.
Splits, hunting algorithm, and predict semantics are taken as fully
resolved arguments — no defaults are inferred from the data.
Usage
new_dScoreTest(
y,
X,
idx.hunt,
idx.debias,
idx.test,
score_fun,
weight_fun,
fit_method,
wls_method,
hunt.style = "optimal",
hunt.method = "customized",
fit_alt_method = NULL,
wls_alt_method = NULL,
X.cols.hunt = 1:ncol(X),
binary.y = FALSE,
trim.outlier.hunt = TRUE,
predict_fun = stats::predict,
predict_fun_alt = stats::predict,
arg.fit_method = NULL,
arg.wls_method = NULL,
arg.fit_alt_method = NULL,
arg.wls_alt_method = NULL
)Arguments
- y
Numeric response vector of length n.
- X
Numeric covariate matrix of dimension n x p.
- idx.hunt
Integer indices into
1:nfor the hunting subsample.- idx.debias
Integer indices into
1:nfor the debiasing subsample (refitting the null model and projecting the hunted direction).- idx.test
Integer indices into
1:nfor the test subsample on which the test statistic is evaluated. May coincide withidx.debias(two-way split) or be disjoint (three-way split).- score_fun
Function with signature
score_fun(fit, y, X)returning a vector of scores \(l'(\hat{f}(x_i), y_i)\).- weight_fun
Function with signature
weight_fun(fit, X)returning the weight \(\mathbb{E}[l''(\hat{f}(x_i), y_i) | x_i]\) for each row ofX.- fit_method
Function with signature
fit_method(y, X, ...)returning a fitted null model. The returned object must supportpredict_fun(fit, X).- wls_method
Function with signature
wls_method(y, X, w, ...)that fits the null model by weighted least squares. The returned object must supportpredict_fun(fit, X).- hunt.style
One of
"optimal"(default),"wls", or"vanilla". Selects whichhunt_*routine is used.- hunt.method
String for the hunting method.
- fit_alt_method
Required when
hunt.style = "vanilla"; ignored otherwise. Function with signaturefit_alt_method(y, X, ...)returning a fitted alternative model that supportspredict_fun_alt(g, X).- wls_alt_method
Required when
hunt.style %in% c("optimal", "wls"); ignored otherwise. Function with signaturewls_alt_method(y, X, w, ...)returning a fitted alternative model that supportspredict_fun_alt(g, X).- X.cols.hunt
Integer or name vector selecting which columns of
Xdrive the hunt. Default: all columns.- binary.y
Logical. When
TRUE, the optimal hunter computes \(\mathrm{Var}(l' | x)\) frompredict_fun(fit, X, type='response')assuming a Bernoulli response. Only consulted byhunt.style = "optimal".- trim.outlier.hunt
Logical. Passed to the chosen
hunt_*routine astrim.outlier. IfTRUE(default), extreme values in the hunted function will be removed using Tukey's IQR rule.- predict_fun
Function with signature
predict_fun(fit, X)returning predictions from null-model fits. Defaultstats::predict.- predict_fun_alt
Function with signature
predict_fun_alt(fit, X)returning predictions from alt-model fits. Defaultstats::predict.- arg.fit_method, arg.wls_method, arg.fit_alt_method, arg.wls_alt_method
Named lists of additional arguments forwarded to the corresponding fitter via
do.call. DefaultNULL.
Value
A list of class "dScoreTest" with elements:
t.statDebiased test statistic \(\sqrt{n_{\mathrm{test}}}\,\bar{L}/\hat{\sigma}_L\).
p.valOne-sided p-value (right tail of the standard normal).
residsScore residuals on the test subsample.
hOrthogonalised hunted direction on the test subsample.
h.rawHunted direction before the outer debias projection.
hunted_funThe hunted function that can be applied to X.
DataList with
X,y, and the three index vectors.CallNamed list of methods,
hunt.style,hunt.method, both predict functions, and the fourarg.*lists.
