Skip to content
Please note that GitHub no longer supports your web browser.

We recommend upgrading to the latest Google Chrome or Firefox.

Learn more
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`vcov` argument doesn't affect output #31

Open
vincentarelbundock opened this issue Mar 9, 2019 · 1 comment
Open

`vcov` argument doesn't affect output #31

vincentarelbundock opened this issue Mar 9, 2019 · 1 comment
Labels
bug

Comments

@vincentarelbundock
Copy link
Contributor

@vincentarelbundock vincentarelbundock commented Mar 9, 2019

Please specify whether your issue is about:

  • a possible bug
  • a question about package functionality
  • a suggested code or documentation change, improvement to the code, or feature request

I was trying to figure out why the confidence intervals didn't change in my margins ggplot2 branch when using predictions. So I just want to check here if there should be a difference in se.fitted between those two commands.

Thanks!

library(sandwich)                                                                                                                                                                                                                             
library(prediction)                                                                                                                                                                                                                            
mod <- lm(am ~ wt*drat, data = mtcars)         
                                                                                                                                                                                                
head(prediction(mod, vcov = vcov(mod)))                                                                                                                                                                                                        
#>    mpg cyl disp  hp drat    wt  qsec vs am gear carb     fitted  se.fitted
#> 1 21.0   6  160 110 3.90 2.620 16.46  0  1    4    4 0.62380854 0.07567668
#> 2 21.0   6  160 110 3.90 2.875 17.02  0  1    4    4 0.56084776 0.08093441
#> 3 22.8   4  108  93 3.85 2.320 18.61  1  1    4    1 0.67453295 0.08344169
#> 4 21.4   6  258 110 3.08 3.215 19.44  1  0    3    1 0.17696915 0.10392980
#> 5 18.7   8  360 175 3.15 3.440 17.02  0  0    3    2 0.16609522 0.08536989
#> 6 18.1   6  225 105 2.76 3.460 20.22  1  0    3    1 0.03100386 0.13623569

head(prediction(mod, vcov = sandwich::vcovHC(mod)))    
#>    mpg cyl disp  hp drat    wt  qsec vs am gear carb     fitted  se.fitted
#> 1 21.0   6  160 110 3.90 2.620 16.46  0  1    4    4 0.62380854 0.07567668
#> 2 21.0   6  160 110 3.90 2.875 17.02  0  1    4    4 0.56084776 0.08093441
#> 3 22.8   4  108  93 3.85 2.320 18.61  1  1    4    1 0.67453295 0.08344169
#> 4 21.4   6  258 110 3.08 3.215 19.44  1  0    3    1 0.17696915 0.10392980
#> 5 18.7   8  360 175 3.15 3.440 17.02  0  0    3    2 0.16609522 0.08536989
#> 6 18.1   6  225 105 2.76 3.460 20.22  1  0    3    1 0.03100386 0.13623569

Created on 2019-03-09 by the reprex package (v0.2.1)

@leeper leeper added the bug label Jun 26, 2019
@leeper

This comment has been minimized.

Copy link
Owner

@leeper leeper commented Dec 24, 2019

Note for myself: this is because the se.fit column is taken directly from predict.lm() but there's no way to pass a custom vcov value to that function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.