LSMESTIMATE


LSMESTIMATE算是总和了ESTIMATE和LSMEANS,可以算最小二乘均值也可以用来比较。

逗号后的第一个数字是第一个变量,逗号后的第二个数字是第二个变量
数字表示是第几个值水平
如果有负号,逗号前的数字表示对比。如果没有就是算均值。
;

ACT 1就是ACT在VISIT 1的均值

OTH 3就是OTH在VISIT 3的均值

divisor算比例算均值会用到。

e选项是打出来L矩阵。

LSMESTIMATE vacgrp*visit 'Positional - - - OTH 3 means' 0 0 0 0 0 0 1 ,完整的应该是 0 0 0 0 0 0 1 0 0 0 0 0,后面的0不写也可以。

后面数字的长度是取决于LSMESTIMATE 后的变量值得水平个数,如果有*号,就是交叉相乘。
LSMESTIMATE vacgrp*visit 'Positional - - - ACT 1 means' 1 0 0 0 ,
                        'Nonpositional - - - ACT 1 means' [1,1 1] / e;
LSMESTIMATE vacgrp*visit 'Positional - - - OTH 3 means' 0 0 0 0 0 0 1 ,
                          'Nonpositional - - - OTH 3 means' [1,2 3]    / e;
LSMESTIMATE vacgrp 'Positional - - - OTH means' 0 1 0 ,
                    'Nonpositional - - - OTH means' [1,2] / e;
LSMESTIMATE vacgrp 'Positional - - - ACT and PBO means' 1 0 1 ,
                    'Nonpositional - - -  ACT and PBO  means' [1,1][1,3] / e;

LSMESTIMATE vacgrp 'Positional - - - ACT vs PBO means' 1 0 -1 ,
                    'Nonpositional - - -  ACT vs PBO means' [1,1][-1,3] / e;
LSMESTIMATE vacgrp 'Positional - - - ACT + OTH means' 1 1 0 ,
                    'Positional - - - PBO means' 0 0 1 ,
                    'Positional - - - ACT + OTH vs PBO means' 1 1 -1 ,
                    'Positional - - - avg(ACT,OTH) vs PBO means' 1 1 -2  DIVISOR = 2,
                    'Positional - - - avg(ACT,OTH) vs PBO means' 0.5 0.5 -1 ,
                    'Nonpositional - - - ACT + OTH vs PBO means' [1,1][1,2][-1,3],
                    'Nonpositional - - -  avg(ACT,OTH) vs PBO means' [1,1][1,2][-2,3] divisor = 2 / e;

LSMESTIMATE vacgrp*visit 'Positional - - - OTH 2+3+4  means' 0 0 0 0 0 1 1 1,
                          'Nonpositional - - - OTH 2+3+4 means' [1,2 2][1,2 3][1,2 4],
                          'Positional - - - avg(OTH 2+3+4)  means' 0 0 0 0 0 1 1 1  DIVISOR = 3,
                          'Nonpositional - - - avg(OTH 2+3+4) means' [1,2 2][1,2 3][1,2 4]  DIVISOR = 3,

                          'Positional - - - ACT 2+3+4  means' 0 1 1 1,
                          'Nonpositional - - - ACT 2+3+4 means' [1,1 2][1,1 3][1,1 4],
                          'Positional - - - avg(ACT 2+3+4)  means' 0 1 1 1  DIVISOR = 3,
                          'Nonpositional - - - avg(ACT 2+3+4) means' [1,1 2][1,1 3][1,1 4]  DIVISOR = 3,

                          'Positional - - - ACT 2+3+4 vs OTH 2+3+4 means' 0 1 1 1 0 -1 -1 -1,
                          'Nonpositional - - - ACT 2+3+4 vs OTH 2+3+4 means' [1,1 2][1,1 3][1,1 4][-1,2 2][-1,2 3][-1,2 4],
                          'Positional - - - avg(ACT 2+3+4) vs avg(OTH 2+3+4) means' 0 1 1 1 0 -1 -1 -1 DIVISOR = 3,
                          'Nonpositional - - - avg(ACT 2+3+4) vs avg(OTH 2+3+4) means' [1,1 2][1,1 3][1,1 4][-1,2 2][-1,2 3][-1,2 4] DIVISOR = 3,

                          'Positional - - - OTH 2 means' 0 0 0 0 0 1 0,
                          'Nonpositional - - - OTH 2 means' [1,2 2]    ,

                           'Positional - - - ACT 2+3+4 vs OTH 2 means' 0 1 1 1 0 -1 0 0 ,
                          'Nonpositional - - - ACT 2+3+4 vs OTH 2 means' [1,1 2][1,1 3][1,1 4][-1,2 2],
                           'Positional - - - avg(ACT 2+3+4) vs OTH 2 means' 0 1 1 1 0 -3 0 0 DIVISOR = 3,
                          'Nonpositional - - - avg(ACT 2+3+4) vs OTH 2 means' [1,1 2][1,1 3][1,1 4][-3,2 2] DIVISOR = 3

/ e;
data arthr;
 input vacgrp $ pat mo1 mo2 mo3 mo4;
 datalines;
ACT 101 6 3 0 3
ACT 103 7 3 1 2
ACT 104 4 1 2 8
ACT 107 8 4 3 1
PBO 102 6 5 5 7
PBO 105 9 4 6 6
PBO 106 5 3 4 3
PBO 108 6 2 3 9
OTH 109 7 6 4 6
OTH 113 8 5 5 7
OTH 116 4 2 5 4
OTH 123 7 3 5 9
; 

data discom; set arthr;
 keep vacgrp pat visit score;
 score = mo1; visit = 1; output;
 score = mo2; visit = 2; output;
 score = mo3; visit = 3; output;
 score = mo4; visit = 4; output;
run;

ods html;
proc mixed data = discom;
class vacgrp pat visit ;
model score = vacgrp visit visit*vacgrp / solution;
repeated visit / subject = pat(vacgrp) type=un r rcorr;
lsmeans vacgrp visit vacgrp*visit;

LSMESTIMATE vacgrp*visit 'Positional - - - ACT 1 means' 1 0 0 0 ,
                        'Nonpositional - - - ACT 1 means' [1,1 1] / e;
LSMESTIMATE vacgrp*visit 'Positional - - - OTH 3 means' 0 0 0 0 0 0 1 ,
                          'Nonpositional - - - OTH 3 means' [1,2 3]    / e;
LSMESTIMATE vacgrp 'Positional - - - OTH means' 0 1 0 ,
                    'Nonpositional - - - OTH means' [1,2] / e;
LSMESTIMATE vacgrp 'Positional - - - ACT and PBO means' 1 0 1 ,
                    'Nonpositional - - -  ACT and PBO  means' [1,1][1,3] / e;

LSMESTIMATE vacgrp 'Positional - - - ACT vs PBO means' 1 0 -1 ,
                    'Nonpositional - - -  ACT vs PBO means' [1,1][-1,3] / e;
LSMESTIMATE vacgrp 'Positional - - - ACT + OTH means' 1 1 0 ,
                    'Positional - - - PBO means' 0 0 1 ,
                    'Positional - - - ACT + OTH vs PBO means' 1 1 -1 ,
                    'Positional - - - avg(ACT,OTH) vs PBO means' 1 1 -2  DIVISOR = 2,
                    'Positional - - - avg(ACT,OTH) vs PBO means' 0.5 0.5 -1 ,
                    'Nonpositional - - - ACT + OTH vs PBO means' [1,1][1,2][-1,3],
                    'Nonpositional - - -  avg(ACT,OTH) vs PBO means' [1,1][1,2][-2,3] divisor = 2 / e;

LSMESTIMATE vacgrp*visit 'Positional - - - OTH 2+3+4  means' 0 0 0 0 0 1 1 1,
                          'Nonpositional - - - OTH 2+3+4 means' [1,2 2][1,2 3][1,2 4],
                          'Positional - - - avg(OTH 2+3+4)  means' 0 0 0 0 0 1 1 1  DIVISOR = 3,
                          'Nonpositional - - - avg(OTH 2+3+4) means' [1,2 2][1,2 3][1,2 4]  DIVISOR = 3,

                          'Positional - - - ACT 2+3+4  means' 0 1 1 1,
                          'Nonpositional - - - ACT 2+3+4 means' [1,1 2][1,1 3][1,1 4],
                          'Positional - - - avg(ACT 2+3+4)  means' 0 1 1 1  DIVISOR = 3,
                          'Nonpositional - - - avg(ACT 2+3+4) means' [1,1 2][1,1 3][1,1 4]  DIVISOR = 3,

                          'Positional - - - ACT 2+3+4 vs OTH 2+3+4 means' 0 1 1 1 0 -1 -1 -1,
                          'Nonpositional - - - ACT 2+3+4 vs OTH 2+3+4 means' [1,1 2][1,1 3][1,1 4][-1,2 2][-1,2 3][-1,2 4],
                          'Positional - - - avg(ACT 2+3+4) vs avg(OTH 2+3+4) means' 0 1 1 1 0 -1 -1 -1 DIVISOR = 3,
                          'Nonpositional - - - avg(ACT 2+3+4) vs avg(OTH 2+3+4) means' [1,1 2][1,1 3][1,1 4][-1,2 2][-1,2 3][-1,2 4] DIVISOR = 3,

                          'Positional - - - OTH 2 means' 0 0 0 0 0 1 0,
                          'Nonpositional - - - OTH 2 means' [1,2 2]    ,

                           'Positional - - - ACT 2+3+4 vs OTH 2 means' 0 1 1 1 0 -1 0 0 ,
                          'Nonpositional - - - ACT 2+3+4 vs OTH 2 means' [1,1 2][1,1 3][1,1 4][-1,2 2],
                           'Positional - - - avg(ACT 2+3+4) vs OTH 2 means' 0 1 1 1 0 -3 0 0 DIVISOR = 3,
                          'Nonpositional - - - avg(ACT 2+3+4) vs OTH 2 means' [1,1 2][1,1 3][1,1 4][-3,2 2] DIVISOR = 3/ e;

run;