Hi,

I have defined my own log-likelihood function named as “aft_lpdf” in Stan, and I have tested the function by plugging in data and specific parameter values. The function returned the value I expected. So I think the function works well.

Then I would like to use Stan to estimate the parameters in my likelihood function. (The “aft_lpdf” function is a bit complicated, so I omitted the details)

function{

real aft_lpdf(…,…) {

…

}

}

data {

int spline_degree;

int num_knots;

int num_obs;

int num_cov;

real int_knots[num_knots-2];

matrix[num_obs,num_cov] Cov;

real Time[num_obs];

int delta[num_obs];

}

parameters{

vector[num_cov] P_Beta;

vector[num_knots + spline_degree - 1] P_Gamma;

}

model {

target+= aft_lpdf(Time|Cov,delta, spline_degree,num_knots,int_knots,P_Beta, P_Gamma);

}

I ran the Stan model in R using the command below:

aft_fit <- stan(file = ‘aft_likelihood.stan’,

data = list(Cov=Cov,Time=Time.obs,delta=delta,

spline_degree=2,num_knots=3,

int_knots=median(Time.obs)))

However, I got the following compilation error. Any suggestion on how to solve this?

Very much appreciated!

Error in compileCode(f, code, language = language, verbose = verbose) :

Compilation ERROR, function(s)/method(s) not created! In file included from file1927e10619.cpp:8:

In file included from /Library/Frameworks/R.framework/Versions/3.4/Resources/library/StanHeaders/include/src/stan/model/model_header.hpp:4:

In file included from /Library/Frameworks/R.framework/Versions/3.4/Resources/library/StanHeaders/include/stan/math.hpp:4:

In file included from /Library/Frameworks/R.framework/Versions/3.4/Resources/library/StanHeaders/include/stan/math/rev/mat.hpp:4:

In file included from /Library/Frameworks/R.framework/Versions/3.4/Resources/library/StanHeaders/include/stan/math/rev/core.hpp:14:

In file included from /Library/Frameworks/R.framework/Versions/3.4/Resources/library/StanHeaders/include/stan/math/rev/core/matrix_vari.hpp:4:

In file included from /Library/Frameworks/R.framework/Versions/3.4/Resources/library/StanHeaders/include/stan/math/rev/mat/fun/Eigen_NumTraits.hpp:4:

In file included from /Library/Frameworks/R.framework/Versions/3.4/Resource

In addition: Warning message:

running command ‘/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file1927e10619.cpp 2> file1927e10619.cpp.err.txt’ had status 1