<p><code>INCOME</code> is already per capita, no need to divide it again by the total population.</p>
<p>You can reproduce the results using the following code</p>
<pre><code>fm &lt;- log(GASEXP/POP) ~ log(INCOME) + log(GASP) +
          log(PNC) + log(PUC) + I(YEAR - 1952)
m &lt;- lm(fm, data = gasoline)
m1 &lt;- lm(fm, data = subset(gasoline, YEAR &lt;= 1973))
m2 &lt;- lm(fm, data = subset(gasoline, YEAR &gt; 1973))
cbind(`1953-2004` = coef(m), 
      `1953-1973` = coef(m1),
      `1974-2004` = coef(m2))
##                   1953-2004    1953-1973     1974-2004
## (Intercept)    -26.67868575 -22.16467953 -15.328319431
## log(INCOME)      1.62496242   0.84819339   0.373900694
## log(GASP)        0.94607774   0.96773822   0.875978379
## log(PNC)        -0.08343220   0.69875951  -0.001146371
## log(PUC)        -0.08467492  -0.29053156  -0.021671064
## I(YEAR - 1952)  -0.01392611   0.01006345   0.004491833
</code></pre>
<p>Hope it helps</p>

CC BY-SA 4.0
2024-01-24T10:50:41.597Z
2024-01-24T10:50:41.597Z
dickoa
<p>I tried, but without success so far, to reproduce Greenes' empirical results using his gasoline data available at:
<a href="https://pages.stern.nyu.edu/%7Ewgreene/Text/econometricanalysis.htm" rel="nofollow noreferrer">https://pages.stern.nyu.edu/~wgreene/Text/econometricanalysis.htm</a><br />
You will find the R-code expected to generate the first column of Table 6.12. However, the results are is quite different from the published numbers... Does anybody see a typo in my code, in the way I manipulate the data? Is anybody able to produce estimates that are close to the published ones?</p>
<pre><code>Dat = read.csv( file= &quot;TableF2_2.csv&quot;, header = TRUE )
nrow( Dat )
# Year = Year, 1953-2004,
# GasExp = Total U.S. gasoline expenditure,
# Pop = U.S. total population in thousands
# GasP = Price index for gasoline,
# Income = Per capita disposable income,
# Pnc = Price index for new cars,
# Puc = Price index for used cars,
# Ppt = Price index for public transportation,
Dat<span class="math-container">$GAS = Dat$</span>GASEXP / Dat<span class="math-container">$GASP
Dat$</span>YEAR_t = Dat$YEAR - 1952
reg &lt;- lm( log( GAS / POP ) ~ log( INCOME/POP ) + log( GASP ) + log( PNC ) + log( PUC ) + YEAR_t,
         data = as.data.frame(Dat) )
summary( reg )
SSR = sum( residuals( reg )^2 )
SSR
</code></pre>

CC BY-SA 4.0
2023-04-19T05:21:53.553Z
Hi: It may not matter but don't do those divisions inside the lm itself. I would create new variables and then use those. The lm call might give a different result because of the subtle way that formulae work in R. For more details on this by doing ?I at the R prompt.
mark leeds
CC BY-SA 4.0
2023-04-19T07:15:28.903Z
@mark leeds: thank you for the hint. Unfortunately the results are identical when I run the alternate formulations:    reg <- lm( I(log( GAS / POP )) ~ I(log( INCOME/POP )) + I(log( GASP )) + I(log( PNC )) + I(log( PUC )) + YEAR_t, data = as.data.frame(Dat) )
or lm( y ~ X) after having defined y and X to correspond to the gasoline demand function.
Bertrand
CC BY-SA 4.0
2023-04-19T17:32:59.130Z
I'm sorry for leading you down the wrong trail. The only other thing I can think of is to take "Dat" and compare it to what Greene uses which means emailing him and asking if he could provide his version of Dat.  Also, you didn't use Year_t in your call. Were you supposed to ? Could Greene be running a GLS instead of an OLS ? I don't have time to run your code right now. Maybe this weekend.
mark leeds
<econometrics><regression><applied-econometrics><replication>
Greene's Econometric Analysis (8th edition), Table 6.12, p.233
Bertrand
# Greene's Econometric Analysis (8th edition), Table 6.12, p.233

(Asked by: username_0 on 2023-04-18)

I tried, but without success so far, to reproduce Greenes' empirical results using his gasoline data available at:
https://pages.stern.nyu.edu/~wgreene/Text/econometricanalysis.htm
You will find the R-code expected to generate the first column of Table 6.12. However, the results are is quite different from the published numbers... Does anybody see a typo in my code, in the way I manipulate the data? Is anybody able to produce estimates that are close to the published ones?
Dat = read.csv( file= "TableF2_2.csv", header = TRUE )
nrow( Dat )
# Year = Year, 1953-2004,
# GasExp = Total U.S. gasoline expenditure,
# Pop = U.S. total population in thousands
# GasP = Price index for gasoline,
# Income = Per capita disposable income,
# Pnc = Price index for new cars,
# Puc = Price index for used cars,
# Ppt = Price index for public transportation,
Dat$GAS = Dat$GASEXP / Dat$GASP
Dat$YEAR_t = Dat$YEAR - 1952
reg <- lm( log( GAS / POP ) ~ log( INCOME/POP ) + log( GASP ) + log( PNC ) + log( PUC ) + YEAR_t,
         data = as.data.frame(Dat) )
summary( reg )
SSR = sum( residuals( reg )^2 )
SSR

**Tags:** econometrics, regression, applied-econometrics, replication
> **Comments:**
> **username_1**: Hi: It may not matter but don't do those divisions inside the lm itself. I would create new variables and then use those. The lm call might give a different result because of the subtle way that formulae work in R. For more details on this by doing ?I at the R prompt.  
> **username_0**: @mark leeds: thank you for the hint. Unfortunately the results are identical when I run the alternate formulations:    reg <- lm( I(log( GAS / POP )) ~ I(log( INCOME/POP )) + I(log( GASP )) + I(log( PNC )) + I(log( PUC )) + YEAR_t, data = as.data.frame(Dat) ) or lm( y ~ X) after having defined y and X to correspond to the gasoline demand function.  
> **username_1**: I'm sorry for leading you down the wrong trail. The only other thing I can think of is to take "Dat" and compare it to what Greene uses which means emailing him and asking if he could provide his version of Dat.  Also, you didn't use Year_t in your call. Were you supposed to ? Could Greene be running a GLS instead of an OLS ? I don't have time to run your code right now. Maybe this weekend.  

---

## 1 answers

### Answer by username_2 on 2024-01-24. Score: 1 | Accepted answer

INCOME is already per capita, no need to divide it again by the total population.
You can reproduce the results using the following code
fm <- log(GASEXP/POP) ~ log(INCOME) + log(GASP) +
          log(PNC) + log(PUC) + I(YEAR - 1952)
m <- lm(fm, data = gasoline)
m1 <- lm(fm, data = subset(gasoline, YEAR <= 1973))
m2 <- lm(fm, data = subset(gasoline, YEAR > 1973))
cbind(`1953-2004` = coef(m), 
      `1953-1973` = coef(m1),
      `1974-2004` = coef(m2))
##                   1953-2004    1953-1973     1974-2004
## (Intercept)    -26.67868575 -22.16467953 -15.328319431
## log(INCOME)      1.62496242   0.84819339   0.373900694
## log(GASP)        0.94607774   0.96773822   0.875978379
## log(PNC)        -0.08343220   0.69875951  -0.001146371
## log(PUC)        -0.08467492  -0.29053156  -0.021671064
## I(YEAR - 1952)  -0.01392611   0.01006345   0.004491833

Hope it helps


---

