[英]Predict ignores newdata argument in feglm estimation
After estimating my model估计我的模型后
train_data <- df_est_hdfe[idx,]
test_data <- df_est_hdfe[-idx,]
est <- c("NATURAL", "GDPsim", "cap_lab_sim", "cap_lab_sim_sq", "cont")
form <- formula(paste0("rta ~ ",paste(est, collapse = " + "), "| exp_ind + imp_ind"))
train_data <- as.data.frame(train_data)
probithdfe <- feglm(form, data = train_data[,c("rta", est, "exp_ind", "imp_ind")], family = binomial(link = "probit"))
I would like to use it to predict the output given some new data我想用它来预测给定一些新数据的输出
pred_LM <- predict(probithdfe, newdata = test_data[,c(est, "exp_ind", "imp_ind")], type = "response")
However, I can't get my new data into the predict function as但是,我无法将我的新数据输入到 predict 函数中
dim(test_data)
[1] 5910 13
while尽管
length(pred_LM)
[1] 11546
which is the size of the training data.这是训练数据的大小。 How can I apply my estimated model to new data?如何将我的估计模型应用于新数据? I assume this might be specific to the feglm specification of the alpaca
package.我认为这可能特定于alpaca
包的 feglm 规范。
I found a workaround using the fixest
package, which yields almost identical estimates but lets me pass new data into the predict
function.我找到了一个使用fixest
包的解决方法,它产生几乎相同的估计,但让我将新数据传递到predict
函数中。 The code is identical to the one displayed above as both packages ( fixest
and alpaca
) use the same feglm
command for the estimation.该代码与上面显示的代码相同,因为两个包( fixest
和alpaca
)都使用相同的feglm
命令进行估计。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.