Category Using gret l for Principles of Econometrics, 4th Edition

Creating indicator variables

It is easy to create indicator variables in gretl. Suppose that we want to create a dummy variable to indicate that a house is large. Large in this case means one that is larger than 2500 square feet.

1 series ld = (sqft>25)

2 discrete ld

3 print ld sqft —byobs

The first line generates a variable called ld that takes the value 1 if the condition in parentheses is satisfied. It will be zero otherwise. The next line declares the variable to be discrete. Often this is unnecessary. “Gretl uses a simple heuristic to judge whether a given variable should be treated as discrete, but you also have the option of explicitly marking a variable as discrete, in which case the heuristic check is bypassed.” (Cottrell and Lucchetti, 2011, p. 53) That is what we did here...

Read More

Okun’s Law

Okun’s Law provides another opportunity to search for an adequate specification of the time – series model. Load the okun. gdt data. These quarterly data begin at 1985:2. Set the data structure to time-series if needed. In this example, the model search is over p = 0,1, 2 and q = 1, 2, 3. There are 12 possible models to consider and loops will again be used to search for the preferred one.

To make the loop simpler, the modelsel function has been modified slightly. It now accepts a single variable list as its input. This allows us to place the dependent variable, x, and its first lag into the model as x(0 to -1). Gretl reads this as x x(-1). Thus, these two regressions would yield the same result

ols x const x(-1) ols x(0 to -1) const

Placing the constant at the end of the list only moves...

Read More

Elasticity

Elasticity is an important concept in economics. It measures how responsiveness one variable is to changes in another. Mathematically, the concept of elasticity is fairly simple:

percentage change in y Ay/y

percentage change in x Ax/x ‘

Подпись: є
Подпись: AE(y)/E(y) Ax/x image031 Подпись: (2.4)

In terms of the regression function, we are interested in the elasticity of average food expenditures with respect to changes in income:

E(y) and x are usually replaced by their sample means and в2 by its estimate. The mean of food_exp and income can be obtained by using the cursor to highlight both variables, use the

View>Summary statistics from the menu bar as shown in Figure 2.10, and the computation can be done by hand...

Read More

Confidence Intervals

Confidence intervals are obtained using the scalar command in the same way as in chapter 3. A 95% confidence interval for в2, the coefficient of the price variable is generated:

1 ols sales const price advert —vcv

2 scalar bL = $coeff(price) – critical(t,$df,0.025) * $stderr(price)

3 scalar bU = $coeff(price) + critical(t,$df,0.025) * $stderr(price)

4 printf "nThe lower = %.2f and upper = %.2f confidence limitsn", bL, bU

The output from the script is:

The lower = -10.09 and upper = -5.72 confidence limits

This nifty piece of output uses the function called, printf. printf stands for print format and it is used to gain additional control over how results are printed to the screen. In this instance we’ve combined descriptive text and numerical results...

Read More

Heteroskedasticity

The simple linear regression models of chapter 2 and the multiple regression model in Chapter 5 can be generalized in other ways. For instance, there is no guarantee that the random variables of these models (either the yi or the ei) have the same inherent variability. That is to say, some observations may have a larger or smaller variance than others. This describes the condition known as heteroskedasticity. The general linear regression model is shown in equation (8.1) below.

yi = ві + в2Хі2 +——- + вкXiK + ei i = 1,2,… ,N (8.1)

where yi is the dependent variable, xik is the ith observation on the kth independent variable, k = 2,3,…, K, ei is random error, and въ в2,…, вК are the parameters you want to estimate...

Read More