- 最后登录
- 2014-6-18
- 注册时间
- 2009-3-1
- 威望
- 0
- 金钱
- 274
- 贡献
- 215
- 阅读权限
- 20
- 积分
- 489
- 日志
- 0
- 记录
- 0
- 帖子
- 56
- 主题
- 7
- 精华
- 0
- 好友
- 0
  
- 注册时间
- 2009-3-1
- 最后登录
- 2014-6-18
- 积分
- 489
- 精华
- 0
- 主题
- 7
- 帖子
- 56
|
我来分享一个计算simple slope effect和画图的SPSS macro (https://people.ok.ubc.ca/brioconn/simple/simple.html)。大家只要自行修改下面Macro中b1,b2,b3的名称就可以了。+ k4 M+ k) H# s# k5 X- O
0 c- L5 ]8 x) y( Y1 M*****************.
3 v6 y9 I% T6 o0 \+ Xdesc b1 b2/save.
$ j c9 {5 A; J7 t% `1 pcompute idv = zb1. S6 X C6 O- F$ a0 q. b9 C
compute mod = zb2.
6 o' ?* a# r: ?8 |6 Bcompute x = idv * mod.2 G" P ^6 d G
compute dv = b3.
: R2 u( f- a- E' J4 I- v- _" |- t/ T8 `' H* Q$ G
regression 9 ]+ O, I% z" J: R8 E
/matrix out ('filename')
1 U9 }8 U8 T% j" K /var= idv mod x dv 2 Q+ V0 }( A% ]- d
/statistics=defaults zpp bcov
* ^" I4 {. L: ?$ [2 }+ Z, c /dependent=dv/ w, x/ r$ L+ \, w* D; B. g
/enter idv mod : J# w- L: J# }3 P# Z
/test (x) .
, P' Z- A% N. l0 r- E- X" H( m- \! ~2 U2 |+ i9 P
set mxloops=65.) |4 p7 a3 W+ b; u
matrix.
$ e: Q. m; Q* R2 a+ a$ T8 E9 u$ d q: F+ j
compute multiMOD = 1.0 .' z. M' J9 A- A. l+ n
compute multiIDV = 1.0 .+ I( `, \$ H$ O+ q9 t% j6 k% S$ h
compute dichotom = 0 .0 O: H, S) w b, J% `0 o" S
compute dichotLo = 1 .
8 ~' F( I8 m7 U$ f3 x7 wcompute dichotHi = 2 .
, o6 G' c$ Z4 A# U: L9 P4 Z5 M* ^mget /file='filename'.
+ W- Z/ u% @' m7 c" T' {' ?6 S$ S! q0 k' ^" g6 U% m! o
* Overall regression coeffs.- r$ {6 F+ @$ Q+ h
compute beta = inv(cr(1:3,1:3)) * cr(1:3,4) .
! z+ j! w r" E# }( `compute b = (sd(1,4) &/ sd(1,1:3)) &* t(beta) .
; q- [# d5 I- L9 O& @" ]compute a = mn(1,4) - ( rsum ( mn(1,1:3) &* b ) ) .5 Q- G0 g! M2 j' R, j
compute r2all = t(beta) * cr(1:3,4) .
; Q/ ~; X9 ?( \$ ~4 Ncompute r2main = t(inv(cr(1:2,1:2))*cr(1:2,4))*cr(1:2,4).
) s. x q- Y+ A7 i; s% X- tcompute r2chXn = r2all - r2main.
+ C# V0 s* V1 `+ l R `5 s4 [2 rcompute fsquare = (r2all - r2main) / (1 - r2all) .# Y5 l7 w5 |/ q! m: W
compute F = (r2all-r2main) / ((1-r2all)/(nc(1,1)-3-1)).* e# S z% b0 H! D9 `; [& z' ^
compute dferror = nc(1,1) - 3 - 1./ D: |! ~& h' H7 m
compute pF = 1 - fcdf(F,1,dferror) .
: P& q) S( I6 Q! E' t [* W
+ Q' }: y' A) u) T2 Wprint {r2chXn,F,{1},dferror,fsquare,pF} /title="Coefficients for the Interaction"2 ]; f) T0 r3 W6 X# l
/clabels="Rsq. ch." "F" "df num." "df denom." "f-squared" "Sig. F"., q Z4 e' T3 j$ e
print {t(b),beta} /title="Beta weights for the full equation:"0 O6 T* F7 ]' e# H
/rlabels="idv" "mod" "Xn" /clabels="raw b" "std.beta" .4 V1 v/ M; n: ^3 h0 }6 u3 O6 n* k
print a /title="The intercept is:" .
^/ E4 s" b- t9 }0 J; b( L7 }% J! f6 d3 ]; O9 L
: |8 h2 \: U- w
* simple slopes info .2 T7 o& o$ @0 h; J; V
compute modlo = mn(1,2) - (sd(1,2) * multiMOD) ./ f/ n3 b4 e0 W- L; Y& w4 A
compute modmd = mn(1,2).6 v- A5 v2 j z: Z+ L& P+ l
compute modhi = mn(1,2) + (sd(1,2) * multiMOD) .+ d9 k& ?0 \7 v8 ^
compute slopes={(b(1,1)+(b(1,3)*modlo)) ;7 [. s! m- s& u5 Q
(b(1,1)+(b(1,3)*modmd)) ; (b(1,1)+(b(1,3)*modhi)) }." ?" G2 Y0 n' Y+ k4 t
compute aslopes={ (b(1,2)*modlo+a) ; (b(1,2)*modmd+a) ; (b(1,2)*modhi+a) }.+ X/ n. y: x M/ Y/ Z+ p7 ^
compute mse = (nc(1,1)/(nc(1,1)-3))*(sd(1,4)**2)*(1-r2all).& y c3 z5 S4 b& S
compute Sb=mse*inv((mdiag(sd(1,1:3))*cr(1:3,1:3)*mdiag(sd(1,1:3)))*(nc(1,1)-1))., [6 I# g: G F1 f6 P; J& \
compute SEslopes={ (sqrt ( {1,0,modlo} * Sb * t({1,0,modlo}) )) ;5 N3 W4 a# D) \5 P( @, X9 m' H
(sqrt ( {1,0,modmd} * Sb * t({1,0,modmd}) )) ;
# Z3 x: F8 t h3 R (sqrt ( {1,0,modhi} * Sb * t({1,0,modhi}) )) }.
1 G, ]; V, g4 G, y% f$ }compute tslopes = slopes &/ SEslopes .% s1 V- M3 M/ A, [! e- {
compute df = { (nc(1,1)-3-1) ; (nc(1,1)-3-1) ; (nc(1,1)-3-1) }.
* g- S; T) Z6 J$ bcompute zslopes = slopes &* (sd(1,1)/sd(1,4)).
& m' b. o0 H' K {" x" p1 [compute zSE = SEslopes &* (sd(1,1)/sd(1,4)) .
) L% I. }# b+ p! m5 m* Q; bcompute dfs = nc(1,1)-3-1 .
% V. P" S D& p( D' zcompute pslopes = (1 - tcdf(abs(tslopes),dfs)) * 2.' z, l' p. @. @& u. r
2 R% O" z) T v+ E* df & t values -- from Darlington p 516 & Howell 87 p 586 -- p = 05 two-tailed .$ {3 O' p) H. p% m
compute dft={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,22,24,26,28,
0 f( M2 U8 x5 @! w 30,32,34,36,38,40,43,46,49,52,56,60,65,70,75,80,85,90,95,100,110,120,130,) z. |1 p& \5 z/ N" y6 u3 f
150,175,200,250,300,400,500,600,700,800,900,1000,1000000000;
9 _' g3 Q! O7 b+ f 12.706,4.303,3.182,2.776,2.571,2.447,2.365,2.306,2.262,2.228,2.201,2.179,3 m" v1 Q4 Q8 r% a( ]* |' B
2.160,2.145,2.131,2.120,2.110,2.101,2.093,2.086,2.074,2.064,2.056,2.048,
& z) }; S; O$ U& l3 X+ B 2.042,2.037,2.032,2.028,2.024,2.021,2.017,2.013,2.010,2.007,2.003,2.000,% x1 A2 I# z7 N8 ]6 i1 Y; U
1.997,1.994,1.992,1.990,1.988,1.987,1.985,1.984,1.982,1.980,1.978,1.976,. y% r! B S' f* B0 R$ x$ `
1.974,1.972,1.969,1.968,1.966,1.965,1.964,1.963,1.963,1.963,1.962,1.962 }.& P9 L9 O$ X2 {* e# \
compute tabledT = 0.1 O# S* c1 e$ P1 d8 u ^: A
loop #a = 1 to 59 ., w' G& [ [8 {# r
do if (dfs ge dft(1,#a) and dfs < dft(1,#a+1) ).
9 a g+ j2 |' pcompute tabledT = dft(2,#a) .9 k* \* `4 \- F' M2 P! D
end if.$ |. A/ B. D7 w7 k
end loop if (tabledT > 0).' y/ g5 @- Z! ?( \1 b4 R6 Q! c T
compute confidLo = (zslopes - (tabledT &* zSE)) .+ F9 m) Z( {) S; v2 f. g; e
compute confidHi = (zslopes + (tabledT &* zSE)) .
' p8 u$ `1 C" O$ U3 h ?: d* Q! F6 V5 @' o
print { aslopes , slopes , tslopes , df , pslopes}
/ O m3 t8 H$ C4 s /title="Simple Slope Coefficients for the DV on the IDV at 3", ]4 H/ t/ v" c5 q
+ " levels of the Moderator:" * p J$ {9 o' t; w8 c' o/ L1 `: y
/rlabels="Mod=low" "Mod=med" "Mod=high": x! R. W! `/ B1 j% n( S! X
/clabels="a" "raw b" "t-test" "df" "Sig. T"., g! R, `/ z) i& t
print { zslopes , zSE , confidLO, confidHI }
# _0 {' Y- ~8 `4 z /title="Standardized Simple Slopes & 95% Confidence Intervals: "( }6 P; X( P" ?2 P% | R1 K+ `3 J
/rlabels="Mod=low" "Mod=med" "Mod=high" ! Y8 e& a8 t3 J. t
/clabels="std. beta" "SE" "95% Low" "95% Hi".
" R3 S* X4 q0 cprint ((b(1,1)/b(1,3))*-1)/title="The simple slope for the DV on the IDV"4 I) \4 E5 c7 `1 Z1 }/ N
+ " is zero (flat) at Moderator =".; Z% E: L0 B8 ]' Q, E* c$ H
print ((b(1,2)/b(1,3))*-1)/title="The simple regression lines at "- F* t, _8 m8 C% G/ p2 y/ o
+ "Mod=high and Mod=low intersect at IDV =".) J' m* R3 ~8 I% R
1 J/ C& q& N4 G8 W* \- L6 r3 [
9 H0 I" d7 X+ u: v* _, T( o* data for plot.& C) c6 t! B# V/ ^" v! e( u7 ~7 e
compute idvlo = mn(1,1) - (sd(1,1) * multiIDV).9 c, L4 O+ q; P, T% T8 r2 t
compute idvhi = mn(1,1) + (sd(1,1) * multiIDV) .- y7 U5 ^0 w, j( P8 j4 h" L
compute idv = { idvlo; idvhi; idvlo; idvhi; idvlo; idvhi } .1 ?5 P0 c3 k4 T, ^% F/ W
do if (dichotom = 1)., ?, P# b1 G0 e5 k# h K+ M8 {2 n( V
compute idv = { dichotLO;dichotHi; dichotLO;dichotHi; dichotLO;dichotHi }.
' j" x' U2 k g, a* d! Rend if.
: d5 T0 ~2 s4 ^0 V0 n$ b( a/ xcompute moder = { modlo;modlo;modmd;modmd;modhi;modhi }.4 I# ^, T- L3 M1 z
compute dv = (b(1,1)&*idv)+(b(1,2)&*moder)+(b(1,3)&*idv&*moder)+a.
, U: N$ u! w+ hcompute data = { idv , moder , dv }.
: K$ i- }% n" j3 t" R0 V/ W! O$ G& d) Z& }2 i4 l$ n% U2 }. Q! o
print data /title="Data for simple slope plots:" /clabels="IV" "Moderator" "DV" .
/ t( R" B& \. n9 u; |; i) L! v, x1 C0 |
save data /outfile=* / var=zb1 zb2 b3.: ~8 t% K* I- _; R4 ~- {3 F; Q: r
, a ^8 i& e% v/ `1 B
end matrix.
/ C! O0 ~, d' ~% N# X' f3 s8 [) m( r. s* ?
plot vsize=15 / hsize=50 / format=contour(3) / plot=b3 with zb1 by zb2.# s$ S, E( s4 y: t
graph / line = mean (b3) by b1 by b2., N& q3 J- }5 h9 a. t( z) z
|
|