Login  Register

Re: Repeated contrast for COXREG

Posted by Bruce Weaver on Jan 03, 2022; 10:28pm
URL: http://spssx-discussion.165.s1.nabble.com/Repeated-contrast-for-COXREG-tp5740927p5740928.html

Here is some code to play with for anyone who is interested in the question.


* Edit next line to point to the folder with the sample datasets.
GET FILE='C:\SPSSdata\telco.sav'.
DATASET NAME raw WINDOW=FRONT.

COXREG tenure
  /STATUS=churn(1)
  /CONTRAST (ed)=Repeated
  /METHOD=ENTER ed
  /PRINT=CI(95)
  /CRITERIA=PIN(.05) POUT(.10) ITERATE(20).

* Compute 4 variables with the coding shown above.
FREQUENCIES ed.
RECODE ed (1=.8) (2 3 4 5 = -0.2) INTO ed1.
RECODE ed (1 2 =.6) (3 4 5 = -0.4) INTO ed2.
RECODE ed (1 2 3 =.4) (4 5 = -0.6) INTO ed3.
RECODE ed (1 2 3 4=.2) (5 = -0.8) INTO ed4.
* Estimate model with 4 computed variables treated as covariates.
COXREG tenure
  /STATUS=churn(1)
  /METHOD=ENTER ed1 ed2 ed3 ed4
  /PRINT=CI(95)
  /CRITERIA=PIN(.05) POUT(.10) ITERATE(20).
* The coefficients & SEs for ed1 to ed4 match
* the coefficients & SEs from the previous model.

* I would have expected the following coding for REPEATED contrasts.
RECODE ed (1=1) (2=-1) (ELSE=0) into rep1.
RECODE ed (2=1) (3=-1) (ELSE=0) into rep2.
RECODE ed (3=1) (4=-1) (ELSE=0) into rep3.
RECODE ed (4=1) (5=-1) (ELSE=0) into rep4.
FORMATS rep1 to rep4 (F1).
COXREG tenure
  /STATUS=churn(1)
  /METHOD=ENTER rep1 to rep4
  /PRINT=CI(95)
  /CRITERIA=PIN(.05) POUT(.10) ITERATE(20).
* But clearly, this way of coding the contrasts gives very different results.

* Show that it works as expected using GLM/UNIANOVA.
* First, include a REPEATED contrast and a series of
* LMATRIX sub-commands that make the same contrasts.
UNIANOVA income BY ed
  /CONTRAST(ed)=Repeated
  /lmatrix "level 1 versus level 2" ed 1 -1 0 0 0
  /lmatrix "level 2 versus level 3" ed 0 1 -1 0 0
  /lmatrix "level 3 versus level 4" ed 0 0 1 -1 0
  /lmatrix "level 4 versus level 5" ed 0 0 0 1 -1
  /DESIGN=ed.
* Second, use the rep1 to rep4 variables computed above.
UNIANOVA income WITH rep1 to rep4 /PRINT=PARAMETER.
* Hmm.  Those results do not match the CONTRAST or LMATRIX results above.
* Try again using ed1 to ed4 variables computed above.
UNIANOVA income WITH ed1 to ed4 /PRINT=PARAMETER.
* The coefficients for ed1 to ed4 do match the results from CONTRAST & LMATRIX.
* I suppose it could have something to do with the unbalanced design.  
* I'll have to think about this some more.
--
Bruce Weaver
bweaver@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/

"When all else fails, RTFM."

PLEASE NOTE THE FOLLOWING: 
1. My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above.
2. The SPSSX Discussion forum on Nabble is no longer linked to the SPSSX-L listserv administered by UGA (https://listserv.uga.edu/).