Questions tagged [rstan]

RStan is an API in R for the STAN programming language for Bayesian Statistical Inference.

Stan uses an R-like language for specifying statistical models, and has an R interface for compiling and running the markov chain analyses, and reporting the results back to R.

Links

299 questions
0
votes
1 answer

rstanarm for adaptive trials

I started exploring the rstanarm package and was curious as how this package could potentially be used in an adaptive trial scenario. The example scenario given within vignette provides a posterior of -0.622 with a credible interval from -0.69 to…
0
votes
0 answers

Using STAN function inside user defined function

The likelihood function for my data (m) is like below: "dexp(m,beta) * pnorm(m,mu,sigma)". The user defined loglikelihood function that I wrote inside my STAN code is like: functions{ real loglikelihood(int N, real mu, real…
Geotas
  • 35
  • 6
0
votes
1 answer

openCPU and rstan - cannot open the connection

I'm using openCPU to create an API to estimate pretty basic models in rstan. I have verified that my function works in my environment when called from a normal R console session, as opposed to called from openCPU. But when called via openCPU, the…
MDe
  • 2,478
  • 3
  • 22
  • 27
0
votes
0 answers

R package development: successfully installed but failed to load. Why?

I am building an R package with some RStan source codes for Bayesian modeling. I succeeded installing the package, but failed to source it in Rstudio via "library". Below are the messages. # first few lines are output for installation. ... ... **…
SixSigma
  • 2,808
  • 2
  • 18
  • 21
0
votes
0 answers

Computation hangs: rstan, plyr, and doMC

I am trying to run a simple rstan example using plyr and doMC for parallel computation. The following code completes normally if I comment out registerDoMC(cores = 2) near the bottom, but as is, my R session hangs indefinitely on the call to adply.…
landau
  • 5,636
  • 1
  • 22
  • 50
0
votes
1 answer

stan programming for ETAS model

I am new in STAN. I am working on temporal ETAS model, a model used for modelling earthquakes.The intensity at earthquake occurrence time t[i] is modelled as- h(t[i]|p,c,mu)=mu+sum((p-1)*(c^(p-1))*(1/((t[i]-t[1:(i-1)]+c)^(p-1)))); where t is the…
Geotas
  • 35
  • 6
0
votes
2 answers

Adding a transformed parameter to stanfit object

I have a stanfit object called fit returned by rstan::stan(...) to infer a parameter theta. I can now analyse theta using e.g. rstan::summary(fit, pars="theta"). I later realised that I am more interested in inference about the square of theta. I…
sieste
  • 8,296
  • 3
  • 33
  • 48
0
votes
0 answers

different mixed effect models with lme4 and lmer2stan

I'm trying the following model with the lme4 package: library(nmle) # for the data data("Machines") # the data library(lme4) # the model: fit1 <- lmer(score ~ -1 + Machine + (1|Worker), data=Machines) summary(fit1) > summary(fit1) Linear mixed…
spore234
  • 3,550
  • 6
  • 50
  • 76
0
votes
2 answers

Assign vector component using string in R

I have a string, say "ti[123]", and a corresponding value, say 1.2 What is the command I should use in R to assign 1.2 to the 123rd position of vector ti ? I tried assign("ti[123]",1.2) but it creates a new variable with name ti[123], which is not…
yannick
  • 397
  • 3
  • 19
0
votes
1 answer

Rstan compile error on OS X

I am having a lot of trouble getting Rstan to work on my OSX setup. For background info, my system is as follows: OSX Yosemite v. 10.10.5 R 3.2.1 GUI 1.66 Mavericks Each time I run a stan model in R through R stan, I get the following error…
0
votes
1 answer

Stan - Mixture of Normals

I'm using RStan to fit a mixture of two normals. data { int K; int N; real y[N]; } parameters { simplex[K] theta; real mu[K]; real sigma; } model{ real ps[K]; // place-holder for log component densities …
Sam
  • 4,357
  • 6
  • 36
  • 60
0
votes
1 answer

How to get eigenvectors of nonsymmetric matrix in Stan?

Stan provides the functions vector eigenvalues_sym(matrix A) matrix eigenvectors_sym(matrix A) for getting eigenvalues and eigenvectors of a symmetric matrix A, but what if your matrix is nonsymmetric? Can you still get the eigenvalues and…
user52291
  • 161
  • 2
  • 2
  • 4
0
votes
2 answers

Problems with loading Rstan in R

I have installed RStan for R. The installation seems to be successful, but when I load the package and use it, I keep getting the error message indicating Rstan isn't installed: > source("http://mc-stan.org/rstan/stan.R") > fit <- stan("7b…
-1
votes
1 answer

R package development: tests pass in console, but fail via devtools::test()

I am developing an R package that calls functions from the package rstan. As a MWE, my test file is currently set up like this, using code taken verbatim from rstan's example: library(testthat) library(rstan) # stan's own example stancode <- 'data…
half-pass
  • 1,851
  • 4
  • 22
  • 33
1 2 3
19
20