heteroskedasticity-consistent (HC) standard errors

General help and assistance with jamovi. Bug reports can be made at our issues page: https://github.com/jamovi/jamovi/issues . (If you're unsure feel free to discuss it here)
NathalieGier
Posts: 1
Joined: Sat Jun 13, 2020 9:22 am

heteroskedasticity-consistent (HC) standard errors

Post by NathalieGier »

Hi together,
I recognized that some of my predictors does not fulfill the assumption of homoskedasticity.
As far as I know, robust standard errors or heteroskedasticity-consistent (HC) standard errors are one possibility to cope with this issue.

Is there any possibility to compute a regression analysis with such HC standard errors? I have already downloaded the module walrus, but can only find t-tests and anova.

Thanks in advance & regards from Germany

Nathalie
User avatar
jonathon
Posts: 2613
Joined: Fri Jan 27, 2017 10:04 am

Re: heteroskedasticity-consistent (HC) standard errors

Post by jonathon »

hi,

not something i know about, sorry.

kind regards

jonathon
User avatar
MAgojam
Posts: 421
Joined: Thu Jun 08, 2017 2:33 pm
Location: Parma (Italy)

Re: heteroskedasticity-consistent (HC) standard errors

Post by MAgojam »

Hi, @NathalieGier.
I am attaching a jamovi file where with a small scrip r for the Rj module you can calculate heteroskedasticity-consistent (HC) standard errors as in STATA.
incoming_saving.omv
(97.32 KiB) Downloaded 367 times
I hope you find it useful, let me know.

Regards from Italy.
Maurizio
tkemeny
Posts: 23
Joined: Mon Sep 07, 2020 2:57 pm

Re: heteroskedasticity-consistent (HC) standard errors

Post by tkemeny »

Hi @Magojam et al,

It is very odd that robust SEs are not a feature, seeing as they are so commonly used.

I tried your code, but it seems to just output the same set of non-robust standard errors. See attached.
Screenshot 2021-02-17 at 11.47.43.png
Screenshot 2021-02-17 at 11.47.43.png (51.46 KiB) Viewed 5028 times
Screenshot 2021-02-17 at 11.48.01.png
Screenshot 2021-02-17 at 11.48.01.png (220.07 KiB) Viewed 5028 times
Any thoughts?
Thanks
Tom
User avatar
MAgojam
Posts: 421
Joined: Thu Jun 08, 2017 2:33 pm
Location: Parma (Italy)

Re: heteroskedasticity-consistent (HC) standard errors

Post by MAgojam »

Hi Tom.
I am attaching you .omv files with Rj scripts and screenshots that should help.
For the script's summary.lm () function that overrides summary (), take a look here:
https://economictheoryblog.com/2016/08/ ... -function/
Sorry if I run, but if it doesn't help, go back.
Rj_robust_stderr.omv
(5.58 KiB) Downloaded 262 times
Rj_robust_stderr.PNG
Rj_robust_stderr.PNG (159.55 KiB) Viewed 4765 times
Cheers,
Maurizio
tkemeny
Posts: 23
Joined: Mon Sep 07, 2020 2:57 pm

Re: heteroskedasticity-consistent (HC) standard errors

Post by tkemeny »

Thanks so much. The code is failing on something very simple - I'm not sure how to refer to the data - forgive me, I'm a Stata person, not an R person.

If I want to run the code on an open Jamovi dataset (.omv), how do I do that? I tried something like

Code: Select all

my_data <- lab_data_baseline.dta ('/Users/tk1/Dropbox/teaching/BUS135_QUANT/data/lab_data_baseline.dta')
my_model <- lm(grsswk ~ sexx + ttushr + sc10mmj, data = my_data)
But this returns an error. I'm sure this is completely simple but I'm not how to solve it.

Thanks
Tom
User avatar
MAgojam
Posts: 421
Joined: Thu Jun 08, 2017 2:33 pm
Location: Parma (Italy)

Re: heteroskedasticity-consistent (HC) standard errors

Post by MAgojam »

Hi, Tom.
Sorry if I tell you things you know, but I don't wish I had misinterpreted your question.

The Stata files (.dta), are files that jamovi is able to import without particular problems by going from the Import->This PC (Hamburger menu).
From the combobox Data files select one of the available formats, in your case it will be Stata files (.dta) and then with Browse go to the folder where the file you want to use is present.
In the Rj editor, you can refer to the dataset with data.

Code: Select all

# Your code:
my_data <- lab_data_baseline.dta ('/Users/tk1/Dropbox/teaching/BUS135_QUANT/data/lab_data_baseline.dta')
my_model <- lm(grsswk ~ sexx + ttushr + sc10mmj, data = my_data)

# it should be this:
my_data <- data
my_model <- lm(grsswk ~ sexx + ttushr + sc10mmj, data = my_data)

# or even just this:
my_model <- lm(grsswk ~ sexx + ttushr + sc10mmj, data = data)
If you prefer to use the Rj editor with a blank jamovi, you can refer to your Stata data with this lightweight code:

Code: Select all

library(haven)
library(lmtest)

# Import Stata file
my_data  <- read_dta('C:/Users/tk1/Dropbox/teaching/BUS135_QUANT/data/lab_data_baseline.dta')
my_model <- lm(grsswk ~ sexx + ttushr + sc10mmj, data = my_data)
Cheers,
Maurizio
tkemeny
Posts: 23
Joined: Mon Sep 07, 2020 2:57 pm

Re: heteroskedasticity-consistent (HC) standard errors

Post by tkemeny »

Again, many thanks Maurizio - I really appreciate your help.

I copied and pasted your code (adjusting the path slightly - I'm on a Mac not a pc), but no matter how I adjust, or which version of your code I use, literally nothing happens. I get no output, and no error.

For instance- running the following:

Code: Select all

library(haven)
library(lmtest)

# Import Stata file
my_data  <- read_dta('/Users/tk1/Dropbox/teaching/BUS135_QUANT/data/lab_data_baseline.dta')
my_model <- lm(grsswk ~ sexx + ttushr + sc10mmj, data = my_data)
I get the attached output (nothing). I also tried this with the data already loaded. Same non-result.

So confusing! Any thoughts?

Best,
Tom
Attachments
Screenshot 2021-02-26 at 10.04.03.png
Screenshot 2021-02-26 at 10.04.03.png (100.6 KiB) Viewed 4489 times
User avatar
jonathon
Posts: 2613
Joined: Fri Jan 27, 2017 10:04 am

Re: heteroskedasticity-consistent (HC) standard errors

Post by jonathon »

put

my_model

on a line at the end by itself.

jonathon
User avatar
MAgojam
Posts: 421
Joined: Thu Jun 08, 2017 2:33 pm
Location: Parma (Italy)

Re: heteroskedasticity-consistent (HC) standard errors

Post by MAgojam »

Hi Tom.
I saw that Jonathon has already answered you (thanks J).
I think he will help you to have the file (attached) with all the code again (to answer the original question).
Check that the file path is correct for your MAC.
If there are any problems, come back here.
Rj_robust_stderr.omv
(2.03 KiB) Downloaded 255 times
Cheers,
Maurizio
Post Reply