Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interactions in control variables (Z) #9

Open
MartinHaus1 opened this issue Jun 10, 2021 · 6 comments
Open

Interactions in control variables (Z) #9

MartinHaus1 opened this issue Jun 10, 2021 · 6 comments

Comments

@MartinHaus1
Copy link

Hi there,

first of all, thank you very much for this amazing package!!

I was wondering whether there is a way to use interactions as control variables Z, i.e., something like A*B.

example:
interflex(estimator="kernel", Y="outcome", D="treatment", X="moderator", Z=c("A*B", "other_control"), FE=c("year", "state"),data=dataset)
This currently leads to
A*B is not in the data

Is there any way to do this at the moment?

Thank you!

Best,
Martin

@xuyiqing
Copy link
Owner

xuyiqing commented Jun 10, 2021 via email

@MartinHaus1
Copy link
Author

Thank you for your response!

Yes, this is a feasible work-around. I was just wondering whether I just missed how to feed interaction terms into interflex, in case there is a direct way.

Thanks!

@MartinHaus1
Copy link
Author

Just a quick follow-up:

I tried to create a new variable (as a factor) and included it in the Z-vector to control for it.

It throws the following error:

Cross-validating bandwidth ... 
Parallel computing with 8 cores...
Optimal bw=0.0609.
Error in names(result) <- c("x0", "(Intercept)", use.variable[2:length(use.variable)]) : 
  'names' attribute [119] must be the same length as the vector [118]

If I remove the new categorical variable from the control vector, it works. Using the same variable for creating a model with plm does not lead to any issues.

Am I doing something wrong? For context, I use the following command options:

interflex(estimator="kernel", Y="y", D="d", X="x", Z=c("new_control_factor","other_controls"), 
          IV="iv", FE=c("year", "state"),data=dataset, cores=8, na.rm = T, vcov.type="cluster", cl="state")

Thank you!

@xuyiqing
Copy link
Owner

xuyiqing commented Jun 10, 2021 via email

@lzy318
Copy link
Collaborator

lzy318 commented Jun 11, 2021

Can you send a sample dataset to [email protected] for debugging as this code works well on my sample dataset? Thanks a lot!

@MartinHaus1
Copy link
Author

Hi,

thanks both for your responses. I mailed a sample dataset that should reproduce the error.

Best,
Martin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants