Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 预测逻辑_R_Machine Learning_Logistic Regression - Fatal编程技术网

R 预测逻辑

R 预测逻辑,r,machine-learning,logistic-regression,R,Machine Learning,Logistic Regression,我正在使用一个名为logistf的R包来进行Logistc回归,我发现这个包中没有新数据的预测函数,并且预测包不适用于此,所以我找到了一个代码,显示了如何使用新数据进行此操作: fit<-logistf(Tax ~ L20+L24+L28+L29+L31+L32+L33+L36+S10+S15+S16+S17+S20, data=trainData) betas <- coef(fit) X <- model.matrix(fit, data=testData) probs

我正在使用一个名为logistf的R包来进行Logistc回归,我发现这个包中没有新数据的预测函数,并且预测包不适用于此,所以我找到了一个代码,显示了如何使用新数据进行此操作:

fit<-logistf(Tax ~ L20+L24+L28+L29+L31+L32+L33+L36+S10+S15+S16+S17+S20, data=trainData) 
betas <- coef(fit)
X <- model.matrix(fit, data=testData)
probs <- 1 / (1 + exp(-X %*% betas))

fit虽然您编写的代码工作得很好,但有一种简洁的方法可以获得相同的结果:

    brglm_model <- brglm(formula = response ~ predictor , family = "binomial", data = train )
brglm_pred <- predict(object = brglm_model, newdata = test , type = "response")

brglm_model虽然您编写的代码工作得很好,但有一种简洁的方法可以获得相同的结果:

    brglm_model <- brglm(formula = response ~ predictor , family = "binomial", data = train )
brglm_pred <- predict(object = brglm_model, newdata = test , type = "response")
brglm\u模型