我对使用RMSE(均方根误差)比较不同逻辑模型的有效性存在疑问。响应为0
或1
,并且预测为0
- 之间的概率1
。
以下应用的方式对二进制响应也有效吗?
# Using glmnet
require(glmnet)
load(url("https://github.com/cran/glmnet/raw/master /data/BinomialExample.RData"))
cvfit = cv.glmnet(x, y, family = "binomial", type.measure = "mse")
A <- predict(cvfit, newx = x, s = "lambda.min", type = "response")
RMSE1 <- mean((y - A)^2)
# 0.05816881
# glm
mydata <- read.csv("https://stats.idre.ucla.edu/stat/data/binary.csv")
mydata$rank <- factor(mydata$rank)
mylogit <- glm(admit ~ gre + gpa + rank, data = mydata, family = "binomial")
AAA <- predict(mylogit, newdata = mydata, type = "response")
RMSE2 <- mean((mydata$admit - AAA)^2)
# 0.194714