Chapter 12 - STATISTICS FOR BUSINESS & ECONOMICS by Paul Newbold
*****************************************************************************
* CHAPTER 11 - STATISTICS FOR BUSINESS & ECONOMICS, 4th Ed., by Paul Newbold*
*****************************************************************************
*
* Example 11.1, page 408
*
* The SAMPLE command is used to specify the sample range of the data to be
* read.  The READ command is used to read in a gas company's findings of a
* random sample of 400 of its accounts which is defined as O and the
* corresponding probability of the accounts being fully paid or in arrears
* is defined as P.  The LIST option on the READ command lists all data read.
*
SAMPLE 1 4
READ O P / LIST
287  0.80 
 49  0.10 
 30  0.06 
 34  0.04
*
* The GEN1 command is used to calculate the expected number of the present
* accounts to fall in each of the four categories P is defined as EXPECT.
*
GENR EXPECT=400*P
*
* The STAT command with the SUM= option is used to save the sum of the
* variable in a specified vector.
*
STAT O / SUM=SO
STAT P / SUM=SP
STAT EXPECT / SUM=SEXPECT
*
* The PRINT command is used to replicate the Table on page 409.
*
PRINT O P EXPECT
PRINT SO SP SEXPECT
*
* The Null Hypothesis is that the proportion in the present winter conform to
* the historical records.   The GENR and STAT commands are used to generate
* the Chi-squared test value.
* 
GENR CHI=((O-EXPECT)**2)/EXPECT
STAT CHI / SUM=CHI2
PRINT CHI2
*
DELETE / ALL
*
*-----------------------------------------------------------------------------
* Example 11.2, page 418
*
* The SAMPLE command is used to specify the sample range of the data to be 
* read.  The READ command is used to read in the data.  The low range of the
* Percentage Debt is defined as LOWPD, the high range of the Percentage Debt
* is defined as UPPD, the number of Older Firms is defined as OLDF, the
* expected number of Older Firms is defined as EXPECTOF, the number of Newer
* Firms is defined as NEWF, and the expected number of Newer Firms is defined
* as EXPECTNF.  The LIST option on the READ command lists all data read.
*
SAMPLE 1 4
READ LOWPD UPPD OLDF EXPECTOF NEWF EXPECTNF / LIST
 0   25  19  16.5  29  31.5
26   50  13   7.9  10  15.1
51   75   7   6.2  11  11.8
76  100   4  12.4  32  23.6
*
* The GENR and STAT command is used to calculate the sum of Older Firms,
* Newer Firms and the total of Older and Newer Firms in each of the four
* Percentage Debt categories.
*
GENR TOTALS=OLDF+NEWF
STAT OLDF / SUM=SOLDF
STAT NEWF / SUM=SNEWF
STAT TOTALS / SUM=STOTALS
*
* The PRINT command is used to replicate the second table on page 418.
*
PRINT LOWPD UPPD OLDF EXPECTOF 
PRINT NEWF EXPECTNF TOTALS
PRINT SOLDF SNEWF STOTALS
*
* The Null Hypothesis is that no association between firm age and debt as a
* percentage of capital structure is tested using the GENR and STAT commands.
*
GENR CHI=(((OLDF-EXPECTOF)**2)/EXPECTOF)+(((NEWF-EXPECTNF)**2)/EXPECTNF)
STAT CHI / SUM=CHI2
PRINT CHI2
*
DELETE / ALL
*
*-----------------------------------------------------------------------------
STOP