Description Usage Arguments Value Examples
A kinetic prediction implemented with Sequential Monte Carlo algorithm
1 | PFSMC(Y, eta, alpha, N, c, T, loss, resample = resampleMultinomial)
|
Y |
a 1*T vector of sequential data sequence. |
eta |
learning parameter. Determines the rate of weight updating process. |
alpha |
mixing parameter. Determines the speed of model convergence and the rate of trakcing changepoints. |
N |
number of particles to predict underlying densities. |
c |
effective sample size thershold. |
T |
number of data sequence. Time index. |
loss |
loss function for the underlying density. Used to update sample weights. |
resample |
resampling function. |
PFSMC
returns a list of effective sample size, normalized constants, predicted parameters theta and resample flags at each time.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #Generate true parameters and data sequence with 5 change points
k=5; T=200
library(PFSMC)
Data=datagenNoml(200,5,-10,10)
Y=Data[[1]]
theta_true=Data[[2]]
#Detecting changepoints using `PFSMC` funciton.
#We choose a score function for Gaussian distribution and
a multinomial resampling method.
Simulation<-PFSMC(Y=Y,eta=10*T^(-1/3),alpha=k/(T-1),N=1000,
c=0.5,T=200,loss= lossGaussian, resample=resampleMultinomial)
ESS=Simulation[[1]]
theta_hat=Simulation$theta_hat
#Result visulization
plot(theta_true, type="l", ylim=c(-12,12), xlab="Time", ylab="Predictive/True Parameters")
lines(theta_hat, col="red")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.