Skip to content

Post-fit screen of fuel x climate interactions: fuelClimateInteractionScreen() - #243

Open
eliotmcintire wants to merge 4 commits into
developmentfrom
fuelClimate-interaction-test
Open

eliotmcintire wants to merge 4 commits into
developmentfrom
fuelClimate-interaction-test

Conversation

@eliotmcintire

@eliotmcintire eliotmcintire commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Spread fits assume a fuel's effect is the same in every year's climate. This adds a screen, run on the fires each fit was made from, that asks whether fuel matters more in hot, dry years, so that every ELF can show that interactions were tested and what they gave.

Affects: Adds new functions and one ledger column name; nothing existing changes.

Technical details

It is a screen of observed fire sizes: it does not fit or test a spread model with interaction terms (the separate spreadInteractions option, #242).

New fuelClimateInteractionScreen() and fuelClimateFires() (R/fuelClimateInteraction.R), and the constant spreadFitInteractionScreenTxt ("interactionScreen_spread", R/constants.R) for the ledger column fireSense_spreadFit fills (companion PR). It is the exploratory analysis of fuelClimate/extract.R and analyse.R, done on data already in memory, with no simulation.

Per fitted fire: observed size, the in-sample simulated size (median over the best members' runs), the year's climate (median of the formula's first annual covariate over the year's pixels; the burned-pixel median is in the per-fire table), and each non-annual formula covariate averaged over the burned pixels and at the start pixel (plus nonForest, the sum of nfLCC_* groups when there are two or more). A fire year reads the vegetation table of the data year strictly before it (dataYearBefore(), as the objective does). For each fuel and each of logSize, logSim (simulated size) and resid (log(obs/sim)): y ~ climate + fuel against + climate:fuel, standardised predictors; interaction coefficient as the median and 2.5-97.5% of a bootstrap over years (default 999 draws), P(coef > 0), leave-one-year-out squared error of both models and the number of years improved; for logSize, Spearman(size, fuel) in the hottest third of years against the rest, bootstrapped over years. Medians and ranges only. seed makes it deterministic and restores the session's random numbers. Returns NULL with no climate or fuel covariate, under 4 years with fires, or nBoot = 0.

Climate: the formula's first annual covariate by its base name; a _yr/_dev split (#244) counts as one climate with the _yr value (the ELF median) as the year's climate, and names with : (#242) are neither climate nor fuel (handled by name, tested with both forms; neither PR is needed). Without a split the year's climate is the median over that year's rows of the annual table, which are the fire-buffer pixels (every flammable pixel only with wholeLandscapeSpreadCovariates), not the ELF's burnable pixels: documented. Predictors are standardised once; least-squares predictions do not depend on centring or scale, so only the reported coefficients are affected: documented.

Cost: 11 s on a 35-year, 525-fire, 2-million-pixel, 6-fuel toy (999 draws, one thread), 5 s of it the bootstrap.

Reuses: spreadDesignCols(), spreadCovCols(), dataYearBefore(), the fitSims columns of simulateFireSizes(), withr::local_seed(); new: fuelClimateFires()/fuelClimateInteractionScreen() and small helpers (bootYears() serves both bootstraps; perFireSizes() is the per-fire table lifted from the two inline copies in scoreFireSizes() and scoreFireSizesByYear(), now shared by them and fuelClimateFires()) (nothing existing computes a per-fire climate and fuel table or a year-bootstrapped interaction; spreadFitValidationData() works per pixel, not per fire).

Tests (tests/testthat/test-fuelClimateInteraction.R, toy fires with a planted interaction): the planted one is found (coefficient > 0, range above 0, leave-one-year-out error lower, most years improved); without one it is not; the model side and the Spearman strata; one row per fuel and location; same seed same result, session RNG restored; vegetation-year rule; no test without climate, fuel, enough years or draws. On development the new file errors (fuelClimateInteractionScreen not found). Full suite, devtools::test() with 1 BLAS/DT thread, scratch library for missing packages: branch 800 test blocks, 3199 expectations passed, 0 failed, 0 errors, 7 skipped; development 789 blocks, 3154 passed, 0 failed, 0 errors, 8 skipped (skips are xgboost-dependent and vary by library). rcmdcheck::rcmdcheck(args = "--no-manual") on the last commit, suggested packages in a scratch library: 0 errors, 0 warnings, 2 notes, neither from this PR (.git in the check copy; objFunInner's s, already on development). document() and codoc() clean.

No version bump. The fireSense_spreadFit PR depends on this one and raises its reqdPkgs floor after this merges.

🤖 Generated with Claude Code

https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6

eliotmcintire and others added 2 commits November 16, 2026 16:00
…tions in a spread fit's own fires

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
@eliotmcintire eliotmcintire added the enhancement New feature or request label Nov 16, 2026
@codecov

codecov Bot commented Nov 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.93814% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.60%. Comparing base (0ab500d) to head (15d0d7b).
⚠️ Report is 1 commits behind head on development.

Files with missing lines Patch % Lines
R/fuelClimateInteraction.R 97.93% 2 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff               @@
##           development     #243      +/-   ##
===============================================
+ Coverage        93.52%   93.60%   +0.07%     
===============================================
  Files               67       68       +1     
  Lines             5265     5362      +97     
===============================================
+ Hits              4924     5019      +95     
- Misses             341      343       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…ading any table

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
…es), one year bootstrap, climate by base name (_yr/_dev split, ':' names ignored), standardisation documented

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
@eliotmcintire eliotmcintire changed the title Post-fit test of fuel x climate interactions: fuelClimateInteractionTest() Post-fit screen of fuel x climate interactions: fuelClimateInteractionScreen() Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant