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

# st: R: comparing two linear slopes - flag: Stata 9.2/SE

 From "Carlo Lazzaro" To Subject st: R: comparing two linear slopes - flag: Stata 9.2/SE Date Sun, 31 Oct 2010 11:49:22 +0100

```Ashwin may want to consider the increased number of hospitalizations between
"year end" and "year start" for both the diseases under investigation (A and
B) as a proxy for the increase in the number of episodes of A and B.
Hence, Ashwin may want to perform a parametric ttest on the differences in
hospitalizations for A and B and then test the results in terms of
significance via a bootstrap p-value:

*********************** code begins *************************************
drop _all
set obs 100
g H_1_Start=2*uniform()
g H_1_End=8*uniform()
g H_2_Start=1*uniform()
g H_2_End=2*uniform()
g Diff_1= H_1_End- H_1_Start
g Diff_2= H_2_End- H_2_Start
ttest Diff_1 == Diff_2, unpaired unequal
return list
scalar tobs=r(t)
replace  Diff_1= Diff_1-r(mu_1)+(r(mu_1)+r(mu_2))/2
replace  Diff_2= Diff_2-r(mu_2)+(r(mu_1)+r(mu_2))/2
bootstrap r(t), reps(10000) nodots saving(C:\Documents and
Settings\carlo\Desktop\Ashwin_boot.dta, every(1) double replace): ttest
Diff_1 == Diff_2, unpaired unequal
use "C:\Documents and Settings\carlo\Desktop\Ashwin_boot.dta", clear
g indicator =abs(_bs_1)>=abs(scalar(tobs))
sum indicator, mean
di "p_bootstrap =" r(mean)
*********************** code ends *************************************

HTH and Kind Regards,
Carlo
-----Messaggio originale-----
Da: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Per conto di Ashwin
Ananthakrishnan
Inviato: venerdì 29 ottobre 2010 22.40
A: statalist@hsphsun2.harvard.edu
Oggetto: st: comparing two linear slopes

Hi,

I'm examining the rate of change of two proportions over time. I'd be
grateful if someone could help me figure this out:

I'm looking at the proportional increase in two specific disease (as a
proportion of all hospitalizations) over time and need to see if the rate of
increase for one disease is statistically greater than the rate of increase
for disease 2.

I have the sum totals for the numerators (i.e disease 1 or disease 2) and
denominators (total hospitalization 1 and total hospitalizations 2) for the
start and the end year (the relationship is linear for the intervening years
- that's been looked at).

Is there a way to compare these two trends statistically to say that the
4-fold increase for disease 1 is significant greater than the 2-fold
increase for disease 2?

Should i calculate the annual percent change for each disease and then use
the two-sample t test? How i get the Std dev for the annual percent change?

Thanks,

Ashwin

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