Repository navigation
Post-fit screen of fuel x climate interactions: fuelClimateInteractionScreen() - #243
Open
eliotmcintire wants to merge 4 commits into
Open
eliotmcintire wants to merge 4 commits into
eliotmcintire wants to merge 4 commits into
Conversation
…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
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
…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
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.
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
spreadInteractionsoption, #242).New
fuelClimateInteractionScreen()andfuelClimateFires()(R/fuelClimateInteraction.R), and the constantspreadFitInteractionScreenTxt("interactionScreen_spread",R/constants.R) for the ledger columnfireSense_spreadFitfills (companion PR). It is the exploratory analysis offuelClimate/extract.Randanalyse.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 ofnfLCC_*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 oflogSize,logSim(simulated size) andresid(log(obs/sim)):y ~ climate + fuelagainst+ 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; forlogSize, Spearman(size, fuel) in the hottest third of years against the rest, bootstrapped over years. Medians and ranges only.seedmakes it deterministic and restores the session's random numbers. ReturnsNULLwith no climate or fuel covariate, under 4 years with fires, ornBoot = 0.Climate: the formula's first annual covariate by its base name; a
_yr/_devsplit (#244) counts as one climate with the_yrvalue (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 withwholeLandscapeSpreadCovariates), 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(), thefitSimscolumns ofsimulateFireSizes(),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 inscoreFireSizes()andscoreFireSizesByYear(), now shared by them andfuelClimateFires()) (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. Ondevelopmentthe new file errors (fuelClimateInteractionScreennot 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;development789 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 (.gitin the check copy;objFunInner'ss, already ondevelopment).document()andcodoc()clean.No version bump. The
fireSense_spreadFitPR depends on this one and raises itsreqdPkgsfloor after this merges.🤖 Generated with Claude Code
https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6