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

Re: st: stored p-value of sts test

 From Phil Clayton To statalist@hsphsun2.harvard.edu Subject Re: st: stored p-value of sts test Date Sat, 21 Jan 2012 08:42:24 +1100

```After performing a log-rank test, -sts test- returns the chi-squared and degrees of freedom as r(chi2) and r(df) - see -help sts test-. There is no r(p) but you can easily calculate the p-value using r(chi2), r(p) and Stata's chi2tail() function.

sts test `x', logrank
if chi2tail(r(df), r(chi2)) < 0.05 {
sts graph, by(`x') tmax(60)
graph save `x', replace
}

Phil

On 21/01/2012, at 5:08 AM, Steve Nakoneshny wrote:

> Dear Statalisters,
>
> I am performing some exploratory analyses in an stsetted dataset using Stata 11.2 for Mac.
>
> As part of a loop, I coded the following:
>
> -- start code --
>
> sts test `x', logrank
> sts graph, by(`x') tmax(60)
> graph save `x', replace
>
> -- end code --
>
> My local `x' comprises 18 variables, so the loop generates more graphs than I actually want to save. Looking at the help, I see that -sts graph- accepts -if- statements. What I would like to do is only graph (and save) where -sts test- is statistically significant (p<0.05). According to -help-, -sts test- doesn't save the p-value in r().
>
> What I would like to know is whether or not the p-value is stored somewhere else (if at all) or if there is an alternate workaround I can implement.
>
>
> Thanks,
> Steve
> *
> *   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/

*
*   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/
```