Skip to content
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

Error with estfun with R version 4.0.x #16

Open
jwilliman opened this issue Oct 18, 2020 · 1 comment
Open

Error with estfun with R version 4.0.x #16

jwilliman opened this issue Oct 18, 2020 · 1 comment

Comments

@jwilliman
Copy link

Calculation of robust standard errors using the sandwich package appears to fail under R 4.0.x but not under earlier versions (3.6.0).

I see this issue has already be raised and closed, and am just noting that it is reproducible on versions of R > 4.

suppressPackageStartupMessages({
  library(drc)
  library(lmtest)
  library(sandwich)
})

ryegrass.m1<-drm(rootl ~ conc, data = ryegrass, fct = LL.4())
coeftest(ryegrass.m1, vcov = sandwich)
#> Error in UseMethod("estfun"): no applicable method for 'estfun' applied to an object of class "drc"
sessionInfo()
#> R version 4.0.2 (2020-06-22)
#> Platform: i386-w64-mingw32/i386 (32-bit)
#> Running under: Windows 10 x64 (build 17134)
#> 
#> Matrix products: default
#> 
#> locale:
#> [1] LC_COLLATE=English_New Zealand.1252  LC_CTYPE=English_New Zealand.1252   
#> [3] LC_MONETARY=English_New Zealand.1252 LC_NUMERIC=C                        
#> [5] LC_TIME=English_New Zealand.1252    
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] sandwich_2.5-1 lmtest_0.9-37  zoo_1.8-8      drc_3.0-1      MASS_7.3-51.6 
#> 
#> loaded via a namespace (and not attached):
#>  [1] zip_2.1.1         Rcpp_1.0.5        compiler_4.0.2    pillar_1.4.6     
#>  [5] cellranger_1.1.0  highr_0.8         forcats_0.5.0     tools_4.0.2      
#>  [9] digest_0.6.25     evaluate_0.14     tibble_3.0.3      lifecycle_0.2.0  
#> [13] lattice_0.20-41   pkgconfig_2.0.3   rlang_0.4.7       Matrix_1.2-18    
#> [17] openxlsx_4.1.5    curl_4.3          yaml_2.2.1        mvtnorm_1.1-1    
#> [21] haven_2.3.1       xfun_0.16         rio_0.5.16        stringr_1.4.0    
#> [25] knitr_1.29        vctrs_0.3.3       gtools_3.8.2      hms_0.5.3        
#> [29] grid_4.0.2        data.table_1.13.0 R6_2.4.1          plotrix_3.7-8    
#> [33] survival_3.1-12   readxl_1.3.1      foreign_0.8-80    rmarkdown_2.3    
#> [37] multcomp_1.4-13   TH.data_1.0-10    carData_3.0-4     car_3.0-9        
#> [41] magrittr_1.5      scales_1.1.1      codetools_0.2-16  splines_4.0.2    
#> [45] ellipsis_0.3.1    htmltools_0.5.0   abind_1.4-5       colorspace_1.4-1 
#> [49] stringi_1.4.6     munsell_0.5.0     crayon_1.3.4

Created on 2020-10-19 by the reprex package (v0.3.0)

But works at https://rdrr.io/snippets/ which uses R 3.4.4, but same version of drc and sandwich.


t test of coefficients:

              Estimate Std. Error t value  Pr(>|t|)    
b:(Intercept)  2.98222    0.47438  6.2865 3.882e-06 ***
c:(Intercept)  0.48141    0.12779  3.7672  0.001212 ** 
d:(Intercept)  7.79296    0.15311 50.8976 < 2.2e-16 ***
e:(Intercept)  3.05795    0.26741 11.4355 3.170e-10 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

sh: 1: cannot create /dev/null: Permission denied
R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)

Matrix products: default
BLAS: /usr/lib/atlas-base/atlas/libblas.so.3.0
LAPACK: /usr/lib/lapack/liblapack.so.3.0

locale:
[1] C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] sandwich_2.5-1 lmtest_0.9-37  zoo_1.8-5      drc_3.0-1      MASS_7.3-51.4 

loaded via a namespace (and not attached):
 [1] zip_2.0.1         Rcpp_1.0.1        cellranger_1.1.0  pillar_1.3.1     
 [5] compiler_3.4.4    forcats_0.4.0     tools_3.4.4       tibble_2.1.1     
 [9] lattice_0.20-38   pkgconfig_2.0.2   rlang_0.3.4       openxlsx_4.1.0   
[13] Matrix_1.2-17     curl_3.3          mvtnorm_1.0-8     haven_2.1.0      
[17] rio_0.5.16        gtools_3.8.1      hms_0.4.2         grid_3.4.4       
[21] data.table_1.12.2 plotrix_3.7-5     readxl_1.3.1      survival_2.44-1.1
[25] foreign_0.8-71    multcomp_1.4-8    TH.data_1.0-10    carData_3.0-2    
[29] car_3.0-2         magrittr_1.5      scales_1.0.0      codetools_0.2-16 
[33] splines_3.4.4     abind_1.4-5       colorspace_1.4-1  munsell_0.5.0    
[37] crayon_1.3.4    

@rhurlin
Copy link

rhurlin commented Sep 11, 2021

Hi @jwilliman ,

I just tried your example with an up to date package drc, reinstalled via install_github, now at version 3.2.0:

library(devtools)
install_github("DoseResponse/drc")

As far as I can say, it works as expected now:

> coeftest(ryegrass.m1, vcov = sandwich)

t test of coefficients:

              Estimate Std. Error t value  Pr(>|t|)    
b:(Intercept)  2.98222    0.47438  6.2865 3.882e-06 ***
c:(Intercept)  0.48141    0.12779  3.7672  0.001212 ** 
d:(Intercept)  7.79296    0.15311 50.8976 < 2.2e-16 ***
e:(Intercept)  3.05795    0.26741 11.4355 3.170e-10 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

I am on R-4.2.0 (devel), but before updating drc via github this R version gave the exact same error. Here is my sessionInfo:

> sessionInfo()
R Under development (unstable) (2021-08-27 r80829)
Platform: amd64-portbld-freebsd14.0 (64-bit)
Running under: FreeBSD xxx.xxx.xxx 14.0-CURRENT FreeBSD 14.0-CURRENT #0 main-n249159-bb61ccd530b: Sun Sep  5 18:50:40 CEST 2021     xxx@xxx.xxx.xxx:/usr/obj/usr/src/amd64.amd64/sys/RHURLIN  amd64

Matrix products: default
LAPACK: /usr/local/lib/R/lib/libRlapack.so.4.2.0

Random number generation:
 RNG:     Mersenne-Twister 
 Normal:  Inversion 
 Sample:  Rounding 
 
locale:
[1] C/de_DE.UTF-8/de_DE.UTF-8/C/de_DE.UTF-8/de_DE.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] sandwich_3.0-1 lmtest_0.9-38  zoo_1.8-9      drc_3.2-0      drcData_1.1-3  MASS_7.3-54   

loaded via a namespace (and not attached):
 [1] zip_2.2.0         Rcpp_1.0.7        pillar_1.6.2      compiler_4.2.0    cellranger_1.1.0 
 [6] forcats_0.5.1     tools_4.2.0       lifecycle_1.0.0   tibble_3.1.4      lattice_0.20-44  
[11] pkgconfig_2.0.3   rlang_0.4.11      Matrix_1.3-4      openxlsx_4.2.4    curl_4.3.2       
[16] mvtnorm_1.1-2     haven_2.4.3       rio_0.5.27        vctrs_0.3.8       gtools_3.9.2     
[21] hms_1.1.0         grid_4.2.0        data.table_1.14.0 R6_2.5.1          plotrix_3.8-2    
[26] fansi_0.5.0       survival_3.2-13   readxl_1.3.1      foreign_0.8-81    multcomp_1.4-17  
[31] TH.data_1.0-10    carData_3.0-4     car_3.0-11        magrittr_2.0.1    scales_1.1.1     
[36] codetools_0.2-18  splines_4.2.0     ellipsis_0.3.2    abind_1.4-5       colorspace_2.0-2 
[41] utf8_1.2.2        stringi_1.7.4     munsell_0.5.0     crayon_1.4.1

HTH,
Rainer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants