// This Stan block defines a simple Student-t regression model with fixed lower censoring point, by Sean van der Merwe, UFS
data {
  int<lower=1> n;   			   // number of observations
  real y[n];                // observations
  real x[n];                // explanatory variables
  int<lower=1> ncens;   			 // number of censored observations
  real ycens;            // censoring point
  real xcens[ncens];            // explanatory variables
}
// The parameters of the model
parameters {
  real b0;
  real b1;
  real<lower=0> s;
  real<lower=0.5> v;
}
model {
  for (i in 1:n) {
    y[i] ~ student_t(v, b0 + b1*x[i], s);
  }
  for (i in 1:ncens) {
    target += student_t_lcdf(ycens | v, b0 + b1*xcens[i], s);
  }
  target += log(v) - 3*log(v+0.75) - 2*log(s);   // joint objective prior
}

CXXFLAGS = -O2 -Wall $(DEBUGFLAG) -mfpmath=sse -msse2 -mstackrealign $(LTO)