我正在学习“时间序列数据的概述游戏分析”(http://www.sfs.uni-tuebingen.de/~jvanrij/Tutorial/GAMM.html)。
我用以下代码对模型进行了拟合:
m1 <- bam(Y ~ Group
+ s(Time, by=Group)
+ s(Condition, by=Group, k=5)
+ ti(Time, Condition, by=Group)
+ s(Time, Subject, bs='fs', m=1)
+ s(Trial, Subject, bs='fs', m=1),
data=simdat)I从itsadug包运行以下命令:
check_resid(m1, split_pred=c("Subject", "Trial") )这将返回一个异常:
Warning message in is.na(res.rho):
"is.na() applied to non-(list or vector) of type 'NULL'"
Error in ts(x): 'ts' object must have one or more observations
Traceback:
1. check_resid(m1, split_pred = c("Subject", "Trial"))
2. acf(res, main = sprintf("ACF resid(%s)", deparse(substitute(model))),
. col = "darkgray", ylim = range(c(0, acf(res, plot = FALSE)$acf[,
. , 1], acf(res.rho[!is.na(res.rho)], plot = FALSE)$acf[,
. , 1]), na.rm = TRUE), bty = "L")
3. plot.acf(acf.out, ...)
4. acf(res.rho[!is.na(res.rho)], plot = FALSE)
5. na.action(as.ts(x))
6. as.ts(x)
7. as.ts.default(x)
8. ts(x)
9. stop("'ts' object must have one or more observations")前两个情节只产生(而不是4个)。
我检查了命令的文档,也许这是相关的:
AR_start 默认为NULL。只有当模型在旧版本的mgcv包中运行并且该函数无法从模型中检索使用的AR.start值时才使用此方法。当用较新版本的mgcv显示错误时,请检查作为AR.start值提供的列。当使用旧版本的包mgcv时。函数在找不到AR.start时会出现错误。
我怎样才能纠正这个问题?
发布于 2018-03-17 10:41:55
正确的语法(请参阅help ?check_resid)是:
check_resid(m1, split_by=c("Subject", "Trial") )产出如下:

https://stackoverflow.com/questions/49334586
复制相似问题