[R] Error: Invalid parent values
Md. Moyazzem Hossain
ho@@@|nmm @end|ng |rom jun|v@edu
Thu Feb 2 15:28:30 CET 2023
Hi,
I hope that you are doing well.
I am Md Hossain, trying to fit the ARIMAX model in RJAGS. However, I got an
error message while I ran the code. Initially, I am using data obtained
from R-package then I will implement it into real data.
The code and error message are given below.
library(rjags)
#### load the data
data("mtcars")
#### select the response and predictor variables
y <- mtcars$mpg
x <- mtcars[,c("wt","qsec")]
### write the JAGS model code
jags_arimax_model <- "
model {
beta0 ~ dnorm(0,0.0001)
beta1 ~ dnorm(0,0.0001)
beta2 ~ dnorm(0,0.0001)
phi ~ dnorm(0,0.0001)
tau ~ dgamma(0.001,0.001)
#####
beta0a[1] <- beta0
beta1a[1] <- beta1
beta2a[1] <- beta2
phia[1] <- phi
mu[1] <- beta0a + beta1a * x[1,1] + beta2a * x[1,2] + phia * y[2]
ypred[1] ~ dnorm(mu[1], tau)
######
for (i in 2:length(y)) {
mu[i] <- beta0 + beta1 * x[i,1] + beta2 * x[i,2] + phi * y[i-1]
ypred[i] ~ dnorm(mu[i], tau)
}
}
"
####Fit the Bayesian ARIMAX model using JAGS:
jags_arimax_fit <- jags.model(textConnection(jags_arimax_model), data =
list(y = y, x = x) )
update(jags_arimax_fit, n.iter=2000, thin=1)
####
output_arimax=coda.samples(model=jags_arimax_fit, variable.names="ypred",
n.iter=2000, thin=5)
However, I got the following error message.
*Error in update.jags(model, n.iter, ...) : Error in node ypred[1]Invalid
parent values*
Please help me in this regard.
Thanks in advance.
Hossain
[[alternative HTML version deleted]]
More information about the R-help
mailing list