R Shiny app for cost-effectiveness simulation

Hi everyone,

I want to use RShiny to make a simulation of cost-effectiveness for two treatment strategies (say, therapy A vs. B). The input values should be mean costs and mean effectiveness of both strategies, together with standard deviations. The results (incremental cost-effectiveness ratio, ICER) should be calculated from it. This would be easy, but I also need cost-effectiveness acceptability curves (CEAC). For that, I need to bootstrap the results of two hypothetical trials with prespecified effectiveness and costs, plus standard deviation for each of them.

The general idea and outputs can be found on RPubs - R Simulation for CEACs and the codes on pastebin: R Simulation for CEACs - codes - Pastebin.com.

My skills in RShiny are very limited. So far, I managed to create a simple app that generates histograms of the distributions (and their differences) based on slider inputs of costs and effects of strategies 1 and 2.

Does anybody have an idea how to implement this in Shiny? In other words, the ICER plane with the "trial results" and the CEAC shoud be (re)generated when an input parameter is changed. My problems is mainly the following:
Bootstrapping of the results fails because I don't know how to put the generated input (e.g. 500 values each for costs1, effects1, costs2, effects2) in a data frame in RShiny. Any ideas on how to do bootstrapping in a Shiny app and plot the results?

I googled for hours and could neither find a similar app nor any solutions to my problem.

Thanks in advance!

Hi everyone,

You can forget about my previous post, I solved the problem and you can find and try out my app at Bootstrapped Trial Effects and Costs - no correlation between costs and effects
It works as I hoped it would. I even managed to create tab panels to have the results a bit structured instead of scattered around in one huge page. My only problem: When I run the app in RStudio, it shows a warning message (3 times, actually), saying: "Warning: Navigation containers expect a collection of bslib::nav_panel()/shiny::tabPanel()s and/or bslib::nav_menu()/shiny::navbarMenu()s. Consider using header or footer if you wish to place content above (or below) every panel's contents."
It doesn't seem to affect the functionality of the app. Still, I'm curious what that means, if I can ignore it, and how I could fix the problem.
The only thing I changed in the codes is that instead of putting all results in one page, I created tabPanel()s and put the results into one of them. For example:

mainPanel(
plotOutput(outputId = "plot_output1"),
plotOutput(outputId = "plot_output2")
)
would now be:

mainPanel(
tabsetPanel(type = "tabs",
tabPanel("plot_output1",
plotOutput(outputId = "plot_output1")
),
tabsetPanel(type = "tabs",
tabPanel("plot_output2",
plotOutput(outputId = "plot_output2")
),
)

Does anybody have an idea what could be the cause of the problem and how to fix it?
Thanks in advance.

Hi,

Welcome to the RStudio community!

Your problem arises from some incorrect nesting of UI elements. First of all, the mainPanel() wrapper is part of the larger sidebarLayout() architecture like this

ui <- fluidPage(
  sidebarLayout(
    sidebarPanel(),
    mainPanel( )
   )
)

This will generate a sidebar on the left, with a larger body on the right of the screen

Second, when you are using a tabsetPanel all tabPanels are nested in it (you were creating a new tabsetpanel for each, which I don't think you intended). It looks like this

tabsetPanel(
     tabPanel(),
     tabPanel()
)

The type = "tabs" is not needed as it is the default.

Now if we combine all of this together using your example we get this:

library(shiny)
ui <- fluidPage(
  titlePanel("Hello Shiny!"),
  sidebarLayout(
    sidebarPanel(
     selectInput("points", "# Points", choices = c(5,10,15))
    ),
    mainPanel(
      tabsetPanel(
        tabPanel("plot_output1",
          plotOutput(outputId = "plot_output1")
        ),
        tabPanel("plot_output2",
            plotOutput(outputId = "plot_output2")
        )
      )
    )
))
server <- function(input, output, session) {
  output$plot_output1 = renderPlot(plot(1:input$points))
  output$plot_output2 = renderPlot(plot(input$points:1))
}
shinyApp(ui, server)

I created some dummy plots and an extra input to show off the different components better. The titlePanel() is optional but can show a title for the app.

Hope this helps,
PJ

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.