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]

st: lincom after margins


From   "Airey, David C" <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: lincom after margins
Date   Sat, 8 May 2010 12:42:14 -0500

.

I noticed that use of -lincom- after -margins- can make it easier to get linear combinations than -lincom- immediately after -regress-. Immediately after -regress-, you need to know what the coefficients mean. This is not so true after use of margins. Is the example below fair use?

clear

/* made up data, two factor regress/anova model
using margins & lincom to get simple main effect tests
after significant interaction */

input group dose y 
        1      1    1  
        1      1    2  
        1      1    3  
        1      2    4  
        1      2    5  
        1      2    6  
        1      3    9  
        1      3   10  
        1      3   11  
        1      4   14  
        1      4   15  
        1      4   16  
        0      1    0  
        0      1    1  
        0      1    2  
        0      2    2  
        0      2    3  
        0      2    4  
        0      3    3  
        0      3    4  
        0      3    5  
        0      4    5  
        0      4    6  
        0      4    7  
end

table group dose, c(mean y)

regress y i.group##i.dose

/* notes about coefficients:

_cons = group 0 at dose 1
1.group = group 1 at dose 1 - group 0 at dose 1
2.dose = group 0 at dose 2 - _cons
3.dose = group 0 at dose 3 - _cons
4.dose = group 0 at dose 4 - _cons
2.dose#1.group = (5-3)-(2-1) = 1 <-- a difference in the differences
	(group 1 at dose 2 - group 0 at dose 2) - (group 1 at dose 1 - group 0 at dose 1)
[email protected] = (10-4)-(2-1) = 5
	(group 1 at dose 3 - group 0 at dose 3) - (group 1 at dose 1 - group 0 at dose 1)
[email protected] = (15-6)-(2-1) = 8
	(group 1 at dose 4 - group 0 at dose 4) - (group 1 at dose 1 - group 0 at dose 1)
*/

/*
All pairwise comparions have:

_cons + ?.group + ?.dose + ?.group#?.dose

which simplify when ? refers to the base category not in the model

see <http://www.stata.com/support/faqs/stat/test1.html>,
section "Overparameterized ANOVA model" 
*/


/* group 1 at dose 1 ... why?
group0@dose1 + (group1@dose1 - group0@dose1) */

lincom _cons + 1.group


/* group 0 at dose 2 ... why?
group0@dose1 + (group0@dose2 - group0@dose1) */

lincom _cons + 2.dose

/* group 1 at dose 2 ...why?
group0@dose1 + (group0@dose2 - group0@dose1) + (group1@dose1 - group0@dose1) + 
	(group1@dose2 - group0@dose2) - (group1@dose1 - group0@dose1)
= group1@dose2, after simplification */

lincom _cons + 2.dose + 1.group + 2.dose#1.group

/* group 1 - group 0 at dose 2 ...
we can simplify from the lincom statements rather than the coefficients */

lincom 1.group + 2.dose#1.group

/* the other differences follow the same pattern */

lincom 1.group + 3.dose#1.group
lincom 1.group + 4.dose#1.group

/* but use of lincom after margins may be easier, e.g., */

regress y i.dose##i.group
margins i.dose##i.group, post
lincom 1.dose#1.group - 1.dose#0.group
lincom 2.dose#1.group - 2.dose#0.group
lincom 3.dose#1.group - 3.dose#0.group
lincom 4.dose#1.group - 4.dose#0.group

/* is this use of lincom after margins fair? */





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


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