Skip to content

New parameter spreadInteractions: fuel x climate terms in the spread formula - #107

Merged
eliotmcintire merged 3 commits into
developmentfrom
spreadInteractions
Nov 17, 2026
Merged

eliotmcintire merged 3 commits into
developmentfrom
spreadInteractions

Conversation

@eliotmcintire

@eliotmcintire eliotmcintire commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

The fire spread model can now be fitted with terms that multiply each fuel by the climate, so the effect of fuel can change with how dry the year is. This adds a setting that turns those terms on. It is off by default, so nothing changes unless it is set.

Affects: nothing by default; with the new setting on, the spread model has one extra coefficient per fuel class.

Depends-on: PredictiveEcology/fireSenseUtils#242

Technical details

Gap. The spread formula was built as ~ 1 + climate + youngAge + fuel... with no way to add terms (fireSense_dataPrepFit.R:1059, R/spreadFormula.R).

Fix. New parameter spreadInteractions (character, default character(0)). "climate:fuel" adds climate:fuel for each spread climate variable and each fuel covariate (fireSenseUtils::spreadFuelCols(): not youngAge, nfLCC_* or treedWetland) after the main effects. The RHS is built in new spreadRHS() (the code that was inline at :1059, moved unchanged); Init() calls new checkSpreadInteractions() (stops on any other value, and with spreadCovariates = "none"). With the default the formula string is byte-identical (tested against the old inline expression). The products are made in fireSenseUtils (spreadProbFromIntegerCovs()) from the rescaled, centred covariates, 0 where youngAge cleared the fuel, in the fit and in prediction; each main effect is then the slope at the mean of the other covariate. fireSenseUtils::spreadFuelCols is added to prepSpreadFitData's .cacheExtra (a test requires every package function the event reaches to be listed), which re-runs that event once; the floor bump below does the same.

Reuses: spreadFormula(), checkSpreadCovariates() as the model for the check, fireSenseUtils::spreadFuelCols()/spreadIndicatorCols(), fireSenseUtils::youngAgeTxt; new: spreadRHS() (the inline RHS expression moved so it is tested alone and takes the interaction terms), checkSpreadInteractions() (a check of the new parameter; nothing checks it).

Tests. New tests/testthat/test-spreadInteractions.R; the prepare_SpreadFit() formula helper from test-spreadIntercept.R moved to helper-formulaFor.R so both use it. Default string byte-identical, interactions per climate variable and fuel (indicators and youngAge excluded, emptied fuels dropped), parameter defined and checked. On base the new tests fail (6 failures, 3 errors); full suite (convertToPackage() + test_local()): branch 0 failures, 0 errors, 1 skipped, 537 passed; base 0 / 0 / 1 / 524. Scratch library only.

Floors: the reqdPkgs floor on fireSenseUtils is raised after PredictiveEcology/fireSenseUtils#242 merges and is bumped. The same spreadInteractions value is needed by the matching fireSense_spreadFit and fireSense_spreadPredict PRs (branch spreadInteractions).

🤖 Generated with Claude Code

https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6

…terms to the spread formula

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014G18Mik3fH4z5M5CyMSUS6
@eliotmcintire eliotmcintire added enhancement New feature or request backwards compatible Existing code and results keep working unchanged labels Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backwards compatible Existing code and results keep working unchanged enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant