data {
real m_mu_theta; // prior for mean of theta
real var_mu_theta; // prior for variance of mean of theta
int<lower=0> T; // number of categorical time points
int<lower=0> N; // number of subjects
int<lower=0> J; // number of items
int<lower=1, upper=7> K[J]; // max level for each item
int Y[N, J, T]; // data, 3D array of integers
}
parameters {
ordered[6] kappa[J]; // intercept : array of ordered vectors
vector[T] theta[N]; // ability : theta[N,T] - array of vectors
real<lower=0.0, upper=10.0> alpha[J]; // discrimination
real<lower=0.0, upper=1.0> rho; // Correlation parameter
}
model{
real sigsq_theta;
vector[T] mu_theta;
matrix[T, T] var_theta;
matrix[T, T] L_theta;
real p[N, J, T, 7];
real Q[N, J, T, 6];
// prior for mu_theta
mu_theta[1] <- 0.0; // fix to 0 for identifiability
for (t in 2:T){
mu_theta[t] ~ normal(m_mu_theta, var_mu_theta);
}
// Compound symmetry structure for the covariance of thetas
sigsq_theta <- 1.0; // fix to 1 for identifiability
var_theta[1,1] <- sigsq_theta;
for (t in 2:T) {
var_theta[t,t] <- sigsq_theta;
for (j in 1:(t-1)) {
var_theta[t,j] <- sigsq_theta*rho;
var_theta[j,t] <- var_theta[t,j];
}
}
L_theta <- cholesky_decompose(var_theta);
theta ~ multi_normal_cholesky(mu_theta, L_theta);
// alpha ~ uniform(0.0, 10.0);
for (j in 1:J) {
for (k in 1:(K[j] - 1)) {
kappa[j,k] ~ normal(0.0, 5.0);
}
}
for (t in 1:T){
for (i in 1:N) {
for (j in 1:J) {
for (k in 1:(K[j] - 1)) {
Q[i, j, t, k] <- inv_logit(kappa[j,k] - alpha[j]*theta[i,t]);
}
p[i, j, t, 1] <- Q[i, j, t, 1];
for (k in 2:(K[j] - 1)){
p[i, j, t, k] <- Q[i, j, t, k] - Q[i, j, t, k-1];
}
p[i, j, t, K[j]] <- 1 - Q[i, j, t, K[j] - 1];
// incement log probability directly because Y[i, j]
// has categorical distribution with varying dimension
increment_log_prob(log(p[i, j, t, Y[i, j, t]]));
}
}
}
}
Error : Error during user-specified initialization:
Error in function stan::prob::normal_log(N4stan5agrad3varE): Random variable is 1.#QNAN:0, but must not be nan!
error occurred during calling the sampler; sampling not done
mu_theta[t] ~ normal(m_mu_theta, var_mu_theta);--
You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stan-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Warning (non-fatal): Left-hand side of sampling statement (~) contains a non-linear transform of a parameter or local variable.
You must call increment_log_prob() with the log absolute determinant of the Jacobian of the transform.
Sampling Statement left-hand-side expression:
get_base1(mu_theta,t,"mu_theta",1) ~ normal_log(...)
data {
real m_mu_theta; // prior for mean of theta
real var_mu_theta; // prior for variance of mean of theta
int<lower=0> T; // number of categorical time points
int<lower=0> N; // number of subjects
int<lower=0> J; // number of items
int<lower=1, upper=7> K[J]; // max level for each item
int Y[N, J, T]; // data, 3D array of integers
}
parameters {
ordered[6] kappa[J]; // intercept : array of ordered vectors
vector[T] theta[N]; // ability : theta[N,T] - array of vectors
real<lower=0.0, upper=10.0> alpha[J]; // discrimination
real<lower=0.0, upper=1.0> rho; // Correlation parameter
vector[T-1] mu_theta_raw;
}
model{
real sigsq_theta;
vector[T] mu_theta;
matrix[T, T] var_theta;
matrix[T, T] L_theta;
real p[N, J, T, 7];
real Q[N, J, T, 6];
// prior for mu_theta
mu_theta[1] <- 0.0; // fix to 0 for identifiability
for (t in 1:(T-1))
mu_theta[t+1] <- mu_theta_raw[t];
mu_theta_raw ~ normal(m_mu_theta, var_mu_theta);
T1 T2 T3 T4 T5 T6 T7
X1 6 6 6 5 5 6 6
X2 6 6 6 6 6 6 6
X3 7 6 6 6 7 6 6
X4 7 6 6 6 6 6 6
X5 6 6 6 7 6 6 6
X6 7 7 6 7 6 6 6
X7 6 6 6 6 6 6 6
alpha ~ normal(1.0, 3.0);
for (j in 1:J) {
kappa[j] ~ normal(0.0, 2.5);
}