Error in factorial(n) : argument "n" is missing, with no default.

library(ISLR)
library(MASS)
data("Weekly")
fit<-glm(Direction~Lag1+Lag2+Lag3+Lag4+Lag5+Volume,family = "binomial",data = Weekly)
summary(fit)

then it comes out this warning error information as same as the topic
Error in factorial(n) : argument "n" is missing, with no default.
I found whenever I use the function glm() and family="binomial", this error exists, if family="poisson", it's fine. Help! Thx in advance!

Try in a fresh R session. You may have a namespace conflict.

library(ISLR)
library(MASS)
data("Weekly")
fit<-glm(Direction~Lag1+Lag2+Lag3+Lag4+Lag5+Volume,family = "binomial",data = Weekly)
summary(fit)
#> 
#> Call:
#> glm(formula = Direction ~ Lag1 + Lag2 + Lag3 + Lag4 + Lag5 + 
#>     Volume, family = "binomial", data = Weekly)
#> 
#> Deviance Residuals: 
#>     Min       1Q   Median       3Q      Max  
#> -1.6949  -1.2565   0.9913   1.0849   1.4579  
#> 
#> Coefficients:
#>             Estimate Std. Error z value Pr(>|z|)   
#> (Intercept)  0.26686    0.08593   3.106   0.0019 **
#> Lag1        -0.04127    0.02641  -1.563   0.1181   
#> Lag2         0.05844    0.02686   2.175   0.0296 * 
#> Lag3        -0.01606    0.02666  -0.602   0.5469   
#> Lag4        -0.02779    0.02646  -1.050   0.2937   
#> Lag5        -0.01447    0.02638  -0.549   0.5833   
#> Volume      -0.02274    0.03690  -0.616   0.5377   
#> ---
#> Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#> 
#> (Dispersion parameter for binomial family taken to be 1)
#> 
#>     Null deviance: 1496.2  on 1088  degrees of freedom
#> Residual deviance: 1486.4  on 1082  degrees of freedom
#> AIC: 1500.4
#> 
#> Number of Fisher Scoring iterations: 4

Created on 2020-07-24 by the reprex package (v0.3.0)

Thanks for replying, I tried but still not working. I updated both R and Rstudio and receive same results of error. :pensive:

Sorry to be unclear. I meant that you should open R or RStudio and before doing anything else ("new session"), cut and paste the code. The stats::glm function does not return this error; other packages' glm function might. That's what I meant by namespace.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.