I do Bayesian statistics programming in R with Stan, but the console couldn’t find the function “stan”. There is an error in the code
stanfit <- stan(file=scr, model_name=scr, data=data, pars=par, verbose=F,seed=see, chains=cha, warmup=war,iter=ite)
the whole code as follows.
library(rstan)
library(rstanarm)
library(loo)
library(bayesplot)
library(ggplot2)
options(mc.cores = paralles::detectCores())
scr <- "modelbeforeafter.stan"
source("databeforeafter.R")
data <- list(N=N,xA=xA,xB=xB)
par <-c("muA","muB", "SigmaA","SigmaB","log_likA","log_likB","rhoA", "rhoB","deltaA","deltaB","es","deltaA_over","deltaB_over","es_over","delta_r","delta_r_over")
war <- 1000
ite <- 11000
see <- 1234
dig <- 3
cha <- 1
stanfit <- stan(file=scr, model_name=scr, data=data, pars=par, verbose=F,seed=see, chains=cha, warmup=war,iter=ite)
loo1 <- rstan:::loo.stanfit