AggregatedEffects {sharp} | R Documentation |
Summarised coefficients conditionally on selection
Description
Computes descriptive statistics (defined by FUN
) for coefficients of
the (calibrated) models conditionally on selection across resampling
iterations.
Usage
AggregatedEffects(
stability,
lambda_id = NULL,
side = "X",
comp = 1,
FUN = stats::median,
...
)
Arguments
stability |
output of |
lambda_id |
parameter ID with respect to the grid |
side |
character string indicating if coefficients of predictors
( |
comp |
component ID. Only applicable to PLS models. |
FUN |
function to use to aggregate coefficients of visited models over
resampling iterations. Recommended functions include
|
... |
additional arguments to be passed to |
Value
A matrix of summarised coefficients conditionally on selection across
resampling iterations. Missing values (NA
) are returned for
variables that are never selected.
See Also
VariableSelection
, BiSelection
,
Refit
Examples
# Example with univariate outcome
set.seed(1)
simul <- SimulateRegression(n = 100, pk = 50, family = "gaussian")
stab <- VariableSelection(xdata = simul$xdata, ydata = simul$ydata, family = "gaussian")
median_betas <- AggregatedEffects(stab)
# Comparison with refitted model
refitted <- Refit(xdata = simul$xdata, ydata = simul$ydata, stability = stab)
refitted_betas <- coef(refitted)[-1, 1]
plot(median_betas[names(refitted_betas), ], refitted_betas,
panel.first = abline(0, 1, lty = 2)
)
# Extracting mean betas conditionally on selection
mean_betas <- AggregatedEffects(stab, FUN = mean)
plot(median_betas, mean_betas)
# Regression with multivariate outcomes
set.seed(1)
simul <- SimulateRegression(n = 100, pk = 50, q = 2, family = "gaussian")
stab <- VariableSelection(xdata = simul$xdata, ydata = simul$ydata, family = "mgaussian")
median_betas <- AggregatedEffects(stab)
dim(median_betas)
# Sparse PLS with multivariate outcome
if (requireNamespace("sgPLS", quietly = TRUE)) {
set.seed(1)
simul <- SimulateRegression(n = 50, pk = 15, q = 3, family = "gaussian")
x <- simul$xdata
y <- simul$ydata
stab <- BiSelection(
xdata = x, ydata = y,
family = "gaussian", ncomp = 3,
LambdaX = seq_len(ncol(x) - 1),
implementation = SparsePLS
)
median_betas <- AggregatedEffects(stab)
dim(median_betas)
median_betas <- AggregatedEffects(stab, side = "Y")
dim(median_betas)
}