boxTidwell - 'NA' 处理
boxTidwell - 'NA' Handling
我的数据框是
library(car)
DF2 <- data.frame(WindVel=c(2.45,2.7,2.9,3.05,3.4,3.6,3.95,4.1,4.6,5),
DCOutput=c(0.123,0.5,0.653,0.558,1.057,1.137,1.144,NA,NA,NA))
稍后我想通过排除 NA 对数据框执行 Box-Tidwell 转换。因此我使用了:
boxTidwell(DF2$DCOutput, DF2$WindVel, options(na.action="na.exclude"))
这给出了一个错误:
Error in model.frame.default(formula = y ~ cbind(x1, x2), drop.unused.levels = TRUE) :
invalid type (list) for variable 'cbind(x1, x2)'
我试过了:
boxTidwell(DF2$DCOutput, DF2$WindVel, na.action=na.exclude)
然而,它并不那么有效。请让我知道如何在使用 boxTidwell
时排除 NA。我无法从 car
软件包的用户手册中了解与 NA 的使用相关的内容。
或者您可以使用 boxTidwell
的公式方法。来自 ?boxTidwell
:
## S3 method for class 'formula'
boxTidwell(formula, other.x=NULL, data=NULL, subset,
na.action=getOption("na.action"), verbose=FALSE, tol=0.001,
max.iter=25, ...)
na.action: a function that indicates what should happen when the data contain NAs. The default is set by the na.action setting of options.
由于 na.action
选项的开箱即用值为 na.omit
,您将获得完整的案例分析,就像在 na.exclude
中一样。
对于你的情况,你可以使用
boxTidwell(WindVel ~ DCOutput, data=DF2, na.action = na.exclude)
这种参数模式对于使用公式接口的统计建模函数很常见。
约翰
我的数据框是
library(car)
DF2 <- data.frame(WindVel=c(2.45,2.7,2.9,3.05,3.4,3.6,3.95,4.1,4.6,5),
DCOutput=c(0.123,0.5,0.653,0.558,1.057,1.137,1.144,NA,NA,NA))
稍后我想通过排除 NA 对数据框执行 Box-Tidwell 转换。因此我使用了:
boxTidwell(DF2$DCOutput, DF2$WindVel, options(na.action="na.exclude"))
这给出了一个错误:
Error in model.frame.default(formula = y ~ cbind(x1, x2), drop.unused.levels = TRUE) :
invalid type (list) for variable 'cbind(x1, x2)'
我试过了:
boxTidwell(DF2$DCOutput, DF2$WindVel, na.action=na.exclude)
然而,它并不那么有效。请让我知道如何在使用 boxTidwell
时排除 NA。我无法从 car
软件包的用户手册中了解与 NA 的使用相关的内容。
或者您可以使用 boxTidwell
的公式方法。来自 ?boxTidwell
:
## S3 method for class 'formula'
boxTidwell(formula, other.x=NULL, data=NULL, subset,
na.action=getOption("na.action"), verbose=FALSE, tol=0.001,
max.iter=25, ...)
na.action: a function that indicates what should happen when the data contain NAs. The default is set by the na.action setting of options.
由于 na.action
选项的开箱即用值为 na.omit
,您将获得完整的案例分析,就像在 na.exclude
中一样。
对于你的情况,你可以使用
boxTidwell(WindVel ~ DCOutput, data=DF2, na.action = na.exclude)
这种参数模式对于使用公式接口的统计建模函数很常见。
约翰