-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path02_example.R
43 lines (42 loc) · 1.37 KB
/
02_example.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Testing SVmodelExamples
library(SVmodelRcppSMC)
set.seed(123)
Tinit <- 100
phiXinit <- 0.9
sigmaXinit <- 0.15
betaYinit <- 0.9
Xinit <- 0
dataSimulSV <- generateDataSimulSV(TT = Tinit,
phiX = phiXinit,
sigmaX = sigmaXinit,
betaY = betaYinit,
initStateX0 = Xinit)
xt <- dataSimulSV$statesXt
yt <- dataSimulSV$measurementsYt
particleNumber <- 5000
MM <- 1000
burn <- round(MM/2)
rwSD <- c(0.1, 0.1)
startingVals <- c(phiXinit, 2, 2)
rwSD <- c(0.1, 0.1)
system.time(
outPMMHsmctc <- svModelPMMH(data = yt,
initVals = startingVals,
rwMHsd = rwSD,
particles = particleNumber,
iterations = MM,
burnin = burn)
)
plotPMCMCoutput(outputPMCMC = outPMMHsmctc,
burn,
trueVals = c(sigmaXinit, betaYinit))
system.time(
outPMMHr <- svModelPMMHr(numParticles = particleNumber,
rwVCMprop = diag(rwSD^2),
y = yt,
initVals = startingVals,
numIter = MM)
)
plotPMCMCoutput(outputPMCMC = outPMMHr,
burnin = burn,
trueVals = c(sigmaXinit, betaYinit))