If you want to estimate OLS with clustered robust standard errors in R you need to specify the cluster. In your case you can simply run “summary.lm(lm(gdp_g ~ GPCP_g + GPCP_g_l), cluster = c(“country_code”))” and you obtain the same results as in your example.

Check out the instructions for clustered standard errors in R on the following post: https://economictheoryblog.com/2016/12/13/clustered-standard-errors-in-r/

Thanks again for you comment. I hope I was able to help you.

Cheers

]]>library(readstata13)

library(dplyr)

library(countrycode)

# get the data mss_repdata.dta from http://emiguel.econ.berkeley.edu/research/economic-shocks-and-civil-conflict-an-instrumental-variables-approach

df <- read.dta13(file = "mss_repdata.dta")

df$iso2c |t| [95% Conf. Interval]

# ————-+—————————————————————-

# GPCP_g | .0554296 .0163015 3.40 0.002 .0224831 .0883761

# GPCP_g_l | .0340581 .0132131 2.58 0.014 .0073535 .0607628

# _cons | -.0061467 .0024601 -2.50 0.017 -.0111188 -.0011747

# Same regression in R:

# Country specific time trends

df % group_by(ccode) %>% mutate(tt = year-1978)

for (cc in unique(df$iso2c)) {

tmp <- df[df$iso2c == cc,]$tt

df[, paste0("tt.", cc)] <- ifelse(df$iso2c == cc, tmp, 0)

}

## Country fixed effects

for (cc in unique(df$iso2c)) {

df[, paste0("fe.", cc)] <- ifelse(df$iso2c == cc, 1, 0)

}

ols |t|)

# (Intercept) -0.00615 0.00262 -2.35 0.0191 *

# GPCP_g 0.05543 0.01418 3.91 0.0001 ***

# GPCP_g_l 0.03406 0.01190 2.86 0.0043 **

# —

# The same applies for:

coeftest(ols, vcov = function(x) sandwich::vcovHC(x, type = “HC1”, cluster = “group”))

and what about Debian Xfce?… ]]>