Installing stan on R cloud

I installed Stan on my R cloud and when I run this command to make sure stan is properly installed I get this error message

example (stan_model, package = “rstan”, run.dontrun = TRUE)

Compilation ERROR, function (s) / method (s) not created!
Error in compileCode (f, code, language = language, verbose = verbose):
g ++: Internal compiler error: Killed (cc1plus program) Please submit a complete bug report, with the source preprocessed if applicable. See <file: /// usr / share / doc / gcc-5 / README.Bugs > for instructions. make: *** [file12a7d4ce2bc.o] Error 4

1 Like

This usually indicates that there isn’t enough RAM available for the model compilation. Stan models can require > 1.5GB RAM for compilation, so you need to have a cloud session with sufficient RAM

2 Likes

I really can’t install stan on my computer
I deposited my rstudio on the cloud
to come and use my rstudio on Ananconda !!!
but I absolutely cannot install rtsan, I explain:
I have a version.string R version 4.0.2 rstudio (06/22/2020)
I even wanted to force the installation of Rtools to then install RStan itself but nothing, still errors and yet I followed the recommendation of this github to the letter https://github.com/stan-dev/ rstan / wiki / RStan-First do not
moreover there is no c compiler for a configuration of the C ++ toolchain for this version of rstudio by installing RTools
(RTools does not exist for this version of rstudio in clear !!!)

and if i directly install rstan by running
install.packages (“rstan”) then run this code Check
Installation
To verify your installation, you can run the RStan example / test template:

example (stan_model, package = “rstan”, run.dontrun = TRUE)
to make sure Stan is working properly I still have errors
I even cloned the github that I still have stan which doesn’t work what to do thanks (I looked for everything)

Hello,

Did you get any success on rstudio on Ananconda? I can install stan on my system.

I have used the Rtools to then install RStan and it worked fine.

here is what I explain to you in picture
as a reminder I have the latest version of R and Rstudio
I explain in fact that rtools is not available for installation

Thank you

Hi Orson,

You need to follow the instructions on the Getting Started page: https://github.com/stan-dev/rstan/wiki/RStan-Getting-Started

These contain a link to instructions for installing RTools: https://github.com/stan-dev/rstan/wiki/Configuring-C---Toolchain-for-Windows#r40

hello all everyone ,

I have already put my coding skills to the test a lot but I keep tripping over running the Stan SIR (covid 19) model by referring to this tutorial on how an epidemic spreads

I have already correctly installed stan on google colab but I want to run this code
model <- stan_model (“sir_negbin.stan”)
I would like to know if this model “sir_negbin.stan” is already installed in stan or I still have to program it because when I run this code
model <- stan_model (“sir_negbin.stan”)
I’m getting errors
but i have run other models and everything is fine
Thank you for your help
And Happy New Year to all
it is this tutorial that I would like to apply to my own data
https://mc-stan.org/users/documentation/case-studies/boarding_school_case_study.html

https://colab.research.google.com/drive/1AlU1yw6QCn2g6gZbKBiE3vIVwfS3buav?usp=sharingconfirmes.csv (9.9 KB)

Warning in install.packages :
package ‘cmdstanr’ is not available (for R version 4.0.2)

all your explanation which is on your github seems to never run on version R 4.0.2 with the latest version of R in addition there are a lot of compatibility problems with stan and cran that’s especially ca

we recommend running this is a fresh R session or restarting your current session

install.packages(“cmdstanr”, repos = c(“https://mc-stan.org/r-packages/”, getOption(“repos”)))

this code you give is invalid because CRAN totally denies access

Do I have to downgrade my version of r in this case?

Can you post the error message that is displayed?

Are you having issues installing RStan or cmdstanR?

here is a picture of the error message received

I have already tried on different platforms

but still errors on

anaconda rstudio

on google colab with an r interface
on the cloud too

should i disable my antivirus ?

The error is saying that you don’t have permissions in the folder that you’re installing packages into. Are you able to install other packages?

Can you post the output get from:

install.packages("abind")

or

install.packages("jsonlite")

I am going to install its packages on google colab it seems that everything works I attach the link
thank you

https://colab.research.google.com/drive/1ZAZ0nh2A51-khc9dwAJVTeuNaY4MPW98?usp=sharing

I’m not sure I understand, is everything resolved and you don’t need any more help?

there remains rstan who refuses to settle down
here is a picture of the error message

Try installing rstan via:

Sys.setenv(DOWNLOAD_STATIC_LIBV8 = 1)
install.packages("rstan", repos = "https://cloud.r-project.org/", dependencies = TRUE)

sircode_v2=’
functions {
real[] sir(real t, real[] y, real[] theta,
real[] x_r, int[] x_i) {

real S = y[1];
real I = y[2];
real R = y[3];
real N = x_i[1];

real beta = theta[1];
real gamma = theta[2];

real dS_dt = -beta * I * S / N;
real dI_dt = beta * I * S / N - gamma * I;
real dR_dt = gamma * I;

return {dS_dt, dI_dt, dR_dt};
}
}
data {
int<lower=1> n_days;
real y0[3];
real t0;
real ts[n_days];
int N;
int cases[n_days];
}
transformed data {
real x_r[0];
int x_i[1] = { N };
}
parameters {
real<lower=0> gamma;
real<lower=0> beta;
real<lower=0> phi_inv;
}
transformed parameters{
real y[n_days, 3];
real phi = 1. / phi_inv;
{
real theta[2];
theta[1] = beta;
theta[2] = gamma;

y = integrate_ode_rk45(sir, y0, t0, ts, theta, x_r, x_i);
}
}
model {
//priors
beta ~ normal(2, 1);
gamma ~ normal(0.4, 0.5);
phi_inv ~ exponential(5);

//sampling distribution
//col(matrix x, int n) - The n-th column of matrix x. Here the number of infected people
cases ~ neg_binomial_2(col(to_matrix(y), 2), phi);
}
generated quantities {
real R0 = beta / gamma;
real recovery_time = 1 / gamma;
real pred_cases[n_days];
pred_cases = neg_binomial_2_rng(col(to_matrix(y), 2), phi);
}

fit model

mod_v2 = stan_model(model_name = ‘sir_negbin.stan’,model_code = sircode_v2)

model <- stan_model(“sir_negbin.stan”)