stan

Multiply two 1*k vectors but got No matches for: real ~ normal(matrix, real) error in pystan

泪湿孤枕 提交于 2019-12-24 20:36:05
问题 Now I am implementing the pmf model as below: pmf_code = """ data { int<lower=0> K; //number of factors int<lower=0> N; //number of user int<lower=0> M; //number of item int<lower=0> D; //number of observation int<lower=0> D_new; //number of pridictor int<lower=0, upper=N> ii[D]; //item int<lower=0, upper=M> jj[D]; //user int<lower=0, upper=N> ii_new[D_new]; // item int<lower=0, upper=N> jj_new[D_new]; // user real<lower=0, upper=5> r[D]; //rating real<lower=0, upper=5> r_new[D_new]; /

Stan version of a JAGS model which includes a sum of discrete values - Is it possible?

时光毁灭记忆、已成空白 提交于 2019-12-24 14:34:08
问题 I was trying to run this model in Stan. I have a running JAGS version of it (that returns highly autocorrelated parameters) and I know how to formulate it as CDF of a double exponential (with two rates), which would probably run without problems. However, I would like to use this version as a starting point for similar but more complex models. By now I have the suspicion that a model like this is not possible in Stan. Maybe because of the discreteness introduces by taking the sum of a Boolean

Suppress running messages from RStan in Rmarkdown HTML output

时光怂恿深爱的人放手 提交于 2019-12-23 07:47:16
问题 The following are my r code. ```{r message=FALSE, warning=FALSE, cache=0,eval=TRUE, error=FALSE} stan_m1 <- rethinking::map2stan( alist( y ~ dbinom(n, p), logit(p) <- alpha + bP*P + bA*A + bV*V, alpha ~ dnorm(0, 10), bP ~ dnorm(0, 5), bA ~ dnorm(0, 5), bV ~ dnorm(0, 5) ), data = d1, chains=2 , iter=2500 , warmup=500, debug=FALSE , verbose=FALSE,refresh=-1 ) When I knit my rmarkdown file as html output, I am getting following output. Is there any way to turn off these messages? 回答1: Put

Calculating marginal effects in binomial logit using rstanarm

邮差的信 提交于 2019-12-22 17:42:11
问题 I am trying to get the marginal effects, according to this post: http://andrewgelman.com/2016/01/14/rstanarm-and-more/ td <- readRDS("some data") CHAINS <- 1 CORES <- 1 SEED <- 42 ITERATIONS <- 2000 MAX_TREEDEPTH <- 9 md <- td[,.(y,x1,x2)] # selection the columns i need. y is binary glm1 <- stan_glm(y~x1+x2, data = md, family = binomial(link="logit"), prior = NULL, prior_intercept = NULL, chains = CHAINS, cores = CORES, seed = SEED, iter = ITERATIONS, control=list(max_treedepth=MAX_TREEDEPTH)

pystan: distutils.errors.CompileError: command 'gcc' failed with exit status 1

折月煮酒 提交于 2019-12-12 18:36:30
问题 I'm using Ubuntu 14.04.3 and latest version of anaconda. When pystan tries to compile models, I get the following error: distutils.errors.CompileError: command 'gcc' failed with exit status 1 When I try running the models on my RHEL server at work, everything works fine. Before installing pystan, I ran apt-get install build-essential I've tried installing stan using anaconda and building from source, and I still get the error. I have no idea what to try next. Edit: Full error output is below

Exceeded maximum number of DLLs in R

喜夏-厌秋 提交于 2019-12-08 15:28:40
问题 I am using RStan to sample from a large number of Gaussian Processes (GPs), i.e., using the function stan(). For every GP that I fit, another DLL gets loaded, as can be seen by running the R command getLoadedDLLs() The problem I'm running into is that, because I need to fit so many unique GPs, I'm exceeding the maximum number of DLLs that can be loaded, at which point I receive the following error: Error in dyn.load(libLFile) : unable to load shared object '/var/folders/8x

Extract and add to the data frame the values of sigma from a stan distributional linear model

狂风中的少年 提交于 2019-12-08 05:02:45
问题 Given the sample data sampleDT and the brms models brm.fit and brm.fit.distr below, I would like to: estimate, extract and add to the data frame the values of the standard deviations for each observation from the distributional model brm.fit.distr . I can do this using brm.fit , but my approach fails when I use brm.fit.distr . Sample data sampleDT<-structure(list(id = 1:10, N = c(10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L), A = c(62L, 96L, 17L, 41L, 212L, 143L, 143L, 143L, 73L, 73L), B

Developing Hierarchical Version of Nonlinear Growth Curve Model in Stan

不问归期 提交于 2019-12-08 03:13:07
问题 The following model is model 1 of Preece and Baines (1978, Annals of Human Biology ), and is used to describe human growth. My Stan code for this model is as follows: ```{stan output.var="test"} data { int<lower=1> n; ordered[n] t; // age ordered[n] y; // height of human } parameters { positive_ordered[2] h; real<lower=0, upper=t[n-1]>theta; positive_ordered[2] s; real<lower=0>sigma; } model { h[1] ~ uniform(0, y[n]); h[2] ~ normal(180, 20); sigma ~ student_t(2, 0, 1); s[1] ~ normal(5, 5); s

Can you use sample weights in pystan or pymc3?

老子叫甜甜 提交于 2019-12-08 01:19:56
问题 If my observed dataset has weights (for example tracking multiplicity) is it possible to provide this either to pystan or pymc3, similar to the function signature (http://mc-stan.org/rstanarm/reference/stan_glm.html) in the rstanarm package: stan_glm(formula, family = gaussian(), data, weights, subset, na.action = NULL, offset = NULL, model = TRUE, x = FALSE, y = TRUE, contrasts = NULL, ..., prior = normal(), prior_intercept = normal(), prior_aux = exponential(), prior_PD = FALSE, algorithm =

Embedding Stan in C++ application

ⅰ亾dé卋堺 提交于 2019-12-07 10:51:43
问题 I wanted to know whether it is possible to incorporate Stan in another C++ application. Since Stan is also written in C++, there should be a way. Currently, I am using RInside to achieve this but then you have all this data transferring which is time-consuming. 回答1: What specifically did you want from Stan? We're going to separate out the math library into a standalone include for Stan 2.7 --- that contains all the matrix, probability, and autodiff code. Our repos already reflect this