开发者

R: logit{gregmisc}

开发者 https://www.devze.com 2023-03-17 02:58 出处:网络
I want to do a logistic transformation on a variable, specifying upper and lower boundaries. I tried to replicated the \"logit\" function in the gregmisc package :

I want to do a logistic transformation on a variable, specifying upper and lower boundaries. I tried to replicated the "logit" function in the gregmisc package :

  library(gregmisc)
  x <- seq(0,10, by=0.25)
  xt <- logit(x, min=0, max=10)

but I get an error message:

Error in logit(x, min = 0, max = 10) : 
  unused argument(s) (min = 0, max = 10)

What gives? (P.S. gtools doesn't work either).

Here's the sessionInfo():

> library(gregmisc)    
+ x <- seq(0,10, by=0.25)
+ xt <- logit(x, min=0, max=10)
Error in logit(x, min = 0, max = 10) : 
  unused argument(s) (min = 0, max = 10)
> sessionInfo()
R version 2.13.0 (2011-04-13)
Platform: i486-pc-linux-gnu (32-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8          LC_NUMERIC=C                 
 [3] LC_TIME=en_US.UTF-8           LC_COLLATE=en_US.UTF-8       
 [5] LC_MONETARY=en_US.UTF-8       LC_MESSAGES=en_US.UTF-8      
 [7] LC_PAPER=en_US.UTF-8          LC_NAME=en_US.UTF-8          
 [9] LC_ADDRESS=en_US.UTF-8        LC_TELEPHONE=en_US.UTF-8     
[11] LC_MEASUREMENT=en_US.UTF-8    LC_IDENTIFICATION=en_US.UTF-8

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

other attached packages:
 [1] car_2.0-10      survival_2.36-9 nnet_7.3-1      MASS_7.3-13    
 [5] gregmisc_2.1.1  gplots_2.8.0    caTools_1.12    bitops_1.0-4.1 
 [9] gtools_2.6.2    gmodels_开发者_开发问答2.15.1  gdata_2.8.2     foreign_0.8-44 
[13] rkward_0.5.6   

loaded via a namespace (and not attached):
[1] tools_2.13.0


The clue is that you have the car package loaded as well, which also contains a logit function.

find("logit")

would have shown you

[1] "package:car"    "package:gtools"

They have different sets of arguments:

> names(formals(car::logit))
[1] "p"        "percents" "a
> names(formals(gtools::logit))
[1] "x"   "min" "max"

Either specifying gtools::logit explicitly or doing detach("package:car") should make things work.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号