# Using R to conduct a Cost-Benefit Analysis: An Application to Wind Energy

This Fall Semester I have been teaching the Environmental and Resource Economics course at my university. During lectures, I like to do hands-on exercises with the students so that they can actually use the theory I babble about into practice. Of course these exercises require a lot of preparation beforehand to make sure they go smoothly. A couple of weeks ago I challenged the class to do a cost-benefit analysis of a specific project. Once each of the 12 groups found one specific parameter they were tasked with finding, we were able to calculate the net social benefits of the project as a class and assess whether the project should go forward or not.

In this blog post I will replicate what we did in class and do a cost-benefit analysis using R. The purpose of this post is to provide a template for others to use to conduct their own cost-benefit analyzes.

The Case Study

Our application is to a relatively small onshore wind farm in the county of Rogaland.  I chose to focus on onshore wind because it is one area I am especially knowledgeable (in other words, I know how to find the information more easily!).

The project we analyze is based on this concession in the county of Rogaland. It is an area close to a recreational hiking site, called Dalsnuten. Based on the concession’s webpage, the wind farm under analysis deploys 30 turbines with a capacity of 3 MW each, a total of 90 MW of capacity. I am assuming a lifetime of the turbines of 20 years. These assumptions are important when calculating the net present value.

Carrying out a Cost-Benefit Analysis

A cost benefit analysis (CBA) is an accounting exercise to evaluate whether the social benefits associated with a project exceed the social costs, in which case the project should be carried out. In order to do so, all social costs and benefits are converted into a money metric and are thus compared.

According to Atkinson et al. (2018), there are eight steps to carrying out a CBA:

1. Define the project;
2. Identify the impacts (positive & negative);
3. Identify economically relevant impacts;
4. Quantify impacts physically;
5. Value impacts monetarily;
6. Discount cost & benefits;
7. Apply the net present value;
8. Sensitivity Analysis.

Since I already defined the project (i.e., onshore wind farm in Norway), in class we brainstormed what the costs and benefits of onshore wind could be. Benefits could arise due to sale of electricity, higher tax incomes for municipalities, more jobs and savings in greenhouse gas emissions. As for costs, we identified capital costs, operational and maintenance costs, biodiversity loss (both plant and animal species), and losses of recreational and property values due to visual and noise impacts.

To avoid double counting, I decided to consider only private costs (capital and operational and maintenance costs), private benefits (sale of electricity) and some measure of social net benefit or cost per wind turbine.

To calculate private benefits, we need the spot electricity price (in Norwegian kroners per unit of electricity) and the electricity produced per year. As for the electricity produced in a year, I consulted the concession webpage of this specific project, which projects 306 GWh per year (which is equivalent to 306000 MWh per year). By the way, this corresponds to a capacity rate of 306000/(90*24*365)=38.8%, which is quite optimistic in my opinion.

In R, I defined two parameters: MW_installed (the capacity installed in this wind farm) and MWh_year (production of electricity in a year by this wind farm):

```MW_installed <- 90
MWh_year     <- 306000```

To find the average spot price for electricity in Norway in a year, the students consulted the NordPool website that records the historical price per MWh in the Nordic electricity market (in Euros). The average spot electricity price in the last three years was 353.8 NOK/MWh, but the students also provided with a minimum of 223.2 NOK and a maximum of 543.5 NOK. These alternative values are very useful if we wanted to conduct sensitivity analyzes. I define the parameter Price_MWh as:

`Price_MWh <- 353.8`

To calculate private costs, we first considered capital (or building) costs as one-time costs at time zero of setting up the wind turbines. We had to make sure to get all units in the same metric, so we decided to define the cost per unit of MW. This website indicates an estimate of 9 to 11 million NOK per MW installed. Let’s assume an average of 10 million kroner per MW, and define parameter called Capital_costs_MW:

`Capital_costs_MW <- 10000000`

Besides capital costs, running a wind farm also results in annual operational costs. The same website as before suggests an operational cost of 0.1 NOK per kWh, which corresponds to 100 kroners per MWh. I defined the parameter OM_costs_MWh:

`OM_costs_MWh <- 100`

So far the information was relatively easy to find. This is where cost-benefit becomes complicated.

When considering which the costs and benefits of onshore wind are economically significant, we mentioned the recreational impact. In other words, the presence of wind turbines in the viewscape decreases both the quality of a recreational trip and decreases the probability of a visit. To obtain a measure of this loss, one could apply the travel cost method or use contingent behavior.

That is precisely what Kipperberg et al. (2019) did, who found that a welfare loss of 16.61 NOK per trip. The same paper also provided an estimate of the number of visits to Dalsnuten (the nearby recreational site) per year of around 200000. These are the parameters that I defined in R:

```Visits_year <- 200000
Price_visit <- 16.61```

However, one can argue that recreational losses are but a fraction of the welfare losses incurred in case of a wind farm. If there are both non-use and use losses at stake, then using the contingent valuation or choice experiment methods are more appropriate. Two papers have done so in southern Norway: Garcia et al. (2016) and Lindhjem et al. (2019).

These two papers provide a measure of the willingness to pay (WTP) per household to avoid the construction of a certain number of wind turbines. I will just use the values from Lindhjem et al. (2019) as an example. The authors conducted a choice experiment and found that in Rogaland each household would have to be paid 500, 461 and 273 per month to accept 3000, 1200 and 600 turbines, respectively. I will define the WTP and Turbines vector. I then calculate the marginal WTP for each additional turbine as the WTP_turbine vector.

```WTP <- c(500, 461, 273)
Turbines <- c(3000, 1200, 600)
WTP_turbine <- WTP/Turbines```

I can visualize the WTP_turbine by typing:

```plot(Turbines, WTP_turbine, ylim=c(0,0.5))
abline(lm(WTP_turbine ~ Turbines), col="blue")``` Surprisingly, the linear line is a perfect fit to the data. If we assume this linear relationship, I find a WTP of 0.5248 NOK per turbine and per household for 30 turbines. I multiply it by 12 to obtain the WTP per year.

The only thing missing is finding out the number of households in Rogaland, which is 203147 according to SSB. These are our final parameters:

```WTP_30turbine <- 0.5248*30*12
Households    <- 203147```

In step 6 of conducting a cost-benefit analysis, we have to choose a discount rate. I didn’t ask the students to find an appropriate onw, but I use 4% as the social discount rate.

`i <- 0.04`

Now we have all the necessary parameters. I will follow two possible strategies:

1. Consider private costs and benefits and then assume the highest social loss would be recreational losses at Dalsnuten recreational site (i.e. only use value losses)
2. Consider private costs and benefits but assume instead both non-use and use value losses by using the results from Lindhjem et al. (2019)

All of the costs and benefits are incurred annually, except the capital costs that are incurred at time zero. I define the annual cashflows as the following:

```# Private Costs
Costs_0 <- Capital_costs_MW*MW_installed
Costs_1 <- OM_costs_MWh*MWh_year

# Private Benefits
Revenues_1 <- Price_MWh*MWh_year

# Social Costs
Loss_Rec_1 <- Price_visit*Visits_year
Loss_WTP_1 <- WTP_30turbine*Households```

To get an overview of the cash flows, I just typed:

```> c(Costs_0,Costs_1,Loss_Rec_1,Revenues_1)
 900000000  30600000   3322000 121778820
> c(Costs_0,Costs_1,Loss_WTP_1,Revenues_1)
 900000000  30600000  38380156 121778820```

As expected, when only considering losses in use values (Strategy 1), the annual losses are only 3.3 million NOK, while these are almost 38 million NOK when considering use and non-use losses.

I calculate the net present value for both strategies:

```# NPV Calculation for Strategy 1

CF0 <- (-Costs_0)                      /((1+i)^(0 ))
CF1 <- (-Costs_1-Loss_Rec_1+Revenues_1)/((1+i)^(1 ))
CF2 <- (-Costs_1-Loss_Rec_1+Revenues_1)/((1+i)^(2 ))
CF3 <- (-Costs_1-Loss_Rec_1+Revenues_1)/((1+i)^(3 ))
CF4 <- (-Costs_1-Loss_Rec_1+Revenues_1)/((1+i)^(4 ))
CF5 <- (-Costs_1-Loss_Rec_1+Revenues_1)/((1+i)^(5 ))
CF6 <- (-Costs_1-Loss_Rec_1+Revenues_1)/((1+i)^(6 ))
CF7 <- (-Costs_1-Loss_Rec_1+Revenues_1)/((1+i)^(7 ))
CF8 <- (-Costs_1-Loss_Rec_1+Revenues_1)/((1+i)^(8 ))
CF9 <- (-Costs_1-Loss_Rec_1+Revenues_1)/((1+i)^(9 ))
CF10 <- (-Costs_1-Loss_Rec_1+Revenues_1)/((1+i)^(10))
CF11 <- (-Costs_1-Loss_Rec_1+Revenues_1)/((1+i)^(11))
CF12 <- (-Costs_1-Loss_Rec_1+Revenues_1)/((1+i)^(12))
CF13 <- (-Costs_1-Loss_Rec_1+Revenues_1)/((1+i)^(13))
CF14 <- (-Costs_1-Loss_Rec_1+Revenues_1)/((1+i)^(14))
CF15 <- (-Costs_1-Loss_Rec_1+Revenues_1)/((1+i)^(15))
CF16 <- (-Costs_1-Loss_Rec_1+Revenues_1)/((1+i)^(16))
CF17 <- (-Costs_1-Loss_Rec_1+Revenues_1)/((1+i)^(17))
CF18 <- (-Costs_1-Loss_Rec_1+Revenues_1)/((1+i)^(18))
CF19 <- (-Costs_1-Loss_Rec_1+Revenues_1)/((1+i)^(19))
CF20 <- (-Costs_1-Loss_Rec_1+Revenues_1)/((1+i)^(20))
NPV_1 <- CF0 +CF1 +CF2 +CF3 +CF4 +CF5 +CF6 +CF7 +CF8 +CF9 +
CF10+CF11+CF12+CF13+CF14+CF15+CF16+CF17+CF18+CF19+CF20```
```# NPV Calculation for Strategy 2

CF0 <- (-Costs_0)                      /((1+i)^(0 ))
CF1 <- (-Costs_1-Loss_WTP_1+Revenues_1)/((1+i)^(1 ))
CF2 <- (-Costs_1-Loss_WTP_1+Revenues_1)/((1+i)^(2 ))
CF3 <- (-Costs_1-Loss_WTP_1+Revenues_1)/((1+i)^(3 ))
CF4 <- (-Costs_1-Loss_WTP_1+Revenues_1)/((1+i)^(4 ))
CF5 <- (-Costs_1-Loss_WTP_1+Revenues_1)/((1+i)^(5 ))
CF6 <- (-Costs_1-Loss_WTP_1+Revenues_1)/((1+i)^(6 ))
CF7 <- (-Costs_1-Loss_WTP_1+Revenues_1)/((1+i)^(7 ))
CF8 <- (-Costs_1-Loss_WTP_1+Revenues_1)/((1+i)^(8 ))
CF9 <- (-Costs_1-Loss_WTP_1+Revenues_1)/((1+i)^(9 ))
CF10 <- (-Costs_1-Loss_WTP_1+Revenues_1)/((1+i)^(10))
CF11 <- (-Costs_1-Loss_WTP_1+Revenues_1)/((1+i)^(11))
CF12 <- (-Costs_1-Loss_WTP_1+Revenues_1)/((1+i)^(12))
CF13 <- (-Costs_1-Loss_WTP_1+Revenues_1)/((1+i)^(13))
CF14 <- (-Costs_1-Loss_WTP_1+Revenues_1)/((1+i)^(14))
CF15 <- (-Costs_1-Loss_WTP_1+Revenues_1)/((1+i)^(15))
CF16 <- (-Costs_1-Loss_WTP_1+Revenues_1)/((1+i)^(16))
CF17 <- (-Costs_1-Loss_WTP_1+Revenues_1)/((1+i)^(17))
CF18 <- (-Costs_1-Loss_WTP_1+Revenues_1)/((1+i)^(18))
CF19 <- (-Costs_1-Loss_WTP_1+Revenues_1)/((1+i)^(19))
CF20 <- (-Costs_1-Loss_WTP_1+Revenues_1)/((1+i)^(20))

NPV_2 <- CF0 +CF1 +CF2 +CF3 +CF4 +CF5 +CF6 +CF7 +CF8 +CF9 +
CF10+CF11+CF12+CF13+CF14+CF15+CF16+CF17+CF18+CF19+CF20```

These are the net social benefits of the same project but assuming different strategies:

```> NPV_1
 294002855
> NPV_2
 -182448931```

I can conclude that if I only consider use value losses, the NPV is positive, which means building this wind farm makes economical sense for society, which does not hold true if one considers both use and non-use losses (i.e., NPV is negative). I would argue that all losses should be considered, so strategy 2 makes the most sense. However, it would be ideal to understand how this conclusion changes when one uses different parameters. What are the parameters that change the outcome from profitable to non-profitable? What is the impact of the electricity price, or of the WTP estimate, for example?

To conclude this blog post, I will graphically demonstrate how cash flows vary across years using the two strategies. I like to use the ggplot2 package to create these graphs:

```library(ggplot2)
t <- seq(0, 20, length.out = 21)
Cum_CF <- c(CF0,
CF0+CF1 ,
CF0+CF1+CF2 ,
CF0+CF1+CF2+CF3 ,
CF0+CF1+CF2+CF3+CF4 ,
CF0+CF1+CF2+CF3+CF4+CF5 ,
CF0+CF1+CF2+CF3+CF4+CF5+CF6 ,
CF0+CF1+CF2+CF3+CF4+CF5+CF6+CF7 ,
CF0+CF1+CF2+CF3+CF4+CF5+CF6+CF7+CF8 ,
CF0+CF1+CF2+CF3+CF4+CF5+CF6+CF7+CF8+CF9 ,
CF0+CF1+CF2+CF3+CF4+CF5+CF6+CF7+CF8+CF9+CF10,
CF0+CF1+CF2+CF3+CF4+CF5+CF6+CF7+CF8+CF9+CF10+CF11,
CF0+CF1+CF2+CF3+CF4+CF5+CF6+CF7+CF8+CF9+CF10+CF11+CF12,
CF0+CF1+CF2+CF3+CF4+CF5+CF6+CF7+CF8+CF9+CF10+CF11+CF12+CF13,
CF0+CF1+CF2+CF3+CF4+CF5+CF6+CF7+CF8+CF9+CF10+CF11+CF12+CF13+CF14,
CF0+CF1+CF2+CF3+CF4+CF5+CF6+CF7+CF8+CF9+CF10+CF11+CF12+CF13+CF14+CF15,
CF0+CF1+CF2+CF3+CF4+CF5+CF6+CF7+CF8+CF9+CF10+CF11+CF12+CF13+CF14+CF15+CF16,
CF0+CF1+CF2+CF3+CF4+CF5+CF6+CF7+CF8+CF9+CF10+CF11+CF12+CF13+CF14+CF15+CF16+CF17,
CF0+CF1+CF2+CF3+CF4+CF5+CF6+CF7+CF8+CF9+CF10+CF11+CF12+CF13+CF14+CF15+CF16+CF17+CF18,
CF0+CF1+CF2+CF3+CF4+CF5+CF6+CF7+CF8+CF9+CF10+CF11+CF12+CF13+CF14+CF15+CF16+CF17+CF18+CF19,
CF0+CF1+CF2+CF3+CF4+CF5+CF6+CF7+CF8+CF9+CF10+CF11+CF12+CF13+CF14+CF15+CF16+CF17+CF18+CF19+CF20)
CF <- data.frame(t,CF=c(CF0,CF1 ,CF2 ,CF3 ,CF4 ,CF5 ,CF6 ,CF7 ,CF8 ,CF9 ,CF10,CF11,CF12,CF13,CF14,CF15,CF16,CF17,CF18,CF19,CF20),Cum_CF)

ylab <- c(-800,-600,-400,-200,0,200,400)

Cash_Flows_2 <- ggplot(data=CF) +
geom_bar(aes(x=t, y=CF), stat="identity", fill="steelblue") +
geom_line(aes(x=t, y=Cum_CF),stat="identity", color='#000066', size=2) +
scale_y_continuous(name = "Present Value of Cash Flows", labels = paste0(ylab, "M"), breaks = ylab*10^6)
Cash_Flows_2```

The two graphs are called Cash_Flows_1 (left) and Cash_Flows_2 (right), using Strategy 1 and 2, respectively. The graph below shows how they look like. The blue bars indicate the annual cash flow and the line indicates the cumulative value of the investment. Just like I mentioned above, Strategy 1 indicates the wind farm has a positive social value, while Strategy 2 suggests that such a wind farm would not be an economically viable project for society. Final note: I actually did not use any special package in R to conduct this analysis. Other softwares, such as Excel, can also be used to conduct CBAs. However, I favour the use of R to graphically illustrate the outcome of the CBA.

References:

Atkinson, G., Braathen, N. A., Mourato, S., & Groom, B. (2018). Cost Benefits Analysis and the Environment: Further Developments and Policy Use. Organisation for Economic Co-operation and Development.

García, J. H., Cherry, T. L., Kallbekken, S., & Torvanger, A. (2016). Willingness to accept local wind energy development: Does the compensation mechanism matter?. Energy Policy, 99, 165-173.

Kipperberg, G., Onozaka, Y., Bui, L. T., Lohaugen, M., Refsdal, G., & Sæland, S. (2019). The impact of wind turbines on local recreation: Evidence from two travel cost method–contingent behavior studies. Journal of Outdoor Recreation and Tourism25, 66-75.

Lindhjem, H., A. Dugstad, K. Grimsrud, Øyvind N. Handberg, G. Kipperberg, E. Kløw, S. Navrud. 2019. «Vindkraft i motvind- Miljøkostnadene er ikke til å blåse av» Aktuell kommentar Samfunnsøkonomen 4 (133): 6-17.