How to Calculate Interpolated Median (IM) Using Syntax

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

How to Calculate Interpolated Median (IM) Using Syntax

asp778ACU-2
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
[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: How to Calculate Interpolated Median (IM) Using Syntax

Art Kendall
Is this what you are looking for?


GET
  FILE='C:\Users\Art\AppData\Local\Temp\SampleData.sav'.
DATASEt NAME ExampleData.
DISPLAY DICTIONARY.
VARIABLE LEVEL Q1 Q2 (ORDINAL).
*Perhaps even interval.
NUMERIC MyScore (f3.1).
*using MEAN to get a summative score with the same meaning as the response
scale.
COMPUTE MYScore=Mean.2(Q1 to Q2).
FREQUENCIES VARIABLES = Q1 Q2 MyScore /STATISTICS =ALL.
NUMERIC NewVar (F2).
RECODE MyScore(Missing=Copy)(4.0 THRU HI =2)(1 THRU 3.9999 =1)(ELSE = -1)
INTO NewVar.
VALUE LABELS NewVar
    -1 'Oops weird result'
    1 'Below Median'
    2 'At or above Median'.
MISSING VALUES NewVar (LO THRU -1).
CROSSTABS TABLES = MyScore BY NewVar.



-----
Art Kendall
Social Research Consultants
--
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
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: How to Calculate Interpolated Median (IM) Using Syntax

Art Kendall
This post was updated on .
Since the score is at least ordinal, why not use both the mean and median in
your reasoning?

In SPSS click <Help> theu enter "RANK"

then paste this after the syntax I posted before.
RANK VARIABLES=Q1 /RANK INTO RMEAN /TIES=MEAN.
RANK VARIABLES=Q1 /RANK INTO RCONDS /TIES=CONDENSE.
RANK VARIABLES=Q1 /RANK INTO RHIGH /TIES=HIGH.
RANK VARIABLES=Q1 /RANK INTO RLOW /TIES=LOW.
DESCRIPTIVES VARIABLES= RMEAN TO RLOW /statistics=ALL.




-----
Art Kendall
Social Research Consultants
--
Sent from: http://spssx-discussion.1045642.n5.nabble.com/

=====================
To manage your subscription to SPSSX-L, send a message to
LISTSERV@LISTSERV.UGA.EDU (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
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: How to Calculate Interpolated Median (IM) Using Syntax

Bruce Weaver
Administrator
In reply to this post by asp778ACU-2
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
> &lt;http://spssx-discussion.1045642.n5.nabble.com/file/t341643/SampleData.sav&gt; 
> 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/).
Reply | Threaded
Open this post in threaded view
|

Re: How to Calculate Interpolated Median (IM) Using Syntax

Art Kendall
In reply to this post by Art Kendall
Since the score is at least ordinal, why not use both the mean and median in
your reasoning?

In SPSS click <Help> theu enter "RANK"

then paste this after the syntax I posted before.
RANK VARIABLES=Q1 /RANK INTO RMEAN /TIES=MEAN.
RANK VARIABLES=Q1 /RANK INTO RCONDS /TIES=CONDENSE.
RANK VARIABLES=Q1 /RANK INTO RHIGH /TIES=HIGH.
RANK VARIABLES=Q1 /RANK INTO RLOW /TIES=LOW.
DESCRIPTIVES VARIABLES= RMEAN TO RLOW /statistics=ALL.



-----
Art Kendall
Social Research Consultants
--
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
Art Kendall
Social Research Consultants
Reply | Threaded
Open this post in threaded view
|

Re: How to Calculate Interpolated Median (IM) Using Syntax

asp778ACU-2
Many thanks for the enlightenment and sharing back bone syntax.

I shall cook survey data using scripts provided and wish me luck how it goes
.

As I am number crunch (e.g.: BI analyst by trade) and not statistician so I
just follow the tradition using the hard complicated way  - Interpolated
Median Score rather than using the old school (e.g.: basic statistics –
median, etc).







-----
Andre
--
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