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
Wed, 19 Feb 2014 20:15:36 +0900
Try using the -gw.- contrast operator.
Joseph Coveney
. version 13.1
.
. clear *
. set more off
. set seed `=date("2014-02-19", "YMD")'
. quietly set obs 30
. generate byte clinic = _n
. generate double clinic_u = rnormal()
. quietly expand 30
. bysort clinic: generate byte treatment = mod(_n, 2)
. drop if runiform() < 0.10
(79 observations deleted)
.
. generate double response = treatment / 10 + clinic_u + rnormal()
.
. anova response clinic treatment clinic#treatment, sequential
Number of obs = 821 R-squared = 0.4323
Root MSE = .992115 Adj R-squared = 0.3883
Source | Seq. SS df MS F Prob > F
-----------------+----------------------------------------------------
Model | 570.498163 59 9.66946039 9.82 0.0000
|
clinic | 532.275049 29 18.354312 18.65 0.0000
treatment | 7.84163637 1 7.84163637 7.97 0.0049
clinic#treatment | 30.3814777 29 1.04763716 1.06 0.3754
|
Residual | 749.046921 761 .984292931
-----------------+----------------------------------------------------
Total | 1319.54508 820 1.60920132
. quietly regress response i.clinic i.treatment i.clinic#i.treatment
. contrast gw.treatment, asobserved
Contrasts of marginal linear predictions
Margins : asobserved
------------------------------------------------
| df F P>F
-------------+----------------------------------
treatment |
(0 vs mean) | 1 7.98 0.0049
(1 vs mean) | 1 7.98 0.0049
Joint | 1 7.98 0.0049
|
Denominator | 761
------------------------------------------------
--------------------------------------------------------------
| Contrast Std. Err. [95% Conf. Interval]
-------------+------------------------------------------------
treatment |
(0 vs mean) | -.0978414 .0346361 -.1658351 -.0298477
(1 vs mean) | .09808 .0347206 .0299205 .1662395
--------------------------------------------------------------
.
. exit
end of do-file
On Wed, Feb 19, 2014 at 7:02 PM, David Fisher <[email protected]> wrote:
> Dear all,
>
> As part of a larger piece of research, I am interested in recreating
> the series of related one-stage meta-analysis models described by Senn
> (2000)*. These are described in terms of SAS-style ANOVA "sums of
> squares", which I would like to recreate in terms of a regression
> model.
>
> The models are as follows:
> Model 2: Fixed trial strata, fixed treatment effect, no interaction
> (i.e. the standard one-stage fixed-effects meta-analysis model)
> Model 4.1: Trial + treatment interaction model using Type II SS
> Model 4.2: Trial + treatment interaction model using Type III SS.
>
> Given outcome "y", treatment "trt" and trial strata "trial", where the
> effect of interest is that of "trt" (binary), Model 2 can be fitted
> as:
> . anova y i.trial i.trt
> or
> . regress y i.trial i.trt
>
> Model 4.2 can be fitted as:
> . anova y i.trial##i.trt
> or
> . regress y i.trial##i.trt
> . contrast r.trt, asbalanced
>
> No problems -- the anova and regress F and p values for "trt" match exactly.
>
> Now, Model 4.1 can be fitted as:
> . anova y i.trial##i.trt, seq
>
> ...and I thought that this could be recreated with regress using
> "contrast, asobserved", that is:
> . qui regress y i.trial##i.trt
> . contrast r.trt, asobserved
>
> But the F and p values for "trt", whilst close, are not the same.
>
> Have I misunderstood what "contrast" is doing here (I am a
> statistician, but don't use ANOVA in my day-to-day work, so this may
> well be the case)? If so, is there a way to recreate this ANOVA
> result using "regress"? If not, why not?
>
> Many thanks,
>
> David.
>
>
> * Senn S. The many modes of meta. Drug Information Journal 2000; 34: 535-49
>
>
>
>
> David Fisher
> Statistician
> MRC Clinical Trials Unit at UCL
> Aviation House
> 125 Kingsway
> London WC2B 6NH
>
> Direct line: +44 (0)20 7670-4646
> Main switchboard: +44 (0)20 7670-4700
> e-mail: [email protected]
> Website: http://www.ctu.mrc.ac.uk/
> *
> * 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/
*
* 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/