GET
* FILE='C:\Documents and Settings\gillian raab\My Documents\aprojects\peas\web\exemp5\data\ex5.sav'.
* Line above reads in the data. If you have opened ex5.sav
interactively you won't need to include it.
* Next stage is to set up survey design.
You can do this interactively, via the complex samples menu.
* At the screen 1: just give a name to the plan file
screen 2: only the WEIGHT box needs to be filled (with gweight)
as there is no clustering or stratification.
* We have pasted the syntax here.
* we must be careful to use the GROSSING UP WEIGHT gweight
to get the right design effects in SPSS.
* Analysis Preparation Wizard.
CSPLAN ANALYSIS
/PLAN FILE='ex5.csaplan'
/PLANVARS ANALYSISWEIGHT=gweight
/PRINT PLAN
/DESIGN
/ESTIMATOR TYPE=WR.
*further steps can also be done from the menus
from the camplex samples sub-menu.
* and the code generated with paste button.
* Complex Samples Frequencies.
CSTABULATE
/PLAN FILE='ex5.csaplan'
/TABLES VARIABLES = genhelf q85a
/CELLS TABLEPCT
/STATISTICS SE COUNT DEFF
/MISSING SCOPE = TABLE CLASSMISSING = EXCLUDE.
* Complex Samples Descriptives.
CSDESCRIPTIVES
/PLAN FILE='ex5.csaplan'
/SUMMARY VARIABLES =genhelf sacc sinc
/MEAN
/STATISTICS SE COUNT DEFF
/MISSING SCOPE = ANALYSIS CLASSMISSING = EXCLUDE.
* Complex Samples Crosstabs.
CSTABULATE
/PLAN FILE='ex5.csaplan'
/TABLES VARIABLES = genhelf BY q85a
/CELLS COLPCT
/STATISTICS SE DEFF
/TEST INDEPENDENCE
/MISSING SCOPE = TABLE CLASSMISSING = EXCLUDE.
* Now with a finite population correction.
* Analysis Preparation Wizard.
CSPLAN ANALYSIS
/PLAN FILE='ex5.csaplan'
/PLANVARS ANALYSISWEIGHT=gweight
/PRINT PLAN
/DESIGN
/ESTIMATOR TYPE=EQUAL_WOR
/POPSIZE VALUE=29457.
* And rerunning to see what difference this makes in one case.
* Complex Samples Descriptives.
CSDESCRIPTIVES
/PLAN FILE='ex5.csaplan'
/SUMMARY VARIABLES =genhelf sacc sinc
/MEAN
/STATISTICS SE COUNT DEFF
/MISSING SCOPE = ANALYSIS CLASSMISSING = EXCLUDE.
* note that SPSS complex surveys does not currently do regressions
but that a weighted regression with weights that add to the number of subjects
will give identical estimates and for a survey like this with no stratification
or clustering it will give standard errors that are acceptable although based on
a model-based rather than a randomisation principle.
* we compare them here with what otehr packages give.
* first get the mean of the weights;
descriptives
VARIABLES=weight
/STATISTICS=MEAN .
* get a new weight that adds to sample size for all respondents.
* before the regressions we need to recode the cannabis and amphetamine variables.
compute nweight=weight/1.2055.
execute.
RECODE
q85a
(1=0) (2=0) (3=1) (4=1) (5=1) (6=0.5) INTO canscore .
VARIABLE LABELS canscore "'scored cannabis'".
RECODE
q85b
(1=0) (2=0) (3=1) (4=1) (5=1) (6=0.5) INTO ampscore .
VARIABLE LABELS ampscore "'scored amphetamines".
EXECUTE .
* now run various regressions.
REGRESSION
/MISSING LISTWISE
/REGWGT=nweight
/STATISTICS COEFF OUTS
/CRITERIA=PIN(.05) POUT(.10)
/NOORIGIN
/DEPENDENT genhelf
/METHOD=ENTER canscore .
REGRESSION
/MISSING LISTWISE
/REGWGT=nweight
/STATISTICS COEFF OUTS
/CRITERIA=PIN(.05) POUT(.10)
/NOORIGIN
/DEPENDENT genhelf
/METHOD=ENTER sinc .
REGRESSION
/MISSING LISTWISE
/REGWGT=nweight
/STATISTICS COEFF OUTS
/CRITERIA=PIN(.05) POUT(.10)
/NOORIGIN
/DEPENDENT genhelf
/METHOD=ENTER ampscore .
REGRESSION
/MISSING LISTWISE
/REGWGT=nweight
/STATISTICS COEFF OUTS
/CRITERIA=PIN(.05) POUT(.10)
/NOORIGIN
/DEPENDENT genhelf
/METHOD=ENTER canscore ampscore sinc .