阅读权限 255 威望 0 级论坛币 50288 个 通用积分 83.6306 学术水平 253 点 热心指数 300 点 信用等级 208 点 经验 41518 点 帖子 3256 精华 14 在线时间 766 小时 注册时间 2006-5-4 最后登录 2022-11-6
*** SPSS Syntax to accompany .
*.
*** Atkins, D. C. (2005). Using multilevel models to analyze couple and family
*** treatment data: Basic and advanced issues. Journal of Family Psychology, 19,
*** 98-110.
*.
*** Introductory: The following SPSS syntax demonstrates how to fit the models for
*** the examples from the article mentioned above, with the exception of the
*** simulations described in the power/sample size section, which is only available
*** in R. I have tried to make this file as clear as possible, but please don't
*** hesitate to contact me with questions and/or clarifications (or suggestions for
*** improvement!).
*.
*** Best, Dave Atkins (datkins@fuller.edu)
*.
*** Import data .
*.
*** NOTE: You'll need to change the /FILE to indicate where the file is saved .
*** on your computer .
GET DATA /TYPE = TXT
/FILE = 'C:\Temp\Atkins JFP data.dat'
/DELCASE = LINE
/DELIMITERS = "\t"
/QUALIFIER = '"'
/ARRANGEMENT = DELIMITED
/FIRSTCASE = 2
/IMPORTCASE = ALL
/VARIABLES =
id F2.1
sex F1.0
therapy F2.1
time F1.0
das F2.1
pilot F16.2
miss F1.0
m.ind F1.0
.
CACHE.
EXECUTE.
*** Save data after import .
*.
*** NOTE: Again, change location to where you'd like to save it .
SAVE OUTFILE='C:\Temp\JFP data.sav'
/COMPRESSED.
*** Value labels for therapy .
Value Labels therapy
-0.5 "Tx1" 0.5 "Tx2" .
*** Value labels for sex .
Value Labels sex
0 "Husband" 1 "Wife" .
************************ Two Level Example ******************* .
*.
*** In SPSS, we need to explicitly create quadratic .
COMPUTE time2 = time**2 .
EXECUTE .
*** To restrict analyses to Wives, need to "filter" Husbands .
USE ALL.
COMPUTE filter_$=(sex=1).
VARIABLE LABEL filter_$ 'sex=1 (FILTER)'.
VALUE LABELS filter_$ 0 'Not Selected' 1 'Selected'.
FORMAT filter_$ (f1.0).
FILTER BY filter_$.
EXECUTE .
*** Run the following command to "turn off" case selection (when you want to) .
FILTER OFF.
USE ALL.
EXECUTE .
*** Next, run HLM analysis with random intercept, slope, and quadratic .
MIXED
das BY id WITH therapy time time2
/FIXED = therapy time time2 therapy*time therapy*time2 | SSTYPE(3)
/METHOD = REML
/PRINT = CORB COVB SOLUTION TESTCOV
/RANDOM INTERCEPT time time2 | SUBJECT(id) COVTYPE(UN) .
*** NOTE: the above code treats "therapy" as a contiuous variable .
*** if we treat it as categorical (factor), SPSS gives the .
*** variable a different set of contrasts; this way we .
*** retain the -0.5, 0.5 contrasts .
*.
*** NOTE: You can use the /TEST command to get specific contrasts.
*** For example, you might try inserting the following .
*** commands after the /RANDOM statement above, but don't .
*** forget to move the "." to the end of the command .
*.
*** /TEST 'SLOPE - TX1-EST' time 1 therapy*time 1 0
*** /TEST 'SLOPE - TX2-EST' time 1 therapy*time 0 1
*** /TEST 'CONTRAST SLOPE ' therapy*time 1 -1
*** /TEST 'POOLED SLOPE' time 1 therapy*time 0.5 0.5
******* Multilevel Models for Longitudinal Couple and Family Data ****** .
*.
*** To run the model in equation 5, first turn off the "case selection" .
*** that we ran earlier to select only Wives (if you haven't already) .
MIXED
das BY id sex WITH therapy time time2
/FIXED = therapy time time2 therapy*time therapy*time2 | SSTYPE(3)
/METHOD = REML
/PRINT = COVB SOLUTION TESTCOV
/RANDOM INTERCEPT | SUBJECT(id*sex) COVTYPE(UN)
/RANDOM INTERCEPT time time2 | SUBJECT(id) COVTYPE(UN)
/SAVE RESID .
*** NOTE: The command above saves the level-1 residuals via the /SAVE .
*** statement. This creates a new column in the datafile with the level-1 .
*** residuals, which can then be used to examine the distributional .
*** assumptions. Unfortunately, it is not straightforward to have SPSS .
*** save the Empirical Bayes residuals of the level-2 and level-3 .
*** random-effects. In a very thorough review of the MIXED command in .
*** SPSS, Alastair Leyland shows how it is possible to calculate the .
*** EB residuals: http://multilevel.ioe.ac.uk/softrev/index.html .
*.
*** To fit the multivariate model in equation 6, we need to create vectors .
*** that specify male intercept, female intercept, male slope, and female slope .
*.
*** We can recode from our sex variable to create the intercepts .
RECODE sex (0=0) (1=1) INTO f.int .
RECODE sex (0=1) (1=0) INTO m.int .
EXECUTE .
*** Now, slopes .
COMPUTE f.slope = f.int*time .
COMPUTE m.slope = m.int*time .
EXECUTE .
*** Now we can run the multivariate model; notice that we exclude the intercept .
*** from both the /FIXED and /RANDOM statements .
MIXED
das BY id WITH f.int m.int f.slope m.slope
/FIXED = f.int m.int f.slope m.slope | NOINT SSTYPE(3)
/METHOD = REML
/PRINT = COVB CORB SOLUTION TESTCOV
/RANDOM f.int m.int f.slope m.slope | SUBJECT(id) COVTYPE(UN) .
*** We could easily extend this model to include quadratic effects and .
*** interactions with therapy. However, the random-effects parameters .
*** in multivariate models grow very quickly. You can end up "over-fitting" .
*** your data, leading to convergence problems and ill-conditioned .
*** random-effects matrices .
*.
********************* Missing Data Example *******************************.
*.
*** The missing data section doesn't really require any special models; if you .
*** wish to reproduce the analyses in the manuscript, use the "miss" variable to select only .
*** those cases with a value of 0 (to mimic missing data); then, m.ind is the .
*** the missing data indicator variable (our pattern) .
*.
*** To restrict analyses to miss = 0 .
USE ALL.
COMPUTE filter_$=(miss=0).
VARIABLE LABEL filter_$ 'miss=0 (FILTER)'.
VALUE LABELS filter_$ 0 'Not Selected' 1 'Selected'.
FORMAT filter_$ (f1.0).
FILTER BY filter_$.
EXECUTE .
*** Run the following command to "turn off" case selection (when you want to) .
FILTER OFF.
USE ALL.
EXECUTE .
*** Here's the command to run the model in equation 7 .
MIXED
das BY id sex WITH therapy m.ind time
/FIXED = therapy m.ind therapy*m.ind time therapy*time m.ind*time therapy*m.ind*time | SSTYPE(3)
/METHOD = REML
/PRINT = COVB SOLUTION TESTCOV
/RANDOM INTERCEPT | SUBJECT(id*sex) COVTYPE(UN)
/RANDOM INTERCEPT time | SUBJECT(id) COVTYPE(UN) .
*** Use the output from the above command along with the description in the text .
*** to estimate the pattern-mixture models .
*.
*** Simulation and power: These analyses are only possible using R; however, I have .
*** recently discovered that Raudenbush, Liu, and Congdon have extended the power .
*** analyses functions of their Optimal Design software to handle some 3-level .
*** models. The program and manual can be downloaded here:
*.
*** http://www.ssicentral.com/other/hlmod.htm
. 复制代码