我有下面的總結輸出,並且我想從選定變量(僅變量名稱= X10)中提取結果。如何從穩定性選擇模型輸出中提取特定值
> stab.glmnet
Stability Selection with unimodality assumption
Selected variables:
X10
10
Selection probabilities:
X2 X1 X7 X3 X6 X4 X5 X8 X9 X10
0.02 0.06 0.20 0.22 0.25 0.32 0.35 0.37 0.41 1.00
---
Cutoff: 0.75; q: 3; PFER (*): 0.918
(*) or expected number of low selection probability variables
PFER (specified upper bound): 1
PFER corresponds to signif. level 0.0918 (without multiplicity adjustment)
我試圖(下文),但它給我只其他值,它是10
var <- stab.glmnet$selected[[1]]
數據:
set.seed(1001)
n <- 100
Y <- c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0)
X1 <- sample(x=c(0,1,2), size=n, replace=TRUE, prob=c(0.1,0.4,0.5))
X2 <- sample(x=c(0,1,2), size=n, replace=TRUE, prob=c(0.5,0.25,0.25))
X3 <- sample(x=c(0,1,2), size=n, replace=TRUE, prob=c(0.3,0.4,0.4))
X4 <- sample(x=c(0,1,2), size=n, replace=TRUE, prob=c(0.35,0.35,0.3))
X5 <- sample(x=c(0,1,2), size=n, replace=TRUE, prob=c(0.1,0.2,0.7))
X6 <- sample(x=c(0,1,2), size=n, replace=TRUE, prob=c(0.8,0.1,0.1))
X7 <- sample(x=c(0,1,2), size=n, replace=TRUE, prob=c(0.1,0.1,0.8))
X8 <- sample(x=c(0,1,2), size=n, replace=TRUE, prob=c(0.35,0.35,0.3))
X9 <- sample(x=c(0,1,2), size=n, replace=TRUE, prob=c(0.35,0.35,0.3))
X10 <- c(2,2,2,2,2,2,2,2,2,2,1,2,2,2,1,2,2,1,2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,
2,1,2,1,1,2,1,2,1,2,1,2,1,1,2,1,2,0,0,0,0,0,0,0,0,1,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,
1,1,1,1,1,0,0,0,0,0,0,0,1,0,0,0,0)
datasim <- data.frame(Y=as.factor(Y),X1,X2,X3,X4,X5,X6,X7,X8,X9,X10)
的包和穩定性選擇代碼
library("stabs")
library("glmnet")
x <- model.matrix(Y~.,datasim)[,-1]
y <- datasim$Y
y <- as.numeric(y)
stab.glmnet <- stabsel(x,y ,fitfun = glmnet.lasso, cutoff = 0.75,PFER = 1)
你用哪個包和功能來創建模型?更一般地說,如果你提供一個可重複的例子,你會讓人們更容易幫助你。 – eipi10
謝謝@ eipi10,我更新了上面的問題 – Shima
你不說你想從摘要中提取什麼。你想要選擇變量的選擇概率還是其他? – eipi10