The linear-log specification of the food expenditure model uses the natural logarithm of income as the independent variable:
food-exp = ві + в2 ln (income) + e (4.6)
Taking the logarithm of income and estimating the model
1 series l_income = ln(income)
2 ols food_exp const l_income
There is a short-cut that enables you to take the natural logs of several variables at a time. The logs function could be use do create ln(income) as
This command produces a new variable called l_income and adds it to the variables list.
Estimation of the model yields
food_exp = -97.1864 + 132.166 Lincome
40 R2 = 0.3396 F(1, 38) = 21.053 <t = 91.567 (standard errors in parentheses)
In Figure 4.6 of POE4 the authors plot food-exp against food-exp. A positive (nonlinear) relationship between the two is expected since the the model was estimated using the natural logarithm of income. To produce this plot, estimate the regression to open the model window. Add the predicted values of from the regression to the dataset using Save>Fitted values from the model window’s pull-down menu. Name the fitted value, yhat2 and click OK. Now, return to the main window, use the mouse to highlight the three variables (food_exp, yhat2, and income),3 then select View>Graph specified vars>X-Y scatter from the pull-down menu.4 This opens the define graph dialog box. Choose yhat2 and food_exp as the Y-axis variables and income as the X-axis variable and click OK. A graph appears that looks similar to Figure 4.8
A simpler approach is to open a console or a new script window and use the following commands: To save the predicted values and plot them against the actual observations add
1 ols food_exp const l_income
2 series yhat2 = $yhat
3 gnuplot yhat2 food_exp income
The first line estimates the regression. The predicted values are held in the accessor, $yhat, and are assigned to a new variable called yhat2 using the series command. Then, call gnuplot with the predicted values, yhat2, as the first variable and the actual values of food expenditure, food_exp,
4You can also right-click the mouse once the variables are selected to gain access to the scatter plot. If you choose this method, gretl will prompt you to specify which of the selected variables is to be used for the X-axis.
Finally, if you execute these commands using a script, the graph is written to a file on your computer rather than opened in a window. For this reason, I recommend executing these commands from the console rather than from the script file that appears at the end of this chapter.