0

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

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.

SimonDude
  • 7
  • 1
  • 4

1 Answers1

0

I found a workaround using the fixest package, which yields almost identical estimates but lets me pass new data into the predict function. The code is identical to the one displayed above as both packages (fixest and alpaca) use the same feglm command for the estimation.

SimonDude
  • 7
  • 1
  • 4