I would like to estimate the parameters of a specific model.
The model specification is as follows:
$p_t = k_t + B_t/(1-B_t) + \eta_t$, where $ \eta_t \sim N(0, \sigma^2)$
$R_{t+1} = R_{t} + R_t (R_t - B_t) (1-R_t) $
$B_{t+1} = B_{t} + (R_t - B_t) \left( \frac{(k_t - d_t B_t + a_t (1-B_t))}{(1-R_t)} + (1-B_t) R_t \right)$
$k_t = k_{t-1} + \epsilon_t$
Conditions for parameters:
- $R_t$ and $B_t$ should be between $0$ and $1$.
- $d_t$ and $a_t$ should be positive.
Estimation attempt in RJAGS
I have attempted to estimate the model (in sample estimation of $p_t$) using RJAGS; see my code below:
jagsscript = cat("
model{
#GARCH observations with latent data
for(t in 1:N)
{
p[t] ~ dnorm(k[t] +(B[t]/(1-B[t]))* (k[t]-d[t]), eta)
p_fitted[t] ~ dnorm(k[t] +(B[t]/(1-B[t]))*(k[t]-d[t]), eta)
}
for(t in 1:N-1)
{
B[t+1] <- B[t]+ (R[t]-B[t])*( (k[t]-d[t]*B[t]+a*(1-B[t]))/(1-R[t]) + (1-B[t])*R[t] )
R[t+1] <- R[t] + R[t]*(R[t]-B[t])*(1-R[t])
}
for(t in 2:N)
{
k[t] ~ dnorm(k[t-1], zeta)
}
#priors for latent data
R[1] ~dnorm(0, 0.001)I(0,1)
B[1] ~dnorm(0, 0.001)I(0,1)
k[1] ~dnorm(0, 0.001)
a ~dnorm(0, 0.001)I(0,1000)
eta ~ dgamma(0.01, 0.01)
zeta ~ dgamma(0.01, 0.01)
}
",file="ss_model.txt")
Using the above code and data, I get the error: Error calculating log density at initial values
.
I checked the priors and I see that I can resolve the error when I assign scalar numbers to R[1] and B[1], for example:
R[1] <-0.5
B[1] <-0.5
However, this is not what I want.
- How can I specify the priors such that the above conditions for the parameters is satisfied?