Problems compiling in ubuntu machine

Hello dear list,

I’m trying to run a model on a linux machine. This model worked just fine on my windows machine, so I suppose it is something related with my ubuntu installation. Could someone point me in the right direction here?

Thanks,

Tada

Operating System: ubuntu 16.04 lts
Interface Version: Rstan
Output of writeLines(readLines(file.path(Sys.getenv(“HOME”), “.R/Makevars”))):
Output of devtools::session_info("rstan”):
Error in prep_call_sampler(object) :
the compiled object from C++ code for this model is invalid, possible reasons:

  • compiled with save_dso=FALSE;
  • compiled on a different platform;
  • does not exist (created from reading csv files).

Hi,

so you tried to compile model on ubuntu (what model) or compiled model on Windows and now try to run it on ubuntu?

Maybe show an example what model does not compile?

Yes, I tried to compile a model in ubuntu that used to compile well with my rstan install in a windows machine. Here’s the model

data{
int<lower=1> N;
int<lower=1> N_sample;
int<lower=1> N_cage;
int histo[N];
real AGD[N];
real Des[N];
real cyst[N];
real PRV[N];
real pox[N];
real Ten[N];
int sample[N];
int cage[N];
real Temp[N];
real time_w[N];
matrix[N_sample,N_sample] Dmat;
}
parameters{
ordered[3] cutpoints;
real bt;
real bwater_t;
real bagd;
real bcyst;
vector[N_sample] a_sample;
real<lower=0> etasq;
real<lower=0> rhosq;
real<lower=0> sigma;
}

model{
matrix[N_sample,N_sample] SIGMA_Dmat;
vector[N] phi;
sigma ~ cauchy( 0 , 1 );
rhosq ~ cauchy( 0 , 1 );
etasq ~ cauchy( 0 , 1 );
for ( i in 1:(N_sample-1) )
for ( j in (i+1):N_sample ) {
SIGMA_Dmat[i,j] = etasq*exp(-rhosq*pow(Dmat[i,j],2));
SIGMA_Dmat[j,i] = SIGMA_Dmat[i,j];
}
for ( k in 1:N_sample )
SIGMA_Dmat[k,k] = etasq + sigma;
a_sample ~ multi_normal( rep_vector(0,N_sample) , SIGMA_Dmat );
cutpoints ~ normal( 0 , 5 );
bt ~ normal( 0 , 0.5 );
bwater_t ~ normal( 0 , 0.5 );
bagd ~ normal( 0 , 0.5 );
bcyst ~ normal( 0 , 0.5 );
for ( i in 1:N ) {
phi[i] = bt * Temp[i] + bwater_t * time_w[i] + bagd * AGD[i] + bcyst * cyst[i] 
+ a_sample[sample[i]];
}
for ( i in 1:N )
histo[i] ~ ordered_logistic( phi[i] , cutpoints );
}
generated quantities{
matrix[N_sample,N_sample] SIGMA_Dmat;
vector[N] phi;
real log_lik[N];

for ( i in 1:(N_sample-1) )
for ( j in (i+1):N_sample ) {
SIGMA_Dmat[i,j] = etasq*exp(-rhosq*pow(Dmat[i,j],2));
SIGMA_Dmat[j,i] = SIGMA_Dmat[i,j];
}
for ( k in 1:N_sample )
SIGMA_Dmat[k,k] = etasq + sigma;

for ( i in 1:N ) {
phi[i] = bt * Temp[i] + bwater_t * time_w[i] + bagd * AGD[i] + bcyst * cyst[i] 
+ a_sample[sample[i]];
}

for ( i in 1:N )
log_lik[i] = ordered_logistic_lpmf( histo[i] | phi[i] , cutpoints );
}    indent preformatted text by 4 spaces

Oh, one more thing. You are able to run simple models?

Just gave it a go with a simpler binary logistic regression model I had. It worked. Any idea of what’s going on?

Thanks,

T

What version of the RStan do you have? There was a problem with error messages being hidden. Try to update your RStan.

I tested this with CmdStan. Here is the error message.

SYNTAX ERROR, MESSAGE(S) FROM PARSER:

No matches for:

  rhosqpow(real, int)

Function rhosqpow not found.
  error in '/data/data/com.termux/files/home/Stan/egtest.stan' at line 38, column 50
  -------------------------------------------------
    36: for ( i in 1:(N_sample-1) )
    37: for ( j in (i+1):N_sample ) {
    38: SIGMA_Dmat[i,j] = etasqexp(-rhosqpow(Dmat[i,j],2));

   ^
    39: SIGMA_Dmat[j,i] = SIGMA_Dmat[i,j];
  -------------------------------------------------

edit. This could also be a copy issue in my end. Here is the next error

SYNTAX ERROR, MESSAGE(S) FROM PARSER:

  error in '/data/data/com.termux/files/home/Stan/egtest.stan' at line 52, column 1
  -------------------------------------------------
    50: phi[i] = bt * Temp[i] + bwater_t * time_w[i] + bagd * AGD[i] + bcyst * cyst[i]
    51:
    52: a_sample[sample[i]];
        ^
    53: }
  -------------------------------------------------

PARSER EXPECTED: ";"

I must have the latest in CRAN, as I just installed it today through install.packages(‘rstan’). I did install it again though, just in case. The error you find is kind of odd, I have in the code -rhosq*pow, not rhosqpow. Is it parsing like it that to C++ then? Is there fix?

Thanks,

T

Can you edit your post that has the model to put the Stan code inside a code block? It is the </> icon above the text input window. Otherwise, Discourse is formatting your post with Markdown which causes all sorts of issues in trying to replicate your error.

Hi,

Yes there were errors in my end when i copied your code.

Now it compiles fine on my CmdStan (android).

OK, I found a solution, which kind of surprised me it actually worked. I just changed

-rhosq*pow for -rhosq * pow

After doing that it compiled and sampled as expected. Not so sure what happened there.

Thanks for all the help. It really helped narrow down where the problem was

1 Like

Hi,

Great that it works now.
What program did you use to create the code? Was it on Windows?

I’m guessing that there were some ‘hidden’ characters.

Yes, I created the code on windows using Rstudio.
Sounds like a good explanation.
Tada