Login  Register

Re: Percent Change Crosstabs

Posted by Bruce Weaver on May 28, 2013; 10:43pm
URL: http://spssx-discussion.165.s1.nabble.com/Percent-Change-Crosstabs-tp5720440p5720443.html

It sounds to me as if you want the risk difference (rather than the odds ratio, for example).  If so, you might want to look at this article by Cheung (2007):

   http://aje.oxfordjournals.org/content/166/11/1337.full

I've also included below some syntax I wrote after looking at that article myself a couple years ago.  

HTH.



* ==================================================================
*  File:   risk difference with robust SEs.SPS .
*  Date:   12-May-2011 .
*  Author:   Bruce Weaver, bweaver@lakeheadu.ca
* ================================================================== .

* Compute Huber-White robust variance when using
  using linear regression to obtain risk difference.

* Macro to define folder with SPSS sample data files.
define !spssdata () "C:\SPSSdata\" !enddefine.

new file.
dataset close all.
get file = !spssdata + "bankloan.sav".

* Variables in model:
  Y = default (1=Yes, 0=No)
  X1 = Age
  X2 = Education (3 indicator variables)
  X3 = Debt to Income Ratio
.

select if nmiss(default, age, ed, debtinc) EQ 0.

freq ed.
compute ed1 = (ed EQ 1).
compute ed2 = (ed EQ 2).
compute ed3 = (ed EQ 3).
compute ed45 = any(ed,4,5).
format ed1 to ed45 (f1.0).
crosstabs ed by ed1 to ed45.

graph histogram age.
* Center AGE on 20 (value near the minimum), and make unit 5 years.
compute AGE.20.5 = (age - 20)/5.
graph histogram age.20.5 .

graph histogram debtinc.
* Set unit = 5 for DEBTINC .
compute debtinc.0.5 = debtinc/5.
graph histogram debtinc.0.5 .


* First try GENLIN with LINK=IDENTITY and ERROR=BINOMIAL.

* Generalized Linear Models.
GENLIN default (REFERENCE=FIRST) WITH age ed2 ed3 ed45 debtinc
  /MODEL age ed2 ed3 ed45 debtinc INTERCEPT=YES
 DISTRIBUTION=BINOMIAL LINK=IDENTITY
  /CRITERIA METHOD=FISHER(1) SCALE=1 COVB=MODEL MAXITERATIONS=100 MAXSTEPHALVING=5
    PCONVERGE=1E-006(ABSOLUTE) SINGULAR=1E-012 ANALYSISTYPE=3(LR) CILEVEL=95 CITYPE=WALD LIKELIHOOD=FULL    
  /MISSING CLASSMISSING=EXCLUDE
  /PRINT CPS DESCRIPTIVES MODELINFO FIT SUMMARY SOLUTION.

* There are problems, which is not unusual according to Cheung (2007).

* Now try OLS linear regression -- save fitted values & residuals.

REGRESSION
  /STATISTICS COEFF
  /DEPENDENT default
  /METHOD=ENTER age.20.5 ed2 ed3 ed45 debtinc.0.5
  /SAVE PRED (fitted_y) RESID (residual).

* The constant = the risk (of Y being 1) when all explanatory variable = 0.
* The coefficients for the other variables are risk differences associated
* with a one-unit increase in that explanatory variable, controlling for the others.
* But because the Y-variable is conditionally dichotmous (rather than contitionally
* normal), the standard errors are not correct. This is why the Huber-White robust
* errors are needed.

* Run the same model via GENLIN.
GENLIN default WITH AGE.20.5 ed2 ed3 ed45 debtinc.0.5
  /MODEL AGE.20.5 ed2 ed3 ed45 debtinc.0.5 INTERCEPT=YES
 DISTRIBUTION=NORMAL LINK=IDENTITY
  /CRITERIA SCALE=MLE COVB=MODEL PCONVERGE=1E-006(ABSOLUTE) SINGULAR=1E-012 ANALYSISTYPE=3(LR)
    CILEVEL=95 CITYPE=WALD LIKELIHOOD=FULL
  /MISSING CLASSMISSING=EXCLUDE
  /PRINT CPS DESCRIPTIVES MODELINFO FIT SUMMARY SOLUTION
  /SAVE MEANPRED RESID.

* Results match those from REGRESSION very closely--slight
  differences are due to use of MLE rather than OLS.
* Note that this model still has incorrect standard errors.

* ---------------------------------------------------------------------- .
* Same model, but with COVB=ROBUST.
* This should give the Huber-White standard errors.
* Reference: https://www-304.ibm.com/support/docview.wss?uid=swg21477323 .
* ---------------------------------------------------------------------- .

GENLIN default WITH AGE.20.5 ed2 ed3 ed45 debtinc.0.5
  /MODEL AGE.20.5 ed2 ed3 ed45 debtinc.0.5 INTERCEPT=YES
 DISTRIBUTION=NORMAL LINK=IDENTITY
  /CRITERIA SCALE=MLE COVB=ROBUST PCONVERGE=1E-006(ABSOLUTE) SINGULAR=1E-012 ANALYSISTYPE=3(LR)
    CILEVEL=95 CITYPE=WALD LIKELIHOOD=FULL
  /MISSING CLASSMISSING=EXCLUDE
  /PRINT CPS DESCRIPTIVES MODELINFO FIT SUMMARY SOLUTION
  /SAVE MEANPRED RESID.

* The coefficients are the same as before, but
* now we have the correct, robust standard errors.

* ================================================================== .



DKUKEC wrote
Greetings,

Is it possible to calculate percent change in 2x2 crosstab?  If yes, can you please point me in the right direction.

I have a crosstab with two vars (treatment group (1) and control group (0)) x (recidivist (1) non-recidivist (0)).  I would like to be able to generate the percent difference in recivisim between the treatment group and the control group, and then percent change between the two vars.   I have reviewed the archives and internet; however, I was unsuccessful in my search.

Thank you,
Damir
--
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/).