Hi @mhunter1,
I used the data simulation codes from 'Oscillator' in dataDoc.R and I found that it is only suitable for equal time interval t = 1.
The main relevant part is
tx[,1] <- x0
for(i in 2:(tdim+1)){
q <- t(rmvnorm(1, rep(0, xdim), tQ))
tdx[,i] <- tA %*% tx[,i-1] + tB %*% tu[,i-1] + q
expA <- as.matrix(expm(tA * (tT[,i]-tT[,i-1])))
intA <- solve(tA) %*% (expA - tI)
tx[,i] <- expA %*% tx[, i-1] + intA %*% tB %*% tu[,i-1] + intA %*% q
ty[,i-1] <- tC %*% tx[,i] + tD %*% tu[,i-1] + t(rmvnorm(1, rep(0, ydim), tR))
}
Here, I think tQ matrix and pulled error q should reflect on the time step in the continuous-time modeling.
Based on Voelkle & Oud (2013, p109, Eq 4), I tried to have the code be flexible to time step, such as:
for(i in 2:(tdim+1)){
deltat <- tT[,i]-tT[,i-1]
tA_pnd <- kronecker(tA, diag(1,xdim))+ kronecker(diag(1,xdim),tA)
expA_pnd <- as.matrix(expm(tA_pnd * deltat))
intA_pnd <- solve(tA_pnd) %*% (expA_pnd - diag(1,dim(expA_pnd)[1]))
tQ_d <- matrix(intA_pnd %*% c(t(tQ)), nrow = xdim, byrow = T)
q <- t(rmvnorm(1, rep(0, xdim), tQ_d))
expA <- as.matrix(expm(tA * deltat))
intA <- solve(tA) %*% (expA - tI)
tx[,i] <- expA %*% tx[, i-1] + intA %*% tB %*% tu[,i-1] + q
ty[,i-1] <- tC %*% tx[,i] + tD %*% tu[,i-1] + t(rmvnorm(1, rep(0, ydim), tR)) # measurement model
}
I checked that the codes worked but I would appreciate it if you can verify this.
Hi @mhunter1,
I used the data simulation codes from 'Oscillator' in dataDoc.R and I found that it is only suitable for equal time interval t = 1.
The main relevant part is
Here, I think tQ matrix and pulled error q should reflect on the time step in the continuous-time modeling.
Based on Voelkle & Oud (2013, p109, Eq 4), I tried to have the code be flexible to time step, such as:
I checked that the codes worked but I would appreciate it if you can verify this.