Repository navigation
Conversation
prepareModelTerms() reads the value of a FactorsForm model-terms option, with or without the term specification of jasp-desktop's FactorsForm, and gives each model's formula (modelTermsFormula()) or numeric design columns (modelTermsDesign()), the display labels of a fit's coefficients (modelTermsLabels()) and its offsets (modelTermsOffset(), modelTermsConstantOffset()). - Without term specification the formula is exactly the one analyses built before. - With it, terms are defined once (`definitions`: a variable and its specification) and combined into each model's terms (`terms`: products of definitions). inst/modelTermSpecifications.json lists every specification once (kind, offered by default or opt-in, title, label pattern, parameters with defaults); jasp-desktop embeds the same file to build its table, and the labels are the form's. - Specifications: transformations (center, scale, logarithms, power, root, Box-Cox, Yeo-Johnson, asinh, logit, probit, arcsine square root, orthogonal and raw polynomials, natural and B-splines, hinge, threshold, quantile bins, Fourier terms, rank and normal scores, Arrhenius), codings (treatment, simple, sum, Helmert and reverse Helmert, successive and forward differences, orthogonal polynomial, SAS, indicators), and offsets of a variable and constant offsets. - Constants learned on the fitting data are embedded in the formula, so new data is coded as the fitting data (rank terms are sample-dependent, like rank(x) in lm()); categorical terms are coded matrices; restrictions (fixed coefficients) and nesting of consecutive models; every inconsistency stops with a message naming the model. - Tests: tests/testthat/test-modelTerms.R. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 7, 2026
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.
Summary
Adds a reader for FactorsForm model-terms options. It is the R side of the opt-in term specification for jasp-desktop's
FactorsForm.prepareModelTerms()reads a model-terms option, with or without the term specification. For each model it returns:the formula (
modelTermsFormula()) or the numeric design columns (modelTermsDesign());display labels for the fit's coefficients (
modelTermsLabels());the offsets (
modelTermsOffset(),modelTermsConstantOffset()).Without the term specification, the formula is exactly the one analyses built before. Analyses can switch to the reader without changing their results.
With the term specification, terms are defined once and combined into each model's terms:
definitionspairs a variable with a specification;termsare products of definitions.Catalogue:
inst/modelTermSpecifications.jsonlists every specification once. Each entry gives its kind, whether it is offered by default or only on request, its title, its label pattern, and its parameters with their defaults. jasp-desktop embeds the same file at build time to build its table, so the desktop and R produce the same labels. To add or remove a specification, edit this file and add a builder inR/modelTerms.R; a test checks that every entry has a builder and that every label pattern fills in.Specifications:
Fitting details:
sampleDependent), likerank(x)inlm().Version bumped to 0.20.6.
Related PRs
Merge this PR first. The desktop PR then moves its submodule to the merged commit, and jaspRegression needs a jaspBase that has the reader.
Tests
tests/testthat/test-modelTerms.R: 103 tests, 1199 expectations, all passing. They cover:lm();🤖 Generated with Claude Code