compute_cAIC_for_model_set: Compute cAIC for different models

Description Usage Arguments Details Value Examples

View source: R/compute_cAIC_for_model_set.R

Description

Function compute_cAIC_for_model_set computes cAIC for different models in the model set

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
compute_cAIC_for_model_set(
  X,
  y,
  clusterID,
  X_cluster_full = NULL,
  model = "NERM",
  covariate_selection_matrix = NULL,
  modelset = "all_subsets",
  intercept = FALSE,
  common = NULL
)

Arguments

X

Matrix with covariates for fixed effects

y

Vector of responses

clusterID

Vector with cluster labels

X_cluster_full

Matrix with cluster level covariates for fixed effects of the full model. Default: NULL

model

Type of mixed model: NERM, FHM, RIRS (random slopes and random intercepts)

covariate_selection_matrix

Matrix composed of zeros and ones indicating fixed models in each parameter. Default: NULL

modelset

Type of model set:

  • "all_subsets" - all possible models using all covariates

  • "nested" - a sequence of nested models using all covariates

  • "part_subset" - all possible models using a subset of covariates

intercept

Is column of ones, representing the intercept, present in X Default: TRUE

common

A vector indicating variables forced to be present in each model. Default: NULL

Details

Value

List with parameters:

cAIC_min

Index of selected model

cAIC_models

cAIC for all considered parameters

degcAIC_models

Penalty for all considered models

beta_sel

Fixed effects of the selected model

mu_sel

Mixed effects of the selected model

indices_sel

Indices of the selected covariates among full covariate set

sig_u_sel

Variance parameter of random effects of the selected model

sig_e_sel

Variance parameter of errors of the selected model

X_full

Matrix with fixed effects covariates of the full model

X_cluster_full

Matrix with cluster level covariates for fixed effects of the full model

modelset_matrix

Matrix composed of zeros and ones. Ones correspond to covariate in a model which is represented in nth row

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
n = 10
m_i = 5
m_total = 50

clusterID = rep(1:n, m_i)
p = 10
beta = rep(2, p)
u_i = rnorm(n, 0, 2)
u_i_aug = rep(u_i, each = m_i)
X = matrix(rnorm(m_total * p), m_total, p)
y = X%*%beta + u_i_aug + rnorm(m_total, 0, 1)

cAIC_model_set =
compute_cAIC_for_model_set(X, y, clusterID,
                           model = "NERM",
                           covariate_selection_matrix = NULL,
                           modelset  = "part_subset",
                           common = c(1:8),
                           intercept = FALSE)

KatarzynaReluga/postcAIC documentation built on Jan. 25, 2022, 12:33 a.m.