【发布时间】:2017-09-26 10:24:18
【问题描述】:
我正在尝试使用以下代码运行 boxcox 转换:
urban1 <- subset(ski,urban <= 4,na.rm=TRUE)
ski$gender <- as.numeric((as.character(ski$gender)),na.rm=TRUE)
urban1 <- as.numeric((as.character(urban1)))
x <- (ski$gender*urban1)
y <- ski$EPSI.
bc <- boxcox(y ~ x)
(trans <- bc$x[which.max(bc$y)])
model3 <- lm(y ~ x)
model3new <- lm(y^trans ~ x)
ski$EPSI. <- ski$EPSI. + 1
但我不断收到此错误:
lm.fit(x,y,offset = offset,singular.ok =singular.ok, ...) 中的错误:0(非 NA)案例调用:... eval -> eval -> boxcar - > boxcar.formula -> lm -> lm.fit 执行停止
提前致谢!
【问题讨论】:
-
你确定第二行吗?如果代码中缺少值,则将数据替换为不正确的值。我可以建议你在tidyverse, and especially dplyr 宇宙中转换你的代码吗?