Crash in Windows - Works in Linux


#1

The following non-linear fit works under several Linux 16.04 variants. Under Windows, it crashes without a message after printing out the first iteration. Reproduced with Command line R. I have several other Stan files working under Window, so the installation is likely ok.

bt.stan (1.8 KB)
expbeta_fit.R (1.3 KB)
expbetadata.txt (12.7 KB)

Operating System: Windows
Interface Version: rstan

Output of writeLines(readLines(file.path(Sys.getenv(“HOME”), “.R/Makevars”))):

CXXFLAGS=-O3 -mtune=native -march=native -Wno-unused-variable -Wno-ignored-attributes -Wno-deprecated-declarations -Wno-unused-local-typedefs -Wno-unused-function
CXX_STD = CXX11

Output of devtools::session_info("rstan”):
R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252   
[3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C                   
[5] LC_TIME=German_Germany.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rstan_2.16.2         StanHeaders_2.16.0-1 ggplot2_2.2.1       

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.12     grid_3.4.1       plyr_1.8.4       gtable_0.2.0     stats4_3.4.1    
 [6] scales_0.4.1     rlang_0.1.1      lazyeval_0.2.0   tools_3.4.1      munsell_0.4.3   
[11] compiler_3.4.1   inline_0.3.14    colorspace_1.3-2 gridExtra_2.2.1  tibble_1.3.3    
>

#2

@bgoodri or @jonah — any idea what might be causing this?


#3

No, in which case it is probably the -mtune=native -march=native in CXXFLAGS.


#4

Another example: Works on Ubuntun, Crashes in Windows
This example uses brms, but the crash occurs after the first rstan iterations. Paul Bürkner noted that it can be tamed by rescaling parameter minutes, but this does not explain the difference between the methods.

suppressPackageStartupMessages(library(brms))

## Package breathtestcore for the data is on CRAN
# install.packages("breathtestcore") # for data

data("usz_13c", package = "breathtestcore")
set.seed(4711)
data = with(usz_13c, usz_13c[group == "liquid_normal" &
                              patient_id <= "norm_006",]) 

# Plot data
ggplot2::ggplot(data, aes(x = minute, y = pdr)) +
  facet_wrap(~patient_id) +
  geom_line()

form = 
  bf(pdr ~ m*beta/tempt*(1-exp(-minute / tempt))^(beta-1)*exp(-minute/tempt),
     m + tempt + beta ~ 1 + (1|ID1|patient_id), nl = TRUE)

prior = c(
  prior(normal(3000, 500), nlpar = "m"),
  prior(normal(2.2, 0.4), nlpar = "beta"),
  prior(normal(90, 30), nlpar = "tempt"),
  prior(normal(500, 200), class = sd, nlpar = "m", group = patient_id),
  prior(normal(100, 10), class = sd, nlpar = "tempt", group = patient_id),
  prior(normal(0, 1), class = sd, nlpar = "beta", group = patient_id)
)

fit1 = brm(form, prior = prior, data = data, family = gaussian(),
             iter = 2000, chains = 1, 
             control = list(adapt_delta = 0.9))
fit1

conds <- data.frame(patient_id = unique(data$patient_id))
marginal_effects(fit1)
marginal_effects(fit1, conditions = conds, re_formula = NULL)