# Can global real GDP be calculated using nominal GDP and inflation rate? If so what is the error?

I am attempting to calculate (in R) the global real GDP using what I assume is the nominal GDP from the World Bank and what I can only identify as the inflation rate, also from the World bank.

Unfortunately I am unable to get reasonable results using my calculation method, and I cannot identify the specific cause:

1. The inflation data is not meant to be used in this way.
2. I have committed a logical or mathematical error.

The most logical way (for me) to do this is to calculate the cumulative product of all the inflation rates, then normalize them around the chosen base year.

adjust_for_inflation <- function(nominal_gdp, inflation_rate, base_year) {
# Get the time indices
time_indices <- time(nominal_gdp)

# Calculate the cumulative inflation rate up to each year
cumulative_inflation <- cumprod(1 + inflation_rate / 100)

# Find the cumulative inflation rate for the base year
base_year_index <- which(time_indices == base_year)
base_year_cumulative_inflation <- cumulative_inflation[base_year_index]

# Normalize cumulative inflation rates so that the base year's rate is 1
normalized_cumulative_inflation <- cumulative_inflation / base_year_cumulative_inflation

# Adjust nominal GDP to real GDP based on the normalized cumulative inflation
real_gdp <- nominal_gdp / normalized_cumulative_inflation

# Print statements for debugging
print(data.frame(Year = time_indices, Nominal_GDP = nominal_gdp, Inflation_Rate = inflation_rate, Cumulative_Inflation = cumulative_inflation, Normalized_Cumulative_Inflation = normalized_cumulative_inflation, Real_GDP = real_gdp))

# Return the real GDP as a ts object with the same time indices
real_gdp_ts <- ts(real_gdp, start=start(nominal_gdp), frequency=frequency(nominal_gdp))

return(real_gdp_ts)
}


This seems well and good, and testing it on some made up data produces exactly the results I intended.

nominal_gdp <- ts(c(100, 100, 100, 100, 100), start=2018, frequency=1)
inflation_rate <- ts(c(10, 10, 10, 10, 10), start=2018, frequency=1)
base_year <- 2020

  Year Nominal_GDP Inflation_Rate Cumulative_Inflation Normalized_Cumulative_Inflation  Real_GDP
1 2018         100             10              1.10000                       0.8264463 121.00000
2 2019         100             10              1.21000                       0.9090909 110.00000
3 2020         100             10              1.33100                       1.0000000 100.00000
4 2021         100             10              1.46410                       1.1000000  90.90909
5 2022         100             10              1.61051                       1.2100000  82.64463


However, when plugging in the data from the World Bank, the result essentially indicates that real GDP has stagnated for the last 4 decades

nominal_gdp_raw <- ts(t(read_excel('world_bank_nominal.xls', col_names = FALSE)), start=1960)[,1]
nominal_gdp <- window(nominal_gdp_raw , start = 1981)
inflation_rate <- ts(t(read_excel("world_bank_inflation_rate.xlsx", col_names = FALSE))[,1], start=1981)
base_year <- 2022



This is obviously wrong, and useless, however I genuinely cannot figure out what I did wrong. I also tried a cumulative sum approach to it cumulative_inflation <- 1 + cumsum(inflation_rate / 100) and it has more rational seeming results, but I can't justify why it would be a cumulative sum instead of compounding percentages.

• If I understand correctly, following the links in your first sentence, nominal GDP is world GDP at current US prices, while inflation is average world inflation. Don't you need US inflation instead? Commented Jun 2 at 19:59
• @AdamBailey I am getting mixed messages, so you are indeed in favor of using Inflation rate to calculate real GDP, consumer prices (annual %), but using the Unites States inflation instead of Global? Commented Jun 3 at 16:55
• I wouldn't claim to be too familiar with the differences between measures such as CPI, deflator, etc. What I am saying is that if you start, as you appear to do, from world GDP at current US prices, and you want to get to real world GDP, then you need to adjust using an appropriate measure relating to the US rather than one relating to the whole world. Commented Jun 3 at 18:45

What you want is to take nominal GDP and divide it by either deflator or price index (which should also be divided by 100). So you want either $$rGDP = nGDP/Def$$ or $$rGDP = nGDP/(CPI/100)$$.
Inflation is defined as positive change in CPI, $$\pi = (CPI_t=CPI_{t-1})/CPI_{t-1}$$ you can't calculate CPI from inflation data unless you know CPI at least in one year and if you know that you probably have dataset of CPI for other years. However, I would be extremely surprised if WB would not have data for world CPI or deflator. You should look for it.