Description Usage Arguments Details Value See Also Examples
View source: R/MEM_Polynomial_Group_structure.R
This function fits a mixed-effects model (MEM) to potentially censored data structured by group when marginal and individual dynamics are described either by polynomials or B-spline curves.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | MEM_Polynomial_Group_structure(
y,
x = NULL,
Group = NULL,
Id = NULL,
Cens = NULL,
marginal_dyn_type = "polynomial",
ind_dyn_type = "polynomial",
global_intercept = TRUE,
group_intercept = FALSE,
degree_group = 3,
Adaptive = "none",
min_knots_group = 2,
max_knots_group = 2,
knots_group = NULL,
df_group = NULL,
Boundary.knots_group = NULL,
ind_intercept = FALSE,
degree_ind = 3,
min_knots_ind = 2,
max_knots_ind = 2,
same_base_group_ind = FALSE,
knots_ind = NULL,
df_ind = NULL,
Boundary.knots_ind = NULL,
...
)
|
y |
observed responses described either as a data frame containing at least a column named 'y' and possibly the columns 'x', 'Group', 'Id' and 'Cens' (among others), or as a vector of numerical values. |
x |
a numerical vector representing the x-axis coordinates corresponding to the observed responses (e.g. time of observations) which can be defined is |
Group |
a vector of group indicator for each observed responses which can be defined if |
Id |
a vector of individual ID for each observed responses which can be defined if |
Cens |
a vector of censoring indicator (if |
marginal_dyn_type |
a character variable indicating the type of marginal dynamics. Options are 'polynomial' (default) and 'spline'. |
ind_dyn_type |
a character variable indicating the type of individual dynamics (random effects). Options are 'polynomial' (default) or 'spline'. |
global_intercept |
a logical scalar. If TRUE (default) a global intercept (no group-specific) is included in the marginal dynamics. |
group_intercept |
a logical scalar (same option for all groups) or vector. For each group, if TRUE, a group-specific intercept is included in the marginal dynamics. By default, this variable is defined as FALSE |
degree_group |
an integer scalar (same option for all groups) or vector. The variable indicates for each group either the degree of polynomial functions or spline curves describing marginal dynamics. By default, the variable is fixed at 3. |
Adaptive |
an optional character variable that can be used when |
min_knots_group |
an optional integer scalar indicating the minimum number of internal knots to consider in the research of optimal knots for marginal dynamics. This variable is used only if |
max_knots_group |
an optional integer scalar indicating the maximum number of internal knots to consider in the research of optimal knots for marginal dynamics. This variable is used only if |
knots_group |
a numerical vector (same option for all groups) or a list of either numerical vectors or NULL (one for each group) indicating the internal knots for group-specific B-spline curves. This variable will be used only if |
df_group |
an integer scalar (same option for all groups) or vector indicating the degrees of freedom to consider to build marginal B-spline curves. This variable will be used only if |
Boundary.knots_group |
a numerical vector (same option for all groups) or a list of either numerical vectors or NULL (one for each group) indicating the boundary knots for group-specific B-spline curves. This variable will be used only if |
ind_intercept |
a logical scalar. If TRUE, an intercept is included in the individual dynamics (random effects). By default, this variable is defined as FALSE. |
degree_ind |
an integer scalar indicating either the degree of the polynomial functions or the B-spline curves describing individual dynamics. By default, this variable is fixed at 2. |
min_knots_ind |
an optional interger scalar indicating the minimum number of internal knots to consider in the research of optimal knots for individual dynamics. This variable is used only if |
max_knots_ind |
an optional interger scalar indicating the maximum number of internal knots to consider in the research of optimal knots for individual dynamics. This variable is used only if |
same_base_group_ind |
an optional logical scalar indicating whether or not the same B-spline basis must be considered in group-specific and individual dynamics. This variable is used only if |
knots_ind |
a numerical vector (same option for all individuals) or a list of numerical values or NULL indicating the internal knots for individual-specific B-spline curves. This variable will be used only if |
df_ind |
an integer scalar (same option for all individuals) or vector indicating the degrees of freedom to consier to build individual B-splines curves. This variable can be choosen different for each individual or equivalent for each individual belonging to the same group (one value for each group). By default, this variable is defined as NULL(see bs for more details). |
Boundary.knots_ind |
a numerical vector indicating the boundary knots for individual-specific B-spline curves. This variable will be used only if |
... |
Further arguments to be passed (see lmec for more details). |
The Mixed-Effects model describing the outcome of interest \mjseqnY_ij,g_i of the subject \mjseqni in the group \mjseqng_i at the \mjseqnjth time point (x-axis) is given by
\mjsdeqnY_ij,g_i = \gamma_0+ \sum_g=1^G \mathbb1_[g_i=g] \times F_g(t_ij,g) + h_i(t_ij,g_i) + \varepsilon_ij
where \mjseqn\gamma_0 is the global (non group-specific) intercept and the functions \mjseqnF_g and \mjseqnh_i are the non-linear smooth functions describing respectively the marginal group-specific dynamics and the individual dynamics (random effects).
Through this function, the group-specific functions are defined as following, where \mjseqn\beta_0^g is the optional group_intercept
:
\mjsdeqnF_g(t_ij,g) = \beta_0^g + \sum_k=1^K_g \beta^g_k f^k_g(t_ij,g)
If marginal_dyn_type
is defined as 'polynomial', \mjseqnK_g = degree_group
and \mjseqnf^k_g(t_ij,g) = t_ij,g^k and if marginal_dyn_type
is defined as 'spline', \mjseqnK_g = df_group
(see bs for more details) and \mjseqnf^k_g(t_ij,g) is the \mjseqnkth group-specific spline basis.
Similarly, the indvidual dynamics are described by the following functions, with \mjseqnb_0i as optional ind_intercept
:
\mjsdeqnh_i(t_ij,g) = b_0i + \sum_k=1^K_i b_ki \Psi_k^i(t_ij,g)
If ind_dyn_type
is defined as 'polynomial', \mjseqnK_i = degree_ind
and \mjseqn\Psi_k^i(t_ij,g) = t_ij,g^k and if ind_dyn_type
is defined as 'spline', \mjseqnK_i = df_ind
(see bs for more details) and \mjseqn\Psi_k^i(t_ij,g) is the \mjseqnkth individual spline basis.
A list containing:
Model_estimation | a list containing the results of the model estimation provided by the function lmec. In this list, the vector of fixed parameters called beta , the parameters are returned in the following order: \mjseqn\beta = (\gamma_0,\beta_0^1, \cdots, \beta_K_1^1,\cdots,\beta_0^g,\cdots,\beta_K_g^g,\cdots,\beta_0^G,\cdots,\beta_K_G^G). |
Model_features | a list of 3 elements: |
1. Groups - a vector indicating the names of the groups involved in the model |
|
2. Marginal.dyn.feature - a list summarizing the features of the marginal dynamics defined in the model (through input arguments): |
|
|
|
3. Individual.dyn.feature - a list summarizing the features of the individual dynamics defined in the model (through input arguments) |
|
|
|
bs
,
lmec
,
Optimal_knot_research
1 2 3 4 5 6 7 8 9 10 11 12 13 | # Download of data
data("HIV_Simu_Dataset_Delta01_cens")
data <- HIV_Simu_Dataset_Delta01_cens
# Change factors in character vectors
data$id <- as.character(data$id) ; data$Group <- as.character(data$Group)
# We call the function considering the variable 'y' as a vector (we need to specify the groups )
MEM_Pol_Group <- MEM_Polynomial_Group_structure(y=data$VL,x=data$time,Group=data$Group,Id=data$id,Cens=data$cens)
# We call the function considering the variable 'y' as a data frame (the column 'VL' in data has to be rename)
colnames(data)[4] <- "y"
MEM_Pol_Group <- MEM_Polynomial_Group_structure(y=data,x=data$time,Cens=data$cens,Id=data$id)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.