我想引導一個邏輯模型。整個數據集的模型收斂良好。但是,啓動功能選擇不再收斂的子集。我能做什麼?bootstrapping邏輯模型 - 一些子集不收斂
library(boot)
set.seed(2)
y <- c(rep(0,10),rep(1,10))
x <- c(rnorm(10,2,1),rnorm(10,6,1))
dat = data.frame(x, y)
fit <- glm(y ~ x, quasibinomial(), data=dat) # Model with all data workes fine
bs <- function(data, indices) {
d <- data[indices,]
fitboot <- glm(y ~ x, family = quasibinomial(), data=d)
return(coef(fitboot))
}
results <- boot(data=dat, statistic=bs, R=10) # I get warnings
我得到警告說:
1: glm.fit: algorithm did not converge
2: glm.fit: algorithm did not converge
3: glm.fit: algorithm did not converge
4: glm.fit: algorithm did not converge
這似乎是由於選擇的子集。
有趣的是這個子集的工作原理:
fit <- glm(y ~ x, quasibinomial(), data=dat[1:13,])
但這並不:
fit <- glm(y ~ x, quasibinomial(), data=dat[1:14,])
這是爲什麼?我能做些什麼來引導這種模式?
謝謝!這工作!你幫了我很多。我已經花了整整一天的時間,現在它工作。謝謝! – Stefan