DMR: Delete or Merge Regressors

Description Usage Arguments Value Author(s) See Also Examples

View source: R/DMR.r

Description

DMR is a stepwise backward model selection procedure which simultaneously deletes continuous variables and merges levels of factors. It is based on ranking linear hypotheses with squared t-statistics, using hierarchical clustering for each categorical variable. The final model is selected by minimization of generalized information criterion in the nested family of models.

Usage

1
 DMR(model, K = log(nrow(model$model)), clust.method = "complete") 

Arguments

model

initial model of class lm.

K

penalty for the number of parameters in generalized information criterion, default is log(n).

clust.method

method of clustering the same as in hclust.

Value

a list including elements

Partitions

a list of partitions of factors for the models on the nested path searched through

Crit

values of generalized information criterion for the models on the nested path searched through

LogLik

values of log-likelihood for the models on the nested path searched through

Best

a list containing features of the selected model: Partition, Model of class lm, Crit and Hypotheses represesnted as a matrix of lienear hypotheses imposed on the model's parameters

Author(s)

Piotr Pokarowski, Agnieszka Prochenka, Aleksandra Maj

See Also

stepDMR, DMR4glm, plot_bf, roc

Examples

1
2
3
4
5
6
7
8
9
k=4
v1 <- factor(rep(1:8, each = 12*k))
v2 <- factor(rep(1:4, times = 24*k))
v3 <- factor(rep(1:3, times = 32*k))
x1 <- rnorm(96*k)
x2 <- runif(96*k)
y <- rep(c(2, 2, -1, -1, -1, -1, 0, 0), each = 12*k) + rnorm(96*k)
m <- lm(y ~ v1 + v2 + v3 + x1 + x2)
(out <- DMR(m))

Example output

Loading required package: magic
Loading required package: abind
$Partitions
$Partitions[[1]]
$Partitions[[1]]$v1
1 2 3 4 5 6 7 8 
1 2 3 4 5 6 7 8 

$Partitions[[1]]$v2
1 2 3 4 
1 2 3 4 

$Partitions[[1]]$v3
1 2 3 
1 2 3 


$Partitions[[2]]
$Partitions[[2]]$v1
1 2 3 4 5 6 7 8 
1 2 3 4 5 6 7 8 

$Partitions[[2]]$v2
1 2 3 4 
1 2 3 2 

$Partitions[[2]]$v3
1 2 3 
1 2 3 


$Partitions[[3]]
$Partitions[[3]]$v1
1 2 3 4 5 6 7 8 
1 2 3 4 5 6 7 8 

$Partitions[[3]]$v2
1 2 3 4 
1 2 2 2 

$Partitions[[3]]$v3
1 2 3 
1 2 3 


$Partitions[[4]]
$Partitions[[4]]$v1
1 2 3 4 5 6 7 8 
1 2 3 4 5 5 6 7 

$Partitions[[4]]$v2
1 2 3 4 
1 2 2 2 

$Partitions[[4]]$v3
1 2 3 
1 2 3 


$Partitions[[5]]
$Partitions[[5]]$v1
1 2 3 4 5 6 7 8 
1 2 3 4 5 5 6 7 

$Partitions[[5]]$v2
1 2 3 4 
1 2 2 2 

$Partitions[[5]]$v3
1 2 3 
1 2 3 


$Partitions[[6]]
$Partitions[[6]]$v1
1 2 3 4 5 6 7 8 
1 1 2 3 4 4 5 6 

$Partitions[[6]]$v2
1 2 3 4 
1 2 2 2 

$Partitions[[6]]$v3
1 2 3 
1 2 3 


$Partitions[[7]]
$Partitions[[7]]$v1
1 2 3 4 5 6 7 8 
1 1 2 3 3 3 4 5 

$Partitions[[7]]$v2
1 2 3 4 
1 2 2 2 

$Partitions[[7]]$v3
1 2 3 
1 2 3 


$Partitions[[8]]
$Partitions[[8]]$v1
1 2 3 4 5 6 7 8 
1 1 2 3 3 3 4 5 

$Partitions[[8]]$v2
1 2 3 4 
1 2 2 2 

$Partitions[[8]]$v3
1 2 3 
1 2 2 


$Partitions[[9]]
$Partitions[[9]]$v1
1 2 3 4 5 6 7 8 
1 1 2 3 3 3 4 4 

$Partitions[[9]]$v2
1 2 3 4 
1 2 2 2 

$Partitions[[9]]$v3
1 2 3 
1 2 2 


$Partitions[[10]]
$Partitions[[10]]$v1
1 2 3 4 5 6 7 8 
1 1 2 3 3 3 4 4 

$Partitions[[10]]$v2
1 2 3 4 
1 2 2 2 

$Partitions[[10]]$v3
1 2 3 
1 2 2 


$Partitions[[11]]
$Partitions[[11]]$v1
1 2 3 4 5 6 7 8 
1 1 2 3 3 3 4 4 

$Partitions[[11]]$v2
1 2 3 4 
1 1 1 1 

$Partitions[[11]]$v3
1 2 3 
1 2 2 


$Partitions[[12]]
$Partitions[[12]]$v1
1 2 3 4 5 6 7 8 
1 1 2 3 3 3 4 4 

$Partitions[[12]]$v2
1 2 3 4 
1 1 1 1 

$Partitions[[12]]$v3
1 2 3 
1 1 1 


$Partitions[[13]]
$Partitions[[13]]$v1
1 2 3 4 5 6 7 8 
1 1 2 2 2 2 3 3 

$Partitions[[13]]$v2
1 2 3 4 
1 1 1 1 

$Partitions[[13]]$v3
1 2 3 
1 1 1 


$Partitions[[14]]
$Partitions[[14]]$v1
1 2 3 4 5 6 7 8 
1 1 2 2 2 2 2 2 

$Partitions[[14]]$v2
1 2 3 4 
1 1 1 1 

$Partitions[[14]]$v3
1 2 3 
1 1 1 


$Partitions[[15]]
$Partitions[[15]]$v1
[1] 1 1 1 1 1 1 1 1

$Partitions[[15]]$v2
[1] 1 1 1 1

$Partitions[[15]]$v3
[1] 1 1 1



$Crit
 [1] 1121.893 1115.945 1110.039 1104.151 1098.338 1092.576 1086.860 1081.441
 [9] 1076.060 1072.057 1068.429 1064.365 1060.997 1139.985 1421.514

$LogLik
 [1] -513.3413 -513.3427 -513.3650 -513.3961 -513.4653 -513.5592 -513.6770
 [8] -513.9428 -514.2274 -515.2013 -516.3626 -517.3057 -518.5974 -561.0665
[15] -704.8064

$Best
$Best$Partition
$Best$Partition$v1
1 2 3 4 5 6 7 8 
1 1 2 2 2 2 3 3 

$Best$Partition$v2
1 2 3 4 
1 1 1 1 

$Best$Partition$v3
1 2 3 
1 1 1 


$Best$Model

Call:
lm(formula = y ~ ., data = newdata)

Coefficients:
(Intercept)          v12          v13  
      1.909       -2.922       -1.784  


$Best$Crit
[1] 1060.997

$Best$Hypotheses
      Intercept v1 v1 v1 v1 v1 v1 v1 v2 v2 v2 v3 v3 x1 x2
 [1,]         0  0  0  0  0  0  0  0 -1  0  1  0  0  0  0
 [2,]         0  0  0  0  0  0  0  0 -1  1  0  0  0  0  0
 [3,]         0  0  0  0 -1  1  0  0  0  0  0  0  0  0  0
 [4,]         0  0  0  0  0  0  0  0  0  0  0  0  0  0  1
 [5,]         0  1  0  0  0  0  0  0  0  0  0  0  0  0  0
 [6,]         0  0  0 -1  1  0  0  0  0  0  0  0  0  0  0
 [7,]         0  0  0  0  0  0  0  0  0  0  0 -1  1  0  0
 [8,]         0  0  0  0  0  0 -1  1  0  0  0  0  0  0  0
 [9,]         0  0  0  0  0  0  0  0  0  0  0  0  0  1  0
[10,]         0  0  0  0  0  0  0  0  1  0  0  0  0  0  0
[11,]         0  0  0  0  0  0  0  0  0  0  0  1  0  0  0
[12,]         0  0 -1  1  0  0  0  0  0  0  0  0  0  0  0


Warning messages:
1: In sigma_sq * (apply(x, 1, function(y) t(y) %*% y)) :
  Recycling array of length 1 in array-vector arithmetic is deprecated.
  Use c() or as.vector() instead.

2: In sigma_sq * (apply(x, 1, function(y) t(y) %*% y)) :
  Recycling array of length 1 in array-vector arithmetic is deprecated.
  Use c() or as.vector() instead.

DMR documentation built on May 30, 2017, 6:25 a.m.