Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201945

Calculating confusion matrix for fixed effect logit

$
0
0

I would like to ask how to calculate a confusion matrix for a fixed effect logit model (bife package)

With the basic logit model (glm) there is no problem, but with fixed effect logit there is.

For some reason the number of predictions is different for logit and fixed effect logit.

Example:

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)


Viewing all articles
Browse latest Browse all 201945

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>