Hi folks, I'm looking to create successive Mantel–Haenszel estimate of rate ratios across various categories in a variable, each time comparing to the previous value.
i.e.
stmh agecat, c(1,0)
stmh agecat, c(2,1)
etc.
I thought of doing this via a forvalues loop as such:
forvalues x = 1/6 {
stmh agecat, c(`x',`x'-1)
}
However as you can see in bold, for some reason the subtraction isn't being evaluated, and it's being concatenated as though a string and failing.
Mantel–Haenszel estimate of the rate ratio
comparing agecat==1 vs. agecat==1-1
unknown el 1-1 in rule
r(198);
Out of interest, I tried to display `x'-1, but the math works there but the rest doesn't.
forvalues x = 1/6 {
display `x'-1
stmh agecat, c(`x',`x'-1)
}
0
Mantel–Haenszel estimate of the rate ratio
comparing agecat==1 vs. agecat==1-1
unknown el 1-1 in rule
r(198);
Any hints? Thanks!
i.e.
stmh agecat, c(1,0)
stmh agecat, c(2,1)
etc.
I thought of doing this via a forvalues loop as such:
forvalues x = 1/6 {
stmh agecat, c(`x',`x'-1)
}
However as you can see in bold, for some reason the subtraction isn't being evaluated, and it's being concatenated as though a string and failing.
Mantel–Haenszel estimate of the rate ratio
comparing agecat==1 vs. agecat==1-1
unknown el 1-1 in rule
r(198);
Out of interest, I tried to display `x'-1, but the math works there but the rest doesn't.
forvalues x = 1/6 {
display `x'-1
stmh agecat, c(`x',`x'-1)
}
0
Mantel–Haenszel estimate of the rate ratio
comparing agecat==1 vs. agecat==1-1
unknown el 1-1 in rule
r(198);
Any hints? Thanks!
Comment