Difference between revisions of "Decision"

From Testiwiki
Jump to: navigation, search
(Rcode)
(Rcode: code works and includes BAU)
Line 65: Line 65:
 
<rcode name="answer" label="Only defines functions">
 
<rcode name="answer" label="Only defines functions">
  
############### decis
+
############### decisions.apply takes a decision table and applies that to an assessment.
 
## scen is a data.frame that must have columns Decision, Option, Variable, Cell, Change, Result. It can have several variables.
 
## scen is a data.frame that must have columns Decision, Option, Variable, Cell, Change, Result. It can have several variables.
decis <- function(scen) {
+
decisions.apply <- function(scen) {
 
out <- as.list(unique(scen$Variable))
 
out <- as.list(unique(scen$Variable))
 
names(out) <- as.character(unique(scen$Variable))
 
names(out) <- as.character(unique(scen$Variable))
Line 82: Line 82:
 
decs <- data.frame(temp = 1)
 
decs <- data.frame(temp = 1)
 
for(decisions in unique(scen$Decision)) {
 
for(decisions in unique(scen$Decision)) {
temp <- scen[scen$Decision == decisions, ]["Option"]
+
temp <- as.character(scen[scen$Decision == decisions, "Option"])
 +
print(temp)
 +
temp <- data.frame(Options = c(temp, "BAU"))
 +
print(temp)
 
colnames(temp) <- decisions
 
colnames(temp) <- decisions
 
decs <- merge(decs, temp)
 
decs <- merge(decs, temp)
 
}
 
}
  
out <- merge(decs[colnames(decs) != "temp"], get(as.character(scen$Variable[1])))
+
out <- merge(decs[colnames(decs) != "temp"], get(as.character(scen$Variable[1]))) # This should be updated so that if necessary, the variable is downloaded from Opasnet Base.
out <- decisions.apply(scen, out)
+
out <- options.apply(scen, out)
 
return(out)
 
return(out)
 
}
 
}
Line 95: Line 98:
 
## dec: a data.frame with decisions. It must contain columns Cell, Change, and Result.
 
## dec: a data.frame with decisions. It must contain columns Cell, Change, and Result.
 
## var: a variable data frame.
 
## var: a variable data frame.
decisions.apply <- function(dec, var) {
+
options.apply <- function(dec, var) {
 
for(s in 1:nrow(dec)) { # Each row in decision handled separately
 
for(s in 1:nrow(dec)) { # Each row in decision handled separately
 
cell <- strsplit(as.character(dec$Cell[s]), split = ";")
 
cell <- strsplit(as.character(dec$Cell[s]), split = ";")
 
cell <- strsplit(cell[[1]], split = ":")
 
cell <- strsplit(cell[[1]], split = ":")
 
+
cond <- as.character(dec$Decision[s])
cond <- var[, dec$Decision[s]] == dec$Option[s] # Only the rows with the relevant option.
+
cond <- var[, cond] == cond # Only the rows with the relevant option.
 
for(r in 1:length(cell)) { # All Cell conditions extracted and combined with AND.
 
for(r in 1:length(cell)) { # All Cell conditions extracted and combined with AND.
 
cond <- cond * (var[, cell[[r]][1]] == cell[[r]][2])
 
cond <- cond * (var[, cell[[r]][1]] == cell[[r]][2])
Line 112: Line 115:
 
}
 
}
  
var1 <- data.frame(c = c("A", "A", "C"), d = c("D", "E", "E"), Result = 4:6)
 
var2 <- var1
 
dec <- data.frame(Decision = rep(c("1", "2"), each = 2), Option = c("OptA", "OptB"), Variable = c("var1", "var1", "var1", "var1"), Cell = c("c:A;d:E", "d:D"), Change = c("Replace", "Multiply"), Result = 7:10)
 
var1
 
dec
 
#scenarios.apply(dec)
 
decis(dec)
 
 
# In the data frame with decisions, for each decision, create an additional row where the option is "BAU".
 
# Create a data.frame named options that contains the right structure.
 
## For each Decision, create a column with the decision as colname and the Options as content. There should be one row for each combination of options.
 
## This will result in a structure where there are as many columns as there are decisions, and as many rows as is the product of numbers of options of decisions.
 
# Go through the unique(decision$variable), and bring in each variable mentioned.
 
# Make a list vars of all variables.
 
# For each variable, go through vars$variableoptions[options$variable == variable, ]...
 
### Change the defined cell of ...
 
  
 
</rcode>
 
</rcode>
  
{{attack|# |This works for one variable, but not many.|--[[User:Jouni|Jouni]] 22:04, 26 April 2012 (EEST)}}
 
 
{{attack|# |Does not yet develop BAU options.|--[[User:Jouni|Jouni]] 05:18, 27 April 2012 (EEST)}}
 
  
 
'''Test code
 
'''Test code
  
 
<rcode include="page:Decision|name:answer">
 
<rcode include="page:Decision|name:answer">
var1 <- data.frame(c = c("A", "A", "C"), d = c("D", "E", "E"), Result = 6:8)
+
var1 <- data.frame(c = c("A", "A", "C"), d = c("D", "E", "E"), Result = 4:6)
dec <- data.frame(Decision = rep(c("1", "2"), each = 2), Option = c("A", "B"), Variable = "var1", Cell = c("c:A;d:E", "d:D"), Change = c("Replace", "Multiply"), Result = 7:10)
+
var2 <- var1
 +
dec <- data.frame(Decision = rep(c("1", "2"), each = 2), Option = c("OptA", "OptB"), Variable = c("var1", "var1", "var1", "var2"), Cell = c("c:A;d:E", "d:D"), Change = c("Replace", "Multiply"), Result = 7:10)
 
var1
 
var1
 
dec
 
dec
scenarios.apply(dec)
+
decisions.apply(dec)
  
 
</rcode>
 
</rcode>

Revision as of 05:46, 27 April 2012


<section begin=glossary />
Decision is a special kind of variable: it answer a question like this: "What are different decisions that decision maker X can make in situation Y, and what are different options of each decision?" Decision maker X may be a single individual, a decision making body with several individuals, or a set of separate decision makers, who each can decide about some but not all decisions. In such a situation, an especially interesting part of the related assessment is to look at the interactions of the decisions by different decision makers, none of which can fully control the decision situation.
The decisions have a special role in causal diagrams, as they list such specific structural parts of variables in a causal diagrams that can be modified by a decision maker. Without a decision, the causal diagram describes the business-as-usual (BAU) situation. A decision variable describes how the situation changes if a decision maker chooses an option over another options of a decision.

<section end=glossary />

Question

How should decisions be described in open assessment and what should their structure be?

Answer

A typical structure of a data table of a decision.
Decision Option Variable Cell Change ... Value Description
A group of options that are exclusive and the choice between them is made by one decision making body. An option within one decision. A variable whose value is to be changed by the decision option. A cell whose value is to be changed within the variable data table. The type of change. Possible options:
  • Add the value to the existing value.
  • Multiply the value with the existing value.
  • Replace the existing value with this value.
  • Remove those rows from the variable that fulfil the cell criterion.
  • Insert rows to the variable based on data in the decision.
  • Split the existing random sample into two parts from the value. This is especially needed in upstream inference.
The table may also contain other indices. The functions dealing with decision variables use the default merge functionality when combining objects. The value to be used in the calculations. This row contains descriptions about columns. The next rows contain examples.
Energy saving education Training to house owners Energy balance in Kuopio Activity: Residential; Fuel: Heat Multiply 0.94 Energy training leads to renovation of houses and leads to heating demand reduction by 6 %.
Public transport subsidy More money to bus transport Energy balance in Kuopio Activity: Transport; Fuel: Petrochemical products Multiply 0.95 Energy consumption of buses increases diesel use by 2.5 % but the reduced car transport causes a net reduction of 5 % in fuel use.
Public transport subsidy Much more money to bus transport Energy balance in Kuopio Activity: Transport; Fuel: Petrochemical products Multiply 0.9 Energy consumption of buses increases diesel use by 5 % but the reduced car transport causes a net reduction of 10 % in fuel use.

Rcode

+ Show code


Test code

+ Show code

Rationale

Previously, it was thought that decision variables are an essential starting point of a causal diagram, and that they should be general and applicable to all possible situations where that causal diagram is used. Now the thinking is different. Decisions are seen as descriptions of plausible options decision makers have in a particular situation. Decisions are implemented in an assessment as scenarios (deliberate deviations from the truth, asking: "What would happen if the truth about the decision maker's action was this?"). It was previously also thought that decisions are probability distributions about what a decision maker will decide, and assessment-specific scenarios are used separately to select the interesting options from the decision distribution in a particular assessment. Now the thinking is different: instead of attempting to describe all the decisions explicitly, the core of a causal diagram does not describe any decisions. It just describes the phenomena that are important for understanding a situation, such as activities, emissions, exposures, and health effects. Decisions that may change the future situation are implicitly included in the probability distributions as uncertainties. Then, decisions are added to that for describing how e.g. activities would change if some decision options would be chosen. Mathematically, this means that one or more variables in a model are conditionalised to reflect the impact of decisions. In other words, decision variables are used as scenarios. What are scenarios, anyway?

A scenario is a deliberate deviation from the truth in a description. In the case of decisions, it is a particular value of some variable that is changed if the decision option at hand is implemented. It can also be a set of particular values of several variables changed by the decision. For policy assessments, often several scenarios are defined and then compared to each other, e.g. if the impacts of a certain policy (measure) is assessed. A particular set of scenarios can be saved and used in several risk assessments. A scenario therefore can be a part of an assessment but is not an assessment itself. In a sense, BAU is not a scenario, it is our best estimate about what will actually happen, implicitly including all plausible decisions by all decision makers.

A decision describes changes in values of other variables. These changes must be within the range of values the variable has.R↻

See also

References


Related files

<mfanonymousfilelist></mfanonymousfilelist>