Date: Wed, 22 Apr 1998 20:34:39 -0500
Reply-To: "Matheson, David" <davidm@SPSS.COM>
Sender: "SPSSX(r) Discussion" <SPSSX-L@UGA.CC.UGA.EDU>
From: "Matheson, David" <davidm@SPSS.COM>
Subject: Re: var function and sd function in aggregate
Gene,
The VAR and SD functions for compute and the SD function for AGGREGATE
all use N-1. You can get the variance or SD based on N as divisor by
multiplying the result of the function by (N-1)/N [for variance
function] or
sqrt((N-1)/N) [for SD], as in the following examples.
* for these COMPUTEs, the N (3 in this example) is likely to be known
* and is easiest to enter directly in that case. For purposes of a
macro,
* or if the arguments were a large set of variables that you didn't want
* to count, you could use a COUNT command to create a
* variable (nx, for example) with the number of elements
* and replace 2/3 in this example with (nx-1)/nx .
COMPUTE xvarpop = VARIANCE(x1,x2,x3) * 2/3 .
COMPUTE xsdpop = SD(x1,x2,x3) * SQRT(2 / 3) .
AGGREGATE
/OUTFILE=*
/BREAK=brk
/x1sd = SD(x1)
/NX1=N(x1).
* If you set outfile to a filename, rather than * (replace active file),
* you'll need to open that file before running the next compute.
COMPUTE x1sdpop = x1sd * SQRT((nx1-1) /nx1) .
execute.
David Matheson
SPSS Statistical Support
>----------
>From: Gene Maguin[SMTP:maguin@RIA.ORG]
>Sent: Wednesday, April 22, 1998 9:41 AM
>To: SPSSX-L@UGA.CC.UGA.EDU
>Subject: var function and sd function in aggregate
>
>Spss folks,
>
>First question. Does anyone know whether the divisor used in the VAR
>function (part of the COMPUTE command) is N or N-1?
>
>Second question. Does anyone know whether the divisor used in the SD
>subcommand of the AGGREGATE command) is N or N-1?
>
>In both cases, the documentation says nothing. It seems to me
>that both variations should be offered (i.e., divisor of N and
>divisor of N-1).
>
>Thanks,
>
>Gene Maguin
>
|