Prediction in the Food Expenditure Model

Generating predicted values of food expenditure for a person with a given income is very simple in gretl. After estimating the model with least squares, you can use the genr or series to get predicted values for all the observations or use scalar to get a prediction at a specific point. In the example, a household having incomeo = $2000 of weekly income is predicted to spend approximately $287.61 on food. Recalling that income is measured in hundreds of dollars in the data, the gretl commands to compute this from the console are: [13] [14]

з scalar yhatO = $coeff(const) + $coeff(income)*20

This yields food-exp0 = 287.609. We could have used genr rather than scalar (or nothing at all before yhat0) and the correct result would be computed. Using scalar makes it clear to someone else reading the program that you intend this to compute a single number, not a series.

var(f) = a2 + + (incomeo — income)2 var(b2)

image090 Подпись: (4.1)

Obtaining the 95% confidence interval is slightly harder in that there are no internal commands in gretl that will do this. The information needed is readily available, however. The formula is:

In section 2.4 we estimated a2 = 8013.29 and var(b2) = 4.3818. The mean value of income is found by highlighting the variable income in the main gretl window and the selecting View>Summary Statistics from the pull-down menu. This yields income = 19.6047.1 The t38 5% critical value is 2.0244 and the computation2

8013.2941

var(f) = 8013.2941 +—— ——- + (20 — 19.6047)2 * 4.3818 = 8214.31 (4.2)

Then, the confidence interval is:

foodlexp0 ± tcse(f) = 287.6069 ± 2.0244%8214.31 = [104.132, 471.086] (4.3)

The complete script to produce the computed results in gretl is:

1 ols food_exp const income

2 scalar yhat0 = $coeff(const) + $coeff(income)*20

3 scalar f=8013.2941+(8013.2941/40)+4.3818*(20-19.6047)~2

4 scalar ub=yhat0+2.0244*sqrt(f)

5 scalar lb=yhat0-2.0244*sqrt(f)

At this point, you may be wondering if there is some way to use the internal functions of gretl to produce the same result? As we’ve seen, gretl saves many of the results we need internally and these can in turn be called into service in subsequent computations using their accessors.

For instance, the sum of squared errors from the least squares regression can be accessed using $ess. The degrees of freedom and number of observations are saved as $df and $nobs, respectively. Also, you can use an internal gretl function to compute income, mean(income), and the critical function discussed in the preceding chapter to get the desired critical value. Hence, the prediction interval can be automated and made more precise by using the following script. [15] [16]

1 ols food_exp const income

2 scalar yhat0=$coeff(const)+20*$coeff(income)

3 scalar sig2 = $ess/$df

4 scalar f = sig2 + sig2/$nobs + ((20-mean(income))"2)*($stderr(income)"2)

5 scalar lb = yhat0-critical(t,$df,0.025)*sqrt(f)

6 scalar ub = yhat0+critical(t,$df,0.025)*sqrt(f)

7 print yhat0 sig2 f lb ub

This produces

yhat0 = 287.60886

sig2 = 8013.2941

f = 8214.3110

lb = 104.13228

ub = 471.08545

which are the values we expect.

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>