- 最后登录
- 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的名称就可以了。/ O% _7 X" h( p& i# E
5 z: o0 D; I9 {, s& m8 E7 i. q/ i*****************.
$ g# K) ]# n' odesc b1 b2/save.! Y! \" L2 }, i& c# s
compute idv = zb1.( q* P$ y6 W: B8 a% B' e7 z s5 K" J u
compute mod = zb2.
- w! V/ {; U+ x* p$ t1 ^compute x = idv * mod.' C' l( n O4 S# `
compute dv = b3.
* B- L4 [8 \* }! L7 j) g" b2 X7 K/ v# O
regression
; r& @- |# K G3 Z3 _4 A /matrix out ('filename') + k9 u+ m! }+ c3 h- N( M$ C
/var= idv mod x dv
$ ~ L' `4 {' T7 ~ /statistics=defaults zpp bcov P! m2 \7 l% q* L( v7 H/ e
/dependent=dv: y3 A4 U* m# [# ~+ q
/enter idv mod
8 \! z/ s# |* H8 T7 c: w /test (x) . t) M' t y! t. K- S
/ w- H2 J/ Y# O6 _/ p
set mxloops=65.
& m5 b& V2 y& }: ]3 u1 w+ m- o1 D, Lmatrix.* x6 Y: N- o* }+ I/ L) D. r5 ~3 z
/ w$ p: P" s6 n# Z K+ Q+ I7 ^
compute multiMOD = 1.0 .
; x* u- G: H' f* Q+ G, ?' t- V0 Bcompute multiIDV = 1.0 .6 H7 |" C) w* N) c
compute dichotom = 0 .% p2 q" w% t' r9 J( l d. w" O
compute dichotLo = 1 .7 \ w: f: [6 K8 c# ~: a
compute dichotHi = 2 .
& }! g8 X4 `0 x7 V0 y% p% |, Pmget /file='filename'.7 _6 Z5 V. r* T' [& D2 Z ]2 W
; }3 f! E" l/ j* Overall regression coeffs.
- s' S3 O/ K3 B$ Jcompute beta = inv(cr(1:3,1:3)) * cr(1:3,4) .8 b3 J- x1 F# S, ~' E
compute b = (sd(1,4) &/ sd(1,1:3)) &* t(beta) .
/ |" u' W7 E* n# I+ s$ d. Bcompute a = mn(1,4) - ( rsum ( mn(1,1:3) &* b ) ) .
5 t5 ?# Z( l7 p6 }# y% h* ^% mcompute r2all = t(beta) * cr(1:3,4) .6 Z- J/ N1 v" Y# |
compute r2main = t(inv(cr(1:2,1:2))*cr(1:2,4))*cr(1:2,4).7 u8 M) Y& A9 _- p
compute r2chXn = r2all - r2main.) f8 e" x# ~& h
compute fsquare = (r2all - r2main) / (1 - r2all) .( A0 v5 U* L* f F" b; z8 h
compute F = (r2all-r2main) / ((1-r2all)/(nc(1,1)-3-1)).
r9 C U- z/ T' c: G6 j5 \compute dferror = nc(1,1) - 3 - 1.! R; m3 a$ \1 I# X4 q# \: Q% X
compute pF = 1 - fcdf(F,1,dferror) .
}2 m ~! x- v& S0 j1 c( ~. w* Z" I3 H; n- y
print {r2chXn,F,{1},dferror,fsquare,pF} /title="Coefficients for the Interaction"
; G( i0 p8 W- k+ c7 k /clabels="Rsq. ch." "F" "df num." "df denom." "f-squared" "Sig. F".- Z* g# F/ N+ i) ], S; p, Y
print {t(b),beta} /title="Beta weights for the full equation:"7 H) B, b9 Q/ m" X4 Q
/rlabels="idv" "mod" "Xn" /clabels="raw b" "std.beta" .
; C# M3 y* ?- Q5 i( C4 T" cprint a /title="The intercept is:" .4 o0 z' D( w ^ i4 K/ R6 c
: a) \6 n+ u. l( I6 p5 v9 _% f$ q# o0 |
* simple slopes info . ^0 i% r9 w( E
compute modlo = mn(1,2) - (sd(1,2) * multiMOD) .
) l; o0 W: f/ N0 W- Hcompute modmd = mn(1,2).
* J# M( e6 L8 Lcompute modhi = mn(1,2) + (sd(1,2) * multiMOD) .2 \9 p3 j. \; F$ S8 n
compute slopes={(b(1,1)+(b(1,3)*modlo)) ; G: S; {1 b1 t* K8 o- r! W7 `. G# l
(b(1,1)+(b(1,3)*modmd)) ; (b(1,1)+(b(1,3)*modhi)) }.
. S' h$ i. u1 Y" O) @2 {compute aslopes={ (b(1,2)*modlo+a) ; (b(1,2)*modmd+a) ; (b(1,2)*modhi+a) }.
3 L( R7 V% b& o2 c0 ^: i: hcompute mse = (nc(1,1)/(nc(1,1)-3))*(sd(1,4)**2)*(1-r2all).$ m' `: f) P3 @2 ~4 F% d6 p. h
compute Sb=mse*inv((mdiag(sd(1,1:3))*cr(1:3,1:3)*mdiag(sd(1,1:3)))*(nc(1,1)-1)).
0 T$ G8 m- f: K0 wcompute SEslopes={ (sqrt ( {1,0,modlo} * Sb * t({1,0,modlo}) )) ;
2 y7 F* j6 Q* z; S: \$ m5 a8 E (sqrt ( {1,0,modmd} * Sb * t({1,0,modmd}) )) ;
) C8 M0 |0 n& k4 @* @6 T (sqrt ( {1,0,modhi} * Sb * t({1,0,modhi}) )) }.
8 J _( E( M fcompute tslopes = slopes &/ SEslopes .
V5 @1 A- l( g* T7 {+ r. t' Scompute df = { (nc(1,1)-3-1) ; (nc(1,1)-3-1) ; (nc(1,1)-3-1) }.
# x) S4 q, m: g+ A0 Pcompute zslopes = slopes &* (sd(1,1)/sd(1,4)).4 F& m; Z+ u. |, n
compute zSE = SEslopes &* (sd(1,1)/sd(1,4)) .1 F$ ]+ m9 g9 ]7 Z- `- w
compute dfs = nc(1,1)-3-1 .+ A# L. k6 I: U7 ] H: s
compute pslopes = (1 - tcdf(abs(tslopes),dfs)) * 2., Y8 ]9 z* p6 b- h: i
! k0 L8 ~ j1 p' o, g* df & t values -- from Darlington p 516 & Howell 87 p 586 -- p = 05 two-tailed .: c5 f' O# }+ |* x
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,, k- i, ~+ B7 D5 o' e& g8 c
30,32,34,36,38,40,43,46,49,52,56,60,65,70,75,80,85,90,95,100,110,120,130,& [0 U; ]" t- a
150,175,200,250,300,400,500,600,700,800,900,1000,1000000000;
/ C% y2 g6 w& \8 o/ k 12.706,4.303,3.182,2.776,2.571,2.447,2.365,2.306,2.262,2.228,2.201,2.179,) j6 p- M8 K W) A5 c. e" p! z
2.160,2.145,2.131,2.120,2.110,2.101,2.093,2.086,2.074,2.064,2.056,2.048,: ]# M# ?' L: H. p% G4 Z: Q
2.042,2.037,2.032,2.028,2.024,2.021,2.017,2.013,2.010,2.007,2.003,2.000,! v/ i. l& r* O" @) v* }
1.997,1.994,1.992,1.990,1.988,1.987,1.985,1.984,1.982,1.980,1.978,1.976,
$ z8 V: d2 `% I, K+ Q8 u/ { 1.974,1.972,1.969,1.968,1.966,1.965,1.964,1.963,1.963,1.963,1.962,1.962 }.
5 k3 C/ y8 E9 Q1 L+ mcompute tabledT = 0.
6 F; n2 |9 _- o' I+ [loop #a = 1 to 59 .. w; O% U5 {& q
do if (dfs ge dft(1,#a) and dfs < dft(1,#a+1) ).
+ V3 N# Y) `2 U2 E1 ?- y6 S3 r8 Tcompute tabledT = dft(2,#a) .
& H3 v6 H/ f3 n& Aend if.
C% k' `7 E. I; Q0 j: ^end loop if (tabledT > 0).
% v4 [2 m( i3 v$ ]; z5 wcompute confidLo = (zslopes - (tabledT &* zSE)) .8 o" C) M+ ^* F- z: B; P
compute confidHi = (zslopes + (tabledT &* zSE)) .( c0 V, ^% @( G% p
3 A4 e0 a/ A, g) J. k4 t8 a
print { aslopes , slopes , tslopes , df , pslopes}
7 D1 A+ ?) s' a, q/ ^/ x L3 K- v /title="Simple Slope Coefficients for the DV on the IDV at 3"
' y; e3 E% A$ S* U+ ^) R N+ " levels of the Moderator:"
1 K! w9 H; F. Z- S+ K8 X /rlabels="Mod=low" "Mod=med" "Mod=high"7 D' p+ k3 }) h% j: q
/clabels="a" "raw b" "t-test" "df" "Sig. T".' d; k, R- Q& i1 Y
print { zslopes , zSE , confidLO, confidHI } : d" F' Y& b ]) ^
/title="Standardized Simple Slopes & 95% Confidence Intervals: "
3 h/ p5 V) p% ^3 m /rlabels="Mod=low" "Mod=med" "Mod=high" ! X4 R, [; q( x- C
/clabels="std. beta" "SE" "95% Low" "95% Hi".3 {: v+ x$ I" t w6 [0 {: J
print ((b(1,1)/b(1,3))*-1)/title="The simple slope for the DV on the IDV"3 c6 G- @" T8 B1 m" K' F- @( v: [
+ " is zero (flat) at Moderator ="./ e9 T r' W5 Z' c+ U/ T7 p
print ((b(1,2)/b(1,3))*-1)/title="The simple regression lines at ") ]! _; Y2 T* j, h
+ "Mod=high and Mod=low intersect at IDV =".
6 d) M1 T" @% M- ~( d; z! j' m0 G! q+ _. T/ `" i" L' ^4 \6 c) R
# m; S" f% _: p1 K' C* data for plot.
! c. Y! D+ U7 P4 m; g% v% Jcompute idvlo = mn(1,1) - (sd(1,1) * multiIDV).' w# Z5 w) T" V
compute idvhi = mn(1,1) + (sd(1,1) * multiIDV) .- b C( S# Z0 ~" t* N0 S8 t% I
compute idv = { idvlo; idvhi; idvlo; idvhi; idvlo; idvhi } .6 X* u" }2 h% `1 V { M
do if (dichotom = 1).
7 K# o1 y" o& O: L; ecompute idv = { dichotLO;dichotHi; dichotLO;dichotHi; dichotLO;dichotHi }.
7 D# l! o6 b/ {1 T4 f( H/ oend if.
" e! _5 K7 {8 G; V2 X$ P3 Ecompute moder = { modlo;modlo;modmd;modmd;modhi;modhi }.3 c% x( O7 m& l; X$ O1 _+ X
compute dv = (b(1,1)&*idv)+(b(1,2)&*moder)+(b(1,3)&*idv&*moder)+a.
* ~7 g# u, y0 y6 ^( _compute data = { idv , moder , dv }.# v0 p5 `; D1 L) j+ c# b6 ^! F3 [/ [
' `/ D9 M0 M# _
print data /title="Data for simple slope plots:" /clabels="IV" "Moderator" "DV" .% V* T4 P" `3 G- k" S
+ U0 d2 C# F' D, E/ i3 Osave data /outfile=* / var=zb1 zb2 b3.8 \' s4 F% }: b5 j. E$ M
. h* k: n8 e$ l$ l, Yend matrix./ X6 B6 Y9 b. g C2 p* l3 w, m+ I
7 L$ K! T$ {% X: q+ T
plot vsize=15 / hsize=50 / format=contour(3) / plot=b3 with zb1 by zb2.
8 c2 W" T, @. V8 w! ~" U ?7 r/ ]7 P+ ^graph / line = mean (b3) by b1 by b2." O: M4 m7 s( ?
|
|