Download presentation
Presentation is loading. Please wait.
1
Discussion Week 1 (4/1/13 – 4/5/13)
Biostat 513 Discussion Week 1 (4/1/13 – 4/5/13)
2
Aims Review key Stata commands OR RR RD Data manipulation
Categorical data OR RR RD Data manipulation
3
Stata tab, tabi – basic tabling
cs, csi – analysis of prospective/cross-sectional studies, single binary covariate cc, cci – analysis of case-control studies, single binary covariate mcc, mcci – analysis of matched data epitab – “help epitab” provides summary of most relevant commands expand – expand summary dataset reshape – convert between long and wide formats
4
UGDP The ugdp.dta dataset describes the results from a drug trial among diabetics. The exposure (exposed) is tolbutamide, and the outcome (case) is death within a fixed time period. The dataset is provided in tabular form with pop indicating the number of subjects in each cell.
5
use http://courses. washington. edu/b513/datasets/ugdp. dta
. use . list | age case exposed pop | | | 1. | < | 2. | < | 3. | < | 4. | < | 5. | | 6. | | 7. | | 8. | |
6
use http://courses. washington. edu/b513/datasets/ugdp. dta
. use . list | age case exposed pop | | | 1. | < | 2. | < | 3. | < | 4. | < | 5. | | 6. | | 7. | | 8. | | . tab case exposed | exposed case | 0 1 | Total | 2 2 | 4 1 | 2 2 | 4 Total | 4 4 | 8
7
use http://courses. washington. edu/b513/datasets/ugdp. dta
. use . list | age case exposed pop | | | 1. | < | 2. | < | 3. | < | 4. | < | 5. | | 6. | | 7. | | 8. | | . tab case exposed | exposed case | 0 1 | Total | 2 2 | 4 1 | 2 2 | 4 Total | 4 4 | 8
8
use http://courses. washington. edu/b513/datasets/ugdp. dta
. use . list | age case exposed pop | | | 1. | < | 2. | < | 3. | < | 4. | < | 5. | | 6. | | 7. | | 8. | | . tab case exposed [freq=pop] | exposed case | 0 1 | Total | | | | 51 Total | | 409
9
Common options for tab: by, chi2, exact, row, col, missing
. expand pop (401 observations created) . tab case exposed | exposed case | | Total 0 | | 1 | | Total | | . tabi \ | col row | | Total 1 | | 2 | | Total | | Fisher's exact = 1-sided Fisher's exact = Common options for tab: by, chi2, exact, row, col, missing
10
. bysort age: tab case exposed > age = <55 | exposed case | 0 1 | Total | | | 5 8 | 13 Total | | 226 -> age = | | | | 38 Total | | 183
11
Why choose column percents?
. tab case exposed, chi2 exact col | Key | | | | frequency | | column percentage | | exposed case | | Total 0 | | | | 1 | | | | Total | | | | Pearson chi2(1) = Pr = 0.172 Fisher's exact = 1-sided Fisher's exact = Why choose column percents? Which Fisher’s test corresponds to the chi-squared test?
12
Why choose column percents? P(died | exp)
. tab case exposed, chi2 exact col | Key | | | | frequency | | column percentage | | exposed case | | Total 0 | | | | 1 | | | | Total | | | | Pearson chi2(1) = Pr = 0.172 Fisher's exact = 1-sided Fisher's exact = Why choose column percents? P(died | exp) Which Fisher’s test corresponds to the chi-squared test?
13
Better to use cs or cc for these data? why?
Okay or not to use the other? why?
14
Better to use cs or cc for these data? why?
prospective study Okay or not to use the other? why?
15
Better to use cs or cc for these data? why?
prospective study Okay or not to use the other? why? OR is fine to report
16
Better to use cs or cc for these data? why?
Okay or not to use the other? why? . cs case exposed, or | exposed | | Exposed Unexposed | Total Cases | | Noncases | | Total | | | | Risk | | | Point estimate | [95% Conf. Interval] | Risk difference | | Risk ratio | | Attr. frac. ex. | | Attr. frac. pop | | Odds ratio | | (Cornfield) chi2(1) = Pr>chi2 = Note “exposed, case” in upper left. Interpret OR and RR.
17
Predict the RD, RR and OR for each of these
csi <exposed cases> <unexposed cases> <exposed controls> <unexposed controls> . csi , or | Exposed Unexposed | Total Cases | | Noncases | | Total | | | | Risk | | | Point estimate | [95% Conf. Interval] | Risk difference | | Risk ratio | | Attr. frac. ex. | | Attr. frac. pop | | Odds ratio | | (Cornfield) chi2(1) = Pr>chi2 = Predict the RD, RR and OR for each of these . csi /* switch exposed and unexposed */ . csi /* switch death and no death */ . csi /* switch both */
18
Predict the RD, RR and OR for each of these RD RR OR
csi <exposed cases> <unexposed cases> <exposed controls> <unexposed controls> . csi , or | Exposed Unexposed | Total Cases | | Noncases | | Total | | | | Risk | | | Point estimate | [95% Conf. Interval] | Risk difference | | Risk ratio | | Attr. frac. ex. | | Attr. frac. pop | | Odds ratio | | (Cornfield) chi2(1) = Pr>chi2 = Predict the RD, RR and OR for each of these RD RR OR . csi /* switch exposed and unexposed */ /1.44 1/1.5 . csi /* switch death and no death */ . csi /* switch both */
19
Predict the RD, RR and OR for each of these RD RR OR
csi <exposed cases> <unexposed cases> <exposed controls> <unexposed controls> . csi , or | Exposed Unexposed | Total Cases | | Noncases | | Total | | | | Risk | | | Point estimate | [95% Conf. Interval] | Risk difference | | Risk ratio | | Attr. frac. ex. | | Attr. frac. pop | | Odds ratio | | (Cornfield) chi2(1) = Pr>chi2 = Predict the RD, RR and OR for each of these RD RR OR . csi /* switch exposed and unexposed */ /1.44 1/1.5 . csi /* switch death and no death */ ??? 1/1.5 . csi /* switch both */
20
Predict the RD, RR and OR for each of these RD RR OR
csi <exposed cases> <unexposed cases> <exposed controls> <unexposed controls> . csi , or | Exposed Unexposed | Total Cases | | Noncases | | Total | | | | Risk | | | Point estimate | [95% Conf. Interval] | Risk difference | | Risk ratio | | Attr. frac. ex. | | Attr. frac. pop | | Odds ratio | | (Cornfield) chi2(1) = Pr>chi2 = Predict the RD, RR and OR for each of these RD RR OR . csi /* switch exposed and unexposed */ /1.44 1/1.5 . csi /* switch death and no death */ ??? 1/1.5 . csi /* switch both */ ???
21
Which of these statements is correct?
| Exposed Unexposed | Total Alive | | Died | | Total | | | | Risk | | | Point estimate | [95% Conf. Interval] | Risk difference | | Risk ratio | | Prev. frac. ex. | | Prev. frac. pop | | Odds ratio | | (Cornfield) chi2(1) = Pr>chi2 = Which of these statements is correct? The odds of death among those exposed to tolbutamide is (1/.662) times the odds of death among those not exposed to tolbutamide The risk of death among those exposed to tolbutamide is (1/.950) times the risk of death among those not exposed to tolbutamide The risk of death among those exposed to tolbutamide is ~1.51 (1/.662) times the risk of death among those not exposed to tolbutamide
22
Which of these statements is correct?
| Exposed Unexposed | Total Alive | | Died | | Total | | | | Risk | | | Point estimate | [95% Conf. Interval] | Risk difference | | Risk ratio | | Prev. frac. ex. | | Prev. frac. pop | | Odds ratio | | (Cornfield) chi2(1) = Pr>chi2 = Which of these statements is correct? The odds of death among those exposed to tolbutamide is (1/.662) times the odds of death among those not exposed to tolbutamide The risk of death among those exposed to tolbutamide is (1/.950) times the risk of death among those not exposed to tolbutamide The risk of death among those exposed to tolbutamide is ~1.51 (1/.662) times the risk of death among those not exposed to tolbutamide
23
Which of these statements is correct?
| Exposed Unexposed | Total Alive | | Died | | Total | | | | Risk | | | Point estimate | [95% Conf. Interval] | Risk difference | | Risk ratio | | Prev. frac. ex. | | Prev. frac. pop | | Odds ratio | | (Cornfield) chi2(1) = Pr>chi2 = Which of these statements is correct? The odds of death among those exposed to tolbutamide is (1/.662) times the odds of death among those not exposed to tolbutamide The risk of death among those exposed to tolbutamide is (1/.950) times the risk of death among those not exposed to tolbutamide The risk of death among those exposed to tolbutamide is ~1.51 (1/.662) times the risk of death among those not exposed to tolbutamide
24
Which of these statements is correct?
| Exposed Unexposed | Total Alive | | Died | | Total | | | | Risk | | | Point estimate | [95% Conf. Interval] | Risk difference | | Risk ratio | | Prev. frac. ex. | | Prev. frac. pop | | Odds ratio | | (Cornfield) chi2(1) = Pr>chi2 = Which of these statements is correct? The odds of death among those exposed to tolbutamide is (1/.662) times the odds of death among those not exposed to tolbutamide The risk of death among those exposed to tolbutamide is (1/.950) times the risk of death among those not exposed to tolbutamide The risk of death among those exposed to tolbutamide is ~1.51 (1/.662) times the risk of death among those not exposed to tolbutamide
25
HIVNET VPS 750 individuals participating in an HIV vaccine preparedness study were administered a questionnaire at enrollment and after 6 months. Between the two questionnaires, all subjects participated in an educational program about HIV and vaccines. We focus on a single question, asking about the safety of an HIV vaccine (coded 1=correct answer, 0=incorrect).
26
What’s wrong with this analysis?
. use . tab q4safe0 q4safe0 | Freq. Percent Cum. 0 | 1 | Total | . tab q4safe6 q4safe6 | Freq. Percent Cum. 0 | 1 | . cci Proportion | month month 0 | Total Exposed correct | | incorrect | | Total | | | | | Point estimate | [95% Conf. Interval] | Odds ratio | | (exact) Attr. frac. ex. | | (exact) Attr. frac. pop | | chi2(1) = Pr>chi2 = What’s wrong with this analysis?
27
What’s wrong with this analysis? Paired data! (McNemar)
. use . tab q4safe0 q4safe0 | Freq. Percent Cum. 0 | 1 | Total | . tab q4safe6 q4safe6 | Freq. Percent Cum. 0 | 1 | . cci Proportion | month month 0 | Total Exposed correct | | incorrect | | Total | | | | | Point estimate | [95% Conf. Interval] | Odds ratio | | (exact) Attr. frac. ex. | | (exact) Attr. frac. pop | | chi2(1) = Pr>chi2 = What’s wrong with this analysis? Paired data! (McNemar)
28
Interpret the OR . tab q4safe6 q4safe0 | q4safe0 q4safe6 | 0 1 | Total
0 | | 1 | | Total | | . mcci | month | month | correct incorrect | Total correct | | incorrect | | Total | | McNemar's chi2(1) = Prob > chi2 = Exact McNemar significance probability = Proportion with factor Cases Controls [95% Conf. Interval] difference ratio rel. diff odds ratio (exact) Interpret the OR
29
Interpret the OR . tab q4safe6 q4safe0 | q4safe0 q4safe6 | 0 1 | Total
0 | | Discordant pairs 1 | | Total | | . mcci | month | month | correct incorrect | Total correct | | incorrect | | Total | | McNemar's chi2(1) = Prob > chi2 = Exact McNemar significance probability = Proportion with factor Cases Controls [95% Conf. Interval] difference ratio rel. diff odds ratio (exact) Interpret the OR
30
RESHAPE Wide form . input id cd1 cd2 cd3 cd4 cd5 cd6
4. end . list | id cd1 cd2 cd3 cd4 cd5 cd6 | | | 1. | | 2. | | 3. | | Wide form
31
reshape keyword stem, i(unit id) j(newvar)
. reshape long cd, i(id) j(visit) reshape keyword stem, i(unit id) j(newvar) . list | id visit cd | | | 1. | | 2. | | 3. | | 4. | | 5. | | 6. | | 7. | | 8. | | 9. | | 10. | | 11. | | 12. | | 13. | | 14. | | 15. | | 16. | | 17. | | 18. | | Long form
32
reshape keyword stem, i(unit id) j(dropvar)
. reshape wide cd, i(id) j(visit) reshape keyword stem, i(unit id) j(dropvar) New variable is stem+dropvar (cd+visit) . list | id cd1 cd2 cd3 cd4 cd5 cd6 | | | 1. | | 2. | | 3. | | Wide form
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.