Announcement

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

  • Using the cluster() function for ANOVA?

    Hello Everyone!
    I have a question about the cluster() function. I am using a twin data set for running some analyses and I would like to control for non-independence of observations (as most of my participants have someone related to them in my sample) - I think the cluster(famid) funtion (famid to indicate which participants are related) is the correct command to use for this, right? However, I can get it to run only for a regression, e.g. regress variable1 variable2, cluster(famid). What I wanted to run is an ANOVA with a Scheffe post-hoc, e.g. one-way variable1 variable2, scheffe; but it seems like I can't use the cluster() function with this? Any idea how I could get this to run? OR how I could work around this? Thank you very much for your help!

  • #2
    Stata's anova command doesn't have a cluster() option. I believe that, in order to model nonindependence of observations in ANOVA, you'd use nesting, which in anova would be by means of a the solidus, often in combination with a pipe. Check the documentation, looking for examples of the form anova response A / B . . . or anova response A / B|A . . ..

    Comment


    • #3
      Thank you very much for your response, Joseph! And thank you for the tip about nesting, but I am not sure exactly how the cluster(function) is working in the background therefore it makes it difficult for me to use the nested function instead. Can you tell if cluster(famid) (if famid if a variable indicating who of my participants are related and therfore have the same famid) is just selectig one observation per famid (family ID)? I am not sure, how the nested function would be able to replace the cluster() function if this was the case. Would that mean that I would need to have two variables, one for twin one, the other for twin two and then nest one twin in the other twin to tell ANOVA that the two are related - is that what you suggest?

      Comment


      • #4
        look at "help contrast" and "help pwcompare", each of which has Scheffe options to use after regression

        Comment


        • #5
          The regression analysis would do the trick. Therefore, I wonder why you shan't stick to it... That said, and considering you really want to keep the estimations under ANOVA, inserting "famid" as a grouping factor would perhaps be of some help, albeit somewhat violating the independence assumption.
          Best regards,

          Marcos

          Comment


          • #6
            Thank you very much!! You guys are brilliant! The command pmcompare in connection with contrasts was doing the trick. :-) As my independent variable is just 3 groups, not a continuous variable...Is there any way I can get the group means like I would get with the ANOVA?... meaning after I have applied the custer(famid) command, because my degress of freedom are lowered quite a bit after applying cluster(famid) (1,492 down to 880)? Thank you very much again!!

            Comment


            • #7
              Originally posted by Mel Schneider View Post
              As my independent variable is just 3 groups, not a continuous variable...Is there any way I can get the group means like I would get with the ANOVA?... meaning after I have applied the custer(famid) command, because my degress of freedom are lowered quite a bit after applying cluster(famid) (1,492 down to 880)?
              From your description, it seems as if your data structure is a "between" type of analysis (variable2 varies across pairs of twins) and not a "within" type ("fixed effects" where variable2 varies between twins within a pair). If you're using regress variable1 i.variable2, cluster(famid) as others have suggested, then group means will be just the "marginal" means that you can compute with bysort variable2: summarize variable1. You can see that below in the output (start at the "Begin here" comment): compare the results from table and margins for either of the estimation commands in the first approach.

              The output is a little long, sorry, but it gives you an idea of your options in Stata, one or more of which might be appropriate, depending upon your research problem. (The denominator degrees-of-freedom adjustment that I use in the fourth approach is a bit silly given 880 pairs of twins, but it does illustrate the features available in Stata.)

              .ÿversionÿ14.0

              .ÿ
              .ÿclearÿ*

              .ÿsetÿmoreÿoff

              .ÿsetÿseedÿ`=date("2015-06-03",ÿ"YMD")'

              .ÿquietlyÿsetÿobsÿ880

              .ÿ
              .ÿgenerateÿintÿfamidÿ=ÿ_n

              .ÿgenerateÿdoubleÿfam_uÿ=ÿrnormal()

              .ÿ
              .ÿgenerateÿbyteÿvariable2ÿ=ÿmod(_n,ÿ3)

              .ÿ
              .ÿforvaluesÿtwinÿ=ÿ1/2ÿ{
              ÿÿ2.ÿÿÿÿÿÿÿÿÿgenerateÿdoubleÿvariable1`twin'ÿ=ÿfam_uÿ+ÿ(variable2ÿ-ÿ1ÿ)ÿ/ÿ8ÿ+ÿrnormal()
              ÿÿ3.ÿ}

              .ÿquietlyÿreshapeÿlongÿvariable1,ÿi(famid)ÿj(twin)

              .ÿsortÿfamidÿtwin

              .ÿquietlyÿdropÿifÿ_nÿ>ÿ1225ÿ&ÿtwinÿ==ÿ2

              .ÿ
              .ÿ*
              .ÿ*ÿBeginÿhere
              .ÿ*
              .ÿtableÿvariable2,ÿcontents(meanÿvariable1)ÿ//ÿ<-ÿmarginalÿmeans

              --------------------------
              variable2ÿ|ÿmean(variab~1)
              ----------+---------------
              ÿÿÿÿÿÿÿÿ0ÿ|ÿÿÿÿÿ-.06187176
              ÿÿÿÿÿÿÿÿ1ÿ|ÿÿÿÿÿÿ.10340446
              ÿÿÿÿÿÿÿÿ2ÿ|ÿÿÿÿÿÿ.20186574
              --------------------------

              .ÿ
              .ÿ*
              .ÿ*ÿ1ÿMarginal
              .ÿregressÿvariable1ÿi.variable2,ÿcluster(famid)

              LinearÿregressionÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿ1,492
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿF(2,ÿ879)ÿÿÿÿÿÿÿÿÿ=ÿÿÿÿÿÿÿ3.27
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿFÿÿÿÿÿÿÿÿÿÿ=ÿÿÿÿÿ0.0384
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿR-squaredÿÿÿÿÿÿÿÿÿ=ÿÿÿÿÿ0.0062
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿRootÿMSEÿÿÿÿÿÿÿÿÿÿ=ÿÿÿÿÿ1.3838

              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ(Std.ÿErr.ÿadjustedÿforÿ880ÿclustersÿinÿfamid)
              ------------------------------------------------------------------------------
              ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿRobust
              ÿÿÿvariable1ÿ|ÿÿÿÿÿÿCoef.ÿÿÿStd.ÿErr.ÿÿÿÿÿÿtÿÿÿÿP>|t|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
              -------------+----------------------------------------------------------------
              ÿÿÿvariable2ÿ|
              ÿÿÿÿÿÿÿÿÿÿ1ÿÿ|ÿÿÿ.1652762ÿÿÿ.1031206ÿÿÿÿÿ1.60ÿÿÿ0.109ÿÿÿÿ-.0371151ÿÿÿÿ.3676675
              ÿÿÿÿÿÿÿÿÿÿ2ÿÿ|ÿÿÿ.2637375ÿÿÿ.1037762ÿÿÿÿÿ2.54ÿÿÿ0.011ÿÿÿÿÿ.0600593ÿÿÿÿ.4674157
              ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
              ÿÿÿÿÿÿÿ_consÿ|ÿÿ-.0618718ÿÿÿ.0756286ÿÿÿÿ-0.82ÿÿÿ0.414ÿÿÿÿ-.2103054ÿÿÿÿ.0865619
              ------------------------------------------------------------------------------

              .ÿtestÿ1.variable2ÿ2.variable2

              ÿ(ÿ1)ÿÿ1.variable2ÿ=ÿ0
              ÿ(ÿ2)ÿÿ2.variable2ÿ=ÿ0

              ÿÿÿÿÿÿÿF(ÿÿ2,ÿÿÿ879)ÿ=ÿÿÿÿ3.27
              ÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿFÿ=ÿÿÿÿ0.0384

              .ÿmarginsÿvariable2

              AdjustedÿpredictionsÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿ1,492
              ModelÿVCEÿÿÿÿ:ÿRobust

              Expressionÿÿÿ:ÿLinearÿprediction,ÿpredict()

              ------------------------------------------------------------------------------
              ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿÿÿÿDelta-method
              ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿMarginÿÿÿStd.ÿErr.ÿÿÿÿÿÿtÿÿÿÿP>|t|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
              -------------+----------------------------------------------------------------
              ÿÿÿvariable2ÿ|
              ÿÿÿÿÿÿÿÿÿÿ0ÿÿ|ÿÿ-.0618718ÿÿÿ.0756286ÿÿÿÿ-0.82ÿÿÿ0.414ÿÿÿÿ-.2103054ÿÿÿÿ.0865619
              ÿÿÿÿÿÿÿÿÿÿ1ÿÿ|ÿÿÿ.1034045ÿÿÿ.0701012ÿÿÿÿÿ1.48ÿÿÿ0.141ÿÿÿÿ-.0341807ÿÿÿÿ.2409897
              ÿÿÿÿÿÿÿÿÿÿ2ÿÿ|ÿÿÿ.2018657ÿÿÿ.0710622ÿÿÿÿÿ2.84ÿÿÿ0.005ÿÿÿÿÿ.0623944ÿÿÿÿ.3413371
              ------------------------------------------------------------------------------

              .ÿ
              .ÿ//ÿor
              .ÿxtgeeÿvariable1ÿi.variable2,ÿi(famid)ÿfamily(gaussian)ÿlink(identity)ÿ///
              >ÿÿÿÿÿÿÿÿÿcorr(independent)ÿvce(robust)ÿnolog

              GEEÿpopulation-averagedÿmodelÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿ1,492
              Groupÿvariable:ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿfamidÿÿÿÿÿÿNumberÿofÿgroupsÿÿ=ÿÿÿÿÿÿÿÿ880
              Link:ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿidentityÿÿÿÿÿÿObsÿperÿgroup:
              Family:ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿGaussianÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿminÿ=ÿÿÿÿÿÿÿÿÿÿ1
              Correlation:ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿindependentÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿavgÿ=ÿÿÿÿÿÿÿÿ1.7
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿmaxÿ=ÿÿÿÿÿÿÿÿÿÿ2
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿWaldÿchi2(2)ÿÿÿÿÿÿ=ÿÿÿÿÿÿÿ6.55
              Scaleÿparameter:ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ1.911169ÿÿÿÿÿÿProbÿ>ÿchi2ÿÿÿÿÿÿÿ=ÿÿÿÿÿ0.0378

              Pearsonÿchi2(1492):ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ2851.46ÿÿÿÿÿÿDevianceÿÿÿÿÿÿÿÿÿÿ=ÿÿÿÿ2851.46
              Dispersionÿ(Pearson):ÿÿÿÿÿÿÿÿÿÿÿÿÿ1.911169ÿÿÿÿÿÿDispersionÿÿÿÿÿÿÿÿ=ÿÿÿ1.911169

              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ(Std.ÿErr.ÿadjustedÿforÿclusteringÿonÿfamid)
              ------------------------------------------------------------------------------
              ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿRobust
              ÿÿÿvariable1ÿ|ÿÿÿÿÿÿCoef.ÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
              -------------+----------------------------------------------------------------
              ÿÿÿvariable2ÿ|
              ÿÿÿÿÿÿÿÿÿÿ1ÿÿ|ÿÿÿ.1652762ÿÿÿ.1030514ÿÿÿÿÿ1.60ÿÿÿ0.109ÿÿÿÿ-.0367008ÿÿÿÿ.3672532
              ÿÿÿÿÿÿÿÿÿÿ2ÿÿ|ÿÿÿ.2637375ÿÿÿ.1037066ÿÿÿÿÿ2.54ÿÿÿ0.011ÿÿÿÿÿ.0604763ÿÿÿÿ.4669987
              ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
              ÿÿÿÿÿÿÿ_consÿ|ÿÿ-.0618718ÿÿÿ.0755778ÿÿÿÿ-0.82ÿÿÿ0.413ÿÿÿÿ-.2100016ÿÿÿÿÿ.086258
              ------------------------------------------------------------------------------

              .ÿtestÿ1.variable2ÿ2.variable2,ÿdf(`=e(N_g)ÿ-ÿe(rank)')

              ÿ(ÿ1)ÿÿ1.variable2ÿ=ÿ0
              ÿ(ÿ2)ÿÿ2.variable2ÿ=ÿ0

              ÿÿÿÿÿÿÿF(ÿÿ2,ÿÿÿ877)ÿ=ÿÿÿÿ3.28
              ÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿFÿ=ÿÿÿÿ0.0383

              .ÿmarginsÿvariable2

              AdjustedÿpredictionsÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿ1,492
              ModelÿVCEÿÿÿÿ:ÿRobust

              Expressionÿÿÿ:ÿLinearÿprediction,ÿpredict()

              ------------------------------------------------------------------------------
              ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿÿÿÿDelta-method
              ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿMarginÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
              -------------+----------------------------------------------------------------
              ÿÿÿvariable2ÿ|
              ÿÿÿÿÿÿÿÿÿÿ0ÿÿ|ÿÿ-.0618718ÿÿÿ.0755778ÿÿÿÿ-0.82ÿÿÿ0.413ÿÿÿÿ-.2100016ÿÿÿÿÿ.086258
              ÿÿÿÿÿÿÿÿÿÿ1ÿÿ|ÿÿÿ.1034045ÿÿÿ.0700541ÿÿÿÿÿ1.48ÿÿÿ0.140ÿÿÿÿ-.0338991ÿÿÿÿÿ.240708
              ÿÿÿÿÿÿÿÿÿÿ2ÿÿ|ÿÿÿ.2018657ÿÿÿ.0710145ÿÿÿÿÿ2.84ÿÿÿ0.004ÿÿÿÿÿ.0626799ÿÿÿÿ.3410516
              ------------------------------------------------------------------------------

              .ÿ
              .ÿ*
              .ÿ*ÿ2ÿANOVAÿ(unbalanced)
              .ÿsetÿmatsizeÿ11000

              .ÿanovaÿvariable1ÿvariable2ÿ/ÿfamid,ÿsequentialÿdropemptycells

              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿ=ÿÿÿÿÿÿ1,492ÿÿÿÿR-squaredÿÿÿÿÿ=ÿÿ0.7766
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿRootÿMSEÿÿÿÿÿÿ=ÿÿÿÿ1.02344ÿÿÿÿAdjÿR-squaredÿ=ÿÿ0.4557

              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿSourceÿ|ÿÿÿÿSeq.ÿSSÿÿÿÿÿÿÿÿÿdfÿÿÿÿÿÿÿÿÿMSÿÿÿÿÿÿÿÿFÿÿÿÿProb>F
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-----------+----------------------------------------------------
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿModelÿ|ÿÿ2228.0976ÿÿÿÿÿÿÿÿ879ÿÿÿ2.5348096ÿÿÿÿÿÿ2.42ÿÿ0.0000
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿvariable2ÿ|ÿÿ17.655314ÿÿÿÿÿÿÿÿÿÿ2ÿÿÿ8.8276571ÿÿÿÿÿÿ3.50ÿÿ0.0305
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿfamidÿ|ÿÿ2210.4423ÿÿÿÿÿÿÿÿ877ÿÿÿ2.5204587ÿÿ
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-----------+----------------------------------------------------
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿResidualÿ|ÿÿÿ641.0215ÿÿÿÿÿÿÿÿ612ÿÿÿ1.0474208ÿÿ
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ-----------+----------------------------------------------------
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿTotalÿ|ÿÿ2869.1191ÿÿÿÿÿÿ1,491ÿÿÿ1.9242918ÿÿ

              .ÿmarginsÿvariable2

              PredictiveÿmarginsÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿ1,492

              Expressionÿÿÿ:ÿLinearÿprediction,ÿpredict()

              ------------------------------------------------------------------------------
              ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿÿÿÿDelta-method
              ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿMarginÿÿÿStd.ÿErr.ÿÿÿÿÿÿtÿÿÿÿP>|t|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
              -------------+----------------------------------------------------------------
              ÿÿÿvariable2ÿ|
              ÿÿÿÿÿÿÿÿÿÿ0ÿÿ|ÿÿÿÿÿÿÿÿÿÿ.ÿÿ(notÿestimable)
              ÿÿÿÿÿÿÿÿÿÿ1ÿÿ|ÿÿÿÿÿÿÿÿÿÿ.ÿÿ(notÿestimable)
              ÿÿÿÿÿÿÿÿÿÿ2ÿÿ|ÿÿÿÿÿÿÿÿÿÿ.ÿÿ(notÿestimable)
              ------------------------------------------------------------------------------

              .ÿ
              .ÿ//ÿor
              .ÿxtregÿvariable1ÿi.variable2,ÿi(famid)ÿbeÿwls

              Betweenÿregressionÿ(regressionÿonÿgroupÿmeans)ÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿ1,492
              Groupÿvariable:ÿfamidÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿgroupsÿÿ=ÿÿÿÿÿÿÿÿ880

              R-sq:ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿObsÿperÿgroup:
              ÿÿÿÿÿwithinÿÿ=ÿÿÿÿÿÿ.ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿminÿ=ÿÿÿÿÿÿÿÿÿÿ1
              ÿÿÿÿÿbetweenÿ=ÿ0.0079ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿavgÿ=ÿÿÿÿÿÿÿÿ1.7
              ÿÿÿÿÿoverallÿ=ÿ0.0062ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿmaxÿ=ÿÿÿÿÿÿÿÿÿÿ2

              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿF(2,877)ÿÿÿÿÿÿÿÿÿÿ=ÿÿÿÿÿÿÿ3.50
              sd(u_iÿ+ÿavg(e_i.))=ÿÿ1.219261ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿFÿÿÿÿÿÿÿÿÿÿ=ÿÿÿÿÿ0.0305

              ------------------------------------------------------------------------------
              ÿÿÿvariable1ÿ|ÿÿÿÿÿÿCoef.ÿÿÿStd.ÿErr.ÿÿÿÿÿÿtÿÿÿÿP>|t|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
              -------------+----------------------------------------------------------------
              ÿÿÿvariable2ÿ|
              ÿÿÿÿÿÿÿÿÿÿ1ÿÿ|ÿÿÿ.1652762ÿÿÿ.1006604ÿÿÿÿÿ1.64ÿÿÿ0.101ÿÿÿÿ-.0322871ÿÿÿÿ.3628395
              ÿÿÿÿÿÿÿÿÿÿ2ÿÿ|ÿÿÿ.2637375ÿÿÿ.1007109ÿÿÿÿÿ2.62ÿÿÿ0.009ÿÿÿÿÿ.0660749ÿÿÿÿ.4614001
              ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
              ÿÿÿÿÿÿÿ_consÿ|ÿÿ-.0618718ÿÿÿ.0712134ÿÿÿÿ-0.87ÿÿÿ0.385ÿÿÿÿ-.2016403ÿÿÿÿ.0778968
              ------------------------------------------------------------------------------

              .ÿtestÿ1.variable2ÿ2.variable2

              ÿ(ÿ1)ÿÿ1.variable2ÿ=ÿ0
              ÿ(ÿ2)ÿÿ2.variable2ÿ=ÿ0

              ÿÿÿÿÿÿÿF(ÿÿ2,ÿÿÿ877)ÿ=ÿÿÿÿ3.50
              ÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿFÿ=ÿÿÿÿ0.0305

              .ÿcaptureÿnoisilyÿmarginsÿvariable2ÿ//ÿ(noteÿtoÿStataCorp)
              __000005ÿnotÿfound

              .ÿ
              .ÿ*
              .ÿ*ÿ3ÿ"Between"ÿestimator
              .ÿxtregÿvariable1ÿi.variable2,ÿi(famid)ÿbe

              Betweenÿregressionÿ(regressionÿonÿgroupÿmeans)ÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿ1,492
              Groupÿvariable:ÿfamidÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿgroupsÿÿ=ÿÿÿÿÿÿÿÿ880

              R-sq:ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿObsÿperÿgroup:
              ÿÿÿÿÿwithinÿÿ=ÿÿÿÿÿÿ.ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿminÿ=ÿÿÿÿÿÿÿÿÿÿ1
              ÿÿÿÿÿbetweenÿ=ÿ0.0075ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿavgÿ=ÿÿÿÿÿÿÿÿ1.7
              ÿÿÿÿÿoverallÿ=ÿ0.0060ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿmaxÿ=ÿÿÿÿÿÿÿÿÿÿ2

              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿF(2,877)ÿÿÿÿÿÿÿÿÿÿ=ÿÿÿÿÿÿÿ3.29
              sd(u_iÿ+ÿavg(e_i.))=ÿÿ1.254777ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿFÿÿÿÿÿÿÿÿÿÿ=ÿÿÿÿÿ0.0376

              ------------------------------------------------------------------------------
              ÿÿÿvariable1ÿ|ÿÿÿÿÿÿCoef.ÿÿÿStd.ÿErr.ÿÿÿÿÿÿtÿÿÿÿP>|t|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
              -------------+----------------------------------------------------------------
              ÿÿÿvariable2ÿ|
              ÿÿÿÿÿÿÿÿÿÿ1ÿÿ|ÿÿÿ.1922238ÿÿÿ.1035805ÿÿÿÿÿ1.86ÿÿÿ0.064ÿÿÿÿ-.0110708ÿÿÿÿ.3955185
              ÿÿÿÿÿÿÿÿÿÿ2ÿÿ|ÿÿÿ.2553757ÿÿÿ.1036687ÿÿÿÿÿ2.46ÿÿÿ0.014ÿÿÿÿÿ.0519079ÿÿÿÿ.4588434
              ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
              ÿÿÿÿÿÿÿ_consÿ|ÿÿ-.0646939ÿÿÿ.0733048ÿÿÿÿ-0.88ÿÿÿ0.378ÿÿÿÿ-.2085673ÿÿÿÿ.0791795
              ------------------------------------------------------------------------------

              .ÿmarginsÿvariable2

              AdjustedÿpredictionsÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿ1,492
              ModelÿVCEÿÿÿÿ:ÿConventional

              Expressionÿÿÿ:ÿLinearÿprediction,ÿpredict()

              ------------------------------------------------------------------------------
              ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿÿÿÿDelta-method
              ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿMarginÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
              -------------+----------------------------------------------------------------
              ÿÿÿvariable2ÿ|
              ÿÿÿÿÿÿÿÿÿÿ0ÿÿ|ÿÿ-.0646939ÿÿÿ.0733048ÿÿÿÿ-0.88ÿÿÿ0.377ÿÿÿÿ-.2083688ÿÿÿÿ.0789809
              ÿÿÿÿÿÿÿÿÿÿ1ÿÿ|ÿÿÿ.1275299ÿÿÿ.0731801ÿÿÿÿÿ1.74ÿÿÿ0.081ÿÿÿÿ-.0159004ÿÿÿÿ.2709602
              ÿÿÿÿÿÿÿÿÿÿ2ÿÿ|ÿÿÿ.1906818ÿÿÿ.0733048ÿÿÿÿÿ2.60ÿÿÿ0.009ÿÿÿÿÿ.0470069ÿÿÿÿ.3343566
              ------------------------------------------------------------------------------

              .ÿ
              .ÿ*
              .ÿ*ÿ4ÿMaybeÿrecommended,ÿdependingÿuponÿtheÿquestionÿtoÿbeÿaddressed
              .ÿmixedÿvariable1ÿi.variable2ÿ||ÿfamid:ÿ,ÿremlÿnolrtestÿdfmethod(kroger)ÿnolog

              Mixed-effectsÿREMLÿregressionÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿ1,492
              Groupÿvariable:ÿfamidÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿgroupsÿÿ=ÿÿÿÿÿÿÿÿ880

              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿObsÿperÿgroup:
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿminÿ=ÿÿÿÿÿÿÿÿÿÿ1
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿavgÿ=ÿÿÿÿÿÿÿÿ1.7
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿmaxÿ=ÿÿÿÿÿÿÿÿÿÿ2
              DFÿmethod:ÿKenward-RogerÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿDF:ÿÿÿÿÿÿÿÿÿÿÿminÿ=ÿÿÿÿÿ860.09
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿavgÿ=ÿÿÿÿÿ860.26
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿmaxÿ=ÿÿÿÿÿ860.61

              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿF(2,ÿÿÿ860.43)ÿÿÿÿ=ÿÿÿÿÿÿÿ3.40
              Logÿrestricted-likelihoodÿ=ÿ-2538.6553ÿÿÿÿÿÿÿÿÿÿProbÿ>ÿFÿÿÿÿÿÿÿÿÿÿ=ÿÿÿÿÿ0.0338

              ------------------------------------------------------------------------------
              ÿÿÿvariable1ÿ|ÿÿÿÿÿÿCoef.ÿÿÿStd.ÿErr.ÿÿÿÿÿÿtÿÿÿÿP>|t|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
              -------------+----------------------------------------------------------------
              ÿÿÿvariable2ÿ|
              ÿÿÿÿÿÿÿÿÿÿ1ÿÿ|ÿÿÿÿ.178518ÿÿÿ.1018043ÿÿÿÿÿ1.75ÿÿÿ0.080ÿÿÿÿ-.0212958ÿÿÿÿ.3783318
              ÿÿÿÿÿÿÿÿÿÿ2ÿÿ|ÿÿÿ.2596312ÿÿÿ.1018729ÿÿÿÿÿ2.55ÿÿÿ0.011ÿÿÿÿÿ.0596826ÿÿÿÿ.4595798
              ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
              ÿÿÿÿÿÿÿ_consÿ|ÿÿ-.0632577ÿÿÿÿ.072035ÿÿÿÿ-0.88ÿÿÿ0.380ÿÿÿÿ-.2046426ÿÿÿÿ.0781273
              ------------------------------------------------------------------------------

              ------------------------------------------------------------------------------
              ÿÿRandom-effectsÿParametersÿÿ|ÿÿÿEstimateÿÿÿStd.ÿErr.ÿÿÿÿÿ[95%ÿConf.ÿInterval]
              -----------------------------+------------------------------------------------
              famid:ÿIdentityÿÿÿÿÿÿÿÿÿÿÿÿÿÿ|
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿvar(_cons)ÿ|ÿÿÿ.8648018ÿÿÿ.0810164ÿÿÿÿÿÿ.7197377ÿÿÿÿ1.039104
              -----------------------------+------------------------------------------------
              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿvar(Residual)ÿ|ÿÿÿ1.056715ÿÿÿ.0600478ÿÿÿÿÿÿ.9453405ÿÿÿÿÿ1.18121
              ------------------------------------------------------------------------------

              .ÿtestÿ1.variable2ÿ2.variable2,ÿdf(`=e(df_avg)')

              ÿ(ÿ1)ÿÿ[variable1]1.variable2ÿ=ÿ0
              ÿ(ÿ2)ÿÿ[variable1]2.variable2ÿ=ÿ0

              ÿÿÿÿÿÿÿF(ÿÿ2,ÿÿÿ860)ÿ=ÿÿÿÿ3.40
              ÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿFÿ=ÿÿÿÿ0.0338

              .ÿmarginsÿvariable2

              AdjustedÿpredictionsÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿ1,492

              Expressionÿÿÿ:ÿLinearÿprediction,ÿfixedÿportion,ÿpredict()

              ------------------------------------------------------------------------------
              ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿÿÿÿDelta-method
              ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿMarginÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
              -------------+----------------------------------------------------------------
              ÿÿÿvariable2ÿ|
              ÿÿÿÿÿÿÿÿÿÿ0ÿÿ|ÿÿ-.0632577ÿÿÿ.0720287ÿÿÿÿ-0.88ÿÿÿ0.380ÿÿÿÿ-.2044314ÿÿÿÿ.0779161
              ÿÿÿÿÿÿÿÿÿÿ1ÿÿ|ÿÿÿ.1152604ÿÿÿ.0719317ÿÿÿÿÿ1.60ÿÿÿ0.109ÿÿÿÿ-.0257231ÿÿÿÿ.2562439
              ÿÿÿÿÿÿÿÿÿÿ2ÿÿ|ÿÿÿ.1963735ÿÿÿ.0720287ÿÿÿÿÿ2.73ÿÿÿ0.006ÿÿÿÿÿ.0551998ÿÿÿÿ.3375472
              ------------------------------------------------------------------------------

              .ÿ
              .ÿ//ÿor
              .ÿxtregÿvariable1ÿi.variable2,ÿi(famid)ÿre

              Random-effectsÿGLSÿregressionÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿ1,492
              Groupÿvariable:ÿfamidÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿgroupsÿÿ=ÿÿÿÿÿÿÿÿ880

              R-sq:ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿObsÿperÿgroup:
              ÿÿÿÿÿwithinÿÿ=ÿÿÿÿÿÿ.ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿminÿ=ÿÿÿÿÿÿÿÿÿÿ1
              ÿÿÿÿÿbetweenÿ=ÿ0.0074ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿavgÿ=ÿÿÿÿÿÿÿÿ1.7
              ÿÿÿÿÿoverallÿ=ÿ0.0061ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿmaxÿ=ÿÿÿÿÿÿÿÿÿÿ2

              ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿWaldÿchi2(2)ÿÿÿÿÿÿ=ÿÿÿÿÿÿÿ6.74
              corr(u_i,ÿX)ÿÿÿ=ÿ0ÿ(assumed)ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿchi2ÿÿÿÿÿÿÿ=ÿÿÿÿÿ0.0345

              ------------------------------------------------------------------------------
              ÿÿÿvariable1ÿ|ÿÿÿÿÿÿCoef.ÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
              -------------+----------------------------------------------------------------
              ÿÿÿvariable2ÿ|
              ÿÿÿÿÿÿÿÿÿÿ1ÿÿ|ÿÿÿ.1787805ÿÿÿ.1022884ÿÿÿÿÿ1.75ÿÿÿ0.080ÿÿÿÿ-.0217011ÿÿÿÿ.3792622
              ÿÿÿÿÿÿÿÿÿÿ2ÿÿ|ÿÿÿ.2595497ÿÿÿ.1023577ÿÿÿÿÿ2.54ÿÿÿ0.011ÿÿÿÿÿ.0589323ÿÿÿÿ.4601672
              ÿÿÿÿÿÿÿÿÿÿÿÿÿ|
              ÿÿÿÿÿÿÿ_consÿ|ÿÿ-.0632852ÿÿÿ.0723778ÿÿÿÿ-0.87ÿÿÿ0.382ÿÿÿÿ-.2051431ÿÿÿÿ.0785728
              -------------+----------------------------------------------------------------
              ÿÿÿÿÿsigma_uÿ|ÿÿ.94406608
              ÿÿÿÿÿsigma_eÿ|ÿÿ1.0234358
              ÿÿÿÿÿÿÿÿÿrhoÿ|ÿÿ.45972521ÿÿÿ(fractionÿofÿvarianceÿdueÿtoÿu_i)
              ------------------------------------------------------------------------------

              .ÿtestÿ1.variable2ÿ2.variable2,ÿdf(`=e(N_g)ÿ-ÿe(rank)')

              ÿ(ÿ1)ÿÿ1.variable2ÿ=ÿ0
              ÿ(ÿ2)ÿÿ2.variable2ÿ=ÿ0

              ÿÿÿÿÿÿÿF(ÿÿ2,ÿÿÿ877)ÿ=ÿÿÿÿ3.37
              ÿÿÿÿÿÿÿÿÿÿÿÿProbÿ>ÿFÿ=ÿÿÿÿ0.0349

              .ÿmarginsÿvariable2

              AdjustedÿpredictionsÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿNumberÿofÿobsÿÿÿÿÿ=ÿÿÿÿÿÿ1,492
              ModelÿVCEÿÿÿÿ:ÿConventional

              Expressionÿÿÿ:ÿLinearÿprediction,ÿpredict()

              ------------------------------------------------------------------------------
              ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿÿÿÿÿÿÿÿDelta-method
              ÿÿÿÿÿÿÿÿÿÿÿÿÿ|ÿÿÿÿÿMarginÿÿÿStd.ÿErr.ÿÿÿÿÿÿzÿÿÿÿP>|z|ÿÿÿÿÿ[95%ÿConf.ÿInterval]
              -------------+----------------------------------------------------------------
              ÿÿÿvariable2ÿ|
              ÿÿÿÿÿÿÿÿÿÿ0ÿÿ|ÿÿ-.0632852ÿÿÿ.0723778ÿÿÿÿ-0.87ÿÿÿ0.382ÿÿÿÿ-.2051431ÿÿÿÿ.0785728
              ÿÿÿÿÿÿÿÿÿÿ1ÿÿ|ÿÿÿ.1154954ÿÿÿ.0722798ÿÿÿÿÿ1.60ÿÿÿ0.110ÿÿÿÿ-.0261705ÿÿÿÿ.2571612
              ÿÿÿÿÿÿÿÿÿÿ2ÿÿ|ÿÿÿ.1962646ÿÿÿ.0723778ÿÿÿÿÿ2.71ÿÿÿ0.007ÿÿÿÿÿ.0544066ÿÿÿÿ.3381225
              ------------------------------------------------------------------------------

              .ÿ
              .ÿexit

              endÿofÿdo-file


              .






              Comment


              • #8
                Thank you very much for the detailed response! Having the between r squared for between groups is very helpful! I will definitely use that! But the commands for getting the means of variable1 for each of the groups (defined by variable2) is not giving me exactly what I want, because the number of observation indicates that this is before cluster(famid) is applied? (if I understand this correctly) I would be interested in the means AND number of cases (as considered in the regression) after cluster was applied... any suggestions?

                Comment


                • #9
                  Originally posted by Mel Schneider View Post
                  . . . the commands for getting the means of variable1 for each of the groups (defined by variable2) is not giving me exactly what I want, because the number of observation indicates that this is before cluster(famid) is applied . . . I would be interested in the means AND number of cases (as considered in the regression) after cluster was applied...
                  As I mentioned at first, with regress . . . cluster(), the means are just the marginal means that you get from summarize. More important, though, is that, with any of the four approaches illustrated, the means (in linear models, coefficients and their linear combinations) do use all individual observations, and so it is meaningless to speak of a number of cases as considered in the regression (to compute the means) as different from all of the observations included in fitting the model.

                  Comment


                  • #10
                    Ahhh! Now I am getting thins! Thank you very much for clarifiying - I thought the cluster() function was literally cutting down my sample, but I see that the total observations in the regression is still about 1,500! Thank you very much for all your detailed responses, this has been very helpful!!

                    Comment

                    Working...
                    X