Chapter 18 - STATISTICS FOR BUSINESS & ECONOMICS by Paul Newbold
```*****************************************************************************
* CHAPTER 18 - STATISTICS FOR BUSINESS & ECONOMICS, 4th Ed., by Paul Newbold*
*****************************************************************************
*
* Example 18.1, page 745
*
* The GEN1 command is used to generate the constants in calculating the 95%
* Confidence Interval.
*
GEN1 BN=1118
GEN1 LN=60
GEN1 XBAR=87300
GEN1 S=19200
GEN1 SIGMA2=(S**2/LN)*((BN-LN)/BN)
GEN1 SIGMA=SQRT(SIGMA2)
*
* The Lower and Upper bounds of the 95% Confidence Interval for the mean
* amount of all mortgages taken out in this city last year is calculated
* using the GEN1 command.
*
GEN1 LOWER=XBAR-1.96*SIGMA
GEN1 UPPER=XBAR+1.96*SIGMA
*
* The PRINT command is prints out the results for the constants specified.
*
PRINT SIGMA2 SIGMA LOWER UPPER
*
DELETE / ALL
*
*-----------------------------------------------------------------------------
* Example 18.2, page 746
*
* The GEN1 command is used to generate the constants in calculating the 99%
* Confidence Interval.
*
GEN1 BN=1395
GEN1 LN=400
GEN1 XBAR=320.8
GEN1 S=149.7
GEN1 NXBAR=BN*XBAR
GEN1 BNSIGMA2=((S**2/LN)*BN)*(BN-LN)
GEN1 BNSIGMA=SQRT(BNSIGMA2)
*
* The Lower and Upper bounds of the 99% Confidence Interval for the population
* total is calculated using the GEN1 command.
*
GEN1 LOWER=NXBAR-2.575*BNSIGMA
GEN1 UPPER=NXBAR+2.575*BNSIGMA
PRINT NXBAR BNSIGMA2 BNSIGMA LOWER UPPER
*
DELETE / ALL
*
*-----------------------------------------------------------------------------
* Example 18.3, page 747
*
* The GEN1 command is used to generate the constants in calculating the 90%
* Confidence Interval.
*
GEN1 BN=1395
GEN1 LN=400
GEN1 PHAT=141/LN
GEN1 SIGMA2=(PHAT*(1-PHAT)/(LN-1))*((BN-LN)/BN)
GEN1 SIGMA=SQRT(SIGMA2)
*
* The Lower and Upper bounds of the 90% Confidence Interval for the percentage
* of all colleges in which business statistics is a two-semester course is
* calculated using the GEN1 command.
*
GEN1 LOWER=PHAT-1.645*SIGMA
GEN1 UPPER=PHAT+1.645*SIGMA
PRINT PHAT SIGMA2 SIGMA LOWER UPPER
*
DELETE / ALL
*
*-----------------------------------------------------------------------------
* Example 18.4, page 753
*
* The GEN1 command is used to generate the constants in calculating the 95%
* Confidence Interval.
*
GEN1 X1BAR=21.2
GEN1 S1=12.8
GEN1 X2BAR=13.3
GEN1 S2=11.4
GEN1 X3BAR=26.1
GEN1 S3=9.2
GEN1 BN1=60
GEN1 LN1=12
GEN1 BN2=50
GEN1 LN2=10
GEN1 BN3=45
GEN1 LN3=9
GEN1 BN=155
GEN1 LN=31
*
* Population mean estimate XSTBAR.
*
GEN1 XSTBAR=((BN1*X1BAR)+(BN2*X2BAR)+(BN3*X3BAR))/BN
PRINT XSTBAR
*
* Estimated mean number of weekly orders per restaurant is:
*
GEN1 SIGMAX12=(S1**2/LN1)*((BN1-LN1)/BN1)
GEN1 SIGMAX22=(S2**2/LN2)*((BN2-LN2)/BN2)
GEN1 SIGMAX32=(S3**2/LN3)*((BN3-LN3)/BN3)
PRINT SIGMAX12 SIGMAX22 SIGMAX32
*
* An ampersand, &, is used at the end of the line to be continued.  SHAZAM
* will remove the & from the equation and put the two pieces together.  Any
* space typed before the ampersand will be retained in the equation.  The
* maximum length of a command including continuation lines is 4096 characters.
*
GEN1 SIGXST2=(((BN1**2)*SIGMAX12)+((BN2**2)*SIGMAX22)+((BN3**2)*SIGMAX32))/&
BN**2
GEN1 SIGMAXST=SQRT(SIGXST2)
*
* The Lower and Upper bounds of the 95% Confidence Interval for the mean
* number of orders per restaurant received in a week is:
*
GEN1 LOWER=XSTBAR-1.96*SIGMAXST
GEN1 UPPER=XSTBAR+1.96*SIGMAXST
PRINT SIGXST2 SIGMAXST LOWER UPPER
*
DELETE / ALL
*
*-----------------------------------------------------------------------------
* Example 18.5, page 755
*
GEN1 BN1=364
GEN1 BN2=1031
GEN1 LN1=40
GEN1 LN2=60
GEN1 X1BAR=154.3
GEN1 X2BAR=411.8
GEN1 S1=87.3
GEN1 S2=219.9
*
* Population total estimate is:
*
GEN1 NXSTBAR=(BN1*X1BAR)+(BN2*X2BAR)
PRINT NXSTBAR
*
* Total number of students in business courses estimate is:
*
GEN1 SIGX12=((S1**2)/LN1)*((BN1-LN1)/BN1)
GEN1 SIGX22=((S2**2)/LN2)*((BN2-LN2)/BN2)
GEN1 N2SIGXST=((BN1**2)*SIGX12)+((BN2**2)*SIGX22)
GEN1 NSIGXST=SQRT(N2SIGXST)
PRINT SIGX12 SIGX22 N2SIGXST NSIGXST
*
* The Upper and Lower bounds of the 99% Confidence Interval for the estimated
* total number of students in business statistics courses is:
*
GEN1 LOWER=NXSTBAR-2.575*NSIGXST
GEN1 UPPER=NXSTBAR+2.575*NSIGXST
PRINT LOWER UPPER
*
DELETE / ALL
*
*-----------------------------------------------------------------------------
* Example 18.6, page 757
*
GEN1 BN1=364
GEN1 BN2=1031
GEN1 LN1=40
GEN1 LN2=60
GEN1 PHAT1=7/40
GEN1 PHAT2=13/60
*
* Population proportion estimate is:
*
GEN1 PHATST=((BN1*PHAT1)+(BN2*PHAT2))/(BN1+BN2)
*
* The quantities are:
*
GEN1 SIGPHAT1=((PHAT1*(1-PHAT1))/(LN1-1))*((BN1-LN1)/BN1)
GEN1 SIGPHAT2=((PHAT2*(1-PHAT2))/(LN2-1))*((BN2-LN2)/BN2)
PRINT PHATST SIGPHAT1 SIGPHAT2
GEN1 SIGPST2=(((BN1**2)*SIGPHAT1)+((BN2**2)*SIGPHAT2))/(BN1+BN2)**2
GEN1 SIGPST=SQRT(SIGPST2)
PRINT SIGPST2 SIGPST
*
* The Lower and Upper bounds of the 90% Confidence Interval for the proportion
* of all colleges in which this course is taught in the economics department
* is:
*
GEN1 LOWER=PHATST-1.645*SIGPST
GEN1 UPPER=PHATST+1.645*SIGPST
PRINT LOWER UPPER
*
DELETE / ALL
*
*-----------------------------------------------------------------------------
* Example 18.7, page 763
*
* The required sample observations needed in Example 18.1 is calculated with
* the GEN1 command.
*
GEN1 N=1118
GEN1 SIGMA=20000
GEN1 SIGXBAR=4000/1.96
*
* The required sample size, LN, is:
*
GEN1 LN=(N*SIGMA**2)/(((N-1)*SIGXBAR**2)+SIGMA**2)
PRINT LN
*
DELETE / ALL
*
*-----------------------------------------------------------------------------
* Example 18.8, page 765
*
* The required sample observations needed in Example 18.3 is calculated with
* the GEN1 command.
*
GEN1 N=1395
GEN1 SIGPHATX=0.04/1.96
*
* The required sample observations, NMAX, is:
*
GEN1 NMAX=(0.25*N)/(((N-1)*(SIGPHATX**2))+0.25)
PRINT NMAX
*
DELETE / ALL
*
*-----------------------------------------------------------------------------
* Example 18.9, page 766
*
* The required sample observations need in Example 18.4 is calculated with
* the GEN1 command.
*
GEN1 N1=60
GEN1 N2=50
GEN1 N3=45
GEN1 SIGMA1=13
GEN1 SIGMA2=11
GEN1 SIGMA3=9
GEN1 SIGXST=3/1.96
GEN1 NSIGMA=((N1*SIGMA1**2)+(N2*SIGMA2**2)+(N3*SIGMA3**2))
GEN1 NNSIGMA=((N1*SIGMA1)+(N2*SIGMA2)+(N3*SIGMA3))**2/(N1+N2+N3)
*
* The sample size needed for proportional allocation is:
*
GEN1 N=NSIGMA/(((N1+N2+N3)*SIGXST**2)+(NSIGMA/(N1+N2+N3)))
PRINT NSIGMA NNSIGMA N
*
* When the optimal allocation method is used, the sample observation required
* is:
*
GEN1 TOP=(((N1*SIGMA1)+(N2*SIGMA2)+(N3*SIGMA3))**2)/(N1+N2+N3)
GEN1 BOT=((N1+N2+N3)*(SIGXST**2))+(NSIGMA/(N1+N2+N3))
GEN1 OPTN=TOP/BOT
PRINT OPTN
*
DELETE / ALL
*
*-----------------------------------------------------------------------------
* Example 18.10, page 769
*
SAMPLE 1 20
READ I XBAR P N / LIST
1  26283  0.1304  23
2  19197  0.4516  31
3  37911  0.1250  24
4  14527  0.6585  41
5  16753  0.5143  35
6  28312  0.2692  26
7  21646  0.3548  31
8  29312  0.1563  32
9  31829  0.1333  30
10  18412  0.3846  39
11  33893  0.0769  26
12  38409  0.0476  21
13  43911  0.0000  20
14  14699  0.4375  32
15  24921  0.1111  36
16  31827  0.0909  33
17  34436  0.0833  24
18  37647  0.0400  25
19  30026  0.1081  37
20  16493  0.3659  41
*
GEN1 M=1000
GEN1 LM=20
*
* The STAT command is used to calculate the total number of households in
* the sample.  The SUM= option saves the sum of N in the constant SUMN.
*
STAT N / SUM=SUMN
GENR NXBAR=N*XBAR
STAT NXBAR / SUM=SNXBAR
GENR NP=N*P
STAT NP / SUM=SNP
PRINT SUMN SNXBAR SNP
*
* The Point Estimates are:
*
GEN1 XC=SNXBAR/SUMN
GEN1 PC=SNP/SUMN
PRINT XC PC
*
* The average cluster size is calculated with the GEN1 command.
*
GEN1 NBAR=SUMN/20
PRINT NBAR
GENR FRAC=(N**2)*(XBAR-XC)**2
STAT FRAC / SUM=SFRAC
GEN1 SIGMA2=((M-LM)/(M*LM*NBAR**2))*(SFRAC/(LM-1))
GEN1 SIGMA=SQRT(SIGMA2)
PRINT SIGMA2 SIGMA
*
* The Lower and Upper bounds of the 95% Confidence Interval for the mean
* income of all families in this area is:
*
GEN1 LOWER=XC-1.96*SIGMA
GEN1 UPPER=XC+1.96*SIGMA
PRINT LOWER UPPER
*
* The interval estimate for the population proportion is:
* area is
*
GENR Z=(N**2)*(P-PC)**2
STAT Z / SUM=SZ
GEN1 ZZ=SZ/(LM-1)
GEN1 SIGMAPC2=((M-LM)/(M*LM*NBAR**2))*ZZ
GEN1 SIGMAPC=SQRT(SIGMAPC2)
PRINT ZZ SIGMAPC2 SIGMAPC
*
* The Lower and Upper bounds of the 95% Confidence Interval for the mean
* income of all families in this area is:
*
GEN1 LOWER=PC-1.96*SIGMAPC
GEN1 UPPER=PC+1.96*SIGMAPC
PRINT LOWER UPPER
*
DELETE / ALL
*
*-----------------------------------------------------------------------------
* Example 18.11, page 772
*
* The GEN1 command is used to generate the constants to estimate a population
* mean.
*
GEN1 N=1120
GEN1 MEAN=4
GEN1 SIGMA=30.27
GEN1 SMEAN=4/1.96
*
* The total number of sample observations required in this study of 100
* accounts receivable is calculated with the GEN1 command.
*
GEN1 LN=(N*SIGMA**2)/(((N-1)*SMEAN**2)+SIGMA**2)
PRINT LN
*
DELETE / ALL
*
*-----------------------------------------------------------------------------
* Example 18.12, page 773
*
* The mean family incomes and sample standard deviations in three stratum
* districts in a town are defined using the GEN1 command.
*
GEN1 N1=1150
GEN1 N2=2120
GEN1 N3=930
*
GEN1 STD1=3657
GEN1 STD2=6481
GEN1 STD3=8403
*
* The DO-loop is used to repeat operations.  In this case, the DO-loop is
* used to calculate the proportion of the total sample to be allocated to
* each stratum under the optimal scheme.  The statements between the DO and
* ENDO commands are repeatedly executed.  In this example, the statements
* are repeated 3 times.
*
DO #=1,3
GEN1 NN#=(N#*STD#)/((N1*STD1)+(N2*STD2)+(N3*STD3))
PRINT NN#
ENDO
*
* Now the total number of sample observations needs to be determined with
* the GEN1 command.  The total number of population members is the sum
* of the three districts.  The GEN1 command is used to calculate this number
* and the constant is stored in the variable BN.
*
GEN1 SIGMAX=500/1.96
GEN1 BN=N1+N2+N3
PRINT SIGMAX BN
GEN1 NUMERAT=(1/BN)*((N1*STD1)+(N2*STD2)+(N3*STD3))**2
*
* The GEN1 statement for the denominator is too long.  An ampersand, &, is
* used at the end of the line to be continued.  SHAZAM will remove the &
* from the equation and put the two pieces together.
*
GEN1 DENOMIN=(BN*(SIGMAX**2))+((1/BN)*((N1*STD1**2)+(N2*STD2**2)+&
(N3*STD3**2)))
*
* The total number of sample observations is:
*
GEN1 LN=NUMERAT/DENOMIN
PRINT LN
*
* A DO-loop is used to calculate the sample in each stratum.
*
DO %=1,3
GEN1 FN%=NN%*LN
PRINT FN%
ENDO
*
DELETE / ALL
*
*-----------------------------------------------------------------------------
*
STOP
```