我的数据框是
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)
但是,它不能很好地工作。请让我知道如何在使用时排除NA boxTidwell
。我从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)
这种参数模式是使用公式接口的统计建模函数所共有的。
约翰
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句