Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Could you please help with coding "mixed-effects model"?

    I'd like to ask for advice on coding the "mixed-effects model" to see the percent change in health between year1 and year2. In the dataex, I have info on person, home, intervention (ventilation type), demographics, health outcomes and NO2 concentrations in both year 1 and year 2.
    Specifically, I'd like to know:
    1) percent change in health as a function of intervention (all ventilation types)
    2) percent change in health as a function of each of the three intervention types
    3) percent change in health per NO2 decrease

    Lastly, as I also want to make models adjusted for sex, age, and edu (education level), how can I determine if those factors were potential confounding variables?
    Any comments or suggestions are much appreciated!


    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int personID str4 Home byte Homeid str8 Ventilation byte vent double(year1_health year2_health) str6 sex str25 race str38 edu double(year1_no2 year2_no2)
    112 "H111"  1 "Exhaust"  1 16.294117647058822 15.117647058823529 "Female" "Hispanic or Latino"        "Completed graduate degree "             58.292660375545566  59.15929968049114
    143 "H138"  2 "Balanced" 3 21.384615384615383 20.428571428571427 "Female" "White"                     ""                                        62.76490172807987 63.038986394450205
    145 "H138"  2 "Balanced" 3 13.923076923076923               17.4 "Male"   "White"                     "Completed college undergraduate degree"  62.76490172807987 63.038986394450205
    170 "H167"  3 "CFIS"     2 22.466666666666665              23.25 "Female" "White"                     "Completed graduate degree "              56.33193661785609  63.27032227341164
    171 "H168"  4 "CFIS"     2 20.857142857142858 21.555555555555557 "Female" "White"                     "Completed college undergraduate degree"   66.1585704109377  57.13051973184713
    174 "H172"  5 "CFIS"     2 23.307692307692307  24.11764705882353 "Female" "White"                     "Completed some college no degree"        57.68708598542611 57.236005188120224
    180 "H177"  6 "Exhaust"  1                 21  22.23076923076923 "Female" "White"                     "Completed graduate degree "             61.899636465072604  60.68360524908931
    183 "H179"  7 "Balanced" 3                 19 19.529411764705884 "Female" "White"                     "Completed college undergraduate degree"  60.53874811766886  63.55254164483663
    185 "H181"  8 "Exhaust"  1 14.666666666666666                 19 "Female" "Black or African American" ""                                        63.30054657137316 59.039874414657966
    186 "H182"  9 "CFIS"     2 11.153846153846153 17.333333333333332 "Female" "Black or African American" "Completed college undergraduate degree"  61.58640446216849  51.43792454544989
    187 "H182"  9 "CFIS"     2 14.666666666666666 22.952380952380953 "Female" "Black or African American" ""                                        61.58640446216849  51.43792454544989
    194 "H187" 10 "Balanced" 3               21.5 21.210526315789473 "Female" "Black or African American" "Completed graduate degree "             51.518544973948785 54.768295587682665
    201 "H193" 11 "CFIS"     2 20.692307692307693 22.058823529411765 "Male"   "Hispanic or Latino"        "Completed graduate degree "             50.357783289201876  70.68138079860094
    204 "H196" 12 "CFIS"     2 23.642857142857142 24.705882352941178 "Male"   "Hispanic or Latino"        "Completed some college no degree"       58.260161671038105  62.27559967087857
    205 "H197" 13 "Balanced" 3              15.75               20.5 "Female" "Black or African American" "Completed some college no degree"       62.838209840768165   53.1536962580685
    216 "H207" 14 "Exhaust"  1               23.5 24.444444444444443 "Female" "White"                     "Completed college undergraduate degree"  54.84059779036874  57.47775108340378
    252 "H207" 14 "Exhaust"  1                 23 24.666666666666668 "Male"   "White"                     ""                                        54.84059779036874  57.47775108340378
    217 "H208" 15 "Balanced" 3 23.666666666666668  24.46153846153846 "Female" "Black or African American" "Completed college undergraduate degree"  62.02773449694277  53.51241752751034
    222 "H213" 16 "CFIS"     2 19.470588235294116 19.307692307692307 "Female" "Hispanic or Latino"        "Completed some college no degree"        58.59340280008861   55.9058420869943
    223 "H214" 17 "Balanced" 3 14.266666666666668 16.666666666666668 "Female" "White"                     "Completed graduate degree "              56.51526616909314  59.47893759021493
    228 "H217" 18 "Exhaust"  1               18.8 20.555555555555557 "Female" "White"                     "Completed graduate degree "              71.91513763347969   63.7320198003429
    229 "H218" 19 "Exhaust"  1 22.466666666666665 19.833333333333332 "Female" "White"                     "Completed graduate degree "              59.04828438480723 57.676655048614386
    230 "H218" 19 "Exhaust"  1 19.933333333333334  21.61111111111111 "Male"   "White"                     ""                                        59.04828438480723 57.676655048614386
    232 "H220" 20 "CFIS"     2  23.31578947368421                 24 "Female" "Hispanic or Latino"        "Completed graduate degree "              72.34145468609995  68.82807516238483
    233 "H220" 20 "CFIS"     2  16.36842105263158 14.846153846153847 "Female" "Hispanic or Latino"        ""                                        72.34145468609995  68.82807516238483
    234 "H220" 20 "CFIS"     2  18.88888888888889  20.76923076923077 "Male"   "Hispanic or Latino"        "Completed graduate degree "              72.34145468609995  68.82807516238483
    235 "H220" 20 "CFIS"     2  17.05263157894737              15.75 "Female" "Hispanic or Latino"        ""                                        72.34145468609995  68.82807516238483
    end

  • #2
    Originally posted by Insung Kang View Post
    I'd like to ask for advice on coding the "mixed-effects model" to see the percent change in health between year1 and year2. . . .
    Specifically, I'd like to know:
    1) percent change in health as a function of intervention (all ventilation types)
    2) percent change in health as a function of each of the three intervention types
    3) percent change in health per NO2 decrease
    You wouldn't need to fit any regression model to attain any of these three objectives.

    For the first two, you could compute change between year1_health and year2_health health (outcome?) variables as a percentage of the initial value and then summarize overall (first objective) or by type of home ventilation (second objective). The Stata commands for these are straightforward and are shown below. Begin at the "Begin here" comment; the lines above it are data management (encoding categorical variables, shortening the variable names and so on).

    For your third objective, you could likewise do a simple calculation (difference between year1_no2 and year2_no2 variables) for change in nitrogen dioxide level and then summarize the ratio. Nevertheless, I've shown one way how to fit a model with Stata's xtmixed (the sections in the output below are demarcated by a copy-and-paste of each of your three objectives in a comment). There are a few households that share the same decrease in nitrogen dioxide levels (see confirmation in output below), but your dataset is too small to obtain reliable estimates of parameters related to such nesting of household member within household in a regression model.

    But for this third objective you might want to think a little more about things: see the scatterplot of percent change in health score and decrease in NO2.

    Lastly, as I also want to make models adjusted for sex, age, and edu (education level), how can I determine if those factors were potential confounding variables?
    I've shown one approach to this objective below using mixed. (You don't show age, but the approach for it would be analogous.)

    Keep in mind, though, that if your dataex listing is exhaustive, then your dataset is just too small in order to accomplish such an ambitious objective. You can see that if you execute the code for the analogous ANOVA mixed models that I've commented out at the end: it's such a small dataset that for factors like sex, educational level and intervention (ventilation type) that you end up with zero degrees of freedom (confounding) for two of the three error mean squares when you include all three factors in the ANOVA model.

    .ÿ
    .ÿversionÿ17.0

    .ÿ
    .ÿclearÿ*

    .ÿ
    .ÿquietlyÿinputÿintÿpersonIDÿstr4ÿHomeÿbyteÿHomeidÿstr8ÿVentilationÿ///
    >ÿÿÿÿÿÿÿÿÿbyteÿventÿdouble(year1_healthÿyear2_health)ÿstr6ÿsexÿstr25ÿraceÿ///
    >ÿÿÿÿÿÿÿÿÿstr38ÿeduÿdouble(year1_no2ÿyear2_no2)

    .ÿ
    .ÿduplicatesÿtagÿHome,ÿgenerate(dups)

    DuplicatesÿinÿtermsÿofÿHome

    .ÿlistÿpersonIDÿHomeidÿHomeÿifÿdups,ÿnoobsÿsepby(Homeid)ÿabbreviate(20)

    ÿÿ+--------------------------+
    ÿÿ|ÿpersonIDÿÿÿHomeidÿÿÿHomeÿ|
    ÿÿ|--------------------------|
    ÿÿ|ÿÿÿÿÿÿ143ÿÿÿÿÿÿÿÿ2ÿÿÿH138ÿ|
    ÿÿ|ÿÿÿÿÿÿ145ÿÿÿÿÿÿÿÿ2ÿÿÿH138ÿ|
    ÿÿ|--------------------------|
    ÿÿ|ÿÿÿÿÿÿ186ÿÿÿÿÿÿÿÿ9ÿÿÿH182ÿ|
    ÿÿ|ÿÿÿÿÿÿ187ÿÿÿÿÿÿÿÿ9ÿÿÿH182ÿ|
    ÿÿ|--------------------------|
    ÿÿ|ÿÿÿÿÿÿ216ÿÿÿÿÿÿÿ14ÿÿÿH207ÿ|
    ÿÿ|ÿÿÿÿÿÿ252ÿÿÿÿÿÿÿ14ÿÿÿH207ÿ|
    ÿÿ|--------------------------|
    ÿÿ|ÿÿÿÿÿÿ229ÿÿÿÿÿÿÿ19ÿÿÿH218ÿ|
    ÿÿ|ÿÿÿÿÿÿ230ÿÿÿÿÿÿÿ19ÿÿÿH218ÿ|
    ÿÿ|--------------------------|
    ÿÿ|ÿÿÿÿÿÿ232ÿÿÿÿÿÿÿ20ÿÿÿH220ÿ|
    ÿÿ|ÿÿÿÿÿÿ233ÿÿÿÿÿÿÿ20ÿÿÿH220ÿ|
    ÿÿ|ÿÿÿÿÿÿ234ÿÿÿÿÿÿÿ20ÿÿÿH220ÿ|
    ÿÿ|ÿÿÿÿÿÿ235ÿÿÿÿÿÿÿ20ÿÿÿH220ÿ|
    ÿÿ+--------------------------+

    .ÿsortÿHomeÿpersonID

    .ÿforeachÿvarÿofÿvarlistÿ*_no2ÿ{
    ÿÿ2.ÿÿÿÿÿÿÿÿÿbyÿHome:ÿassertÿ`var'ÿ==ÿ`var'[1]
    ÿÿ3.ÿ}

    .ÿ
    .ÿrenameÿyear#_healthÿsco#

    .ÿrenameÿyear#_no2ÿnox#

    .ÿ
    .ÿrenameÿpersonIDÿpid

    .ÿ
    .ÿencodeÿHome,ÿgenerate(hid)ÿlabel(Homes)

    .ÿ
    .ÿlabelÿdefineÿVentilationsÿ1ÿExhaustÿ2ÿCFISÿ3ÿBalanced

    .ÿencodeÿVentilation,ÿgenerate(vtp)ÿlabel(Ventilations)ÿnoextend

    .ÿ
    .ÿlabelÿdefineÿSexesÿ0ÿMÿ1ÿF

    .ÿquietlyÿreplaceÿsexÿ=ÿsubstr(sex,ÿ1,ÿ1)

    .ÿencodeÿsex,ÿgenerate(Sex)ÿlabel(Sexes)ÿnoextend

    .ÿ
    .ÿforeachÿstringÿinÿ"some"ÿ"undergraduate"ÿ"graduate"ÿ{
    ÿÿ2.ÿÿÿÿÿÿÿÿÿquietlyÿreplaceÿeduÿ=ÿ"`string'"ÿifÿstrpos(edu,ÿ"`string'")
    ÿÿ3.ÿ}

    .ÿquietlyÿreplaceÿeduÿ=ÿ"Unknown"ÿifÿmi(edu)

    .ÿquietlyÿreplaceÿeduÿ=ÿstrproper(edu)

    .ÿlabelÿdefineÿEducationÿ0ÿUnknownÿ1ÿSomeÿ2ÿUndergraduateÿ3ÿGraduate

    .ÿencodeÿedu,ÿgenerate(Edu)ÿlabel(Education)ÿnoextend

    .ÿ
    .ÿdropÿdupsÿraceÿHomeidÿHomeÿVentilationÿventÿsexÿedu

    .ÿrenameÿ*,ÿlower

    .ÿ
    .ÿ*
    .ÿ*ÿBeginÿhere
    .ÿ*
    .ÿ/*ÿ1)ÿpercentÿchangeÿinÿhealthÿasÿaÿfunctionÿofÿinterventionÿ(allÿventilationÿtypes)ÿ*/
    .ÿgenerateÿdoubleÿdscÿ=ÿ100ÿ*ÿ(sco2ÿ-ÿsco1)ÿ/ÿsco1

    .ÿlabelÿvariableÿdscÿ"PercentÿChangeÿinÿHealthÿScore"

    .ÿformatÿdscÿ%2.0f

    .ÿsummarizeÿdsc,ÿformat

    ÿÿÿÿVariableÿ|ÿÿÿÿÿÿÿÿObsÿÿÿÿÿÿÿÿMeanÿÿÿÿStd.ÿdev.ÿÿÿÿÿÿÿMinÿÿÿÿÿÿÿÿMax
    -------------+---------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿdscÿ|ÿÿÿÿÿÿÿÿÿ27ÿÿÿÿÿÿÿÿÿÿÿ9ÿÿÿÿÿÿÿÿÿÿ17ÿÿÿÿÿÿÿÿ-12ÿÿÿÿÿÿÿÿÿ56

    .ÿ
    .ÿ/*ÿ2)ÿpercentÿchangeÿinÿhealthÿasÿaÿfunctionÿofÿeachÿofÿtheÿthreeÿinterventionÿtypesÿ*/
    .ÿversionÿ16.1:ÿtableÿvtp,ÿcontents(meanÿdscÿsdÿdscÿminÿdscÿmaxÿdscÿnÿdsc)ÿformat(%2.0f)

    ----------------------------------------------------------------------
    ÿÿÿÿÿÿvtpÿ|ÿÿmean(dsc)ÿÿÿÿÿsd(dsc)ÿÿÿÿmin(dsc)ÿÿÿÿmax(dsc)ÿÿÿÿÿÿN(dsc)
    ----------+-----------------------------------------------------------
    ÿÿExhaustÿ|ÿÿÿÿÿÿÿÿÿÿ6ÿÿÿÿÿÿÿÿÿÿ12ÿÿÿÿÿÿÿÿÿ-12ÿÿÿÿÿÿÿÿÿÿ30ÿÿÿÿÿÿÿÿÿÿÿ8
    ÿÿÿÿÿCFISÿ|ÿÿÿÿÿÿÿÿÿ11ÿÿÿÿÿÿÿÿÿÿ22ÿÿÿÿÿÿÿÿÿÿ-9ÿÿÿÿÿÿÿÿÿÿ56ÿÿÿÿÿÿÿÿÿÿ12
    ÿBalancedÿ|ÿÿÿÿÿÿÿÿÿ10ÿÿÿÿÿÿÿÿÿÿ14ÿÿÿÿÿÿÿÿÿÿ-4ÿÿÿÿÿÿÿÿÿÿ30ÿÿÿÿÿÿÿÿÿÿÿ7
    ----------------------------------------------------------------------

    .ÿ
    .ÿ/*ÿ3)ÿpercentÿchangeÿinÿhealthÿperÿNO2ÿdecreaseÿ*/
    .ÿgenerateÿdoubleÿnnoÿ=ÿnox1ÿ-ÿnox2

    .ÿlabelÿvariableÿnnoÿ"NO{subscript:ÿ2}ÿDecrease"

    .ÿ
    .ÿgraphÿtwowayÿ///
    >ÿÿÿÿÿÿÿÿÿlfitÿdscÿnno,ÿlcolor(black)ÿ||ÿ///
    >ÿÿÿÿÿÿÿÿÿscatterÿdscÿnno,ÿmsize(small)ÿmcolor(black)ÿ///
    >ÿÿÿÿÿÿÿÿÿytitle("`:ÿvariableÿlabelÿdsc'")ÿ///
    >ÿÿÿÿÿÿÿÿÿylabel(ÿ,ÿangle(horizontal)ÿnogrid)ÿlegend(off)

    .ÿquietlyÿgraphÿexportÿLinearFit.png,ÿreplace

    .ÿ
    .ÿquietlyÿreshapeÿlongÿscoÿnox,ÿi(pid)ÿj(tim)

    .ÿxtregÿscoÿc.noxÿi.tim,ÿi(pid)ÿfe

    Fixed-effectsÿ(within)ÿregressionÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿÿÿÿ54
    Groupÿvariable:ÿpidÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿgroupsÿÿ=ÿÿÿÿÿÿÿÿÿ27

    R-squared:ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿObsÿperÿgroup:
    ÿÿÿÿÿWithinÿÿ=ÿ0.3469ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿminÿ=ÿÿÿÿÿÿÿÿÿÿ2
    ÿÿÿÿÿBetweenÿ=ÿ0.0361ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿavgÿ=ÿÿÿÿÿÿÿÿ2.0
    ÿÿÿÿÿOverallÿ=ÿ0.0879ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿmaxÿ=ÿÿÿÿÿÿÿÿÿÿ2

    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿF(2,25)ÿÿÿÿÿÿÿÿÿÿÿ=ÿÿÿÿÿÿÿ6.64
    corr(u_i,ÿXb)ÿ=ÿ-0.0113ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿFÿÿÿÿÿÿÿÿÿÿ=ÿÿÿÿÿ0.0049

    ------------------------------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿscoÿ|ÿCoefficientÿÿStd.ÿerr.ÿÿÿÿÿÿtÿÿÿÿP>|t|ÿÿÿÿÿ[95%ÿconf.ÿinterval]
    -------------+----------------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿnoxÿ|ÿÿ-.1290923ÿÿÿ.0696168ÿÿÿÿ-1.85ÿÿÿ0.076ÿÿÿÿ-.2724707ÿÿÿÿ.0142862
    ÿÿÿÿÿÿÿ2.timÿ|ÿÿÿ1.218074ÿÿÿ.4486748ÿÿÿÿÿ2.71ÿÿÿ0.012ÿÿÿÿÿ.2940112ÿÿÿÿ2.142137
    ÿÿÿÿÿÿÿ_consÿ|ÿÿÿ27.24434ÿÿÿ4.296791ÿÿÿÿÿ6.34ÿÿÿ0.000ÿÿÿÿÿ18.39493ÿÿÿÿ36.09375
    -------------+----------------------------------------------------------------
    ÿÿÿÿÿsigma_uÿ|ÿÿ3.0417113
    ÿÿÿÿÿsigma_eÿ|ÿÿ1.6169017
    ÿÿÿÿÿÿÿÿÿrhoÿ|ÿÿ.77968248ÿÿÿ(fractionÿofÿvarianceÿdueÿtoÿu_i)
    ------------------------------------------------------------------------------
    Fÿtestÿthatÿallÿu_i=0:ÿF(26,ÿ25)ÿ=ÿ7.08ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿFÿ=ÿ0.0000

    .ÿ
    .ÿ/*ÿmakeÿmodelsÿadjustedÿforÿsex,ÿage,ÿandÿeduÿ(educationÿlevel),ÿ
    >ÿÿÿÿhowÿcanÿIÿdetermineÿifÿthoseÿfactorsÿwereÿpotentialÿconfoundingÿvariablesÿ*/
    .ÿmixedÿscoÿi.(sexÿedu)ÿi.vtp##i.timÿ||ÿpid:ÿ,ÿremlÿdfmethod(kroger)ÿnolrtestÿnolog

    Mixed-effectsÿREMLÿregressionÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿÿÿÿ54
    Groupÿvariable:ÿpidÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿgroupsÿÿ=ÿÿÿÿÿÿÿÿÿ27
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿObsÿperÿgroup:
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿminÿ=ÿÿÿÿÿÿÿÿÿÿ2
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿavgÿ=ÿÿÿÿÿÿÿÿ2.0
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿmaxÿ=ÿÿÿÿÿÿÿÿÿÿ2
    DFÿmethod:ÿKenward–RogerÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿDF:ÿÿÿÿÿÿÿÿÿÿÿminÿ=ÿÿÿÿÿÿ21.00
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿavgÿ=ÿÿÿÿÿÿ23.53
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿmaxÿ=ÿÿÿÿÿÿ26.77
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿF(8,ÿÿÿÿ31.80)ÿÿÿÿ=ÿÿÿÿÿÿÿ1.42
    Logÿrestricted-likelihoodÿ=ÿ-118.80282ÿÿÿÿÿÿÿÿÿÿProbÿ>ÿFÿÿÿÿÿÿÿÿÿÿ=ÿÿÿÿÿ0.2282

    ------------------------------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿscoÿ|ÿCoefficientÿÿStd.ÿerr.ÿÿÿÿÿÿtÿÿÿÿP>|t|ÿÿÿÿÿ[95%ÿconf.ÿinterval]
    -------------+----------------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿsexÿ|
    ÿÿÿÿÿÿÿÿÿÿFÿÿ|ÿÿ-1.197524ÿÿÿ1.509283ÿÿÿÿ-0.79ÿÿÿ0.436ÿÿÿÿ-4.336249ÿÿÿÿ1.941202
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿÿÿÿÿeduÿ|
    ÿÿÿÿÿÿÿSomeÿÿ|ÿÿÿ2.818989ÿÿÿ2.114726ÿÿÿÿÿ1.33ÿÿÿ0.197ÿÿÿÿ-1.578824ÿÿÿÿ7.216803
    ÿÿÿGraduateÿÿ|ÿÿÿ1.384561ÿÿÿ1.489652ÿÿÿÿÿ0.93ÿÿÿ0.363ÿÿÿÿ-1.713341ÿÿÿÿ4.482463
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿÿÿÿÿvtpÿ|
    ÿÿÿÿÿÿÿCFISÿÿ|ÿÿÿ-1.16565ÿÿÿ1.644358ÿÿÿÿ-0.71ÿÿÿ0.485ÿÿÿÿÿ-4.54215ÿÿÿÿ2.210849
    ÿÿÿBalancedÿÿ|ÿÿ-1.856908ÿÿÿ1.835513ÿÿÿÿ-1.01ÿÿÿ0.321ÿÿÿÿ-5.624602ÿÿÿÿ1.910785
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿÿÿ2.timÿ|ÿÿÿ.9748429ÿÿÿ.8744753ÿÿÿÿÿ1.11ÿÿÿ0.276ÿÿÿÿ-.8299855ÿÿÿÿ2.779671
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿvtp#timÿ|
    ÿÿÿÿÿCFIS#2ÿÿ|ÿÿÿ.5887572ÿÿÿ1.128943ÿÿÿÿÿ0.52ÿÿÿ0.607ÿÿÿÿ-1.741266ÿÿÿÿ2.918781
    ÿBalanced#2ÿÿ|ÿÿÿ.5545413ÿÿÿ1.280101ÿÿÿÿÿ0.43ÿÿÿ0.669ÿÿÿÿ-2.087457ÿÿÿÿ3.196539
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿÿÿ_consÿ|ÿÿÿ19.99039ÿÿÿ1.861653ÿÿÿÿ10.74ÿÿÿ0.000ÿÿÿÿÿ16.14339ÿÿÿÿ23.83739
    ------------------------------------------------------------------------------

    ------------------------------------------------------------------------------
    ÿÿRandom-effectsÿparametersÿÿ|ÿÿÿEstimateÿÿÿStd.ÿerr.ÿÿÿÿÿ[95%ÿconf.ÿinterval]
    -----------------------------+------------------------------------------------
    pid:ÿIdentityÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿvar(_cons)ÿ|ÿÿÿ8.884397ÿÿÿ3.243957ÿÿÿÿÿÿ4.343391ÿÿÿÿ18.17301
    -----------------------------+------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿvar(Residual)ÿ|ÿÿÿ3.058828ÿÿÿ.8830075ÿÿÿÿÿÿ1.737139ÿÿÿÿ5.386117
    ------------------------------------------------------------------------------

    .ÿcontrastÿsexÿeduÿvtpÿtimÿvtp#tim,ÿsmall

    Contrastsÿofÿmarginalÿlinearÿpredictions

    Margins:ÿasbalanced

    -----------------------------------------------------------
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿdfÿÿÿÿÿÿÿÿddfÿÿÿÿÿÿÿÿÿÿÿFÿÿÿÿÿÿÿÿP>F
    -------------+---------------------------------------------
    scoÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿÿÿÿÿsexÿ|ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿÿÿÿ21.00ÿÿÿÿÿÿÿÿ0.63ÿÿÿÿÿ0.4364
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿÿÿÿÿeduÿ|ÿÿÿÿÿÿÿÿÿÿ2ÿÿÿÿÿÿ21.00ÿÿÿÿÿÿÿÿ0.93ÿÿÿÿÿ0.4085
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿÿÿÿÿvtpÿ|ÿÿÿÿÿÿÿÿÿÿ2ÿÿÿÿÿÿ21.00ÿÿÿÿÿÿÿÿ0.42ÿÿÿÿÿ0.6595
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿÿÿÿÿtimÿ|ÿÿÿÿÿÿÿÿÿÿ1ÿÿÿÿÿÿ24.00ÿÿÿÿÿÿÿÿ7.70ÿÿÿÿÿ0.0105
    ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
    ÿÿÿÿÿvtp#timÿ|ÿÿÿÿÿÿÿÿÿÿ2ÿÿÿÿÿÿ24.00ÿÿÿÿÿÿÿÿ0.15ÿÿÿÿÿ0.8588
    -----------------------------------------------------------

    .ÿ
    .ÿ/*ÿanovaÿscoÿsexÿ/ÿpid|sexÿeduÿ/ÿpid|eduÿvtpÿ/ÿpid|vtpÿtimÿvtp#tim
    >ÿanovaÿscoÿeduÿ/ÿpid|eduÿsexÿ/ÿpid|sexÿvtpÿ/ÿpid|vtpÿtimÿvtp#tim
    >ÿanovaÿscoÿvtpÿ/ÿpid|vtpÿsexÿ/ÿpid|sexÿeduÿ/ÿpid|eduÿtimÿvtp#timÿ*/
    .ÿ
    .ÿexit

    endÿofÿdo-file


    .

    Comment


    • #3
      Forgot to attach the graph, sorry.

      Click image for larger version

Name:	LinearFit.png
Views:	1
Size:	25.9 KB
ID:	1664620

      Comment


      • #4
        By the way, there's an error in the encoding of educational level in that a significant space was somehow lost in translation during refactoring the string substitution from three manual lines into a loop, which causes two of the categories to be inadvertently combined.
        Code:
        quietly replace edu = "`string'" if strpos(edu, "`string'")
        should have been
        Code:
        quietly replace edu = "`string'" if strpos(edu, " `string'")
        It shows up in that there are only two categories displayed for education level in the regression output table for mixed, and the degrees of freedom is one shy for education level in the contrast output.

        Comment


        • #5
          Hello Joseph,

          Thank you so much for your help and for walking me through! I really appreciate that! And I was able to get your points for all three goals I tried to do.

          One thing I'm trying to learn from the reference paper is the mean percentage changes in outcomes (w/ 95% CI) graph attached. In "statistical analysis", they just mentioned "We used mixed models to account for measurements clustered within individuals and individuals clustered within homes". Therefore, I tried to fit a mixed-model and see "percentage changes in health outcomes" and their 95% CI so that I can make the graph like that.
          In the graph, their "HEPA Filter On" is kind of my "intervention (all ventilation types)" and other items in the legend are "Pollutant decrease".

          The reference figure from Allen et al. (2011) An Air Filter Intervention Study of Endothelial Function among Healthy Adults in a Woodsmoke-impacted Community. Am J Respir Crit Care Med.

          In this case, would there be any tips?
          Click image for larger version

Name:	figure.JPG
Views:	1
Size:	145.1 KB
ID:	1665352

          Comment


          • #6
            Originally posted by Insung Kang View Post
            I tried to fit a mixed-model and see "percentage changes in health outcomes" and their 95% CI so that I can make the graph like that.
            In the graph, their "HEPA Filter On" is kind of my "intervention (all ventilation types)" and other items in the legend are "Pollutant decrease".

            . . . In this case, would there be any tips?
            I do not have any, except perhaps to be careful of percent change, and change scores in general, as an outcome measure.

            You can Google change score harrell to become aware of some of the pitfalls others have experienced when using change scores as outcome variables in biology.

            Comment


            • #7
              Alright. Thank you so much for your time and help again!

              Comment

              Working...
              X