haghish / rcall

Seamless interactive R in Stata. rcall allows communicating data sets, matrices, variables, and scalars between Stata and R conveniently
http://www.haghish.com/packages/Rcall.php
91 stars 29 forks source link

na.rm=FALSE in fitted #24

Closed mwclance closed 3 years ago

mwclance commented 3 years ago

Hi

After running feglm, I need the fitted responses. The code I use is below, but the fitted command seems to ignore the "na.rm=FALSE" portion of the code. Running the same code in R works correctly. I have also tried attaching the data in R with no luck and the interactive environment.

rcall clear rcall: library(glmhdfe) rcall: library(alpaca) rcall: library(fixest) rcall: data <- st.data() rcall: lm.fit<-feglm(Tij ~ rta | expyear2 + impyear2 + pairid , family = binomial(link="logit"), data = data) rcall: fitted <- fitted(lm.fit, na.rm=FALSE, type="response") rcall: st.load(data)

Thank you in advance for any help you can provide.

mwclance commented 3 years ago

Sorry. There is a correction in 7th line:

rcall: data\$fitted <- fitted(lm.fit, na.rm=FALSE, type="response")

haghish commented 3 years ago

The problem you're facing doesn't seem to be really related to na.rm=FALSE. rcall doesn't do anything with that code. However, you are passing your data from Stata to R and maybe something is going on there.

One thing you can do is to store the data object on a file in your hard drive. Then open it in R and investigate the dataset. If you find an error there, I can fix it...

mwclance commented 3 years ago

Thank you very much for the reply. You are correct that it was the passing of the data from Stata to R. After passing the data, I had to explicitly define the data as a "data.frame(data)".