# Market allocation factor

Market allocation factor is a method to balance out market situations when either the demand or supply increase or decrease. To be able to predict this, elasticity, market allocation factor, or other methods need to be used.

## Question

How to predict market balances when either the demand or supply increases or decreases?

How many per cent does the supply or demand change if the price of the product increases 1 €/product unit?

Market allocation factor(relative change per (€/unit))
ObsMarketActivityUseFuelUnitAmountDescription
1Fuel woodPetroleum refineriesInputRenewables and wasteMWh1
2Fuel woodCHP plantsInputRenewables and wasteton1
3Fuel woodHeatingOutputRenewables and wasteMWh1
4Fuel woodOther energy consumptionOutputRenewables and wasteMWh1
5Traffic fuelPetroleum refineriesOutputPetrochemical productsMWh1
6Traffic fuelFinal energy useOutputPetrochemical productsMWh1
7Traffic fuelPetroleum refineriesOutputPetrochemical productsMWh1
8Traffic fuelPetroleum refineriesOutputPetrochemical productsMWh1
9Global oilPetroleum refineriesInputCrude oilMWh1
10Global oilCHP plantsInputCrude oilton1
11PeatCHP plantsInputCoal and peatton1
12District heatCHP plantsOutputHeatMWh1
13National electricityCHP plantsOutputElectricityMWh1
16CardboardOther energy consumptionOutputCardboard productston1

#: . The input/output column does not make sense. The meaning depends on the part of the energy balance table (supply, transformation, use) where the activity is. Can it be dropped? --Jouni 12:09, 24 April 2012 (EEST) (type: truth; paradigms: science: relevant attack)

 # NOW how do we tell the energy need in the balance sheet? # THIS CODE DOES NOT REALLY WORK. ############# Price is a function that finds the price for the energy in a given situation and calculates the new supplies and demands. # energy = data.frame containing the energy supplies and demands. # cost = data.frame containing the cost curves. # conditions = vector of column names that should be looked at separately, e.g. different policy options. The vector always contains Fuel and Use. price <- function(energy, cost, conditions = NULL) { conditions <- c("Fuel", "Use", conditions) c <- as.data.frame(as.table(tapply(energy$Amount, energy[conditions], sum))) c$Freq <- ifelse(c$Use == "Demand", -c$Freq, c$Freq) c <- as.data.frame(as.table(tapply(c$Freq, c$Fuel, sum))) b <- as.data.frame(as.table(tapply(cost$b, cost$Fuel))) a <- as.data.frame(as.table(tapply(cost$a, cost$Fuel))) a$Freq <- a\$Freq + 0.000000001 p <- c((-b + sqrt(b^2 -4*a*c))/(2*a), (-b-sqrt(b^2-4*a*c))/(2*a)) p <- p[which.min(abs(p))] # Assumes that the root that is closer to the current price is the correct one. return(p) } 

## Rationale

### Explanations of the calculations

The logic of the code is the following:

• Energy contains information about the total amounts of energy in a given Activity * Fuel pair per time unit (typically a year). (For example, 54 ktoe/a petrochemical products are used in road transport.)
• Trans contains descriptions of all activities that result in the production or use of energy. (For each ktoe used in road transport, 1 ktoe is imported.
• When these two are merged, we get a table that explains where the energy came from and where the energy went, assuming that all energy flow goes through that activity.
• The ratio of the actual energy stock to the energy stock in the activity table is used as the factor to scale the whole activity (not only the energy). This is done by merging the data.frame with factors again with the activities (tran) and multiplying the factor with the activities. This gives the BAU situation.
• We assume that current energy production and use is distributed in such a way that the cost curves are in balance. If the price changes, both the supply and demand will change according to their cost curves. The new balance can be found from $\Sigma f_i(p) = 0$ where fi are the cost curves (supply functions producing positive values and demand functions negative values. When p is solved from the equation, values of all supply and demand functions can be solved. If all functions $f_i(p) = a_i p^2 + b_i p + c_i,$

then individual functions and also the sum of all functions can be expanded and then easily be solved by using the equation for polynomial roots: $\Sigma f_i(p) = \Sigma (a_i p^2 + b_i p + c_i) = 0$ $p = \frac{-\Sigma b_i \pm \sqrt{(\Sigma b_i)^2 - 4 \Sigma a_i \Sigma c_i}} {2 \Sigma a_i}$

Cost curves are parameterised in the way that the current price p = 0 and therefore the current supply or demand is ci.

When a demand or supply changes, a new price p must be calculated based on fi, and then the supplies and demands of other actors can be calculated, resulting in a new balance.

Taxes are complicating this picture. They do not actually change the shape of a cost curve (if it is proportional to energy content) but they shift a supply curve to right (or a demand curve to left if the tax is payed by the buyer and not the seller) by the amount of the tax. In other words, instead of p we solve $\Sigma f_i(p - t) = 0$, i.e. $p = \frac{-\Sigma (b_i - 2 a_i t) \pm \sqrt{(\Sigma b_i - 2 t \Sigma a_i)^2 - 4 \Sigma a_i (\Sigma c_i + t^2 - t \Sigma b_i)}} {2 \Sigma a_i},$

where t is the amount of tax to the suppliers. With the same formula, it is also easy to calculate particular taxes, where the tax per unit energy is different to different suppliers. Then we simply use ti instead of t.

How to estimate parameters a, b, and c?

Let's start from a simple approach. If the cost curve is linear, then a = 0. If all suppliers or all buyers change their behaviour in the same way (in relative terms) to price changes, then bi are proportional to ci. If we don't care about the absolute values yet, we can simply start from these assumptions and say: a = 0, b = c, c = the current amount of demand or supply, and p = 0.

The curves can be generalised to that they are polynomials with higher degree than just 2. The computations are more laborious, but the computer solves that problems with no additional burden to the user.

#: . We could use a tool that estimates the parameters based on some points that a user gives on a graph about his/her personal cost curve. --Jouni 06:53, 2 February 2012 (EET) (type: truth; paradigms: science: relevant comment)