I am getting an Rstan error that I don't understand and this particular error hasn't been addressed in the previous Stack Overflow questions.
The R code to call Rstan is
# Fit the model
start = Sys.time()
pvl_d_fit <- stan(file = 'pvl_d.stan', data = pvl_d_dat,
verbose = TRUE,
warmup = 1000, iter = 4000, thin = 3, chains = 3,
init = 'random', pars = c(
"A_ind", "mu_A", "la_A",
"w_ind", "mu_w", "la_w",
"a_ind", "mu_a", "la_a",
"c_ind", "mu_c", "la_c"))
end = Sys.time()
end - start
And get the following output:
SAMPLING FOR MODEL 'pvl_d' NOW (CHAIN 1).
Informational Message: The current Metropolis proposal is about to be rejected becuase of the following issue:
Error in function stan::prob::normal_log(N4stan5agrad3varE): Random variable is -1.#IND:0, but must not be nan!
If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,
but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.
Anyone run into this before?
(Note: this message is repeated over and over again).
Error in compileCode(f, code, language = language, verbose = verbose) :
Compilation ERROR, function(s)/method(s) not created! cygwin warning:
MS-DOS style path detected: C:/PROGRA~1/R/R-30~1.2/etc/x64/Makeconf
Preferred POSIX equivalent is: /cygdrive/c/PROGRA~1/R/R-30~1.2/etc/x64/Makeconf
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
C:/Users/User/Documents/R/win-library/3.0/rstan/include//stansrc/stan/agrad/rev/var_stack.hpp:49:17: warning: 'void stan::agrad::free_memory()' defined but not used [-Wunused-function]
C:/Users/User/Documents/R/win-library/3.0/rstan/include//stansrc/stan/agrad/rev/chainable.hpp:87:17: warning: 'void stan::agrad::set_zero_all_adjoints()' defined but not used [-Wunused-function]
c:/rtools/gcc-4.6.3/bin/../lib/gcc/i686-w64-mingw32/4.6.3/../../../../i686-w64-mingw32/bin/as.exe: file9d8452242a.o: too many sections (39807)
C:\Users\User\AppData\Local\Temp\ccOl2E
In addition: Warning message:
running command 'C:/PROGRA~1/R/R-30~1.2/bin/x64/R CMD SHLIB file9d8452242a.cpp 2> file9d8452242a.cpp.err.txt' had status 1
The stan file is:
data {
int<lower=1> n_s; // # subjects
int<lower=1> n_t; // # trials
int<lower=0,upper=4> choice[n_s, n_t]; // # subj. x # trials matrix with choices
real<lower=-25,upper=2> net[n_s, n_t]; // Net amount of wins + losses
// (# subj. x # trials matrix)
}
parameters {
// Group-level mean parameters
real mu_A_pr;
real mu_w_pr;
real mu_a_pr;
real mu_c_pr;
// Group-level standard deviation
real<lower=0> sd_A;
real<lower=0> sd_w;
real<lower=0> sd_a;
real<lower=0> sd_c;
// Individual-level paramters
real A_ind_pr[n_s];
real w_ind_pr[n_s];
real a_ind_pr[n_s];
real c_ind_pr[n_s];
}
transformed parameters {
real<lower=0,upper=1> mu_A;
real<lower=0,upper=5> mu_w;
real<lower=0,upper=1> mu_a;
real<lower=0,upper=5> mu_c;
// Individual-level paramters
real<lower=0,upper=1> A_ind[n_s];
real<lower=0,upper=5> w_ind[n_s];
real<lower=0,upper=1> a_ind[n_s];
real<lower=0,upper=5> c_ind[n_s];
// Group-level precision parameters
real<lower=0> la_A;
real<lower=0> la_w;
real<lower=0> la_a;
real<lower=0> la_c;
mu_A <- Phi(mu_A_pr);
mu_w <- Phi(mu_w_pr) * 5;
mu_a <- Phi(mu_a_pr);
mu_c <- Phi(mu_c_pr) * 5;
for (s in 1:n_s)
{
A_ind[s] <- Phi(A_ind_pr[s]);
w_ind[s] <- Phi(w_ind_pr[s]) * 5;
a_ind[s] <- Phi(a_ind_pr[s]);
c_ind[s] <- Phi(c_ind_pr[s]) * 5;
}
la_A <- pow(sd_A, -2);
la_w <- pow(sd_w, -2);
la_a <- pow(sd_a, -2);
la_c <- pow(sd_c, -2);
}
model {
vector[4] p;
real Ev[4];
real dummy[4];
real theta;
real v;
# Prior on the group-level mean parameters
# probit scale [-Inf, Inf]
mu_A_pr ~ normal(0, 1);
mu_w_pr ~ normal(0, 1);
mu_a_pr ~ normal(0, 1);
mu_c_pr ~ normal(0, 1);
# Prior on the group-level standard deviation
sd_A ~ uniform(0,1.5);
sd_w ~ uniform(0,1.5);
sd_a ~ uniform(0,1.5);
sd_c ~ uniform(0,1.5);
# Individual-level paramters
for (s in 1:n_s)
{
A_ind_pr[s] ~ normal(mu_A_pr, sd_A);
w_ind_pr[s] ~ normal(mu_w_pr, sd_w);
a_ind_pr[s] ~ normal(mu_a_pr, sd_a);
c_ind_pr[s] ~ normal(mu_c_pr, sd_c);
}
for (s in 1 : n_s) // loop over subjects
{
theta <- pow(3, c_ind[s]) - 1;
// Trial 1
for (d in 1 : 4) // loop over decks
{
p[d] <- .25;
Ev[d] <- 0;
}
choice[s,1] ~ categorical(p);
// Remaining trials
for (t in 1 : (n_t - 1))
{
if (net[s,t] >= 0)
v <- pow(net[s,t], A_ind[s]);
else
v <- -1 * w_ind[s] * pow(abs(net[s,t]), A_ind[s]);
Ev[choice[s,t]] <- (1 - a_ind[s]) * Ev[choice[s,t]] + a_ind[s] * v;
for (d in 1 : 4) // loop over decks
dummy[d] <- exp(fmax(fmin(Ev[d] * theta, 450), -450));
for (d in 1 : 4) // loop over decks
p[d] <- dummy[d] / sum(dummy);
choice[s, t + 1] ~ categorical(p);
}
}
}
The "informational message" is probably the most frequently (un)answered question on the Stan mailing list.
This said, I am totally confused what your "compile" error means. The model should not run at all with that error.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.