xuyiqing / gsynth

Generalized Synthetic Control Method
Other
131 stars 40 forks source link

Error in matrix(panel$eff, T, N) : 找不到对象'panel' #55

Open zdlspace0528 opened 3 years ago

zdlspace0528 commented 3 years ago

I run your codes in your paper,I get an error,

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

Figure A3: Individual effects

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

pdf("sim_iTE.pdf",width=7,height=10) Ntr<-out$Ntr Y.tr<-out$Y.tr Y.ct<-out$Y.ct eff<-out$eff true.effect<-matrix(out$eff,30,50)[,1:5] Error in matrix(panel$eff, T, N) : 找不到对象'panel'

数据中并没有panel,为什么您的代码中有panel 呢

新春快乐! Raymond

xuyiqing commented 3 years ago

I think it is a simulated dataset.

On Tue, Feb 23, 2021 at 9:43 AM zdlspace0528 notifications@github.com wrote:

I run your codes in your paper,I get an error,

################################### Figure A3: Individual effects

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

pdf("sim_iTE.pdf",width=7,height=10) Ntr<-out$Ntr Y.tr<-out$Y.tr Y.ct<-out$Y.ct eff<-out$eff true.effect<-matrix(out$eff,30,50)[,1:5] Error in matrix(panel$eff, T, N) : 找不到对象'panel'

数据中并没有panel,为什么您的代码中有panel 呢

新春快乐! Raymond

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/xuyiqing/gsynth/issues/55, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB2PKGDSOF7CUCQSIZYZRU3TAPSMBANCNFSM4YC5KY2Q .

zdlspace0528 commented 3 years ago

Dear Pro Xu, I run the codes of your paper to get figure A6.But I can not get confidence intervals.In your paper, You plot confidence intervals,but with your codes,there is no confidence intervals.

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

Figiure A6: Each State

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

out<-out.syn2 names(out) time<-out$time T0<-out$T0 T<-out$T states<-out$id.tr

for (abb in states) { # treated states

id<-which(out$id.tr==abb)
t0<-T0[id]

pdf(paste("fg_edr_case_",abb,".pdf",sep=""),width=14,height=5)
par(mfcol=c(1,2),mar=c(4,4,1,1),lend=1)

## counterfactual
yrg<-range(c(out$Y.tr[,id],out$Y.ct[,id]))
ylim=c(yrg[1]-10,yrg[2]+5)
plot(1,type="n",xlab="",ylab='',axes=F,xlim=c(1920,2016),ylim=ylim)
box()
axis(1,at=seq(1920,2016,8));mtext("Year",1,2.5,cex=1.5)
axis(2);mtext("Turnout %",2,2,cex=1.5)
abline(v=time[t0],col="gray",lwd=2)
lines(time,out$xi+mean(out$Y.tr[,id]),col="gray50",lwd=2,lty=5)
lines(time,out$Y.tr[,id],lwd=3)  
lines(time,out$Y.ct[,id],col="gray50",lty=1,lwd=2)
text(1925,yrg[2]+2,abb,cex=2)
legend("bottomright",
       legend=c("Actual Outcome","Estimated Y(0) (DID)","Estimated Y(0) (GSC)"),
       cex=1.3, seg.len=2, col=c(1,"gray50","gray50"),lty=c(1,5,1),
       lwd=c(3,2,2),bty="n")  

yrg<-range(c(out$est.ind[,,id],out$Y.tr[,id]-out$xi-mean(out$Y.tr[,id])))
ylim<-c(yrg[1]-15,yrg[2]+5)
newx<-seq(1920,2012,4)
plot(1,type="n",xlab="",ylab='',axes=F,xlim=c(1920,2016),ylim=ylim)
box()
axis(1,at=seq(1920,2016,8));mtext("Year",1,2.5,cex=1.5)
axis(2);mtext("Turnout %",2,2,cex=1.5)
abline(v=time[t0],col="gray",lwd=2)
abline(h=0,col="gray20",lty=2,lwd=1)
lines(time,out$Y.tr[,id]-out$xi-mean(out$Y.tr[,id]),col=1,lwd=2,lty=5)
polygon(c(rev(newx), newx), c(rev(out$est.ind[ ,3,id]), out$est.ind[ ,4,id]),
        col = "#55555530", border = NA)
lines(time,out$est.ind[,1,id],col=1,lty=1,lwd=2)  
legend("bottomright",
       legend=c("Treatment Effect (DID)","Treatment Effect (GSC)",
                "95% Confidence Interval (GSC)"),
       cex=1.3, seg.len=2, col=c(1,1,"#55555550"),lty=c(5,1,1),lwd=c(2,2,15),
       bty="n")  

graphics.off()
} image

zdlspace0528 commented 3 years ago

为什么我用您的代码之后,上面第二幅图里没有置信区间呢?

zdlspace0528 commented 3 years ago

and also there is no Treatment Effect (GSC) line.

xuyiqing commented 3 years ago

This may be because the package has been updated and the syntax has changed. Please resort to this page ( http://yiqingxu.org/software/gsynth/gsynth_examples.html) for more information.

On Tue, Feb 23, 2021 at 10:49 AM zdlspace0528 notifications@github.com wrote:

and also there is no Treatment Effect (GSC) line.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/xuyiqing/gsynth/issues/55#issuecomment-784428537, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB2PKGBUAIWEQFXP3P3KE2LTAP2CHANCNFSM4YC5KY2Q .

-- Yiqing Xu

Assistant Professor Department of Political Science University of California, San Diego http://yiqingxu.org/

zdlspace0528 commented 3 years ago

Dear Professor Xu, I have simple question when I learn your paper “Trajectory Balancing: A General Reweighting Approach to Causal Inference with Time-Series Cross-Sectional Data.”(2020) What is the meaning of “Trajectory Balancing” in Chinese?Can I translate it into “弹道平衡”?

Best regards Raymond

zdlspace

zdlspace@163.com | 签名由网易邮箱大师定制

在2021年02月24日 08:40,Yiqing Xunotifications@github.com 写道:

This may be because the package has been updated and the syntax has changed. Please resort to this page ( http://yiqingxu.org/software/gsynth/gsynth_examples.html) for more information.

On Tue, Feb 23, 2021 at 10:49 AM zdlspace0528 notifications@github.com wrote:

and also there is no Treatment Effect (GSC) line.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/xuyiqing/gsynth/issues/55#issuecomment-784428537, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB2PKGBUAIWEQFXP3P3KE2LTAP2CHANCNFSM4YC5KY2Q .

-- Yiqing Xu

Assistant Professor Department of Political Science University of California, San Diego http://yiqingxu.org/

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

xuyiqing commented 3 years ago

Haha, maybe 轨迹平衡 is better!

On Mon, Mar 8, 2021 at 10:29 PM zdlspace0528 notifications@github.com wrote:

Dear Professor Xu, I have simple question when I learn your paper “Trajectory Balancing: A General Reweighting Approach to Causal Inference with Time-Series Cross-Sectional Data.”(2020) What is the meaning of “Trajectory Balancing” in Chinese?Can I translate it into “弹道平衡”?

Best regards Raymond

zdlspace

zdlspace@163.com | 签名由网易邮箱大师定制

在2021年02月24日 08:40,Yiqing Xunotifications@github.com 写道:

This may be because the package has been updated and the syntax has changed. Please resort to this page ( http://yiqingxu.org/software/gsynth/gsynth_examples.html) for more information.

On Tue, Feb 23, 2021 at 10:49 AM zdlspace0528 notifications@github.com wrote:

and also there is no Treatment Effect (GSC) line.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/xuyiqing/gsynth/issues/55#issuecomment-784428537, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AB2PKGBUAIWEQFXP3P3KE2LTAP2CHANCNFSM4YC5KY2Q

.

-- Yiqing Xu

Assistant Professor Department of Political Science University of California, San Diego http://yiqingxu.org/

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/xuyiqing/gsynth/issues/55#issuecomment-793452376, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB2PKGH6ZY2EPXQAO244AI3TCW55FANCNFSM4YC5KY2Q .

-- Yiqing Xu

Assistant Professor Department of Political Science University of California, San Diego http://yiqingxu.org/

zdlspace0528 commented 3 years ago

Dear Pro Xu, I try to run your example Xu(2017) with your R package tjbal.But it gets error.

library(panelView) library(gsynth) data(gsynth) panelView(turnout ~ policy_edr, data = turnout, index = c("abb","year"), by.timing = TRUE)

out <- tjbal(data = turnout, Y = "turnout", D = "policy_edr", index = c("abb","year"), demean = TRUE, vce = "jackknife")

Balancing... Subgroup T0 = 14: bias.ratio = 0.5997; num.dims = 6 (mbal) Subgroup T0 = 19: bias.ratio = 0.4563; num.dims = 5 (mbal) Subgroup T0 = 22: bias.ratio = 0.2767; num.dims = 7 (mbal) Subgroup T0 = 23: bias.ratio = 0.3012; num.dims = 2 (mbal)

Jackknife...

Dropping units from Subgroup T0 = 14 Error in fun(A, k, nu, nv, opts, mattype = "matrix") : 'k' must satisfy 0 < k < min(nrow(A), ncol(A)). To calculate all singular values, try svd()

How can I solve this problem?

Best regards.

Raymond

zdlspace

zdlspace@163.com | 签名由网易邮箱大师定制

在2021年03月9日 14:29,张德亮zdlspace@163.com 写道: Dear Professor Xu, I have simple question when I learn your paper “Trajectory Balancing: A General Reweighting Approach to Causal Inference with Time-Series Cross-Sectional Data.”(2020) What is the meaning of “Trajectory Balancing” in Chinese?Can I translate it into “弹道平衡”?

Best regards Raymond

zdlspace

zdlspace@163.com | 签名由网易邮箱大师定制

在2021年02月24日 08:40,Yiqing Xunotifications@github.com 写道:

This may be because the package has been updated and the syntax has changed. Please resort to this page ( http://yiqingxu.org/software/gsynth/gsynth_examples.html) for more information.

On Tue, Feb 23, 2021 at 10:49 AM zdlspace0528 notifications@github.com wrote:

and also there is no Treatment Effect (GSC) line.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/xuyiqing/gsynth/issues/55#issuecomment-784428537, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB2PKGBUAIWEQFXP3P3KE2LTAP2CHANCNFSM4YC5KY2Q .

-- Yiqing Xu

Assistant Professor Department of Political Science University of California, San Diego http://yiqingxu.org/

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

zdlspace0528 commented 3 years ago

Dear Pro Xu, I have a question about your Stata command —fect—,When I do Permutation Test and get p value=0? Does this pass Permutation Test? Many thanks in advance.

Best Raymond

zdlspace

@.*** | 签名由网易邮箱大师定制

在2021年03月10日 @.***> 写道:

Dear Pro Xu, I try to run your example Xu(2017) with your R package tjbal.But it gets error.

library(panelView) library(gsynth) data(gsynth) panelView(turnout ~ policy_edr, data = turnout, index = c("abb","year"), by.timing = TRUE)

out <- tjbal(data = turnout, Y = "turnout", D = "policy_edr", index = c("abb","year"), demean = TRUE, vce = "jackknife")

Balancing... Subgroup T0 = 14: bias.ratio = 0.5997; num.dims = 6 (mbal) Subgroup T0 = 19: bias.ratio = 0.4563; num.dims = 5 (mbal) Subgroup T0 = 22: bias.ratio = 0.2767; num.dims = 7 (mbal) Subgroup T0 = 23: bias.ratio = 0.3012; num.dims = 2 (mbal)

Jackknife...

Dropping units from Subgroup T0 = 14 Error in fun(A, k, nu, nv, opts, mattype = "matrix") : 'k' must satisfy 0 < k < min(nrow(A), ncol(A)). To calculate all singular values, try svd()

How can I solve this problem?

Best regards.

Raymond

zdlspace

@.*** | 签名由网易邮箱大师定制

在2021年03月9日 @.***> 写道: Dear Professor Xu, I have simple question when I learn your paper “Trajectory Balancing: A General Reweighting Approach to Causal Inference with Time-Series Cross-Sectional Data.”(2020) What is the meaning of “Trajectory Balancing” in Chinese?Can I translate it into “弹道平衡”?

Best regards Raymond

zdlspace

@.*** | 签名由网易邮箱大师定制

在2021年02月24日 08:40,Yiqing @.***> 写道:

This may be because the package has been updated and the syntax has changed. Please resort to this page ( http://yiqingxu.org/software/gsynth/gsynth_examples.html) for more information.

On Tue, Feb 23, 2021 at 10:49 AM zdlspace0528 @.***> wrote:

and also there is no Treatment Effect (GSC) line.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/xuyiqing/gsynth/issues/55#issuecomment-784428537, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB2PKGBUAIWEQFXP3P3KE2LTAP2CHANCNFSM4YC5KY2Q .

-- Yiqing Xu

Assistant Professor Department of Political Science University of California, San Diego http://yiqingxu.org/

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

xuyiqing commented 3 years ago

Thank you, we'll look into it.

Ziyi, could you put this on the fect (Stata)'s issue reporting board? Let's make our new system work :-)

On Fri, Jun 11, 2021 at 11:48 AM zdlspace0528 @.***> wrote:

Dear Pro Xu, I have a question about your Stata command —fect—,When I do Permutation Test and get p value=0? Does this pass Permutation Test? Many thanks in advance.

Best Raymond

zdlspace

@.*** | 签名由网易邮箱大师定制

在2021年03月10日 @.***> 写道:

Dear Pro Xu, I try to run your example Xu(2017) with your R package tjbal.But it gets error.

library(panelView) library(gsynth) data(gsynth) panelView(turnout ~ policy_edr, data = turnout, index = c("abb","year"), by.timing = TRUE)

out <- tjbal(data = turnout, Y = "turnout", D = "policy_edr", index = c("abb","year"), demean = TRUE, vce = "jackknife")

Balancing... Subgroup T0 = 14: bias.ratio = 0.5997; num.dims = 6 (mbal) Subgroup T0 = 19: bias.ratio = 0.4563; num.dims = 5 (mbal) Subgroup T0 = 22: bias.ratio = 0.2767; num.dims = 7 (mbal) Subgroup T0 = 23: bias.ratio = 0.3012; num.dims = 2 (mbal)

Jackknife...

Dropping units from Subgroup T0 = 14 Error in fun(A, k, nu, nv, opts, mattype = "matrix") : 'k' must satisfy 0 < k < min(nrow(A), ncol(A)). To calculate all singular values, try svd()

How can I solve this problem?

Best regards.

Raymond

zdlspace

@.*** | 签名由网易邮箱大师定制

在2021年03月9日 @.***> 写道: Dear Professor Xu, I have simple question when I learn your paper “Trajectory Balancing: A General Reweighting Approach to Causal Inference with Time-Series Cross-Sectional Data.”(2020) What is the meaning of “Trajectory Balancing” in Chinese?Can I translate it into “弹道平衡”?

Best regards Raymond

zdlspace

@.*** | 签名由网易邮箱大师定制

在2021年02月24日 08:40,Yiqing @.***> 写道:

This may be because the package has been updated and the syntax has changed. Please resort to this page ( http://yiqingxu.org/software/gsynth/gsynth_examples.html) for more information.

On Tue, Feb 23, 2021 at 10:49 AM zdlspace0528 @.***> wrote:

and also there is no Treatment Effect (GSC) line.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/xuyiqing/gsynth/issues/55#issuecomment-784428537, or unsubscribe < https://github.com/notifications/unsubscribe-auth/AB2PKGBUAIWEQFXP3P3KE2LTAP2CHANCNFSM4YC5KY2Q

.

-- Yiqing Xu

Assistant Professor Department of Political Science University of California, San Diego http://yiqingxu.org/

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/xuyiqing/gsynth/issues/55#issuecomment-859774084, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB2PKGEY5E4GKCGNT6GNVT3TSJLAHANCNFSM4YC5KY2Q .

-- Yiqing Xu

Assistant Professor Department of Political Science University of California, San Diego http://yiqingxu.org/