View source: R/amplitude-persistence.R
| calculate_amplitude_persistence | R Documentation |
Calculates Amplitude and Persistence latent factors from demand metrics for various beezdemand model objects.
calculate_amplitude_persistence(
fit,
amplitude = c("Intensity", "Q0d", "Q0"),
persistence = c("BP0", "Pmaxe", "Omaxe", "Alpha"),
use_inv_alpha = TRUE,
strict = TRUE,
min_persistence_components = 2L,
empirical_y_var = NULL,
basis_means = NULL,
basis_sds = NULL,
...
)
fit |
An object of class |
amplitude |
Character vector of column names to consider for the Amplitude factor.
The function will use the first column found in the data. Default is
|
persistence |
Character vector of column names to include in the Persistence factor.
Default is |
use_inv_alpha |
Logical. If "Alpha" (or a variation) is present in |
strict |
Logical. If |
min_persistence_components |
Integer. Minimum number of non-missing standardized
persistence components required to compute |
empirical_y_var |
For |
basis_means |
Optional named numeric vector of means to use for Z-score standardization.
Names must match the columns used (e.g., |
basis_sds |
Optional named numeric vector of standard deviations to use for Z-score standardization. Names must match the columns used. If NULL (default), the sample SDs are used. |
... |
Additional arguments passed to methods. |
This function calculates Amplitude and Persistence by:
Extracting the relevant demand metrics from the fit object.
Resolving requested metric columns (case-insensitive, with limited synonym support for common beezdemand outputs).
Inverting Alpha if requested (1/Alpha).
Standardizing (Z-scoring) the metrics. If basis_means and basis_sds are provided,
they are used; otherwise, the current sample's statistics are used.
Aggregating the Z-scores into the two latent factors.
Amplitude is defined by the variable specified in amplitude (typically Intensity/Q0).
Persistence is defined as the mean of the standardized values of the variables
specified in persistence (typically Breakpoint, Pmax, Omax, and 1/Alpha).
A data frame with the original ID and calculated Amplitude and Persistence scores, along with the standardized (Z-scored) constituent metrics.
beezdemand_fixed: Extracts metrics from fit$results.
beezdemand_hurdle: Extracts metrics from fit$subject_pars.
beezdemand_nlme: Calculates subject-specific parameters from fixed and random effects.
Parameters Q0 and Alpha are assumed to be on log10 scale for zben and simplified
equations and are converted to linear scale. Omax and Pmax are calculated empirically
from predictions. Breakpoint is calculated empirically from the raw data.
data(apt, package = "beezdemand")
fit <- FitCurves(apt, "hs", k = "share")
calculate_amplitude_persistence(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.