*! version 1.3.4 15dec2022

Title

rtrend -- Trend test (2xk or kx2 table) for frequency and person-time data

Syntax

Syntax for frequency analysis

rtrend var_response var_exposure
[if] [in] [weight], data(freq) [options]

Syntax for person-time analysis

rtrend var_response var_exposure var_person-time
[if] [in], data(pt) [options]

Immediate command (non stratified analysis)

Cohort/Cross-Sectional

rtrendi #metric1 [...] #metricj \ #a1 [...] #aj \ #n1 [...] #nj,
data(freq) [options]

Case-Control

rtrendi #metric1 [...] #metricj \ #a1 [...] #aj \ #b1 [...] #bj,
data(freq) st(cc) [options]

Person-Time

rtrendi #metric1 [...] #metricj \ #a1 [...] #aj \ #t1 [...] #tj,
data(pt) [options]

Immediate command (stratified analysis)

Cohort/Cross-Sectional

rtrendi #metric1 #metric2 [...] #metricj \

#a11 #a12 [...] #a1j \ [...] \ #ak1 #ak2 [...] #akj \

#n11 #n12 [...] #n1j \ [...] \ #nk1 #nk2 [...] #nkj,
data(freq) [options]

Case-Control

rtrendi #metric1 #metric2 [...] #metricj \

#a11 #a12 [...] #a1j \ [...] \ #ak1 #ak2 [...] #akj \

#b11 #b12 [...] #b1j \ [...] \ #bk1 #bk2 [...] #bkj,
data(freq) st(cc) [options]

Person-Time

rtrendi #metric1 #metric2 [...] #metricj \

#a11 #a12 [...] #a1j \ [...] \ #ak1 #ak2 [...] #akj \

#t11 #t12 [...] #t1j \ [...] \ #tk1 #tk2 [...] #tkj,
data(pt) [options]

where j is the number of elements in metric and k is the number of strata

Common
data(string) type of data; valid values are: default is data(freq)

freq (Frequency)

pt (Person-Time)

rc(string) reference category; valid values are: default is rc(f)

f (First)

l (Last)

p (Previous)

s (Subsequent)

by(varname) stratify on varname; this option is not allowed for the immediate command

metric(numlist) metric; this option is not allowed for the immediate command

none do not calculate confidence intervals of the proportions; the default

wilson calculate Wilson confidence intervals (only for frequency data)

exact calculate exact confidence intervals

wald calculate Wald confidence intervals (only for frequency data)

level(#) confidence level (%) default is level(95)

nst(string) name of the study (label)

Frequency only
st(string) study type; valid values are: default is st(co rr)

co or co rr or co or (Cohort)

cs or cs pr or cs or (Cross-Sectional)

cc (Case-Control)

Note: rr pr or specify the required statistic

by default: rr for co study, pr for cs study, or for cc study

zero(correct) continuity correction for cells with zero events: default is zero(n)

n None

c Constant, add k=0.5 to each cell

p Proportional, add k1=N1/N and k0=N0/N for ex, co & cs studies

add k1=M1/N and k0=M0/N for cc studies

r Reciprocal, add k1=1/N0 and k0=1/N1 for ex, co & cs studies

add k1=1/M0 and k0=1/M1 for cc studies

The recommended correction is reciprocal

ordinal(string) ordinal variable:

expo Exposure variable (default)

resp Response variable

fweight is allowed for frequency analysis; see weight.

Description

Compute trend test for frequency and person-time data. For frequency data the command needs the response and exposure variables
to compute the results. For person-time data the command needs the response, the exposure and the person-time variables
to compute the results.

rtrendi is the immediate form of rtrend; see immed. The immediate command needs at least three numlists,
separated by '\':

1. #metric1 #metric2 ... #metricj -- Metric

2. #a1 #a2 ... #aj -- List of exposed cases

3. #n1 #n2 ... #nj -- List of exposed total (cohort/cross-sectional calculations) or

#b1 #b2 ... #bj -- List of controls (case-control calculations) or

#t1 #t2 ... #tj -- List of person-time (person-time calculations)

The number of elements of the three numlists must be the same.

Stratified analysis is available with the option by(). For the immediate
form, several lists of values for a and n|b|t must be supplied (see the examples).

You can click here to pop up a dialog or type db rtrend. For the
immediate command, you can click here to pop up a dialog or type db rtrendi.

Execute net from http://metodo.uab.cat/stata for install.

It is important to keep the commands updated. Execute adoupdate rtrend, update to update the rtrend command.

Execute adoupdate, update to update all the user-written commands.

If you find any bugs or want to suggest any improvements, please send an e-mail to: leam@uab.cat.

Examples

Frequency

. use http://metodo.uab.cat/stata/SmokeApgar.dta

. rtrend Apgar Smoke, data(freq) metric(0 5 15 30) st(cs) wilson zero(n) nst(Study name)

. rtrendi 0 5 15 30 \ 48 6 17 17 \ 520 108 183 105, data(freq) st(co rr) rc(f)

. rtrendi 0 5 15 30 \ 48 6 17 17 \ 520 108 183 105, data(freq) st(cs or) rc(l)

. rtrendi 0 1 2 3 \ 7 565 445 340 \ 61 706 408 182, st(cc) rc(f)

Frequency - stratified analysis

. use http://metodo.uab.cat/stata/SmokeApgarAge.dta

. rtrend Apgar Smoke, data(freq) metric(1 2 3 4) rc(f) by(Age) st(co rr) wilson zero(n)

. rtrendi 1 2 3 4 \ 42 2 9 10 \ 6 4 8 7 \ 330 12 36 31 \ 190 96 147 74, data(freq) rc(f) st(co rr) wilson zero(n)

Person-time

. use http://metodo.uab.cat/stata/SmokeBladder.dta

. rtrend Bladder Smoke Time, data(pt) rc(f)

. rtrendi 0 1 2 3.5 \ 82 0 150 141 \ 31966 49672 44112 37545, data(pt) rc(l)

. rtrendi 0 1 2 3.5 \ 82 140 150 141 \ 31966.7 49672 44112.5 37545.9, data(pt) rc(l)

Person-time - stratified analysis

. use http://metodo.uab.cat/stata/ArsenicRespiratoryYear.dta

. rtrend Respiratory Arsenic Time, data(pt) by(Year) rc(f)

. rtrendi 1 2 3 4 \ 51 17 13 34 \ 100 38 15 8 \ 19017 2683 2600 3871 \ 74667 13693 5940 2510, data(pt) rc(f)

Stored results

The command stores the following in r():

r(N) valid cases

Scalars - Non stratified analysis

r(trend_chi2) MH Test for linear trend - Chi2

r(trend_p) MH Test for linear trend - Significance (p)

r(lin_chi2) Deviation from linearity - Chi2

r(lin_p) Deviation from linearity - Significance (p)

Matrices - Non stratified analysis

r(Results) results for each category, matrix form

Scalars - Stratified analysis

r(trend_chi2_i) MH Test for linear trend - Chi2 Stratum i

r(trend_p_i) MH Test for linear trend - Significance (p) Stratum i

r(lin_chi2_i) Deviation from linearity - Chi2 Stratum i

r(lin_p_i) Deviation from linearity - Significance (p) Stratum i

r(trend_chi2_OVER) MH Test for linear trend - Chi2 OVERALL

r(trend_p_OVER) MH Test for linear trend - Significance (p) OVERALL

r(lin_chi2_OVER) Deviation from linearity - Chi2 OVERALL

r(lin_p_OVER) Deviation from linearity - Significance (p) OVERALL

r(adj_trend_chi2) MH Test for linear trend - Chi2 Adjusted MH

r(adj_trend_p) MH Test for linear trend - Significance (p) Adjusted MH

r(adj_hom_chi2) Homogeneity of Linear trends - Chi2 Adjusted MH

r(adj_hom_p) Homogeneity of Linear trends - Significance (p) Adjusted MH

Matrices - Stratified analysis

r(Stri) results for each category, matrix form Stratum i

r(OVERALL) results for each category, matrix form OVERALL

r(AdjustedMH) results for each category, matrix form Adjusted MH

Version

Version 1.3.4 -- 15 December 2022

Authors

JM.Doménech

Programmer: R.Sesma

Laboratori d'Estadística Aplicada

Universitat Autònoma de Barcelona

leam@uab.cat

Vancouver reference

Doménech JM. Trend Test: User-written command rtrend for Stata [computer program].

V1.3.4. Bellaterra: Universitat Autònoma de Barcelona; 2022.

Available executing from Stata: net from http://metodo.uab.cat/stata

References

Breslow N, Day NE. Statistical methods in cancer research. Vol. I: The analysis of case-control
studies. Lyon: I.A.R.C. Scientific Publications nº 32, 1980.

Breslow N, Day NE. Statistical methods in cancer research. Vol. II: The design and analysis
of cohort studies. Lyon: I.A.R.C. Scientific Publications nº 82, 1987.