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

ols_regress returns error in the presence of interaction terms in the formula #47

Closed
aravindhebbali opened this issue Dec 22, 2017 · 1 comment

Comments

Projects
1 participant
@aravindhebbali
Copy link
Member

commented Dec 22, 2017

library(olsrr)
#> 
#> Attaching package: 'olsrr'
#> The following object is masked from 'package:datasets':
#> 
#>     rivers
mt <- mtcars
mt$cyl <- as.factor(mt$cyl)
ols_regress(mpg ~ disp + cyl + disp*cyl, data = mt)
#> Warning in mean.default(X[[i]], ...): argument is not numeric or logical:
#> returning NA
#> Error in FUN(x, aperm(array(STATS, dims[perm]), order(perm)), ...): non-numeric argument to binary operator

@aravindhebbali aravindhebbali added the bug label Dec 22, 2017

@aravindhebbali aravindhebbali self-assigned this Dec 22, 2017

@aravindhebbali aravindhebbali added this to To Do in 0.5.0 via automation Dec 22, 2017

@aravindhebbali aravindhebbali added this to the 0.5.0 milestone Dec 22, 2017

@aravindhebbali

This comment has been minimized.

Copy link
Member Author

commented Dec 22, 2017

The error was due to scaling and centering all the predictors instead of only the numeric types.

library(olsrr)
#> 
#> Attaching package: 'olsrr'
#> The following object is masked from 'package:datasets':
#> 
#>     rivers
mt <- mtcars
mt$cyl <- as.factor(mt$cyl)
ols_regress(mpg ~ disp + cyl + disp*cyl, data = mt)
#>                         Model Summary                          
#> --------------------------------------------------------------
#> R                       0.933       RMSE                2.372 
#> R-Squared               0.870       Coef. Var          11.804 
#> Adj. R-Squared          0.845       MSE                 5.624 
#> Pred R-Squared          0.794       MAE                 1.778 
#> --------------------------------------------------------------
#>  RMSE: Root Mean Square Error 
#>  MSE: Mean Square Error 
#>  MAE: Mean Absolute Error 
#> 
#>                                ANOVA                                 
#> --------------------------------------------------------------------
#>                 Sum of                                              
#>                Squares        DF    Mean Square      F         Sig. 
#> --------------------------------------------------------------------
#> Regression     979.813         5        195.963    34.842    0.0000 
#> Residual       146.234        26          5.624                     
#> Total         1126.047        31                                    
#> --------------------------------------------------------------------
#> 
#>                                   Parameter Estimates                                    
#> ----------------------------------------------------------------------------------------
#>       model      Beta    Std. Error    Std. Beta      t        Sig      lower     upper 
#> ----------------------------------------------------------------------------------------
#> (Intercept)    -1.725         0.594                 -2.907    0.007    -2.945    -0.505 
#>        disp    -2.779         0.574       -2.779    -4.842    0.000    -3.959    -1.599 
#>        cyl6     1.696         0.639        0.712     2.655    0.013     0.383     3.009 
#>        cyl8     1.296         0.634        0.653     2.044    0.051    -0.008     2.600 
#>   disp:cyl6     2.853         0.748        0.622     3.817    0.001     1.317     4.390 
#>   disp:cyl8     2.375         0.608        1.451     3.909    0.001     1.126     3.624 
#> ----------------------------------------------------------------------------------------
Session info
devtools::session_info()
#> Session info -------------------------------------------------------------
#>  setting  value                       
#>  version  R version 3.4.3 (2017-11-30)
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  English_India.1252          
#>  tz       Asia/Calcutta               
#>  date     2017-12-22
#> Packages -----------------------------------------------------------------
#>  package    * version    date       source                            
#>  assertthat   0.2.0      2017-04-11 CRAN (R 3.4.0)                    
#>  backports    1.1.2      2017-12-13 CRAN (R 3.4.3)                    
#>  base       * 3.4.3      2017-11-30 local                             
#>  bindr        0.1        2016-11-13 CRAN (R 3.4.0)                    
#>  bindrcpp     0.2        2017-06-17 CRAN (R 3.4.1)                    
#>  broom        0.4.2      2017-02-13 CRAN (R 3.4.0)                    
#>  class        7.3-14     2015-08-30 CRAN (R 3.4.3)                    
#>  colorspace   1.2-7      2016-10-11 CRAN (R 3.2.5)                    
#>  compiler     3.4.3      2017-11-30 local                             
#>  CVST         0.2-1      2013-12-10 CRAN (R 3.4.2)                    
#>  datasets   * 3.4.3      2017-11-30 local                             
#>  ddalpha      1.3.1      2017-09-27 CRAN (R 3.4.2)                    
#>  DEoptimR     1.0-8      2016-11-19 CRAN (R 3.4.1)                    
#>  devtools     1.13.3     2017-08-02 CRAN (R 3.4.1)                    
#>  digest       0.6.12     2017-01-27 CRAN (R 3.4.1)                    
#>  dimRed       0.1.0      2017-05-04 CRAN (R 3.4.2)                    
#>  dplyr        0.7.4      2017-09-28 CRAN (R 3.4.2)                    
#>  DRR          0.0.2      2016-09-15 CRAN (R 3.4.2)                    
#>  evaluate     0.10.1     2017-06-24 CRAN (R 3.4.3)                    
#>  foreign      0.8-69     2017-06-22 CRAN (R 3.4.3)                    
#>  ggplot2      2.2.1      2016-12-30 CRAN (R 3.3.3)                    
#>  glue         1.2.0      2017-10-29 CRAN (R 3.4.2)                    
#>  goftest      1.0-3      2015-07-03 CRAN (R 3.2.3)                    
#>  gower        0.1.2      2017-02-23 CRAN (R 3.4.2)                    
#>  graphics   * 3.4.3      2017-11-30 local                             
#>  grDevices  * 3.4.3      2017-11-30 local                             
#>  grid         3.4.3      2017-11-30 local                             
#>  gridExtra    2.2.1      2016-02-29 CRAN (R 3.4.1)                    
#>  gtable       0.2.0      2016-02-26 CRAN (R 3.2.5)                    
#>  htmltools    0.3.6      2017-04-28 CRAN (R 3.4.1)                    
#>  httpuv       1.3.5      2017-07-04 CRAN (R 3.4.1)                    
#>  ipred        0.9-6      2017-03-01 CRAN (R 3.4.2)                    
#>  kernlab      0.9-25     2016-10-03 CRAN (R 3.4.1)                    
#>  knitr        1.17       2017-08-10 CRAN (R 3.4.1)                    
#>  lattice      0.20-35    2017-03-25 CRAN (R 3.4.3)                    
#>  lava         1.5.1      2017-09-27 CRAN (R 3.4.2)                    
#>  lazyeval     0.2.0      2016-06-12 CRAN (R 3.3.2)                    
#>  lubridate    1.7.1      2017-11-03 CRAN (R 3.4.2)                    
#>  magrittr     1.5        2014-11-22 CRAN (R 3.2.2)                    
#>  MASS         7.3-47     2017-02-26 CRAN (R 3.4.3)                    
#>  Matrix       1.2-12     2017-11-20 CRAN (R 3.4.3)                    
#>  memoise      1.0.0.9001 2017-03-06 Github (hadley/memoise@884d565)   
#>  methods    * 3.4.3      2017-11-30 local                             
#>  mime         0.5        2016-07-07 CRAN (R 3.3.2)                    
#>  mnormt       1.5-5      2016-10-15 CRAN (R 3.3.2)                    
#>  munsell      0.4.3      2016-02-13 CRAN (R 3.2.5)                    
#>  nlme         3.1-125    2016-02-27 CRAN (R 3.2.3)                    
#>  nnet         7.3-12     2016-02-02 CRAN (R 3.4.3)                    
#>  nortest      1.0-4      2015-07-30 CRAN (R 3.2.3)                    
#>  olsrr      * 0.4.0.9000 2017-12-22 local                             
#>  parallel     3.4.3      2017-11-30 local                             
#>  pkgconfig    2.0.1      2017-03-21 CRAN (R 3.4.0)                    
#>  plyr         1.8.4      2016-06-08 CRAN (R 3.2.5)                    
#>  prodlim      1.6.1      2017-03-06 CRAN (R 3.4.2)                    
#>  psych        1.6.9      2016-09-17 CRAN (R 3.3.2)                    
#>  purrr        0.2.4      2017-10-18 CRAN (R 3.4.2)                    
#>  R6           2.2.2      2017-06-17 CRAN (R 3.4.1)                    
#>  Rcpp         0.12.14    2017-11-23 CRAN (R 3.4.3)                    
#>  RcppRoll     0.2.2      2015-04-05 CRAN (R 3.4.2)                    
#>  recipes      0.1.1      2017-11-20 CRAN (R 3.4.2)                    
#>  reshape2     1.4.2      2016-10-22 CRAN (R 3.2.5)                    
#>  rlang        0.1.4      2017-11-05 CRAN (R 3.4.3)                    
#>  rmarkdown    1.8.5      2017-12-22 Github (rstudio/rmarkdown@9f45f00)
#>  robustbase   0.92-8     2017-11-01 CRAN (R 3.4.2)                    
#>  rpart        4.1-10     2015-06-29 CRAN (R 3.3.3)                    
#>  rprojroot    1.3-1      2017-12-22 Github (krlmlr/rprojroot@0ec8bf7) 
#>  scales       0.4.1      2016-11-09 CRAN (R 3.2.5)                    
#>  sfsmisc      1.1-1      2017-06-08 CRAN (R 3.4.2)                    
#>  shiny        1.0.5      2017-08-23 CRAN (R 3.4.2)                    
#>  splines      3.4.3      2017-11-30 local                             
#>  stats      * 3.4.3      2017-11-30 local                             
#>  stringi      1.1.5      2017-04-07 CRAN (R 3.4.1)                    
#>  stringr      1.2.0      2017-02-18 CRAN (R 3.4.1)                    
#>  survival     2.41-3     2017-04-04 CRAN (R 3.4.3)                    
#>  tibble       1.3.4      2017-08-22 CRAN (R 3.4.1)                    
#>  tidyr        0.7.2      2017-10-16 CRAN (R 3.4.2)                    
#>  tidyselect   0.2.2      2017-10-10 CRAN (R 3.4.2)                    
#>  timeDate     3012.100   2015-01-23 CRAN (R 3.2.5)                    
#>  tools        3.4.3      2017-11-30 local                             
#>  utils      * 3.4.3      2017-11-30 local                             
#>  withr        2.1.0      2017-11-01 CRAN (R 3.4.3)                    
#>  xtable       1.8-0      2015-11-02 CRAN (R 3.1.3)                    
#>  yaml         2.1.16     2017-12-12 CRAN (R 3.4.3)

0.5.0 automation moved this from To Do to Done Dec 22, 2017

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