RTutor: The Causal Effects of Sweden’s CO2 Tax

[This article was first published on Economics and R - R posts, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Most economists agree that putting a price on greenhouse gas emmissions either in form of emission certificates or a carbon tax should be the main instrument to combat climate change in a cost-efficient manner. Sweden has introduced a steadily increasing Carbon tax in 1991 which reached in 2020 a level of 110 Euro per ton CO2, which makes it the highest carbon tax in the world. The tax applies to those sectors that are not covered by the EU emission trading system (mainly transport and residential heating).

Two important questions related to such a tax are:

  1. How effective was the carbon tax in reducing Sweden’s carbon emissions?

  2. How did the tax affect Sweden’s economic development measured by GDP growth?

One can get a first idea by looking at the development over time for these two variables. The Swedish government made the following plot:

However, obviously we don’t know how those curves would have looked if Sweden would not have introduced the carbon tax. This means just looking at time trends does typically not show us the causal effect of a policy intervention.

The article Carbon Taxes an CO2 Emissions: Sweden as a case study (2019, AEJ: Economic Policy) by Julius J. Andersson estimates the causal effect of Sweden’s CO2 tax on emissions in the transport sector using the synthetic control model.

The key idea is to take as control group a synthetic Sweden constructed as a weighted sample of other countries. The country weights are determined in a nested optimization procedure that gives higher weights to countries that are in the pre-intervention period closer to Sweden with respect to certain explanatory variables, like GDP per capita or the share of urban population. Those explanatory variables are weighted such that the constructed synthetic Sweden well matches Sweden’s time path of the pre-intervention emission levels.

As part of her Master Thesis at Ulm University, Theresa Graefe has created a very nice RTutor problem set that allows you to replicate the analysis and dig deeper into the synthetic control method in an interactive fashion with R. Like in previous RTutor problem sets, you can enter free R code in a web-based shiny app. The code will be automatically checked and you can get hints how to proceed. In addition you are challenged by multiple choice quizzes. This means you will be guided how to generate plots like the following that illustrates the time path of the estimated causal effects as the post-treatment difference between Sweden’s and synthetic Sweden’s CO2 emmissions:

and you will see in similar plots that there was essential no measurable causal effect of the CO2 tax on Sweden’s GDP growth. You will also learn about Placebo tests that help to assess statistic significance (often in an informal manner) of the estimated causal effects.

You can test the problem set online on shinyapps.io:


The free shinyapps.io account is capped at 25 hours total usage time per month. So it may be greyed out when you click at it.

To locally install the problem set, follow the installation guide at the problem set’s Github repository: https://github.com/TheresaGraefe/RTutorCarbonTax

If you want to learn more about RTutor, to try out other problem sets, or to create a problem set yourself, take a look at the Github page


or the documentation at


To leave a comment for the author, please follow the link and comment on their blog: Economics and R - R posts.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)