synth-inference / synthdid

Synthetic difference in differences
https://synth-inference.github.io/synthdid
BSD 3-Clause "New" or "Revised" License
261 stars 96 forks source link

Getting The treatment status should be in 0 or 1 error #102

Open tom-barton opened 1 year ago

tom-barton commented 1 year ago

I'm trying use the panel.matrices function like so: setup <- panel.matrices(as.data.frame(parl), unit = which(names(parl) == 'cntry'), time = which(names(parl) == 'time'), outcome = which(names(parl) == 'trnt'), treated = which(names(parl) == 'treated'))

When I run this it gives: Error in panel.matrices(as.data.frame(parl), unit = which(names(parl) == : The treatment status should be in 0 or 1.

I have checked my data and the values of treated are either 0 or 1 Below is my data

parl.csv

davidahirshberg commented 1 year ago

Hi Tom, The name of the relevant argument to panel.matrices is 'treatment', not 'treated'.

Leoday27 commented 6 months ago

Hi I had a similar problem. I used the following code: setup = panel.matrices(as.data.frame(as_tibble(dt, unit='ID',time='Year',outcome = '万人绿色专利申请量',treatment = 'treatment'))) But the results told me: "Error in panel.matrices(as.data.frame(as_tibble(dt, unit = "ID", time = "Year", : The treatment status should be in 0 or 1."

I'm sure my "treatment" contains only 0s and 1s, no nulls. Also, I changed the "treatment" to int type. So, what should I do for the best? data.xlsx