Error in compileCode

You don’t want to install an old StanHeaders. But you do need to figure out why install.packages is not installing the latest versions of packages.

Managed to install latest StanHeaders but not I get the following error when trying to install rstan:

Error in .shlib_internal(args) :
C++14 standard requested but CXX14 is not defined

  • removing ‘/home/user/R/x86_64-pc-linux-gnu-library/3.5/rstan’
  • restoring previous ‘/home/user/R/x86_64-pc-linux-gnu-library/3.5/rstan’
    Warning in install.packages :
    installation of package ‘/tmp/RtmpeF1lyN/downloaded_packages/rstan_2.19.2.tar.gz’ had non-zero exit status

You need the write configuration file

That seemed to work and was able to install the newest version of rstan. Now I get the following error for the integrate_ode function:

SYNTAX ERROR, MESSAGE(S) FROM PARSER:
Wrong signature for function integrate_ode_bdf; first argument must be the name of a function with signature (real, real, real, data real, data int): real.
error in ‘model872a7f3b82a5_fca4c0fbb43a515d4400ccb09cffb8c2’ at line 34, column 38

32:   = integrate_ode_bdf(dz_dt, z_init, 0, ts, theta,
33:                        rep_array(0.0, 0), rep_array(0, 0),
34:                        1e-5, 1e-3, 5e2);
                                         ^
35: }

PARSER EXPECTED: “)”
Error in stanc(file = file, model_code = model_code, model_name = model_name, :
failed to parse Stan model ‘fca4c0fbb43a515d4400ccb09cffb8c2’ due to the above error.

Not sure what is the issue here. I copied that from an example code. Also I am not sure I understand the data real and data int arguments. What are they exactly?

What is the signature of the dz_dt function?

Hello,

I have the whole code in the first post for reference. The signature is:

real dz_dt(real t,
                real[] z,
                real[] theta,
                real[] x_r,
                int[] x_i ){

I think the output needs to be a real array, even if it is only size 1. Or maybe you need the data qualifiers before the last two arguments.

So how do I need to change the code? I am sorry but I am very new to this and I have no clue about the workings or stan.

Do I just write data[] x_r, data[] x_i and real[] dz_dt?

real[] dz_dt(real t,
             real[] z,
             real[] theta,
             data real[] x_r,
             data int[] x_i ){
// implement, returning a real array (possibly of size 1)
}

I did that but now I get a mismatch error:

TRANSLATING MODEL ‘513bf8af9c5aff7e5bc2ebfa53942dc9’ FROM Stan CODE TO C++ CODE NOW.
SYNTAX ERROR, MESSAGE(S) FROM PARSER:
Mismatched array dimensions.Base type mismatch. Returned expression does not match return type
LHS type = real; RHS type = real
Improper return in body of function.
error in ‘model288f7a5aa245_513bf8af9c5aff7e5bc2ebfa53942dc9’ at line 16, column 0

14:     return dV_dt;
15:   }
16: }
   ^
17: 

Error in stanc(file = file, model_code = model_code, model_name = model_name, :
failed to parse Stan model ‘513bf8af9c5aff7e5bc2ebfa53942dc9’ due to the above error.

I tried putting real dV_dt= … but that returns a wrong syntax error

return {dv_dt};

Thank you that seems to have worked. i get one more error:

Error in new_CppObject_xp(fields$.module, fields$.pointer, ...) : 
  Exception: variable does not exist; processing stage=data initialization; variable name=N; base type=int  (in 'model7bbd3a432e1e_df17e2ae4b6e498fbbfbdfdc8e87c7fa' at line 19)

Although I do provide N

It might not be an integer or something? Maybe it is overwritten by a different symbol also called N? Anyway, that is just a runtime thing.

I cannot find any clash with another N symbol and despite changing the list to:

dat<-list(as.integer(19),c(4,7,11,14,18,21,25,31,35,39,42,46,49,52,56,59,62,67,70),0.215,c(0.2484 ,0.2636, 0.3042 ,0.3678, 0.3767 ,0.3880 ,0.3937 ,0.4087, 0.4282, 0.4599 ,0.4730, 0.5415 ,0.5848, 0.6096, 0.6427, 0.6817 ,0.7308 ,0.7762 ,0.8077))

I have the same issue

The list of data must have names.

Thank did it :) thank you so much for all the help!