Which selector to trust: planted truth at several effect sizes

Two selectors run on the same data often keep different terms, and the data alone cannot say which of them is right, because the true model is unknown. This page plants a known truth into the design of a real field trial, at several effect sizes, and scores how often each selector recovers it. The selector that recovers planted effects on this design is the one to trust on it.

Data

The Las Rosas trial is a corn field in Córdoba, Argentina. It has six nitrogen rates laid out in strips, three replicates, and 3,443 yield-monitor records from the 1999 and 2001 harvests (Anselin, Bongiovanni and Lowenberg-DeBoer, 2004). It ships with the ‘agridat’ package. The data were collected to ask whether the yield response to nitrogen changes with landscape position and with soil brightness, which is higher on soils low in organic matter.

d <- agridat::lasrosas.corn
dim(d)
#> [1] 3443    9
table(d$year, d$topo)
#>       
#>          E  HT  LO   W
#>   1999 368 354 461 555
#>   2001 362 431 424 488

The landscape positions are the west slope (W), the hilltop (HT), the east slope (E) and the low east (LO). The candidate terms are:

  • the nitrogen rate and its square
  • soil brightness (bv)
  • indicators for HT, LO and W, with the east slope as the reference
  • an indicator for the 2001 season
  • nitrogen by LO, nitrogen by HT, and nitrogen by brightness

Nitrogen is centred and expressed in hundreds of kg/ha. Brightness is centred and divided by ten, and the nitrogen-by-brightness term is the product of the two centred variables. All candidates are fixed effects, so the example runs in seconds.

n_c <- (d$nitro - mean(d$nitro)) / 100
bv_c <- (d$bv - mean(d$bv)) / 10
x <- cbind(
  nitro = n_c,
  nitro_sq = n_c^2,
  bv = bv_c,
  topo_HT = as.numeric(d$topo == "HT"),
  topo_LO = as.numeric(d$topo == "LO"),
  topo_W = as.numeric(d$topo == "W"),
  year_2001 = as.numeric(d$year == 2001L),
  nitro_x_LO = n_c * (d$topo == "LO"),
  nitro_x_HT = n_c * (d$topo == "HT"),
  nitro_x_bv = n_c * bv_c
)
round(cor(x)[c("nitro", "nitro_x_LO", "nitro_x_HT"), ], 2)
#>            nitro nitro_sq    bv topo_HT topo_LO topo_W year_2001 nitro_x_LO
#> nitro       1.00     0.03  0.00   -0.01    0.01   0.01      0.01       0.51
#> nitro_x_LO  0.51     0.03  0.01   -0.01    0.02  -0.01      0.00       1.00
#> nitro_x_HT  0.47     0.00 -0.02   -0.02    0.01   0.01      0.01       0.00
#>            nitro_x_HT nitro_x_bv
#> nitro            0.47      -0.01
#> nitro_x_LO       0.00      -0.39
#> nitro_x_HT       1.00       0.46

The candidates are far from independent: each interaction is correlated with nitrogen, and the landscape indicators with the interactions built on them. Correlated candidates are where selectors part company.

Two selectors disagree

marginal_bh fits each candidate alone against yield, takes the Wald p-value of its slope, and keeps the candidates that pass a Benjamini-Hochberg step-up at a false discovery rate q. forward_stepwise starts from the intercept and adds, one at a time, the candidate that lowers the AIC most, stopping when none does.

problem <- fs_problem(d$yield, x)
res_bh <- fs_select(problem, "marginal_bh", q = 0.05, seed = 1L)
res_step <- fs_select(problem, "forward_stepwise", seed = 1L)
res_bh$terms[res_bh$selected]
#> [1] "nitro"      "nitro_sq"   "bv"         "topo_HT"    "topo_LO"   
#> [6] "topo_W"     "year_2001"  "nitro_x_LO" "nitro_x_HT"
res_step$terms[res_step$selected]
#> [1] "nitro"     "nitro_sq"  "bv"        "topo_HT"   "topo_LO"   "topo_W"   
#> [7] "year_2001"

Marginal screening keeps both nitrogen-by-landscape interactions, and stepwise selection drops all three interactions. On these data the two answers to the trial’s own question, whether the nitrogen response changes with landscape position, are opposite.

Planting a known truth

fs_implant() keeps the real candidates and draws a new outcome from a stated truth. With mode = "simulate", it picks n_true of the columns as true predictors, gives them effects, and adds noise. Given the real yield as y, the new outcome has the mean and variance of the real one. The effect size is r2, the share of the outcome’s variance that the planted effects explain.

sim <- fs_implant(x, y = d$yield, n_true = 3L, r2 = 0.02, seed = 1L)
sim$truth$support
#> [1] 4 7 9

Every selector can now be scored against sim$truth, because the true support is known.

Effect size as a factor of the study

A single draw says little. A study repeats the draw and crosses the effect size with the selectors. fs_grid() crosses every argument of the generator given more than one value, so three values of r2 give three data-generating mechanisms. The data arguments x and y are each one value. fs_study() writes the plan, with the replicate count and the seed, and fs_run() runs it.

grid <- fs_grid(fs_implant, x = x, y = d$yield, n_true = 3L,
  r2 = c(0.005, 0.02, 0.08))
grid
#>             mechanism     source    r2
#> 1 fs_implant r2=0.005 fs_implant 0.005
#> 2  fs_implant r2=0.02 fs_implant 0.020
#> 3  fs_implant r2=0.08 fs_implant 0.080
study <- fs_study(
  aims = "Which selector recovers planted effects on the Las Rosas design?",
  data = grid,
  methods = c("marginal_bh", "forward_stepwise"),
  target = "support",
  n_sim = 20L,
  seed = 20261203L
)
run <- fs_run(study)

The true positive rate is the share of the planted predictors a selector keeps, and the false discovery rate is the share of its kept predictors that were not planted. Each comes with its Monte Carlo standard error.

perf <- run$performance
perf <- perf[perf$truth_def %in% "exact" & perf$measure %in% c("tpr", "fdr"),
  c("method", "mechanism", "measure", "estimate", "mcse")]
perf$estimate <- round(perf$estimate, 2)
perf$mcse <- round(perf$mcse, 2)
perf
#>              method           mechanism measure estimate mcse
#> 1       marginal_bh fs_implant r2=0.005     tpr     0.50 0.05
#> 2       marginal_bh fs_implant r2=0.005     fdr     0.17 0.05
#> 7  forward_stepwise fs_implant r2=0.005     tpr     0.58 0.05
#> 8  forward_stepwise fs_implant r2=0.005     fdr     0.30 0.05
#> 13      marginal_bh  fs_implant r2=0.02     tpr     0.92 0.03
#> 14      marginal_bh  fs_implant r2=0.02     fdr     0.44 0.03
#> 19 forward_stepwise  fs_implant r2=0.02     tpr     0.97 0.02
#> 20 forward_stepwise  fs_implant r2=0.02     fdr     0.18 0.04
#> 25      marginal_bh  fs_implant r2=0.08     tpr     0.95 0.03
#> 26      marginal_bh  fs_implant r2=0.08     fdr     0.48 0.02
#> 31 forward_stepwise  fs_implant r2=0.08     tpr     1.00 0.00
#> 32 forward_stepwise  fs_implant r2=0.08     fdr     0.11 0.03

Both selectors find more of the planted predictors as the effects grow. The difference is in what else they keep. The false discovery rate of stepwise selection falls as the effects grow, while that of marginal screening climbs, to about one false term for each true one. Once a true predictor has a strong effect, the candidates correlated with it are significant on their own, and a test of one candidate at a time cannot tell them apart. On this design, the stepwise answer is the one to trust, and the interactions that marginal screening kept on the real yield are the kind of term it keeps falsely.

Twenty replicates keep this page fast. A study to report runs more, and fs_study(mcse = ) chooses the count that reaches a stated precision.

Other ways to set the effect size

Generator Effect size Pattern across true predictors
fs_design() r2, the share of latent variance effects: equal, Gaussian or decreasing
fs_implant() r2, and r2_pair, r2_group, r2_slope effects, as in fs_design()
fs_plant() effect, in outcome standard deviations one planted treatment
fs_grid() on a regime an edge coefficient, as "X->Y" = c(0, 0.2) one coefficient per edge

Any of them can be crossed in fs_grid() in the same way as r2 above.

References

Anselin, L., Bongiovanni, R., & Lowenberg-DeBoer, J. (2004). A spatial econometric approach to the economics of site-specific nitrogen management in corn production. American Journal of Agricultural Economics, 86(3), 675–687. https://doi.org/10.1111/j.0002-9092.2004.00610.x