# Bayesian Measurement error survival model

I’m want to fit a Weibull regression, but I’m considering a covariate to prone measurement error. In particular classical error model. However, I have questions about the priors, because, I have had some problems with the convergence.

This is my code.

``````data{
int n;
vector[n] x_obs; // measurement of x_true
vector[n] Time;
vector[n] x; // group
real<lower=0> tau; // measurement noise
int nbetaS;
vector[n] death;
int K;
vector[K] xk;
vector[K] wk;
}

parameters{
vector[n] x_true; // unknow true value
real<lower=0> taux; # prior scale
real mux;
vector[nbetaS] betaS;
real alpha;
real<lower=0> gamma;
}

model{

matrix[n,K] h;
vector[n] cumHaz;
// LOG-PRIORS

// Measurement error

target += gamma_lpdf(taux | 2, 5);
target += normal_lpdf(mux | 0, 1);
target += normal_lpdf(x_true| mux, taux);
target += normal_lpdf(x_obs| x_true, tau);
// Survival fixed effects
target += normal_lpdf(betaS | 0, 100);

// Association parameter
target += normal_lpdf(alpha | 0, 100);

// Weibull shape parameter
target += gamma_lpdf(gamma | 2, 1);

// LOG-LIKELIHOOD FOR SURVIVAL SUBMODEL
for(i in 1:n){
for(j in 1:K){
// hazard function
h[i,j] = gamma*pow(Time[i]/2*(xk[j]+1), gamma-1) * exp( betaS[1] + betaS[2]*x[i] +   alpha*x_true[i] );
}

// Cumulative hazard H[t] = int_0^t h[u] du - Gauss-Legendre quadrature
cumHaz[i] = Time[i]/2*dot_product(wk,h[i,]);

// Survival log-likelihood
target += death[i]*log(h[i,K]) - cumHaz[i];
}

}

``````

Thanks a lot!

Sorry, it seems your question slipped through - did you manage to resolve this? If not, could you provide more information about your problems? In particular the dataset you are trying to fit (or code to simulate new data), the `pairs` plot (or subset of it) and the exact messages you are getting?

Best of luck with your model!