This function prepares the necessary data structures for implementing the Function Adaptive SHrinkage (FASH) approach. It processes the input data, smoothing variables, offsets, standard errors, and optional precision matrices to generate a list of data frames and supporting matrices.
fash_set_data(
Y,
smooth_var,
offset = 0,
S = NULL,
Omega = NULL,
data_list = NULL
)
Either a numeric matrix of response variables or a character string specifying the column name in data_list
for response variables. Required if data_list
is provided.
A numeric matrix, vector, or a character string specifying the column name in data_list
for smoothing variables. Required if data_list
is provided.
A numeric matrix, vector, scalar, or a character string specifying the column name in data_list
for offset variables.
A numeric matrix, vector, scalar, or list representing the standard errors of Y
. Or a character string specifying the column name in data_list
for SD. If provided as a matrix, it must have the same dimensions as Y
. If a vector or scalar, it will be expanded to match the dimensions of Y
.
Either a list of precision matrices (one for each dataset) or a single precision matrix (shared across all datasets). Default is NULL
.
A list of data frames, where each data frame corresponds to a single dataset.
A list with the following components:
A list of data frames, where each data frame corresponds to a row of Y
. Each data frame contains:
y
The response variables for the corresponding row of NULL
.
x
The smoothing variables for the corresponding row of smooth_var
.
offset
The offset values for the corresponding row of offset
.
A list of standard errors, where each element corresponds to the standard errors for a single dataset.
A list of precision matrices, where each element corresponds to a single dataset's precision matrix.
# Example usage with matrix input
set.seed(1)
Y <- matrix(rnorm(20), nrow = 4, ncol = 5)
smooth_var <- matrix(runif(20), nrow = 4, ncol = 5)
offset <- 1
S <- c(0.5, 0.8, 1.2, 1.0, 0.9)
Omega <- diag(c(1, 2, 3, 4, 5))
result <- fash_set_data(Y = Y, smooth_var = smooth_var, offset = offset, S = S, Omega = Omega)
# Example usage with data_list input
data_list <- list(
data.frame(y = rnorm(5), x = 1:5, offset = 0),
data.frame(y = rnorm(5), x = 1:5, offset = 0)
)
S_list <- list(rep(0.5, 5), rep(0.8, 5))
Omega_list <- list(diag(5), diag(5))
result <- fash_set_data(data_list = data_list, Y = "y", smooth_var = "x", offset = "offset", S = S_list, Omega = Omega_list)