refunders / refund

Regression with functional data
39 stars 23 forks source link

Variables loaded into global environment when a parametric term in included #101

Open fhui28 opened 2 years ago

fhui28 commented 2 years ago

Hi refunders,

I do not know if it is just my computer, or I am missing something silly. But something weird is going when I include a parametric term in pfr, as it for some reason then attaches the corresponding data frame to the global environment. Please see below for an example.

Thanks heaps in advance!

library(refund)

data(DTI)
DTI1 <- DTI[DTI$visit==1 & complete.cases(DTI),]

fit1 <- pfr(pasat ~ lf(cca, k=30), data=DTI1)
ls()
#> [1] "DTI"  "DTI1" "fit1"

Fine

fit1 <- pfr(pasat ~ lf(cca, k=30) + sex, data=DTI1)
ls()
#>  [1] "case"       "cca"        "DTI"        "DTI1"       "fit1"      
#>  [6] "ID"         "Nscans"     "pasat"      "rcst"       "sex"       
#> [11] "visit"      "visit.time"

Why are all the variables in DTI1 suddenly loaded into the environment

sessionInfo()
#> R version 3.6.3 (2020-02-29)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Linux Mint 20.3
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
#> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_AU.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_AU.UTF-8        LC_COLLATE=en_AU.UTF-8    
#>  [5] LC_MONETARY=en_AU.UTF-8    LC_MESSAGES=en_AU.UTF-8   
#>  [7] LC_PAPER=en_AU.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_AU.UTF-8 LC_IDENTIFICATION=C       
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] refund_0.1-26
#> 
#> loaded via a namespace (and not attached):
#>  [1] mclust_5.4.10      Rcpp_1.0.8.3       mvtnorm_1.1-3      lattice_0.20-40   
#>  [5] assertthat_0.2.1   digest_0.6.29      utf8_1.2.2         R6_2.5.1          
#>  [9] magic_1.6-0        reprex_2.0.1       pcaPP_2.0-2        evaluate_0.15     
#> [13] pracma_2.3.8       ggplot2_3.3.6      highr_0.9          pillar_1.7.0      
#> [17] rainbow_3.6        rlang_1.0.4        rstudioapi_0.13    minqa_1.2.4       
#> [21] nloptr_2.0.3       grpreg_3.4.0       fds_1.8            Matrix_1.2-18     
#> [25] rmarkdown_2.14     splines_3.6.3      lme4_1.1-29        stringr_1.4.0     
#> [29] gamm4_0.2-6        RCurl_1.98-1.7     munsell_0.5.0      compiler_3.6.3    
#> [33] xfun_0.31          pbs_1.1            pkgconfig_2.0.3    mgcv_1.8-31       
#> [37] htmltools_0.5.2    tidyselect_1.1.2   tibble_3.1.7       hdrcde_3.4        
#> [41] fansi_1.0.3        crayon_1.5.1       dplyr_1.0.9        withr_2.5.0       
#> [45] MASS_7.3-51.5      bitops_1.0-7       grid_3.6.3         nlme_3.1-144      
#> [49] gtable_0.3.0       lifecycle_1.0.1    DBI_1.1.2          magrittr_2.0.3    
#> [53] scales_1.2.0       KernSmooth_2.23-16 cli_3.3.0          stringi_1.7.6     
#> [57] fs_1.5.2           ellipsis_0.3.2     generics_0.1.2     vctrs_0.4.1       
#> [61] boot_1.3-24        deSolve_1.33       tools_3.6.3        glue_1.6.2        
#> [65] purrr_0.3.4        ks_1.13.5          parallel_3.6.3     abind_1.4-5       
#> [69] fastmap_1.1.0      yaml_2.3.5         colorspace_2.0-3   cluster_2.1.0     
#> [73] fda_6.0.5          RLRsim_3.1-8       knitr_1.39

Created on 2022-08-15 by the reprex package (v2.0.1)