Hi, I have calculated the net present value of a project and the benefit-cost ratio as well in R. While my net present value is negative (-300), my benefit-cost ratio is more than 1. I want to know if my code of calculating the benefit-cost ratio is correct or not.

I have calculated the npv using the following parameters and formula in R:

...

```
# plant info
q_fuel <- 398 #MLPY (million L/yr)
capex <- 422 #MM$ (million) capital exp (default value)
insurance_tax <- capex*.007
opex <- 372 #MM$/yr operating exp (default value)
hrs <- 8400 #hr/yr
# input info
q_fd <- 0.9 #M t/yr (million tonnes annually)
q_water <- 1.6 #M t/yr
q_elec <- 74.4 #M kWh/yr
q_gas <- 0.5 #M t/yr
q_h2 <- 0.01 #M t/yr
q_lab <- 12 #labor
p_fd <- 323 #$/t (default value)
p_water <- .57 #$/t
p_elec <- 0.11 #$/kWh
p_gas <- .8 #$/t
p_h2 <- 1210 #$/t (default value)
p_lab <- 0.043 #MM$/labor
# output info
q_jet <- 219 #MLPY (default value)
q_dsl <- 53 #MLPY (default value)
q_lpg <- 52 #MLPY
q_nap <- 63 #MLPY
q_meal <- 0.6 #M t/yr (default value)
p_jet <- 0.47 #$/L (default value)
p_dsl <- 0.82 #$/L
p_lpg <- 0.21 #$/L
p_nap <- 0.52 #$/L
p_meal <- 300 #$/t
# financial info
life <- 20 #yr
t_dep <- 7
t_loan <- 10 # loan term
r_inf <- 0.02
r_dis <- 0.10 # deflated discount rate (default value)
r_eq <- 0.15 # rate of return
r_tax <- 0.21
#######################################
# NPV calculation
#######################################
# Set inflation rate to 2%
inflation_rate <- 0.02
# Calculate inflation factor for each year
inflation_factor <- (1 + inflation_rate)^(1:20)
CF0 <- capex*0.08*(1+r_dis)^2* inflation_factor[1]+capex*0.6*(1+r_dis)* inflation_factor[2]+capex*0.32* inflation_factor[3]
# Adjust expenses for inflation
exp_ut <- q_water * p_water* inflation_factor +
q_elec * p_elec* inflation_factor +
q_gas * p_gas* inflation_factor +
q_h2 * p_h2 * inflation_factor
exp <- exp_ut+q_fd*p_fd*inflation_factor+q_lab*p_lab*inflation_factor +insurance_tax*inflation_factor
sale_by <- (q_dsl*p_dsl+q_lpg*p_lpg+q_nap*p_nap+q_meal*p_meal)*inflation_factor
sale <- sale_by+q_jet*p_jet*inflation_factor
cat("revenue share for jet:",q_jet*p_jet*inflation_factor/sale,"\n")
cat("revenue share for dsl:",q_dsl*p_dsl*inflation_factor/sale,"\n")
cat("revenue share for lpg:",q_lpg*p_lpg*inflation_factor/sale,"\n")
cat("revenue share for nap:",q_nap*p_nap*inflation_factor/sale,"\n")
cat("revenue share for meal:",q_meal*p_meal*inflation_factor/sale,"\n")
ebitda <- sale-exp
#Calculate annual depreciation
dep_per_year <- capex*.8/ t_dep
dep_schedule <- c(rep(dep_per_year, t_dep), rep(0, life - t_dep))
ebit <- ebitda - dep_schedule
amort <- amort.table(Loan=capex,n=t_loan,pmt=NA,r_dis)[["Schedule"]]
CF1 <- as.data.frame(amort) # cash flow for Y1-10
new_rows <- data.frame(Payment = rep(0, 10),
`Interest Paid` = rep(0, 10),
`Principal Paid` = rep(0, 10),
Balance = rep(0, 10))
names(new_rows) <- names(CF1)
CF <- rbind(CF1, new_rows)
CF$Year <- 1:20
CF$EBIT <- ebit
CF$EBT <- CF$EBIT-CF$`Interest Paid`
CF$Depreciation <- dep_schedule
CF$Flow <- CF$EBT*(1-r_tax)+CF$Depreciation-CF$`Principal Paid`
CF$Discount <- r_dis
CF$PV <- CF$Flow/(1+CF$Discount)^CF$Year
NPV <- sum(CF$PV)-CF0
NPV
```

...

NPV is -383.2081 Million USD. Now, I want to calculate benefit-cost ratio. Benefit-cost ratio= pv of all benefits/pv of all costs

Now, I use the following code ti calculate benefit-cost ratio:

...

```
# Calculate the present value of benefits
benefit <- sum(sale-CF$`Interest Paid`*(1-r_tax)-CF$`Principal Paid`/(1+CF$Discount)^CF$Year)
# Calculate the present value of costs
cost <- sum(exp-CF$`Interest Paid`*(1-r_tax)-CF$`Principal Paid`/(1+CF$Discount)^CF$Year)
bcr <- benefit/cost
bcr
```

...

The benefit cost ratio is 1.18. I tried the following code:

...

```
# Calculate the present value of benefits
benefit <- sum(sale/(1+CF$Discount)^CF$Year)
# Calculate the present value of costs
cost <- sum(exp/(1+CF$Discount)^CF$Year)
bcr <- benefit/cost
bcr =1.17
```

...

So i have a negative net present value, but the benefit-cost ratio is more than 1. How is that possible? do I have anything wrong in my formula of calculation of the benefit-cost ratio? for example, maybe i should not add everything (1-r_tax, interest and payment) in both the benefit and cost side? How do I correctly account for all of these (1-r_tax, and interest and payment) when I calculate the benefit-cost ratio, please?