Posted by
Bruce Weaver on
URL: http://spssx-discussion.165.s1.nabble.com/How-to-Calculate-Interpolated-Median-IM-Using-Syntax-tp5740421p5740425.html
I understood things differently from Art. The following is quite rough and
ready, but I think it does what you describe. (VECTOR and LOOP might be
tidier than DO-REPEAT, but I don't have a lot of time to mess around with it
any further right now.)
HTH.
GET FILE='C:\Temp\SampleData.sav'.
* Get Nvalid and ordinary median for each question.
AGGREGATE
/OUTFILE=* MODE=ADDVARIABLES
/BREAK=
/Nvalid1 Nvalid2 = NU(Q1 Q2)
/med1 med2 = MEDIAN(Q1 Q2).
* n1 = number of scores less than Median (strictly less, not equal)
* n2 = number of scores equal to Median.
DO REPEAT n1 = n1Q1 n1Q2 / n2 = n2Q1 n2Q2 / med = med1 med2.
COMPUTE n1 = Q1 LT med.
COMPUTE n2 = Q1 EQ med.
END REPEAT.
* Sum those flag variables to convert them to counts.
AGGREGATE
/OUTFILE=* MODE=ADDVARIABLES OVERWRITE=YES
/BREAK=
/n1Q1 n2Q1 n1Q2 n2Q2 = SUM(n1Q1 n2Q1 n1Q2 n2Q2).
FORMATS n1Q1 n2Q1 n1Q2 n2Q2 (F5.0).
DESCRIPTIVES n1Q1 n2Q1 n1Q2 n2Q2.
* Compute interpolated median (IM).
DO REPEAT
IM = IM1 IM2 /
med = med1 med2 /
N = Nvalid1 Nvalid2 /
n1 = n1Q1 n1Q2 /
n2 = n2Q1 n2Q2.
DO IF n2 EQ 0.
COMPUTE IM = med.
ELSE.
COMPUTE IM = med-0.5+((0.5*N-n1)/n2).
END IF.
END REPEAT.
DESCRIPTIVES med1 med2 IM1 IM2.
asp778ACU-2 wrote
> Dear SPSS Base Gurus,
>
> I am trying to work something out which I am sure SPSS can do to calculate
> the IM
> N = total number of valid responses to the question
> M = the standard median of the scores
> N1 = number of scores less than M (strictly less, not equal)
> N2 = number of scores equal to M
>
>
https://spu.edu/depts/insdev/interpolated_median_explanation.pdf>
> But I am not sure how to translate the IM formula above into the syntax.
> Attached dummy survey data set list that required interpolated median for
> Q1
> and Q2.
> What I try to achieve populate IM figures using syntax.
> As I am newbie with very basic knowledge of SPSS, any enlightenment will
> be
> appreciated.
>
> SampleData.sav
> <
http://spssx-discussion.1045642.n5.nabble.com/file/t341643/SampleData.sav>
> Thanks in advance.
>
>
>
>
> --
> Sent from:
http://spssx-discussion.1045642.n5.nabble.com/>
> =====================
> To manage your subscription to SPSSX-L, send a message to
> LISTSERV@.UGA
> (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
-----
--
Bruce Weaver
[hidden email]
http://sites.google.com/a/lakeheadu.ca/bweaver/"When all else fails, RTFM."
NOTE: My Hotmail account is not monitored regularly.
To send me an e-mail, please use the address shown above.
--
Sent from:
http://spssx-discussion.1045642.n5.nabble.com/=====================
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
--
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/).