I am analysing the results of a trial & would like to compare the proportion of individuals successfully treated between arms, adjusting for baseline differences (gender & age category). An example of my data is below.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(group outcome gender age agecat) byte t 0 0 0 21 1 1 0 0 0 26 1 1 0 0 1 27 1 1 0 1 0 18 0 1 0 1 1 21 1 1 1 0 1 20 0 1 1 1 0 18 0 1 1 1 0 30 1 1 1 1 1 23 1 1 1 1 1 24 1 1 end label var outcome "=1 if success" label var gender "=1 if female" label var agecat "=1 if age >=21"
I used the cs command to obtain the risk ratio applying the M-H weight using the following code, but have struggled to get the M-H adjusted risk difference.
Code:
cs outcome group, by(gender agecat)
The code I used to generate M-H weights & run the cs risk difference command is as follows:
Code:
gen mhwgt=. forvalues i=0/1 { forvalues x=0/1 { tab outcome group if agecat==`i' & gender==`x', matcell(A) replace mhwgt = (A[2,1] * (A[1,2]+A[2,2])) / ( A[1,1]+A[1,2]+A[2,1]+A[2,2]) if agecat==`i' & gender==`x' } } cs outcome group, by(agecat gender) rd standard(mhwgt)
Alternatively, I have considered using a different methodology, such as glm to fit a risk-difference model as in this post.
Code:
glm outcome group agecat gender, family(binomial) link(identity)
Code:
logit outcome i.group agecat gender margins group, pwcompare
Best wishes,
Bryony
0 Response to Difference in proportion adjusted for baseline characteristics (Mantel Haenszel method)
Post a Comment