Re: [SPSSX-L] Negative Binomial – SPSS Bug (?)
Posted by
Jon K Peck on
Sep 11, 2012; 12:50pm
URL: http://spssx-discussion.165.s1.nabble.com/Negative-Binomial-SPSS-Bug-tp5715014p5715016.html
There are two different parameterizations
of the negative binomial in common usage. You are probably
looking at definitions for a different parameterization than SPSS uses.
Look at http://en.wikipedia.org/wiki/Negative_binomial_distribution
and the SPSS function help for details.
Jon Peck (no "h") aka Kim
Senior Software Engineer, IBM
[hidden email]
new phone: 720-342-5621
From:
drfg2008 <[hidden email]>
To:
[hidden email]
Date:
09/11/2012 05:03 AM
Subject:
[SPSSX-L] Negative
Binomial – SPSS Bug (?)
Sent by:
"SPSSX(r)
Discussion" <[hidden email]>
[This thread refers to the thread: "Poisson -
negative binomial" Dec. 19,
2011 and Sep 06, 2012]
I have E(X) and V(X) of a neg.bin. distributed RV and would like to compute
the cumulative Neg. Bin. function for P(X<=2).
CDF.NEGBIN(quant,thresh,prob)
---------------------
According to my textbook [1]
E(X)= k(1-p)/p
V(X)=k(1-p)/p^2
p = E(x)/V(x)
k= E(X) p(1-p)
(where p is the probability and k is the threshold)
--------------------
Example:
E(x) = 1.0815
V(x) = 1.7697
-> p = 0.611, k = 1.7
--------------------
My problem is that I do not get the results of the SPSS function reproduced
. In the described example the result should be 0.8694. Instead SPSS
computes 0.5366.
See for example this python recursive version:
begin program.
import math
import spss
def negbin(x,k,p):
if x==0:
return math.pow(p,k)
return negbin(x-1,k,p)*(1-p)*(x-1+k)/(x-1+1)
def VertNegBin(x,k,p):
zaehler=x
summe=0
while zaehler>=0:
summe=summe+negbin(zaehler,k,p)
zaehler=zaehler-1
return summe
end program.
*----------------------------------------------------------------.
COMPUTE var = 1.7697.
COMPUTE Lambda_f = 1.0815.
compute wert=2.
*----------------------------------------------------------------.
COMPUTE negProb=LAMBDA_F/var.
COMPUTE thresh=LAMBDA_F*(negProb/(1-negProb)).
execute.
spssinc trans result=CDFnegBinResult /Formula "VertNegBin(
wert,
thresh,negProb)".
execute.
spssinc trans result=PDFnegBinResult /Formula "negbin( wert,
thresh,negProb)".
execute.
COMPUTE SPSS_version=CDF.NEGBIN(wert,thresh,negProb).
EXECUTE.
My question: Is it an SPSS Bug or my misunderstanding of thresh and prob
in
the SPSS function, and if the last applies, how then to compute
CDF.NEGBIN(quant,thresh,prob) ?
Literature:
[1] Schlittgen, R.: Einführung in die Statistik. 5. Auflg. Oldenbourg
1995,
S.203 ff
-----
Dr. Frank Gaeth
FU-Berlin
--
View this message in context: http://spssx-discussion.1045642.n5.nabble.com/Negative-Binomial-SPSS-Bug-tp5715014.html
Sent from the SPSSX Discussion mailing list archive at 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