# Regression Workflow

**URL:** https://discourse.julialang.org/t/regression-workflow/39071
**Category:** Finance and Economics
**Created:** [May 8, 2020, 9:54am UTC](https://discourse.julialang.org/t/regression-workflow/39071 "2020-05-08T09:54:28Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![IljaK91](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iljak91/32/44301_2.png) [@IljaK91](https://discourse.julialang.org/u/IljaK91)
#### Post date: [May 8, 2020, 9:54am UTC](https://discourse.julialang.org/t/regression-workflow/39071/1 "2020-05-08T09:54:28Z")

</div>

Hi everyone,

So far I did not succeed in moving my empirical workflow to Julia:

Data cleaning (`Query.jl/DataFrames.jl`) → Regression (`GLM.jl`) → Custom Standard Errors (`CovarianceMatrices.jl`) ??? Latex-Regressiontable (`RegressionTables.jl`)

The step that I fail at is to use standard custom errors (e.g. HAC) for my regression tables. Being able export tables only using iid standard errors is not really useful. So far I have not seen a solution to this problem in Julia.

What I would do in R is

```julia
# Return regression
regression_model <- lm(Y~ X1+ X2, data = data)
regression_model_2 <- lm(Y~ X1+ X3, data = data)

notes = c("\\parbox[t]{7cm}{" I am using custom standard errors"})

se_new = sqrt(diag(vcovHC(regression_model )))
se_new_2 = sqrt(diag(vcovHC(regression_model_2 )))

stargazer(regression_model, regression_model_2 
          out = paste("RegressionTable" ,spec, ".tex", sep=""), title="Regression", 
          se = list(se_new, se_new_2))

```

Is there any way to do the same in Julia? Maybe people use different packages, that I am not aware of.

Thank you very much!

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [May 8, 2020, 11:40am UTC](https://discourse.julialang.org/t/regression-workflow/39071/2 "2020-05-08T11:40:39Z")

</div>

Unfortunately, it looks like RegressionTables.jl doesn’t have tis functionality. I think you would have to `dev` `RegressionTables.jl` and modify [this line](https://github.com/jmboehm/RegressionTables.jl/blob/9f0240eaa89d54d5298a042ccf5dfd5a6a3398e7/src/regtable.jl#L120) to add that ability.

This is definitely frustrating, and shows what features julia is lacking compared to R right not.

Another reason clustering (and specification of errors in general) should be in the model-fitting process and not after.

---

<div class="post-metadata">

### Author: ![Paul\_Soderlind](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_soderlind/32/1753_2.png) [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)
#### Post date: [May 8, 2020, 2:15pm UTC](https://discourse.julialang.org/t/regression-workflow/39071/3 "2020-05-08T14:15:59Z")

</div>

> HAC for my regression tables

It looks like you do linear regressions. If so, [this notebook, aimed at teaching financial econometrics](https://github.com/PaulSoderlind/FinancialEconometrics/blob/master/Ch04b_OLS2_Testing.ipynb) shows how to do White’s and Newey-West.

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [May 8, 2020, 2:20pm UTC](https://discourse.julialang.org/t/regression-workflow/39071/4 "2020-05-08T14:20:20Z")

</div>

OP can implement the variance-covariance matrix easily using `CovarianceMatrices.jl`. the problem is that when printing them to a latex table they have to let `RegressionTables.jl` know to use the variance-covariance matrix they provided.

---

<div class="post-metadata">

### Author: ![IljaK91](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iljak91/32/44301_2.png) [@IljaK91](https://discourse.julialang.org/u/IljaK91)
#### Post date: [May 10, 2020, 4:48pm UTC](https://discourse.julialang.org/t/regression-workflow/39071/5 "2020-05-10T16:48:59Z")

</div>

It does not sound like something awefully difficult to do. Is anyone interested to have a look together with me?

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [May 10, 2020, 7:51pm UTC](https://discourse.julialang.org/t/regression-workflow/39071/6 "2020-05-10T19:51:22Z")

</div>

I filed an issue [here](https://github.com/jmboehm/RegressionTables.jl/issues/67). If the package author thinks its a good thing to add it shouldn’t be too hard to make a PR.

---

<div class="post-metadata">

### Author: ![IljaK91](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iljak91/32/44301_2.png) [@IljaK91](https://discourse.julialang.org/u/IljaK91)
#### Post date: [May 12, 2020, 7:36am UTC](https://discourse.julialang.org/t/regression-workflow/39071/7 "2020-05-12T07:36:27Z")

</div>

Thank you, it might be an option to include the necessary functionality in `CovarianceMatrices.jl`, there is an issue [here](https://github.com/gragusa/CovarianceMatrices.jl/issues/47).
