# Re: st: Test for trend in surveys

 From Steven Samuels To statalist@hsphsun2.harvard.edu Subject Re: st: Test for trend in surveys Date Wed, 1 Oct 2008 18:05:33 -0400

```
```

There is, to my knowledge, no such thing as test for trend of type Pearson chi-squared. I suspect that Ángel is referring to the Cochran-Armitage test one degree-of-freedom chi square test for trend (A. Agresti, 2002, Categorical Data Analysis, 2nd Ed. Wiley Books, Section 5.3.5).

Let Y be the 0-1 binary outcome variable and X be the variable which contains category scores. One survey-enabled approach is Phil's suggestion: use -svy: logit-.

However -svy: reg- will produce a result closer to that of the Cochran-Armitage test. Why? The Cochran-Armitage test statistic is formally equivalent to an O.L.S. regression of Y on X, with a standard error for beta which substitutes the total variance for the residual variance. The statistic is (beta/se)^2. The total variance is equal to P(1-P), where P is the overall sample proportion. In other words, the standard error is computed under the null hypothesis of equal proportions.

The -svy: reg- command will estimate the same regression coefficient, but with a standard error that is robust to heterogeneity in proportions. In both survey-enabled commands, t = (b/se) has a t distribution with degrees of freedom (d.f.) based on the survey design; t^2 has an F(1, d.f.) distribution.

-Steve

On Sep 30, 2008, at 6:39 AM, Philip Ryan wrote:

Well, the z statistic testing the coefficient on the exposure variable is as
valid and as useful a summary (test) statistic as the chi-square statistic
produced by a test of trend in tables. If you prefer chi-squares, you could
just square the z statistic to get the chi-square on 1 df. And if you prefer
likelihood ratio chi-squares to the Wald z (or Wald chi-square) then the
modelling approach can deliver that also.

Phil

Quoting Ángel Rodríguez Laso <angelrlaso@gmail.com>:

Thanks to Philip and Neil for their advice.

Philip's proposal is absolutely compatible with survey data, but I was
interested in a summary statistic of the type of Pearson chi-squared.

To this respect, Neil puts forward a test (nptrend) that would be
perfect if it allowed complex survey specifications. I believe strata
and clusters are not important because the formula for the standard
error of this nonparametric test (see Stata Reference Manual K-Q page
338) should not be affected by these specifications. But nptrend does
not accept weights as an option, what I think makes it unsuitable for
complex survey analyses.

Angel Rodriguez Laso

For a 2 x k table [with a k-category "exposure" variable] just set up a
logistic
dose-response model:

svyset <whatever>
svy: logistic <binary outcome var> <exposure var>

and check the coefficient of <exposure var>, along with its confidence
interval
and P-value.

If you prefer a risk metric rather than odds, then use svy: glm..... with

Phil

Quoting Ángel Rodríguez Laso <angelrlaso@gmail.com>:

Dear Statalisters,

Is there a way to carry out a test for trend in a two-way table in
survey analysis in Stata?

Many thanks.

Angel Rodriguez Laso
*
*--
```*
*   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/
```