Three headline numbers
- GDP = market value of final goods produced: \(Y = C + I + G + NX\).
- Nominal vs real: nominal GDP uses current prices; real GDP uses base-year prices (so it moves only when quantities move).
- GDP deflator \(= \dfrac{\text{Nominal GDP}}{\text{Real GDP}}\times 100\) — a price index for everything the country produces.
- Unemployment rate \(u = \dfrac{\text{Unemployed}}{\text{Labor force}}\); LFPR \(= \dfrac{\text{Labor force}}{\text{Adult population}}\).
Try it. Change quantities and current prices to see nominal, real, and the deflator split apart. Then switch to the labor-market tab.
#| standalone: true
#| viewerHeight: 520
library(shiny)
ui <- fluidPage(
tags$head(tags$style(HTML("body{font-family:'Inter',system-ui,sans-serif;}
.sb{background:#f0f4f8;border-radius:6px;padding:12px 14px;margin-top:8px;font-size:14px;line-height:1.9;} .sb b{color:#1f3b73;}"))),
tabsetPanel(
tabPanel("GDP & the deflator",
sidebarLayout(
sidebarPanel(width=4,
helpText("One good. Base-year price fixed at $4."),
sliderInput("q","Quantity produced:",min=0,max=20,value=12,step=1),
sliderInput("p","Current price:",min=1,max=10,value=5,step=1),
uiOutput("gdp")),
mainPanel(width=8, plotOutput("bar",height="420px")))),
tabPanel("Labor market",
sidebarLayout(
sidebarPanel(width=4,
sliderInput("E","Employed:",min=0,max=300,value=180,step=5),
sliderInput("U","Unemployed:",min=0,max=100,value=20,step=5),
sliderInput("N","Not in labor force:",min=0,max=200,value=50,step=5),
uiOutput("lab")),
mainPanel(width=8, plotOutput("pie",height="420px"))))
))
server <- function(input,output,session){
nom <- reactive(input$q*input$p)
rea <- reactive(input$q*4)
output$gdp <- renderUI(HTML(sprintf("<div class='sb'>Nominal GDP = q×p = <b>%.0f</b><br>Real GDP (base) = q×$4 = <b>%.0f</b><br>GDP deflator = <b>%.1f</b></div>",
nom(),rea(),nom()/rea()*100)))
output$bar <- renderPlot({ par(mar=c(3,4.4,1,1))
barplot(c(Nominal=nom(),Real=rea()),col=c("#b5462a","#1f3b73"),ylab="GDP",las=1,ylim=c(0,max(nom(),rea())*1.2))
})
LF <- reactive(input$E+input$U); pop <- reactive(input$E+input$U+input$N)
output$lab <- renderUI(HTML(sprintf("<div class='sb'>Labor force = <b>%.0f</b><br>Adult pop = <b>%.0f</b><br>Unemployment u = <b>%.1f%%</b><br>LFPR = <b>%.1f%%</b></div>",
LF(),pop(),100*input$U/LF(),100*LF()/pop())))
output$pie <- renderPlot({ par(mar=c(1,1,1,1))
pie(c(Employed=input$E,Unemployed=input$U,`Not in LF`=input$N),col=c("#1c6b4a","#b5462a","#9aa4b2"))
})
}
shinyApp(ui,server)
What to notice
- Raise only current prices → nominal GDP rises, real GDP doesn’t → the deflator rises. That’s inflation.
- Raise only quantities → real GDP rises too.
- In the labor tab, moving people to “not in labor force” lowers the LFPR but can lower measured unemployment — the denominators differ.