On Wed, Mar 27, 2013 at 2:53 AM, xiangbo_2010 <xiangbo_2...@126.com> wrote:

> Dear Prof Donald McLaren
>
> I am sorry to disturb you! I have four discrete variables {factor 1(A,B),
> factor 2(C,D), factor 3(G,H), and gender(M,F)} and a continuous variable
> (age), I want to use the GLM to analysis the result of the interaction
> among  factor 1(A,B), factor 2(C,D) and factor 3(E,F)
> regressing out the effect of gender and age, and I have 16 classes:
> MACG,MACH, MADG, MADH, MBCG, MBCH, MBDG, MBDH, FACG,FACH, FADG, FADH,
> FBCG, FBCH, FBDG, FBDH, so I design the contrast is following:
> 1 -1 -1 1 -1 1 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> 0 0 0 0 0 0 0 0 1 -1 -1 1 -1 1 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
>

IF - and this is a big if -- the columns are as you have described in this
order, then the contrast should be:
1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1

To create any contrast, you need to start with the null hypothesis and then
you can build up the contrast from its smaller elements:
This is for a design with 18 subjects in group 1, 9 subjects in group
2, 2 group terms and 7 conditions: Start with the simpliest element,
single subject in a single condition, build its contrast, repeat for
all subjects and conditions, and then combine the ones you want.

S1G1C1=[1 zeros(1,26) 1 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0]
S1G1C2=[1 zeros(1,26) 1 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0]
....
Now average your G1C1 and by summing and dividing by the number of
subjects, you'd get
G1C1=[ones(1,18)/18 zeros(1,9) 1 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
0]
and
G1C2=[ones(1,18)/18 zeros(1,9) 1 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
0]
and
G2C1=[zeros(1,18) ones(1,9)/9 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0]
and
G2C2=[zeros(1,18) ones(1,9)/9 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0]

Now subtract G1C1-G1C2 AND G2C2-G2C1
G1C1-G1C2=[zeros(1,27) 0 0 1 -1 0 0 0 0 0 1 -1 0 0 0 0 0 0 0 0 0 0 0 0]
and
G2C1-G2C2=[zeros(1,27) 0 0 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0]

Now subtract these two:
Interaction contrast=[zeros(1,27) 0 0 0 0 0 0 0 0 0 1 -1 0 0 0 0 0 -1
1 0 0 0 0 0]

In your case, if you start with G-H for Males in group A/C:
1 -1 0 0 0 0...

Then Males in group A/D:
0 0 1 -1 0 0....

Subtracting these gives you the interaction of factor 2 and 3 for A males.

1 -1 -1 1 0 0 0 0 0...

You can repeat for A females.

0 0 0 0 0 0 0 0 1 -1 -1 1 0 0 0 0

Now you can do the same for B males and B females:
0 0 0 0 1 -1 -1 1 0 0 0 0 0 0 0 0 and 0 0 0 0 0 0 0 0 0 0 0 0 1 -1 -1 1

Now subtract A from B after adding males and females:
1 -1 -1 1 -1 1 1 -1 1 -1 -1 1 -1 1 1 -1

This will work for any contrast that you ever want to make.




>
> is correct? thank you very much!
>
> look forward for your reply!
>
>
> Bo Xiang
>
>
>
>
>
>
> At 2012-11-21 04:07:37,"MCLAREN, Donald" <mclaren.don...@gmail.com
> > wrote:
> >On Tue, Nov 20, 2012 at 12:56 PM, Douglas N Greve
> ><gr...@nmr.mgh.harvard.edu> wrote:
> >> Thanks Donald. Is this the standard way to do this? I had used 8 rows
> >> instead of 4 with the difference being that 8 rows gives you an opportunity
> >> to look for an effect in males OR females.
> >
> >Yes. Having 8 rows would tell you if you have an interaction between
> >factor 1 and 2 in either males or females. My 4 rows only tell you if
> >the interaction exists. Technically speaking, one would run the
> >three-way interaction first. If nothing existed then you do the
> >two-way interaction as I suggested. If there is a three-way
> >interaction, then you would use Doug's approach of the interaction in
> >either males or females.
> >
> >If there is an effect in both
> >> males and females but the effects go in opposite directions, then the 4 row
> >> implementation will resolve to 0 (no effect). Or am I misunderstanding
> >> something (again:)?
> >
> >Nope. You are right. If the male and female effects are different,
> >then they could cancel each other out. If you suspect this to be the
> >case, then you should be able to demonstrate a three-way interaction.
> >
> >> thanks!
> >> doug
> >>
> >>
> >> On 11/20/2012 01:50 PM, MCLAREN, Donald wrote:
> >>>
> >>> Bo,
> >>>
> >>> Doug asked me to chime in on your issue. Here are some points that you
> >>> (and others) will hopefully find useful.
> >>>
> >>> (1) Inferences are two-step process. First, you create and estimate
> >>> the design matrix. Every column in the design matrix accounts can
> >>> account for some of the variance in the data. Second, you have
> >>> contrasts that allow you to infer specific effects. Because the model
> >>> contains your covariates, you are always controlling for the
> >>> covariates and by extension any factor/covariate not in the contrast.
> >>>
> >>> (2) Forming contrasts is often the most difficult thing to do. I
> >>> assume that your three factors (1, 2, and gender) are all
> >>> between-subject factors. If one of them is a within-subject factor
> >>> please let me know and disregard the rest of the email. The final
> >>> F-contrast will have 4 rows (factor 1 levels-1)*(factor 2 levels
> >>> -1)=(3-1)*(3-1)=2*2=4
> >>>
> >>> The following is an outline for creating contrasts:
> >>> (a) Start simple - difference between levels of 1 factor
> >>> (b) Define your null hypothesis: AO=AP=AQ
> >>> (c) Make it equal to 0: AO-AP=0 AND AP-AQ=0
> >>> (d) Repeat for the other levels of the factor...
> >>> BO-BP=0 AND BP-BQ=0
> >>> CO-CP=0 AND CP-CQ=0
> >>>
> >>> (e) Now combine them AO-AP=BO-BP=CO-CP AND AP-AQ=BP-BQ=CP-CQ
> >>>
> >>> (f) Make them equal to 0:
> >>> AO-AP-BO+BP=0
> >>> BO-BP-CO+CP=0
> >>> AP-AQ-BP+BQ=0
> >>> BP-BQ-CP+CQ=0
> >>>
> >>> (g) Expand them to include gender, for example:
> >>> AO-AP-BO+BP=0 becomes FAO-FAP-FBO+FBP+MAO-MAP-MBO+MBP=0
> >>>
> >>> Since the contrast now has 2 columns per level, you should divide all
> >>> values by 2. This will produce the correct amplitude and statistics.
> >>> If you leave the values as 1 and -1, then you will have an incorrect
> >>> amplitude, but the statistics will still be correct.
> >>>
> >>> (h) Fill in the respective columns of your design matrix.
> >>>
> >>> (3) The degrees of freedom are defined based on the rows of the
> >>> F-matrix and the number of rows in the design matrix. The F-test has a
> >>> numerator and denominator degrees of freedom. F(n,d).
> >>>
> >>> Best Regards, Donald McLaren
> >>> =================
> >>> D.G. McLaren, Ph.D.
> >>> Research Fellow, Department of Neurology, Massachusetts General Hospital
> >>> and
> >>> Harvard Medical School
> >>> Postdoctoral Research Fellow, GRECC, Bedford VA
> >>> Website: http://www.martinos.org/~mclaren
>
> >>> Office: (773) 406-2464
> >>> =====================
> >>> This e-mail contains CONFIDENTIAL INFORMATION which may contain PROTECTED
> >>> HEALTHCARE INFORMATION and may also be LEGALLY PRIVILEGED and which is
> >>> intended only for the use of the individual or entity named above. If the
> >>> reader of the e-mail is not the intended recipient or the employee or
> >>> agent
> >>> responsible for delivering it to the intended recipient, you are hereby
> >>> notified that you are in possession of confidential and privileged
> >>> information. Any unauthorized use, disclosure, copying or the taking of
> >>> any
> >>> action in reliance on the contents of this information is strictly
> >>> prohibited and may be unlawful. If you have received this e-mail
> >>> unintentionally, please immediately notify the sender via telephone at
> >>> (773)
> >>> 406-2464 or email.
> >>>
> >>>
> >>> On Tue, Nov 20, 2012 at 8:17 AM, xiangbo_2010<xiangbo_2...@126.com>
> >>> wrote:
> >>>>
> >>>> Dear doug
> >>>>     Thank you for your reply!
> >>>> +AOM -BOM -APM -BPM    0    0    0    0    0
> >>>>   +AOM -BOM    0    0 -AQM +BQM    0    0    0
> >>>>   +AOM    0 -APM    0    0    0 -COM +CPM    0
> >>>>   +AOM    0    0    0 -AQM      -COM    0 +CQM
> >>>> there should be use 1 -1 or 0.5 -0.5? whether the -BPM should be change
> >>>> BPM?
> >>>> Thanks
> >>>>
> >>>> Bo Xiang
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>> At 2012-11-19 07:23:31,"Douglas Greve"<gr...@nmr.mgh.harvard.edu>  wrote:
> >>>>
> >>>>
> >>>> Hi Bo, you can think of  the Ftest as a logical 'OR' between the t-test
> >>>> contrasts indicated in each row. Each row is a difference of differences,
> >>>> so
> >>>>
> >>>> 1. (A-B)om - (A-B)pm -->  Does the difference between A and B differ
> >>>> between
> >>>> groups O and P for Males?
> >>>> 2. (A-B)om - (A-B)qm
> >>>> 3. (A-C)om - (A-C)pm
> >>>> 4. (A-C)om - (A-C)qm
> >>>> 5. (A-B)of - (A-B)pf -->  Does the difference between A and B differ
> >>>> between
> >>>> groups O and P for Females?
> >>>> 6. (A-B)of - (A-B)qf
> >>>> 7. (A-C)of - (A-C)pf
> >>>> 8. (A-C)of - (A-C)pf
> >>>>
> >>>> I've put together the first 9 columns of the first 4 rows. The last 9
> >>>> columns are all 0s. For the last for rows, the 0s and below matrix are
> >>>> swapped to give you the same for the females
> >>>>
> >>>> doug
> >>>>
> >>>>   AOM  BOM  APM  BPM  AQM  BQM  COM  CPM  CQM
> >>>>
> >>>> --------------------------------------------------------------------------
> >>>>   +AOM -BOM -APM -BPM    0    0    0    0    0
> >>>>   +AOM -BOM    0    0 -AQM +BQM    0    0    0
> >>>>   +AOM    0 -APM    0    0    0 -COM +CPM    0&! nbsp;&nb sp;
> >>>>
> >>>>   +AOM    0    0    0 -AQM      -COM    0 +CQM
> >>>>
> >>>>
> >>>>
> >>>> On 11/17/12 9:21 PM, xiangbo_2010 wrote:
> >>>>
> >>>> Hi Freesurfer experts,
> >>>>
> >>>> I'm very sorry to bother you, but I am very confused with the following
> >>>> questions:
> >>>>
> >>>> My experimental design includes three discrete factors:  factor 1 with
> >>>> three
> >>>> levels (A,B,C ); factor 2 with three levels (O,P,Q); gender (F, M), and
> >>>> one
> >>>> covariate.
> >>>>
> >>>> So I can get 18 classes: FAO, FAP,FAQ,FBO,FBP,FBQ,FCO,FCP,FCQ,MAO,
> >>>> MAP,MAQ,MBO,MBP,MBQ,MCO,MCP,MCQ.  I want to perform the interaction
> >>>> between
> >>>> factor 1 and factor 2 regressing out the effect of gender and one
> >>>> covariate,
> >>>> but I don't know the rules for setting the contrasts for the F-test.  The
> >>>> contrast matrix I used is:
> >>>>
> >>>> 1 1 1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> >>>> 0
> >>>>
> >>>> 1 -1 0 1 -1 0 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> >>>> 0
> >>>>
> >>>> 1 1 1 0 0 0 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> >>>> 0
> >>>>
> >>>> 1 0 -1 1 0 -1 1 0 -1  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> >>>> 0
> >>>>
> >>>> 0 0 0 0 0 0 0 0 0 1 1 1 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> >>>> 0
> >>>>
> >>>> 0 0 0 0 0 0 0 0 0 1 -1 0 1 -1 0 1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> >>>> 0
> >>>>
> >>>> 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 -1 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> >>>> 0
> >>>>
> >>>> 0 0 0 0 0 0 0 0 0 1 0 -1 1 0 -1 1 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
> >>>> 0
> >>>>
> >>>> is it correct?
> >>>>
> >>>>
> >>>>
> >>>> Any help will be very appreciated.
> >>>>
> >>>>
> >>>>
> >>>> Best wishes,
> >>>>
> >>>>
> >>>>
> >>>> Bo Xiang
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>> _______________________________________________
> >>>> Freesurfer mailing list
> >>>> Freesurfer@nmr.mgh.harvard.edu
> >>>> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>> _______________________________________________
> >>>> Freesurfer mailing list
> >>>> Freesurfer@nmr.mgh.harvard.edu
> >>>> https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer
> >>>>
> >>>>
> >>>> The information in this e-mail is intended only for the person to whom it
> >>>> is
> >>>> addressed. If you believe this e-mail was sent to you in error and the
> >>>> e-mail
> >>>> contains patient information, please contact the Partners Compliance
> >>>> HelpLine at
> >>>> http://www.partners.org/complianceline . If the e-mail was sent to you in
> >>>> error
> >>>> but does not contain patient information, please contact the sender and
> >>>> properly
> >>>> dispose of the e-mail.
> >>>>
> >>>
> >>
> >> --
> >> Douglas N. Greve, Ph.D.
> >> MGH-NMR Center
> >> gr...@nmr.mgh.harvard.edu
> >> Phone Number: 617-724-2358
> >> Fax: 617-726-7422
> >>
> >> Bugs: surfer.nmr.mgh.harvard.edu/fswiki/BugReporting
> >> FileDrop: www.nmr.mgh.harvard.edu/facility/filedrop/index.html
> >> Outgoing: ftp://surfer.nmr.mgh.harvard.edu/transfer/outgoing/flat/greve/
> >>
> >_______________________________________________
> >Freesurfer mailing list
> >Freesurfer@nmr.mgh.harvard.edu
> >https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer
>
>
>
>
>
>
_______________________________________________
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.

Reply via email to