Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Recreating SAS "sums of squares" in Stata using anova and regress


From   "Joseph Coveney" <[email protected]>
To   <[email protected]>
Subject   Re: st: Recreating SAS "sums of squares" in Stata using anova and regress
Date   Thu, 20 Feb 2014 18:58:48 +0900

David Fisher wrote:

Thanks again -- that's interesting stuff, and I see what you're
getting at.  I'll have another play when I get a moment.
So do you agree that my basic comparison is valid?  Just knowing that
would be enormously helpful.

--------------------------------------------------------------------------------

My initial impression when I read the documentation for -contrast , asobserved-
was like yours.  But is adjusting sums of squares only for noncontained factors
synonymous with weighting contrasts by cell counts?  

Then there's this:  "Nor are the SAS type II sums of squares and the
corresponding BMDP4V WEIGHTS = SIZES sums of squares always identical to each
other." ( http://www.matstat.com/ss/easleaao.pdf , p. 16).  

Then there's that below.

Joseph Coveney

. set seed `=date("2014-02-20", "YMD")'

. input byte(A B count)

            A         B     count
  1. 1 1 100
  2. 2 1 100
  3. 1 2 100
  4. 2 2 1
  5. end

. quietly expand count

. generate double y = rnormal()

. anova y A B A#B, sequential

                           Number of obs =     301     R-squared     =  0.0104
                           Root MSE      =  1.0728     Adj R-squared =  0.0004

                  Source |    Seq. SS     df       MS           F     Prob > F
              -----------+----------------------------------------------------
                   Model |  3.57840222     3  1.19280074       1.04     0.3767
                         |
                       A |  .566718086     1  .566718086       0.49     0.4834
                       B |  .357057384     1  .357057384       0.31     0.5780
                     A#B |  2.65462675     1  2.65462675       2.31     0.1299
                         |
                Residual |   341.81901   297  1.15090576   
              -----------+----------------------------------------------------
                   Total |  345.397412   300  1.15132471   

. quietly regress y i.A i.B i.A#i.B

. contrast r.B, asobserved

Contrasts of marginal linear predictions

Margins      : asobserved

------------------------------------------------
             |         df           F        P>F
-------------+----------------------------------
           B |          1        1.37     0.2433
             |
    Residual |        297
------------------------------------------------

--------------------------------------------------------------
             |   Contrast   Std. Err.     [95% Conf. Interval]
-------------+------------------------------------------------
           B |
   (2 vs 1)  |  -.4390607   .3755552     -1.178147    .3000257
--------------------------------------------------------------

. 
. exit

end of do-file

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index