我想在R中使用QRM包来适应自激标记点过程模型,其中过程中每次到达的标记都会影响自激。当我使用fit.seMPP()和mark.influence = TRUE从文档中运行示例代码时,出现以下错误:
require(QRM)
data(sp500)
l <- -returns(sp500)
lw <- window(l, start = "1995-12-31", end = end(l))
mod1 <- extremalPP(lw, ne = 100)
mod2b <- fit.seMPP(mod1, mark.influence = TRUE)
Error in SEprocExciteFunc(as.vector(anytimes), as.vector(times), as.vector(marks), :
Expecting a single value: [extent=2].
github在https://github.com/cran/QRM,我看了一下文档,但没有帮助。不确定将C ++代码与Rcpp集成,使用错误的函数或其他原因是否与错误有关。以下是SEprocExciteFunc软件包中的代码:
// [[Rcpp::export]]
NumericVector SEprocExciteFunc(NumericVector anytimes, NumericVector times, NumericVector marks, double theta, int model)
{
int i = 0, j = 0, n = anytimes.size(), nmarks = times.size();
double thetime, delta = 0.0, rho = 0.0, tmp;
NumericVector ans(n);
if (model == 2L)
/* Hawkes with mark influence */
delta = theta + 1;
if (model == 3L)
/* ETAS without mark influence */
rho = theta + 1;
if (model == 4L){
/* ETAS with mark influence */
rho = theta + 1;
delta = theta + 2;
}
while (i < n){
tmp = 0.0;
thetime = times[i];
j = 0;
while ((times[j] < thetime) & (j < nmarks)){
if (model == 1L)
tmp += contribH((thetime - times[j]), 0.0, theta, delta);
if (model == 2L)
tmp += contribH((thetime - times[j]), marks[j], theta, delta);
if (model == 3L)
tmp += contribE((thetime - times[j]), 0.0, theta, rho, delta);
if (model == 4L)
tmp += contribE((thetime - times[j]), marks[j], theta, rho, delta);
j++;
}
ans[i] = tmp;
i++;
}
return ans;
}
谢谢您的任何帮助。