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

Understanding EM algorithm in gsynth #47

Open
yafs123 opened this issue Sep 24, 2020 · 1 comment
Open

Understanding EM algorithm in gsynth #47

yafs123 opened this issue Sep 24, 2020 · 1 comment

Comments

@yafs123
Copy link

yafs123 commented Sep 24, 2020

Hi Yiqing,

Thanks for making such a fantastic package.

I am running an experiment with only 1 treated unit (N_tr = 1) and 38 units in the control group (N_co = 38). The dataset is unbalanced. I have completed the tutorial you have uploaded on your website. (http://yiqingxu.org/software/gsynth/gsynth_examples.html). It seems like "gsynth" can handle unbalanced panel dataset by using the EM algorithm. My question is related to the output of "gsynth". The output only shows NA values in the missing rows. To be precise, the algorithm did not estimate ATT where missing values exists. I thought that the EM algorithm would fill in missing values. You can find the example code below.

Best regards,
Yafee

#####################

Code

#####################

library(gsynth)
library(data.table)

Datasets

data(gsynth)
names(turnout)

Set seed

set.seed(123456)

Remove rows

turnout.ub <- turnout[-c(which(turnout$abb=="WY")[1:15], sample(1:nrow(turnout),50,replace=FALSE)),]

Overview of missing values

panelView(turnout ~ policy_edr + policy_mail_in + policy_motor, data = turnout.ub, index = c("abb","year"), pre.post = TRUE)

Transform to data.table object

setDT(turnout.ub)

Remove all treated units without ID

turnout.ub <- turnout.ub[!(abb %in% c("CT","IA","ME","MN","MT","NH","WI","WY"))]

Run gsynth

out <- gsynth(turnout ~ policy_edr + policy_mail_in + policy_motor,
data = turnout.ub,
index = c("abb","year"),
se = TRUE,
inference = "parametric",
r = c(0, 5),
CV = TRUE,
force = "two-way",
EM = TRUE,
parallel = TRUE,
min.T0 = 8,
nboots = 1000,
seed = 02139)

print results

out

@xuyiqing
Copy link
Owner

xuyiqing commented Sep 24, 2020 via email

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

2 participants