Re: [問題] 迴歸參數的擷取
# 我造的範例
n = 4; p = 13
logit_trans = function(x) exp(x) / (1+exp(x))
data = matrix(rnorm(n*p, 0, 0.1), n)
data = data.frame(y = sapply(logit_trans(cbind(1, data) %*% 1:(p+1)),
function(p) rbinom(1,1,p)), data)
comb = t(combn(4:12,2))
beta = mapply(function(i, j) matrix(coef(glm( data[,1] ~ data[,2] + data[,3] +
data[,i] + data[,j] + data[,i]:data[,j], family=binomial(link="logit"),
data = data))), comb[,1], comb[,2])
beta = cbind(comb, t(beta))
colnames(beta) <- c("i", "j","Intercept", "Gender", "Age", "CAR1", "CAR2",
"CAR1*CAR2")
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.116.152.213
※ 編輯: celestialgod 來自: 140.116.152.213 (08/07 14:10)
推
08/07 17:44, , 1F
08/07 17:44, 1F
→
08/07 17:45, , 2F
08/07 17:45, 2F
→
08/07 18:48, , 3F
08/07 18:48, 3F
→
08/07 18:48, , 4F
08/07 18:48, 4F
→
08/07 18:49, , 5F
08/07 18:49, 5F
推
08/07 23:32, , 6F
08/07 23:32, 6F
※ 編輯: celestialgod 來自: 61.227.245.110 (08/08 13:08)
※ 編輯: celestialgod 來自: 61.227.245.110 (08/08 13:09)
討論串 (同標題文章)
R_Language 近期熱門文章
PTT數位生活區 即時熱門文章