Skip to contents

Bayesian magnitude-composition models for fixed-area stem counts and point-sampling basal area. A negative-binomial model describes the total count, and multinomial allocation distributes that count among categories. Users choose one categorical variable or two in a conditional allocation; neither their names nor their conditioning order is tied to a forestry response. Models can include regression, group effects, spatial effects, and composition factors, with smoothing across ordered categories. Fit either component alone by setting the other formula to NULL; the existing nested composition structure remains available without magnitude.

Getting started

The website articles simulate data and illustrate magnitude, composition, and full models using forest inventory examples. Their Quarto sources and HTML previews are in the source repository; the articles are not installed with the package.

Prepare data

Use magCompData with a fixedArea or pointSampling design. Each sampling unit has total counts, counts by one category, or counts by two crossed categories. Standalone composition does not require a sampling design.

Specify and fit a model

Use magComp. For two categories, magCompComposition specifies the leading allocation and the conditional child allocation. Formula syntax is described in magCompTerms. Set priors with magCompPriors, smoothing with magCompSmooth, and MCMC controls with magCompControl.

Inspect settings

Use magCompSettings for resolved priors, parameter constraints, and editable starting values. Use magCompStarting to extract starts from a previous fit.

Check the chains

Use summary and plot. Both use samples and support individual effects and combined coefficients through their type argument. spatialDiagnostics summarizes spatial parameters. samples extracts all retained parameter draws.

Obtain fitted values and predictions

Use fitted at observed units and predict at new units. Both offer expected quantities or simulated observations. magCompPrediction explains the returned quantities and dimensions.

Summarize and assess

Use summary on stored prediction draws for means and intervals. Use standSummary to aggregate stored expected or observation density draws with represented land-area weights, ppcSummary to compare observed and replicate counts, and magCompCV for cross-validation predictions.

Call generic functions such as summary(fit), plot(fit), fitted(fit), and predict(fit, newdata); R selects the appropriate method. magCompNotation and magCompPrediction are explanatory help topics, not functions.

Technical document

The Methods and Implementation Details guide gives the model equations, notation, priors, full conditional and Metropolis updates, numerical solvers, and prediction calculations. Its source and PDF are maintained in dev/modeling_and_software_details/ in the source repository. Help pages refer to its section titles so those references remain useful when equation and section numbers change.