Another possibility is to use the -somersd- package, downloadable from SSC, to calculate a confidence interval for the difference between the 2 proportions (the proportion using Brand B and the proportion using Brand A). A confidence interval for the difference between proportions is more informative than a P-value for the hypothesis of a zero difference between proportions, because a confidence interval tells the user the range of population differences that are compatible with the sample data, and a P-value only tells the user whether the sample data are compatible with a zero population difference.
The -somersd- package has the option of using the Normalizing and variance-stabilizing hyperbolic arctangent transform (or z-transform) recommended by Edwardes (1995). For more about the theory behind the -somersd- package, see Newson (2006a) and Newson (2006b).
In this case, we would use the -reshape- command to reshape the dataset to have one observation per subject per brand, instead of one observation per subject, and then use the -somersd- package with the -cluster()- option to estimate the difference between proportions, with the subjects as clusters. As in:
preserve
rename BrandA usebrand1
rename BrandB usebrand2
keep Id usebrand1 usebrand2
reshape long usebrand, i(Id) j(brand)
lab def brand 1 "Brand A" 2 "Brand B"
lab val brand brand
lab var brand "Brand"
lab var usebrand "Use of brand"
tabulate brand usebrand, missing row
somersd brand usebrand, transf(z) tdist cluster(Id)
restore
This will produce a tabulation of the 2 proportions, a symmetric confidence interval for the z-trabsformed difference between the proportion using Brand B and the proportion using Brand A (or z-transformed Somers' D), and an asymmetric confidence interval for the untransformed difference between proportions (or untransformed Somers' D).
I hope this helps.
Best wishes
Roger
References
Edwardes, M. D. d. B. 1995. A confidence interval for Pr(X < Y) − Pr(X > Y)
estimated from simple cluster samples. Biometrics 51: 571–578.
Newson R. 2006a. Confidence intervals for rank statistics: Somers' D and extensions. The Stata Journal 6(3): 309-334. Download pre-publication draft from
http://www.imperial.ac.uk/nhli/r.newson/
Newson R. 2006b. On the central role of Somers' D. Presented at the 12th UK Stata User Meeting, 11-12 September, 2006. Download presentation from
http://www.imperial.ac.uk/nhli/r.newson/
Roger Newson
Lecturer in Medical Statistics
Respiratory Epidemiology and Public Health Group
National Heart and Lung Institute
Imperial College London
Royal Brompton campus
Room 33, Emmanuel Kaye Building
1B Manresa Road
London SW3 6LR
UNITED KINGDOM
Tel: +44 (0)20 7352 8121 ext 3381
Fax: +44 (0)20 7351 8322
Email: [email protected]
www.imperial.ac.uk/nhli/r.newson/
Opinions expressed are those of the author, not of the institution.
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Steven Samuels
Sent: 13 April 2007 23:31
To: [email protected]
Subject: Re: st: Fw: PROPORTIONAL T TEST WITH OVERLAPPING
McNemar's test is the standard test of this hypothesis. Do a search
on "mcnemar" to find Stata's implementations & other information.
There is an "exact" version.
Steven
On Apr 13, 2007, at 5:55 PM, keesman wrote:
> Hi,
>
> I want to do a proportional t test with overlapping data (see
> below). Official Stata doesn't have this option for their
> proportion test. The statistical package Quantum has a proportional
> t test with an overlapping option. The overlapping option adjusts
> the results to allow for overlapping.
>
> For example:
>
> Each person is asked if they use BrandA and then a second question
> do they use BrandB
>
> 1 yes and 0 no
>
> Id BrandA BrandB
> 1 1 0
> 2 1 1
> 3 1 0
> 4 0 0
> 5 1 1
> 6 0 1
> 7 0 1
> 8 1 1
> 9 1 0
> 10 1 1
>
> I wish to determine if the proportion of BrandA is significantly
> different from BrandB (taking into account overlapping).
>
> I'm eager to know if there is any Stata program that does this or
> if there is a reference to this procedure.
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/