Announcement

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

  • how to extract the p values after psm (pstest)?

    Code:
    cap ssc installl psmatch2
    sysuse auto,clear
    psmatch2 foreign mpg weight length, out(rep78)  neighbor(1) common caliper(.05) ties
    pstest
    I want to store the maxium of circled p-values, how to extract this?

    Thanks!
    Click image for larger version

Name:	1.png
Views:	1
Size:	93.3 KB
ID:	1641553

  • #2
    one option is to use regress,
    Code:
    clear
    sysuse auto
    psmatch2 foreign mpg weight length, out(rep78)  neighbor(1) common caliper(.05) ties
    pstest
    regress mpg _treated [fw=_weight]
    test _treated
    display r(p)

    Comment


    • #3
      Originally posted by Øyvind Snilsberg View Post
      one option is to use regress,
      Code:
      clear
      sysuse auto
      psmatch2 foreign mpg weight length, out(rep78) neighbor(1) common caliper(.05) ties
      pstest
      regress mpg _treated [fw=_weight]
      test _treated
      display r(p)
      Thank you Øyvind Snilsberg! However, this need to run a lot of regressions one-by-one, will be a little complicated. I hope there is a simpler way.

      Comment


      • #4
        I don't know if it's simpler, but you may run all regressions together

        Code:
        sysuse auto,clear
        psmatch2 foreign mpg weight length, out(rep78)  neighbor(1) common caliper(.05) ties
        pstest
        
        mvreg mpg weight length = _treat [fw=_weight]
        and extract all p-values.

        Code:
        gen variable = ""
        gen pvalue = .
        local l = 1
        foreach var of varlist mpg weight length {
            replace variable = "`var'" in `l'
            replace pvalue = r(table)["pvalue", `=2*`l'-1'] in `l'
            local ++l
        }
        Code:
        . list variable pvalue if !mi(variable)
        
             +---------------------+
             | variable     pvalue |
             |---------------------|
          1. |      mpg   .4582798 |
          2. |   weight   .6133822 |
          3. |   length   .4972447 |
             +---------------------+

        Comment

        Working...
        X