I have three regressions that I am trying to include into one table using the -stargazer- function. I have the following code:
library(Jmisc)
library(tidyverse)
library(sandwich)
library(lmtest)
library(multiwayvcov)
library(stargazer)
set.seed(123)
df <- data.frame(
x1 = rnorm(10, mean=0, sd=1),
x2 = rnorm(10, mean=0, sd=1),
y = rnorm(10, mean=0, sd=1)
)
r1 <- lm(y ~ x1 + x2, df)
cov1 <- vcovHC(r1, type="HC1", cluster="clustervar")
robust.se1 <- sqrt(diag(cov1))
t1 <- coef(r1)/robust.se1
r2 <- lm(y ~ x1, df)
cov2 <- vcovHC(r2, type="HC1", cluster="clustervar")
robust.se2 <- sqrt(diag(cov2))
t2 <- coef(r2)/robust.se2
r3 <- lm(y ~ x2, df)
cov3 <- vcovHC(r3, type="HC1", cluster="clustervar")
robust.se3 <- sqrt(diag(cov3))
t3 <- coef(r3)/robust.se2
stargazer(r1, r2, r3,
se = NULL,
t = list(t1, t2, t3),
align=TRUE,
type="html",
nobs=TRUE,
out="StargazerTest.txt")
The table that is produced reports standard errors as opposed to the t-statistics I created. This is most likely due to the -stargazer- function at the bottom. I have looked up the directory for it and still don't understand how to get it to do what I want.