Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
107 views
in Technique[技术] by (71.8m points)

r - Fatal error every time when using likelihoodHawkes

I'm using RStudio (R version 3.6.1) to run the likelihoodHawkes function from the hawkes package on my data, but every time I execute the function, my session encounters a fatal error.

Please note that I'm attempting to reproduce someone's results on a different dataset.

Example data:

symbol  time          price qty    date        lim      tsign
A 1999-01-04 10:25:55  14.0  50 1999-01-04        1       0
B 1999-01-04 11:27:10  13.8 100 1999-01-04        1       0
C 1999-01-04 10:52:42  34.0 100 1999-01-04        1       0


The code block I'm using is:

library(hawkes)

negloglik_hawkes_m1     <- function(params, history){
    lambda0               <- params[1:2]
    alpha                 <- matrix(params[3:6], byrow = TRUE, nrow = 2) 
    beta                  <- params[7:8]
    return(likelihoodHawkes(lambda0, alpha, beta, history))
}

df                    <- df[(df$tsign!=0)&(df$lim==2),]
ask_arr               <- df[(df$tsign==1),"time"]
ask_arr               <- (ask_arr-ask_arr [1]) [-1]
history               <- list(ask_arr)

init_par              <- c(0.5,0.5,0.2,0.1,0.1,0.2, 1,1)
params_hawkes         <- round(optim(init_par, 
                                     negloglik_hawkes_m1, 
                                     method = "L-BFGS-B", 
                                     lower=rep(1e-6,8),
                                     history = history)$par,2)

Any help is appreciated. Thanks in advance.

question from:https://stackoverflow.com/questions/65871677/fatal-error-every-time-when-using-likelihoodhawkes

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...