使用macOS的Predict()rms软件包中的错误

时间:2019-04-28 22:13:58

标签: macos predict rms

我在MacOS 10.14.4和R 3.5.3下运行Predict()函数时遇到问题。 我正在使用相同的语法,并且db在Windows10中运行良好:

Predict(lvef, LVEF, ModSev_MRAS_overall, fun=exp)

我总是收到错误消息:

Error in match.arg(type) : 'arg' must be NULL or a character vector

我还问其他使用Mac的同事,他们遇到了同样的问题。

然后我尝试阅读帮助Predict {rms},但我也无法运行示例代码,我总是收到错误消息,并且它也没有运行。

n <- 1000    # define sample size
set.seed(17) # so can reproduce the results
age            <- rnorm(n, 50, 10)
blood.pressure <- rnorm(n, 120, 15)
cholesterol    <- rnorm(n, 200, 25)
sex            <- factor(sample(c('female','male'), n,TRUE))
label(age)            <- 'Age'      # label is in Hmisc
label(cholesterol)    <- 'Total Cholesterol'
label(blood.pressure) <- 'Systolic Blood Pressure'
label(sex)            <- 'Sex'
units(cholesterol)    <- 'mg/dl'   # uses units.default in Hmisc
units(blood.pressure) <- 'mmHg'

# Specify population model for log odds that Y=1
L <- .4*(sex=='male') + .045*(age-50) +
  (log(cholesterol - 10)-5.2)*(-2*(sex=='female') + 2*(sex=='male'))
# Simulate binary y to have Prob(y=1) = 1/[1+exp(-L)]
y <- ifelse(runif(n) < plogis(L), 1, 0)

ddist <- datadist(age, blood.pressure, cholesterol, sex)
options(datadist='ddist')

fit <- lrm(y ~ blood.pressure + sex * (age + rcs(cholesterol,4)))
Predict(fit, age, cholesterol, np=4)

我收到错误消息:

Error in model.frame.default(Terms, newdata, na.action = na.action, ...) : 
  variable lengths differ (found for '(np)')
Inoltre: Warning messages:
1: In if (conf.int) { :
  la condizione la lunghezza > 1 e solo il promo elemento verrà utilizzato
2: In qnorm((1 + conf.int)/2) : Si è prodotto un NaN

请帮助! G

0 个答案:

没有答案