


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An example of statistical analysis using the stata software to evaluate the relationship between pain at time of entry (paine) and age group (agegrp) by computing mean pain level for each age group, separately for males and females, using the ankle_full.dta dataset. It also demonstrates plotting the mean pain level against age group with two curves, one for males and one for females.
Typology: Lab Reports
1 / 4
This page cannot be seen from the preview
Don't miss anything!



. table PAINE
Pain | scale at | time on | entry | Freq. ----------+----------- 0 | 32 1 | 47 2 | 68 3 | 72 4 | 92 5 | 106 6 | 78 7 | 67 8 | 48 9 | 32 10 | 18
gen agegrp=. replace agegrp=1 if AGE < 19 replace agegrp=2 if AGE >= 19 & AGE < 24 replace agegrp=3 if AGE >= 24 & AGE < 37 replace agegrp=4 if AGE >= 37 & AGE < 55 replace agegrp=5 if AGE >= 55 & AGE < 86 replace agegrp=6 if AGE >= 86 & AGE <= 90
label define age 1 "13-18" 2 "19-23" 3 "24-36" 4 "37-54" 5 "55-85" 6 "86-90" label values agegrp age
. table agegrp
agegrp | Freq. ----------+----------- 13-18 | 148 19-23 | 176 24-36 | 174 37-54 | 99 55-85 | 65 86-90 | 3
. table SEX
SEX | Freq. ----------+----------- Male | 379 Female | 286
. tabstat PAINE, stat(mean) by(agegrp) notot
Summary for variables: PAINE by categories of: agegrp
agegrp | mean -------+---------- 13-18 | 4. 19-23 | 4. 24-36 | 4. 37-54 | 5. 55-85 | 3. 86-90 | 5.
. tabstat PAINE if SEX==1, stat(mean) by(agegrp) notot
Summary for variables: PAINE by categories of: agegrp
agegrp | mean -------+---------- 13-18 | 4. 19-23 | 4. 24-36 | 4. 37-54 | 5. 55-85 | 3.
. tabstat PAINE if SEX==2, stat(mean) by(agegrp) notot
Summary for variables: PAINE by categories of: agegrp
agegrp | mean -------+---------- 13-18 | 5. 19-23 | 5. 24-36 | 4. 37-54 | 5. 55-85 | 3. 86-90 | 5.
. gen meanpaine = (agegrp==1)4.38 + (agegrp==2)4.59 + (agegrp==3)4.65 + (agegrp==4)5.11 + (agegrp==5)*3.17 if SEX==
. replace meanpaine = (agegrp==1)5.37 + (agegrp==2)5.36 + (agegrp==3)4.17 + (agegrp==4)5.15 + (agegrp==5)3.9 + (agegrp==6)5.67 if SEX==
. tabstat PAINE if SEX==2, stat(mean) by(agegrp) notot save . matrix matrix2 = (r(Stat1)\r(Stat2)\r(Stat3)\r(Stat4)\r(Stat5)\ r(Stat6) ) . svmat matrix . tabstat PAINE if SEX==1, stat(mean) by(agegrp) notot save . matrix matrix1 = (r(Stat1)\r(Stat2)\r(Stat3)\r(Stat4)\r(Stat5)*.* ) . svmat matrix
rd
matrix matrix3=(..\r(Stat1)\r(Stat2)\r(Stat3)\r(Stat4)\r(Stat5)
r(Stat6)\r(Stat7)\r(Stat8))
. gen plotage = _n if _n <= 6
. label values plotage age
. twoway (connected matrix11 plotage) (connected matrix21 plotage), ytitle(Mean pain level) xtitle(Age group) xlabel(1(1)6, labels valuelabel) legend(order(1 "Males" 2 "Females"))
3
4
5
6
Mean pain level
1 2 3 4 5 6 Age group Males Females