NickCH-K/did

No matrix returned when covariates used

heelguru opened this issue · 6 comments

When trying to run the example code with covariates, I no longer get output:
`
. att_gt lemp year firsttreat lpop, idname(countyreal)
Length Class Mode
group 12 -none- numeric
t 12 -none- numeric
att 12 -none- numeric
V_analytical 1 dgCMatrix S4
se 12 -none- numeric
c 1 -none- numeric
inffunc 6000 dgCMatrix S4
n 1 -none- numeric
W 1 -none- numeric
Wpval 1 -none- numeric
aggte 0 -none- NULL
alp 1 -none- numeric
DIDparams 26 DIDparams list
The multiplier bootstrap provides only the diagonal of the V/COV matrix.
Use analytic standard errors with bootstrap_no if you want to do a joint test of coefficients.

`

same is replicated with any selection. I guess the wrong matrix is being passed back. (This may be an Rcall beta issue, btw as it handles passing matrices back in a different way from previous version)

I note thought that without covariates the code runs just fine.

Hmm, this can't seem to be an issue with the matrix being passed back, becuase the output before the "The multiplier bootstrap" note is printed straight from R. That's some strange form of failed estimation.

The code you put in works fine on my side, so. I suspect it's an issue with rcall "remembering" an error, which can mess things up. Can you retry with the clearR option added, and if that doesn't work, after restarting Stata?

error.log
Attached is a trace of the error.

It's not R recalling an error, as this behaviour persists in a loop introducing controls vs without controls. In the loop it alternates between spitting out output when no controls are introduced, and the cryptic response when controls are passed.

Speaking of there is another bug regarding weird edge cases, but please see other bug report.

I don't know what to tell you - I've been running that exact same line dozens of times without that issue popping up. What's the exact code you're running? Also, are you updated to the most recent version of did? It's been getting a lot of updates.

The response you're getting back looks like it's printing the contents of the R model object instead of summary() of the model object, which is odd because no line of code asks it to do that.

The fact that it gets to "the multiplier bootstrap" text means it's finishing the R section without error, and the fact that there is a model object to print out means it did run the model. The other aspect here is not returning the matrix - this could just be an rcall limitation. Sometimes it will just fail to return matrices if they're big. I may add a line in the documentation about how to export the matrix from R to CSV yourself when this happens.

Am now super convinced this is an Rcall beta issue. As I said, I have to use the beta as am trying to push back a huge matrix. I notice that now in some instances the resultant matrix is being pushed back. So perhaps something else is happening when no matrix is returned. (though I cannot tell as you've seen the wrong dialogue is being printed).

The note I'll add to the docs will be something along the lines of suggesting:

rcall: write.csv(table, 'results_matrix.csv')

If that helps for the moment. That should write the results matrix, which from your description should have run and be available in R, to CSV in the working directory. You should then be able to read that into Stata.

I'm recommending a switch over to https://github.com/friosavila/csdid_drdid if you're still having problems