Syntax for summations, but without the AGG function

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

Syntax for summations, but without the AGG function

Jonathan Olmsted
  All-

  While I can't be sure if my subject line is entirely
  accurate, I hope
  to expand on my problem/ question in some detail.  I
  am currently
  working with an aggregated .sav which was created
  from a long (40k
  cases) and wide (several hundred cars) where my
  aggregating factors
  were year and state.  Given that my original
  cumulative file was mostly
  a public opinion file- at least this is what I am
  concerned with- I
  know have a dataset of the same information only my
  unit of analysis
  has gone from Respondent to State.  There are
  several things I am
  attempting to do with this but I should hope that I
  can re-outfit
  syntax to address the multiple issues I have because
  they are
  relatively similar.

  Let 'state' be a variable over the 50 states, 'year'
  be a variable over
  60 (approx) years and each case is a unique
  combination of    'state' X
  'year'   so that based on the numbers above, I have
  300 cases.  Each of
  these 300 cases has values (or sysmis) on many
  variables which reflect
  the descriptives for a particular public opinion
  item.  Let 'opin1' be
  a question of public opinion in the original cum
  .sav (as opposed to my
  agg'd file).  Thus, there exist the vars
  'opin1_mean' 'opin1_median'
  '..._sd' '..._min' '..._max' and a var N which is
  valued according to
  the weighted number of original cases in each
  aggregate case (i.e.
  respondents in each state each year, after
  weighting).

  I am attempting to compute an O'brien reliability
  coefficient
  (Sociological Methods and Research, 1990) which is
  of no real
  signifigance here, just suffice it to say it is the
  appropriate measure
  and I am looking to compute it by hand, that is
  telling SPSS to
  manipulate certain values I have in certain ways.
   As a point of
  information, this measure accounts for the
  reliability of agg'd
  measures that are calculated from nested units of
  analysis.  This
  stands in contrast to something like cronbach's
  alpha which accounts for
  the reliability of a particular respondent.

  Now the heart of it.  I need to calculate xbar where
  xbar= the
  summation of {(nj X xbarj) / n}, where xbar is the
  weighted mean public
  opinion over aggregates 1 through k where 1<j<k
  (INCLUSIVE) , nj is the
  weighted n in the jth aggregate, xbarj is the mean
  in that jth
  aggregate.

  Generally, I want to calculate this xbar measure and
  dump it back into
  my agg.sav, but I do not know how to compute such a
  variable where the
  value in any given case reflects more than just the
  values specific to
  that case.  Notice that if xbar is dumped back into
  agg.sav it will
  have the same value for many of these already agg'd
  cases.  This may or
  may not seem peculiar.  The reason is that I will be
  computing
  something single factor ANOVA-esque on these agg'd
  values where time
  (or state) will be the factor where I compare a
  within value to a between value.
    I recognize that this can be done via the
  AGGREGATE command but I then need
  to manipulate these new agg'd values and as a result
  of there being several agg'd values
  will manipulate to compute the coefficient for each
  case, I am probably capable of punching
  it out sans SPSS just as quickly.  Is there some way
  to compute the variables and use them but only dump
  out the desired, manipulated values?

  So, I ask, does anyone know how to calculate such a
  thing via syntax.
  I have searched here and elsewhere and have not
  found anything.
  Hopefully I have not overlooked anything and am now
  wasting a bunch of
  1's and 0's.

  Thanks for your time!  Pursuers of knowledge, myself
  included, thank
  this group for everything.  As a note, I am not new
  to statistics, but
  very new to SPSS by way of syntax.  Go easy on me
  please.

  -Jonathan Olmsted

Jonathan Paul Olmsted
University of Delaware
Political Science 2007
Reply | Threaded
Open this post in threaded view
|

Re: Syntax for summations, but without the AGG function

emaguin
Jonathan,

I think this is the thing to do because, as i understand you, you want to
multipy your state-year stats (e.g., mean for item 13) by the n associated
with that state-year. You then want to sum up those n(j)*xbar(j) products
and divide that sum by the sum of the n(j)s. If so, then

Compute tot=n*xbar.

comute tag=1.
aggregate /outfile=*/break=tag/tot n=sum(tot n).

compute xbar=tot/n.

Gene Maguin