How to put parameters to stan code

I want to pass the parameters from ui to the stan data list and run the stan codes; However, the shiny reports error for the

 y <- reactive(c(rep(1,round(input$N)),rep(0,round(input$N-input$prop*input$N) ))         
data <-  list(N = reactive(input$N)), y = y)

and the stan cannot run. Can anyone help me on that? Thanks.

ui<-fluidPage(
  
  titlePanel("Model"),
  
  sidebarPanel(
  fileInput('datafile', 'Choose Template file',accept=c('xlsx', '.xlsx')),
  
  sliderInput("input_n", "day",min = 30, max = 730, value = 20),
  numericInput("prop", "proportion", value = 0.2),
  numericInput("N", "sample size", value = 5000)
  ),
  
  mainPanel(
  plotOutput('plot')
  )
  
)

server<-function(input, output,session) {
  Nsize<-reactive(input$N)
  proportion<-reactive(input$prop)
  
  y <- reactive(c(rep(1,round(input$N)),rep(0,round(input$N-input$prop*input$N) ))         
  data <-  list(N = reactive(input$N)), y = y)
  niter <- 10000
  chains<-4
  
  fit <-stan(file="D:/Research/bayes.stan",
             data = data,
             iter = niter,
             chains = chains,
             control = list(adapt_delta = 0.99))
}

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.