## Computing p-values for test statisticsSuppose a test statistic has a t-distribution with k degrees of freedom. For a two-tailed test, the p-value is computed as: p = 2 P(t where To get some further insight into how the computation is done, the
## ExampleThis example uses the Griffiths, Hill and Judge data set on household expenditure for food. The OLS estimation results for the food expenditure relationship can be reviewed. The SHAZAM program (
The commands show a number of useful features of SHAZAM programming. The following steps should be noted: - The
`TRATIO=` option on the`OLS` command is used to save the computed t-ratios in the variable assigned the name`TR` . - After model estimation some scalar results are available in SHAZAM
**temporary variables**. These have special names that start with the $ character. For example, the degrees of freedom is available in the variable with the name`$DF` . The`GEN1` command is used to save this value in the new variable`DF1` . - The
`DISTRIB` command can be used for computing the probability density function and the cumulative distribution function for a wide variety of probability distributions. The options that are used in this example are:`TYPE=` This option specifies the type of distribution. The option `TYPE=T` specifies the t-distribution.`DF=` This option is required when `TYPE=T` is used and this gives the degrees of freedom.`CDF=` This option is used to save the values of the cumulative distribution function in the variable specified.
The SHAZAM output follows. Note that |_SAMPLE 1 40 |_READ (GHJ.txt) FOOD INCOME UNIT 88 IS NOW ASSIGNED TO: GHJ.txt 2 VARIABLES AND 40 OBSERVATIONS STARTING AT OBS 1 |_* Save the t-ratios from the OLS regression in the variable TR |_OLS FOOD INCOME / TRATIO=TR OLS ESTIMATION 40 OBSERVATIONS DEPENDENT VARIABLE = FOOD ...NOTE..SAMPLE RANGE SET TO: 1, 40 R-SQUARE = .3171 R-SQUARE ADJUSTED = .2991 VARIANCE OF THE ESTIMATE-SIGMA**2 = 46.853 STANDARD ERROR OF THE ESTIMATE-SIGMA = 6.8449 SUM OF SQUARED ERRORS-SSE= 1780.4 MEAN OF DEPENDENT VARIABLE = 23.595 LOG OF THE LIKELIHOOD FUNCTION = -132.672 VARIABLE ESTIMATED STANDARD T-RATIO PARTIAL STANDARDIZED ELASTICITY NAME COEFFICIENT ERROR 38 DF P-VALUE CORR. COEFFICIENT AT MEANS INCOME .23225 .5529E-01 4.200 .000 .563 .5631 .6871 CONSTANT 7.3832 4.008 1.842 .073 .286 .0000 .3129 |_* Save the degrees of freedom in the variable DF |_GEN1 DF1=$DF ..NOTE..CURRENT VALUE OF $DF = 38.000 |_* Set the sample period to the number of estimated coefficients |_SAMPLE 1 2 |_* Take the absolute value of the t-ratios. |_GENR TRA=ABS(TR) |_* Use the DISTRIB command - save the CDF in the variable CDF1 |_DISTRIB TRA / TYPE=T DF=DF1 CDF=CDF1 T DISTRIBUTION DF= 38.000 VARIANCE= 1.0556 H= 1.0000 DATA PDF CDF 1-CDF TRA ROW 1 4.2004 .23351E-03 .99992 .77568E-04 ROW 2 1.8420 .74782E-01 .96335 .36648E-01 |_* Get the p-value for a 2-sided test. |_GENR PVAL2=2*(1-CDF1) |_* |_* Now get p-values for 1-sided tests. |_DISTRIB TR / TYPE=T DF=DF1 CDF=CDF1 T DISTRIBUTION DF= 38.000 VARIANCE= 1.0556 H= 1.0000 DATA PDF CDF 1-CDF TR ROW 1 4.2004 .23351E-03 .99992 .77568E-04 ROW 2 1.8420 .74782E-01 .96335 .36648E-01 |_* H0: coefficient > 0 vs. H1: coefficient < 0 |_GENR PA=CDF1 |_* H0: coefficient < 0 vs. H1: coefficient > 0 |_GENR PB=1-CDF1 |_* |_* Print the results |_PRINT TR PVAL2 PA PB TR PVAL2 PA PB 4.200378 .1551364E-03 .9999224 .7756820E-04 1.841956 .7329593E-01 .9633520 .3664796E-01 |_STOP [SHAZAM Guide home] |