3
$\begingroup$

I'm trying to learn how to use R by replicating the regression of the MRW 1992 paper (see Table 1). I've done this in Mathematica, and I got the right coefficients, even for the intercept.

The following R script is what I'm using for this example:

library(foreign)
mrw <- read.dta("https://www.nuffield.ox.ac.uk/teaching/economics/bond/mrw.dta")

mrw$popgrowth <- mrw$popgrowth/100 #the data is in percentage points
mrw$gdpgrowth <- mrw$gdpgrowth/100 #the data is in percentage points

noil <- mrw[mrw$n==1,] #non-oil countries

form1noil <- log(rgdpw85) ~ 1+log(i_y)+log(popgrowth+0.05) #we have to add 0.05 (see paper)
noil.lm <- lm(form1noil, data = noil)
summary(noil.lm) #the intercept has the wrong value !
#Call:
#lm(formula = form1noil, data = noil)
#
#Residuals:
#     Min       1Q   Median       3Q      Max 
#-1.79144 -0.39367  0.04124  0.43368  1.58046 
#
#Coefficients:
#                      Estimate Std. Error t value Pr(>|t|)    
#(Intercept)            -1.1279     1.4274  -0.790 0.431371    
#log(i_y)                1.4240     0.1431   9.951  < 2e-16 ***
#log(popgrowth + 0.05)  -1.9898     0.5634  -3.532 0.000639 ***
#---
#Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#
#Residual standard error: 0.6891 on 95 degrees of freedom
#Multiple R-squared:  0.6009,   Adjusted R-squared:  0.5925 
#F-statistic: 71.51 on 2 and 95 DF,  p-value: < 2.2e-16

The strange thing is that I get the wrong intercept, but all the remaining betas are correct, and so are the R^2 and the std errors. Why is that?

Any help would be appreciated.

EDIT: Mathematica Code and output (data is imported from an excel file, with same values. sav is the i_y column)

YL85 = data[[1, 2 ;; n, 3]];
sav = data[[1, 2 ;; n, 6]]/100;
popgr = data[[1, 2 ;; n, 5]]/100;

logYL85 = Log[YL85];
logsav = Log[sav];
logrates = Log[popgr + 0.05];

lm = LinearModelFit[
   Transpose[{logsav, logrates, logYL85}], {x1, x2}, {x1, x2}];

Normal[lm]

5.42988 + 1.42401 x1 - 1.98977 x2
$\endgroup$
6
  • $\begingroup$ I think the model syntax is wrong - should have lm(y~x) and not lm(y,x) $\endgroup$ May 9, 2016 at 11:28
  • $\begingroup$ Thanks for the answer. Not sure I understand what you've written. The command works in this way lm(formula, data.frame). I've never seen '~' inside the command... $\endgroup$ May 9, 2016 at 11:33
  • 2
    $\begingroup$ The comment/answer is incorrect: f <- mpg ~ cyl; lm(f, mtcars) works properly since f is a formula-object. $\endgroup$
    – Tim
    May 9, 2016 at 11:37
  • 1
    $\begingroup$ the model syntax is correct $\endgroup$
    – mr.rox
    May 9, 2016 at 11:46
  • $\begingroup$ I have no explanation. Results should be equal. Can you check whether the data is exactly the same in R and in Mathematica? $\endgroup$
    – Roland
    May 9, 2016 at 12:36

2 Answers 2

7
$\begingroup$

It appears that in the Mathematica case, you are rescaling the i_y (i.e. sav) variable by a factor of 100, but this is not done in the R case; instead the gdpgrowth variable is rescaled, but this variable is not used in the model. Since the logarithm is being taken of the data, a rescaling would result in the addition of a constant. The discrepancy between the intercept estimates $5.42988-(-1.1279)=6.55778$ is equal to $\log(100)\hat\beta_1 = \log(100)*1.424$, which is exactly what we would expect from this mistake.

$\endgroup$
0
-2
$\begingroup$

If you have clear ideas about the interpretations of multiple correlation coefficients. $\beta_0$ is nothing but the value of response variable when all regressors are at zero level. Hence if it comes out to be insignificant there is nothing wrong in the model as long as adjusted $R^2$ is high,that is your model explains the data. In your case it seem satisfacory enough to me.

$\endgroup$
1
  • $\begingroup$ The OP asked why he got two different intercepts, not why either did not reach some arbitrary level of significance. $\endgroup$
    – mdewey
    May 9, 2016 at 15:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.