Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: How to save cell values in the tabulate twoway output?


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: How to save cell values in the tabulate twoway output?
Date   Wed, 16 Mar 2011 23:34:06 +0000

You have more observations than tables to be generated, so you can do
it in place.

gen a = .
gen b = .
gen c = .
gen d = .

qui forval j = 1/53  {
          capture tab obs`j' diagnose, matcell(table)
          replace a = table[1,1] in `j'
          replace b = table[1,2] in `j'
          replace c = table[2,1] in `j'
          replace d = table[2,2] in `j'
}

keep in 1/53
gen j = _n
keep j a b c d

Warning: untested code.

Nick

On Wed, Mar 16, 2011 at 11:23 PM, Bo Rud <[email protected]> wrote:

> I have a problem with the handling of data resulting from a dichotomous test
> performed by 53 observers in 102 patients.
> My data set consists of the 53 observers' assessments as well as the true
> diagnosis in the coloumns (variables).
> The data set has 102 rows corresponding to the number of patients assessed
> by each of the observers.
>
> patient  obs1  obs2 ... obs53  diagnose
> 1
> 2
> ..
> 102
>
> I use the following commands to generate 2x2 tables with numbers of
> true-positive(tp), false-positive(fp), false-negative(fn) and
> true-negative(tn) test outcomes for each observer:
>
> forvalues i = 1/53 {
> tab obs`i' diagnose
> }
>
> I would like to save the cell values in the tab output for further analysis,
> but I can't find a way to do it.
> My ambition is to generate a new data set with the following structure:
>
> Obs tp fp fn tn
> 1
> 2
> ..
> 53
>
> I'm aware of the matcell-option with tab, but the programing it entails
> appears beyond my level of expertise.
> Is there an easier way around?

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index