【发布时间】:2019-10-14 11:23:12
【问题描述】:
我在逻辑回归模型中使用 'car' 包中的 boxTidwell 函数时遇到错误。
我想当模特
fatalCancer ~ globy1,其中 fatalCancer 是具有两个级别的因子,而 globy1 是数字(全为正)。我正在对此进行测试,以检查 globy1 的线性假设与结果的 logit。
查看错误消息(如下)和 boxTidwell 函数代码,似乎可能有问题,因为 fatalCancer 是一个因素。 boxTidwell 文档中没有任何关于指定它是逻辑模型的内容。在 Fox 的 _An R Companion to Applied Regression (p.312) 第 6.4 节的示例中,示例逻辑回归不需要任何规范。
有没有办法修复下面 boxTidwell 函数的语法?
> library(car)
Loading required package: carData
>
> load("m2dat.RData")
> m2dat <- na.omit(m2dat)
> dim(m2dat)
[1] 116 3
> head(m2dat)
dog globy1 fatalCancer
1 101A 3.1 No
2 102A 2.9 No
3 103A 4.9 No
4 104A 3.1 Yes
5 105A 2.8 Yes
6 106A 3.5 No
> boxTidwell(fatalCancer ~ globy1, data=m2dat)
MLE of lambda Score Statistic (z) Pr(>|z|)
6.5694 NA NA
iterations = 21
There were 48 warnings (use warnings() to see them)
> warnings()
Warning messages:
1: In model.response(mf, "numeric") :
using type = "numeric" with a factor response will be ignored
2: In model.response(mf, "numeric") :
using type = "numeric" with a factor response will be ignored
3: In Ops.factor(y, z$residuals) : ‘-’ not meaningful for factors
4: In model.response(mf, "numeric") :
using type = "numeric" with a factor response will be ignored
5: In Ops.factor(y, z$residuals) : ‘-’ not meaningful for factors
6: In Ops.factor(r, 2) : ‘^’ not meaningful for factors
7: In Ops.factor(y, z$residuals) : ‘-’ not meaningful for factors
8: In Ops.factor(y, z$residuals) : ‘-’ not meaningful for factors
9: In Ops.factor(y, z$residuals) : ‘-’ not meaningful for factors
10: In Ops.factor(y, z$residuals) : ‘-’ not meaningful for factors
...
46: In Ops.factor(y, z$residuals) : ‘-’ not meaningful for factors
47: In Ops.factor(y, z$residuals) : ‘-’ not meaningful for factors
48: In Ops.factor(y, z$residuals) : ‘-’ not meaningful for factors
分数统计结果为 NA,我想成功运行测试。
【问题讨论】:
-
?boxTidwell的文档中没有任何内容表明它适用于常规lm以外的任何内容。
标签: r logistic-regression