Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Hello Adam,

    With the current information it is difficult to identify and solve the problem. It seems to me that some debugging is required, which probably requires a close look at your data and your code. I would suggest that you try to identify in which line of your code the problem occurs, I do this printing text at different points of the code. Once you have identified were the problem is, I would try to print the dimensions of the matrices you are operating over, the value of the subscript you are working with, and a subset of the matrices you are working with. Printing the subscript and the dimensions of the matrices will help you see why "the subscript is invalid". Printing a subset of the matrix is relevant to see if the matrices are not void. If all this is insufficient to identify your problem, I would suggest that you email technical support with your data and do-file.

    Comment


    • #17
      Thanks Enrique,

      I'm not sure what you mean by "printing text at different points in the code" and I don't know how to print the dimensions of the matrices I am operating over. Because its not clear that this would necessarily solve the problem I've sent my .do file and data set to technical support. Hopefully they can help. If they can I'll post any helpful tips on the original statalist thread.

      Adam

      Comment


      • #18
        Dear Statalist,

        I have a similar issue than the previous one, but the answers in the forum didn't help me to solve my problem.

        I have a sample with 320 firms (treated = 134 and control = 186).
        After to run the command "teffect psmatch" and the command "tebalance summarize", I know that matched sample is composed by 134 treated and 134 control firms (= 268 firms).
        So, how to know which non-treated firms (actually the id) are in my matched sample?

        I tried with your suggestion, to run "teffects psmatch" with the option gen(stub).
        The new variable give me the nearest-neighbor index 1. If I run the command "sum stup", I have already 320 observations (= firms).
        After if I check how many similar observations I have for the each value of "stub", I count 55 observations (= firms) which are reported only one time.
        So, if I remove the 55 to 320, I have 265 companies and not 268 (134 + 134).

        I do not know, I did some wrong. From my point of view, I should have to find 268 companies.

        Could you someone help me please?

        Thank in advance,
        Anabela

        Comment


        • #19
          Dear Adam
          This is a bit late.
          Replace
          Code:
           
           mean(w[i[|j,1\j,n[j]|]])
          twice with
          Code:
           
           n[j] ? mean(w[i[|j,1\j,n[j]|]]) : .
          This way you set the mean to missing if no match is present.
          Kind regards

          nhb

          Comment


          • #20
            Hello everyone,

            I am having the same issue when it comes to trying to use this mata code. I am getting an error (3 lines skipped). Does anyone have any ideas?

            Comment


            • #21
              Could you elaborate on your problem?
              Kind regards

              nhb

              Comment


              • #22
                Thank you to everyone who provided help here.

                In response to a private question I received relating to this thread I'm posting a description of how I resolved my issue here.

                I ended up using a user-written propensity score generation and matching programs called 'pscore' & 'psmatch2' respectively. I found these less restrictive than Stata's built-in 'teffects' command (which seems excellent for providing exactly what it intends, just not so easy to alter/verify/customise) . An example of code I used (using an example dataset) is provided below to to achieve what I wanted in the thread above. I found this easier than managing the mata code following 'teffects' when applying it to my actual dataset.


                Code:
                webuse cattaneo2, clear
                
                /* Install user-written programs */
                findit pscore
                net install st0026 /* install pscore*/
                findit psmatch2
                net install psmatch2 /* install pscore*/
                
                pscore (mbsmoke) (mmarried mage medu fbaby), pscore(PS) logit /* generate probability of exposure & label propensity score 'PS' */
                psmatch2 (bweight), outcome(bweight) pscore(PS) logit /* perform propensity score matching */
                gen pair = _id if _treated==0 /* identify matched pairs */
                replace pair = _n1 if _treated==1 /* identify matched pairs */
                bysort pair: egen paircount = count(pair) /* count matched pairs */
                drop if paircount!=2 /* keep only matched individuals */
                bysort _treated: sum mage/* use any means to describe/compare/test variables between the matched exposed & unexposed groups */

                Hope that helps,

                Adam

                Comment

                Working...
                X