Announcement

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

  • accessing stored results saved in matrix r(P)

    Hi,

    I am running a functional Dunn's test (over time) and would like to store results from the matrix for each time observation. I've tried different variations (please see below) but I get an error. I'm not sure how to store these results in .dta. If this is not an option, can you please advise how can I store results of r(P) for each time observation? Stored results of Dunn's test include scalars and matrices but I would like to obtain values from stored matrices.
    statsby matrix r(P) , by(time) clear: dunntest Wchange, by(category) ma(bonferroni)
    statsby matrix p=r(P), by(time) clear: dunntest Wchange, by(category) ma(bonferroni)

    Here is a link to Dunn's test which has a section on Stored Results: https://ageconsearch.umn.edu/record/...art_st0381.pdf

    Thank you in advance,
    Last edited by Jaime Mac; 10 Jul 2023, 09:50.

  • #2
    -statsby- can only collect scalars, not matrices. (Synactically, it will allow you to appear to store the system matrices _b and _se, but, in fact, it does not save those matrices: it instead saves these 1-row matrices as values of new variables in the data set.)

    Caveat: I am not familiar with the -dunntest- command, so there may be technical problems with the solution I propose here that I do not anticipate. But it is likely you can accomplish what you want as follows:
    Code:
    capture program drop one_time
    program define one_time
        local time = time[1]
        dunntest Wchange, by(category) ma(bonferroni)
        matrix P = r(P)
        clear
        svmat P
        gen time = `time'
        exit
    end
    runby one_time, by(time)
    [/code]
    -runby- is written by Robert Picard and me. It is available from SSC.
    The end result will be a data set in which the columns of the r(P) matrices appear as variables, and there is another variable showing the value of time at which they were calculated. The values of the original data will be otherwise lost (so you may want to -preserve- or -save- the data before running this code). It isn't clear to me, however, how one could combine these results with the original data in a single data set since in general the number of rows in the r(P) matrix calculated for a given time will not be the same as the number of observations associated with that value of time in the original data, so there is no obvious way to link them up.

    Comment


    • #3
      Dear Clyde,

      Thank you so much, your suggestion worked perfectly. All the best!

      Comment

      Working...
      X