naive_CI: Naive confidence intervals (CI)

Description Usage Arguments Details Value Examples

View source: R/naive_CI.R

Description

Function naive_CI provides naive CI for fixed and mixed effects after cAIC model selection

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
naive_CI(
  beta_sel,
  mu_sel,
  sig_u_sel,
  sig_e_sel,
  sig_u_full,
  sig_e_full,
  X_full,
  C_cluster_sel,
  clusterID,
  indices_sel = NULL,
  type_MSE_mixed = c("regular", "corrected", "both"),
  x_beta_lin_com = NULL,
  alpha = 0.05
)

Arguments

beta_sel

Fixed effects (regression parameters) of the selected model

mu_sel

Mixed effects of the selected model

sig_u_sel

Variance parameter of random effects of the selected model

sig_e_sel

Variance parameter of errors of the selected model

sig_u_full

Variance parameter of random effects from the full model

sig_e_full

Variance parameter of errors from the full model

X_full

Matrix with a full set of covariates

C_cluster_sel

Matrix with cluster level covariates for fixed and random effects

clusterID

Vector with cluster labels

indices_sel

Indices of the selected covariates among full covariate set

type_MSE_mixed

Type of CI (using first order, second order or both MSE estimators)

x_beta_lin_com

Vector or matrix to create linear combinations with fixed parameters. Default: x_beta_lin_com = NULL

alpha

Construct 1 - alpha confidence intervals. Default: alpha = 0.05

Details

The output changes slightly depending on the value of the parameter type. If type = "regular", naive second-order correct CIs are not present. If type = "corrected", naive first-order correct CIS are not present. If type = "both", naive first- and second-order correct CIs are present.

Value

List with elements:

beta_naive_CI_up

Upper boundary of naive CI for fixed effects

beta_naive_CI_do

Lower boundary of naive CI for fixed effects

mixed_naive_CI_corrected_up

Upper boundary of naive CI for mixed effects with the second order MSE

mixed_naive_CI_corrected_do

Lower boundary of naive CI for mixed effects with the second order MSE

mixed_naive_CI_up

Upper boundary of naive CI for mixed effects with the first order MSE

mixed_naive_CI_do

Lower boundary of naive CI for mixed effects with the first order MSE

beta_x_naive_CI_up

Upper boundary of naive CI for linear combinations of fixed effects

beta_x_naive_CI_do

Lower boundary of naive CI for linear combinations of fixed effects

Examples

 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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)


cAIC_min = cAIC_model_set$cAIC_min
degcAIC_models = cAIC_model_set$degcAIC_models

X_full = cAIC_model_set$X_full
X_cluster_full = cAIC_model_set$X_cluster_full

sig_u_full = cAIC_model_set$sig_u_full
sig_e_full = cAIC_model_set$sig_u_full

beta_sel = cAIC_model_set$beta_sel
mu_sel = cAIC_model_set$mu_sel

sig_u_sel = cAIC_model_set$sig_u_sel
sig_e_sel = cAIC_model_set$sig_e_sel
indices_sel = cAIC_model_set$indices_sel
X_cluster_sel = cAIC_model_set$X_cluster_full[, indices_sel]
C_cluster_sel = cbind(as.matrix(X_cluster_sel), diag(n))


x_beta_lin_com = cAIC_model_set$X_cluster_full

naive_CI_results  = naive_CI(
  beta_sel,
  mu_sel,
  sig_u_sel,
  sig_e_sel,
  sig_u_full,
  sig_e_full,
  X_full,
  C_cluster_sel,
  clusterID,
  indices_sel,
  type_MSE_mixed = "regular",
  x_beta_lin_com)

  plot(naive_CI_results, type = "regular")

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