Automating a Calculation in SPSS

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Automating a Calculation in SPSS

wmartinez
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Automating a Calculation in SPSS

Richard Ristow
At 10:00 PM 7/1/2011, Will Martinez wrote:

>I am in the middle of analyzing data for a within-scale
>meta-analysis. Studies in the meta-analysis are being weighted by
>sample size using SPSS's weighting function. I decided to use
>proportional weights. The issue with proportional weights is that I
>have to continuously recalculate the weighting formulas as the
>number of studies I have for each analyses continually change. Let
>me explain further:
>
>This is the formula I am using to calculate weights for each study:
>
>COMPUTE weight=(n) * (k/N).
>
>Where "n" is the sample size of an outcome in my analysis, "k" is
>the number of outcomes being used in that particular analysis, and
>"N" is the total sample size of all the outcomes used in that analysis.

Let's see if I understand you correctly. You have a record structure
something like this:

StudyID  Outcome n {independent variables}

There's a record for each study, for each combination of independent
variables (this assumes all independent variables are categorical),
for each outcome observed,  giving the number of times ("n") that
outcome occurred in the study named, with those values of the
independent variables.

You *may* want something like this. Your data should initially be
active in a named dataset; I'm taking it as being named "Data". Code
not tested:

NUMERIC   Take_It  (F2).
VAR LABEL Take_It  'Record has data required for analysis'.
COMPUTE   Take_It =NMISS( {required independent variables} ) EQ 0.

SORT CASES
        BY Take_It  /* needed for later MATCH FILES */.

AGGREGATE OUTFILE = * MODE=ADDVARIABLES
   /BREAK=Take_It {required independent variables}
   /N 'Total sample size for analysis' = SUM(n).

*  Counting the number of different outcomes requires an   .
*  auxiliary dataset:                                      .

DATASET   DECLARE OutCount /* Do this only the first time*/.
AGGREGATE OUTFILE=OutCount
   /BREAK=Take_It Outcome
   /NOutcome 'Total instances of this outcome' = SUM(n).

DATASET  ACTIVATE OutCount WINDOW=FRONT.

AGGREGATE OUTFILE=*
   /BREAK=Take_It
   /k 'Total number of outcomes observed' = nu.

DATASET  ACTIVATE Data     WINDOW=FRONT.

MATCH FILES
   /FILE=*
   /TABLE=OutCount
   /BY    Take_It
   /KEEP =StudyID Outcome n N k ALL.

COMPUTE weight=(n) * (k/N).
FILTER BY Take_It.

*  ................................  ... .
*  Analyze to your heart's content!  ... .
*  ................................  ... .

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD
Reply | Threaded
Open this post in threaded view
|

Re: Automating a Calculation in SPSS

Rich Ulrich
In reply to this post by wmartinez
I suggest -- Do not change weights. 

I think your Weight for a study is the ratio of its N  to the average N,
with a total being the "number of studies."  (I find the description
confusing;  if that's not it, what else I say will be nonsense.)

IF you always use the same weight for every analysis, then the
d.f.  reported for the analysis is always a reflection of how complete
the data were;  that is a VERY GOOD thing.   I see no real benefit
from basing the numbers on the data available for one variable.

You want the tests to be as valid as possible, but you also want them
to be as comparable as possible.  The tests you get from these weighted
analyses are going to be approximations -- You do not lose much by
using the same weights, and you gain in what is comparable.  AND
you gain the ability to immediately note which variables are unlike the
others.

(/Pontificate ON).  A good meta-analysis is a rare thing.  It needs a
subject matter specialist to select the studies so that they are actually,
properly comparable, competent studies on the subject; and it needs
a flexible statistician to avoid the numerous pitfalls on that side.  Most
meta-analyses ever published have been pretty bad. 

One problem for testing and inferences arises from disproportionate weights.
You might have 100 studies, but if 80% of the weighting lies with 10 studies,
your effective d.f.  is closer to 10.  One strategy -- for yourself, if not for
publishing -- is to do a separate analysis for the small-N studies, reweighting.

And if some variables are available seldom, they should be treated with
some separate trepidation.

Another problem might be irrelevant, or it might not; I don't know what
"within-scale" means in your context.  But most studies, including meta-studies,
are best analyzed by focusing on a SINGLE outcome, or very few.  Sometimes
the criterion is obvious, like Relapse, or sometimes it is not hard to construct
two or three composite scores that will provide *overall*  tests of hypotheses.
The follow-up testing of dozens of variables is justified as an exploration of
the overall, significant test;  or else, the follow-up is relegated to being
"hopeful exploration" to guide in improving the design. (/Pontificate OFF).

--
Rich Ulrich



Date: Fri, 1 Jul 2011 21:00:20 -0500
From: [hidden email]
Subject: Automating a Calculation in SPSS
To: [hidden email]

Hello everyone,

First, I want to say that I have "lurked" on this listserv for about six months now and that, as a student, it has been nothing but extremely helpful and informative. I have a question I'd like to submit to the group to see if anyone has any ideas on how to automate this process.

I am in the middle of analyzing data for a within-scale meta-analysis. Studies in the meta-analysis are being weighted by sample size using SPSS's weighting function. If I just use a scaled weight (i.e., the sample size alone), my significance tests are inflated due to SPSS using the total sample size of all studies in my sample (over 22,000). So I decided to use proportional weights instead. However, the issue with proportional weights is that I have to continuously recalculate the weighting formulas as the number of studies I have for each analyses continually change. Let me explain further:

This is the formula I am using to calculate weights for each study:

COMPUTE weight=(n) * (k/N).

Where "n" is the sample size of an outcome in my analysis, "k" is the number of outcomes being used in that particular analysis, and "N" is the total sample size of all the outcomes used in that analysis.

So for instance, lets say I want to compare age and trauma, I may have 110 available outcomes but if I compare gender and trauma I have a total of 95 available outcomes that have data on both variables. Because the studies used in these analyses differ, the weight variable has to be recalculated each time. I have at least 50 different analyses (and possible more) to run on this data therefore you can see how cumbersome this can become.

Is there a syntax I could use to essentially tell SPSS to:

a) Select only studies with data on all variables in the analyses
2) Calculating "k" and "N" of those studies
3) Plugging in "k" and "N" into our formula.

I hope I was able to explain this adequately. I've tried the SPSS syntax manual and Google to no avail so any help is greatly appreciated.

Take care,

Will Martinez