Using SPSS to compute binomial distribution pmf and cdf values
Below are instructions for obtaining pmf and cdf values for a binomial
(5, 0.4) distribution. Specifically, if Y is a binomial (5, 0.4)
random variable, the instructions below can be used to obtain the values
of P(Y = y) and
P(Y <= y) for y = 0, 1, 2, 3, 4, 5.
- Start SPSS. The Data Editor spreadsheet should appear in the
background with a smaller window/box opened on top of it. Click the
Type in data "button" and then click OK.
- Enter the values 0 through 5 into the first 6 rows of the first
column on the Data Editor spreadsheet. To name the column, click on
Variable View at the bottom of the Data Editor window, and then
replace VAR00001 in the first row of the name column by
y. Finally, click of Data View at the bottom of the
window to get back the original spreadsheet.
- Click on Transform on the main menu bar near the top of the
window, pull down, and select Compute. This should cause a
Compute Variable window to open.
- In the Target Variable box on the Compute Variable window,
type pmfy. Next, in the Functions box, scroll down and
find PDF.BINOM(q,n,p). Highlight (click on it to make it blue)
PDF.BINOM(q,n,p). At this point, the "up arrow" next to
Functions should become "active." Click on the arrow, and
PDF.BINOM(?,?,?) should appear in the Numeric Expression box, with the
first ? highlighted blue.
- Highlight y in the Type & Label box. Next, click on
the "right arrow" between the Type & Label and Numeric
Expression boxes, which should cause the previously highlighted
? to become y.
- Click in the Numeric Expression box to make it "active" and
use the keys on your computer keyboard (including the right arrow key
on your keyboard) to move the cursor and then replace the next ?
with 5. Then replace the last ? with 0.4.
- Now click OK at near the bottom of the Compute
Variable window. This should cause the numbers .08, .26, .35, .23,
.08, .01 to appear in a column (the 2nd column) of the Data Editor
window, with the column named pmfy. These values are the desired
pmf values --- the values of P(Y=y) corresponding to the
values of y given in the first column.
- An annoying thing is that the probabilities have been rounded to
the nearest hundreth. To get more digits, click on Variable View
at the bottom of the Data Editor window, and then click on the cell in
the 2nd row (the pmfy row) of the Decimals column. (This
cell should contain a 2.) Clicking the cell should make up and down
arrows appear the the cell. Click the up arrow twice to change the 2 to
a 4. Then click Data View at the bottom of the Data
Editor window. Now you should see that the desired probabilities in
the 2nd column have been expressed with 4 digits after the decimal.
- To obtain the desired cdf values, once again click on
Transform and select Compute. Enter cdfy into the
Target Variable box. Next, click in the Numeric
Expression box to make it active, and use your computer keyboard to
change P to C, to make it read
CDF.BINOM(y,5,0.4). Upon clicking OK, the desired cdf
values appear in a column labeled cdfy (annoyingly with only 2 digits
showing after the decimal,
and so again one might want to change things to make the values appear
with 4 or more digits after the decimal).
These are
the values of P(Y<=y) corresponding to the
values of y given in the first column.