简体   繁体   English

R的多元霍克斯分布

[英]Multivariate Hawkes distribution in R

I have a list of N categories that a user can click on. 我有一个用户可以点击的N个类别的列表。 Lets say there are K such users totally. 可以说完全有K这样的用户。 I have the past 3 months data which tells which user has clicked on which category on which date for how many times. 我有过去3个月的数据,告诉哪个用户点击了哪个类别的日期多少次。 For ex - {20th June 2016 : [10,15,12,15]} this dict is for a particular user and says on 20th June he clicked on categories 10,12 once and 15 twice. 对于前 - 2016年6月20日:[10,15,12,15]}这个词是针对特定用户的,并且在6月20日说他点击了类别10,12一次和15次两次。

Given this data, I want to use a Multivariate Hawks distribution to model this, so that I can predict which categories a user will click on based on the past categories(same and different categories) that have been clicked. 鉴于此数据,我想使用多变量Hawks分布对此进行建模,以便我可以根据已点击的过去类别(相同和不同类别)预测用户将点击哪些类别。

I have already looked at a number of examples. 我已经看了很多例子。 http://jheusser.github.io/2013/09/08/hawkes.html uses a univariate Hawks distribution using ptproc package. http://jheusser.github.io/2013/09/08/hawkes.html使用ptproc包使用单变量Hawks发行版。 ptproc however, doesn't exist now. 但是,ptproc现在不存在了。

I want to feed some random initialization of the mean, alpha and beta parameters and want the model to perform Maximum Likelihood estimation using EM algorithm to find the best values of parameters and return it. 我想提供平均值,alpha和beta参数的随机初始化,并希望模型使用EM算法执行最大似然估计,以找到参数的最佳值并将其返回。

Using the hawkes package, 使用hawkes包,

library(hawkes)
lambda0 <- c(0.2,0.2)
alpha   <- matrix(c(0.5,0,0,0.5),byrow=TRUE,nrow=2)
beta    <- c(0.7,0.7)
history <- simulateHawkes(lambda0,alpha,beta,3600)
l       <- likelihoodHawkes(lambda0,alpha,beta,history)

This computes the likelihood for some random initialization of parameters. 这计算了一些随机初始化参数的可能性。 How do I find the best parameters by using EM algorithm and maximizing the likelihood here for Multivariate Hawkes distribution ? 如何通过使用EM算法找到最佳参数并最大化多变量Hawkes分布的可能性?

Thanks! 谢谢!

params_hawkes <- optim(c(rep(1,2), rep(0.2,4),rep(2,2)), nloglik_bi_hawkes, history = history)

The optim function can be used for finding the best parameters. optim函数可用于查找最佳参数。

nloglik_bi_hawkes <- function(params, history){
mu <- c(params[1],params[2])
alpha <- matrix(c(params[3],params[4],params[5],params[6]),byrow=TRUE,nrow=2)
beta <- c(params[7], params[8])
return(likelihoodHawkes(mu, alpha, beta, history))
}

Here, the alpha, beta and mu are initialized to random values then updated by minimizing the negative log likelihood. 这里,alpha,beta和mu被初始化为随机值,然后通过最小化负对数似然来更新。

The final list of parameters is stored in param_hawkes 最后的参数列表存储在param_hawkes中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM