Announcement

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

  • frame post not working after last update

    Has anyone else noticed their code using frame post is now not working? I had code like below that was working and now it is not:

    Code:
    clear
    version 16
    set obs 100
    generate x = rnormal()
    generate y = rnormal()
    generate group = "a" in 1/50
    replace group = "b" in 51/100
    tempname sp_results 
    frame create `sp_results' str10(group) double(N spcorr pvalue)
    levelsof group, local(levels)
    foreach l of local levels {
        spearman x y if group == "`l'"
        frame post `sp_results' ("`l'") (r(N)) (r(rho)) (r(p))
    }
    frames `sp_results': list, sep(0)
    Have I missed something? Running my old code that did pick up results now doesn't. There was a recent update on frame post...

  • #2
    I found a resolution. In my previous code the above worked. Now for it to work I need to quote the return list:

    Code:
    clear
    version 16
    set obs 100
    generate x = rnormal()
    generate y = rnormal()
    generate group = "a" in 1/50
    replace group = "b" in 51/100
    tempname sp_results 
    frame create `sp_results' str10(group) double(N spcorr pvalue)
    levelsof group, local(levels)
    foreach l of local levels {
        spearman x y if group == "`l'"
        frame post `sp_results' ("`l'") (`r(N)') (`r(rho)') (`r(p)')
    }
    frames `sp_results': list, sep(0)

    Comment


    • #3
      Note that the first syntax is straight from the documentation examples. So the documentation needs updating if the frames post command is not.

      Comment


      • #4
        Originally posted by Dave Airey View Post
        Has anyone else noticed their code using frame post is now not working? I had code like below that was working and now it is not:

        Code:
        clear
        version 16
        set obs 100
        generate x = rnormal()
        generate y = rnormal()
        generate group = "a" in 1/50
        replace group = "b" in 51/100
        tempname sp_results
        frame create `sp_results' str10(group) double(N spcorr pvalue)
        levelsof group, local(levels)
        foreach l of local levels {
        spearman x y if group == "`l'"
        frame post `sp_results' ("`l'") (r(N)) (r(rho)) (r(p))
        }
        frames `sp_results': list, sep(0)
        Have I missed something? Running my old code that did pick up results now doesn't. There was a recent update on frame post...
        Thank you for spotting this. frame post originally called an r-class command as part of its code. This had the side-effect of removing/overwriting any r-class results that were in memory before frame post was called. That was changed in a recent update, but a side-effect of that change was that the previously-existing r-class results were not directly available to frame post. That's a bug, and it will be fixed in the next update.

        Comment


        • #5
          Thanks for the reply. But why would the quoted syntax work?

          Comment


          • #6
            Originally posted by Dave Airey View Post
            Thanks for the reply. But why would the quoted syntax work?
            When you quote it, it is handled via macro expansion. So, before frame post ever runs, Stata evaluates the macros on the command line, substituting in the numbers from the r() results, and then frame post is called with the numbers on the command line rather than the r() specifications.

            Comment


            • #7
              Thanks for the explanation, I had also stumbled across this.
              Doug Hemken
              SSCC, Univ. of Wisc.-Madison

              Comment

              Working...
              X