Py学习  »  Git

固定效应logit的混淆矩阵计算

Petr • 4 年前 • 217 次点击  

bife 包装)

使用基本的logit模型( glm

由于某些原因,logit和fixed effect logit的预测数不同。

例子:

library(bife)
library(tidyverse)
library(caret)

dataset <- psid

logit <- glm(LFP ~ AGE + I(AGE^2) + log(INCH) + KID1 + KID2 + KID3, data = dataset, family = "binomial")
mod <- bife(LFP ~AGE +  I(AGE^2) + log(INCH) + KID1 + KID2 + KID3| ID, dataset)

summary(mod)
summary(logit)

predict(logit)
predict(mod)

Y <- factor(dataset$LFP)
PRE <- factor(round(predict(logit, type = "response")))
PRE_FIX <- factor(round(predict(mod, type = "response")))

confusionMatrix(Y, PRE)

# Not working
confusionMatrix(Y, PRE_FIX)

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/56803
 
217 次点击  
文章 [ 1 ]  |  最新文章 4 年前
Alvaro Martinez
Reply   •   1 楼
Alvaro Martinez    4 年前

你可以试试这个密码,

confusionMatrix<-table(true=Y , pred = round(fitted(PRE_FIX)))

从理论上讲,你将能够看到一个表格形状的混乱矩阵。

  0             1
0 TruePositive  FalseNegative
1 FalsePositive TrueNegative