Training assessment: Difference between revisions

From Opasnet
Jump to navigation Jump to search
(created pages for training)
 
 
(45 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Category:Open policy practice]]
[[Category:Decision analysis and risk management]]
[[Category:Urgenche]]
[[Category:Urgenche]]
{{assessment|moderator=Jouni|stub=Yes}}
[[Category:Contains R code]]
{{assessment|moderator=Jouni|stub=Yes|status=Ongoing}}
This is a '''training assessment''' about an imaginary, simple case. The purpose is to illustrate assessment functionalities.
This is a '''training assessment''' about an imaginary, simple case. The purpose is to illustrate assessment functionalities.


Line 6: Line 9:


===Question===
===Question===
What decisions are worth implementing in the training assessment?


===Boundaries===
===Boundaries===


* Time: Year 2010 - 2030
* Time: Year 2012 - 2020


===Scenarios===
===Scenarios===


* Two scenarios for each climate policy (which have not been defined yet): policy is A) implemented, B) not implemented.
* Factory can reduce emissions, or continue business as usual.
* School can increase health education, decrease it to save money, or continue business as usual.


===Intended users===
===Intended users===
Line 22: Line 28:


* Main participants:
* Main participants:
** YMAL
** YMAL,
** Summer workers of YMAL in 2012.
** Summer workers of YMAL in 2012,
** Participants of [[Decision analysis and risk management 2013]]


==Answer==
==Answer==
===Conclusions===


===Results===
===Results===
Line 31: Line 41:
Not yet available.
Not yet available.


===Conclusions===
==Rationale==
 
[[image:Training assessment.svg|thumb|center|500px|The causal diagram for the [[training assessment]].]]
 
===Assessment-specific data===
 
;Decisions
 
<t2b name="Decisions" index="Decisionmaker,Decision,Option,Variable,Cell,Change,Unit" obs="Amount" desc="Description" unit="-">
Factory|Cleaning_policy|BAU|exposure|Year:2020|Multiply|-|1|
Factory|Cleaning_policy|Reduce emissions|exposure|Year:2020|Multiply|-|0.5|
Factory|Cleaning_policy|BAU|costs||Add|€|0|
Factory|Cleaning_policy|Reduce emissions|costs|Year:2020;Expenditure:Cleaning equipment use|Add|€|30000-40000|
City of Kuopio|Health_promotion|BAU|health_impact||Multiply|-|1|
City of Kuopio|Health_promotion|Increase health education|health_impact||Multiply|-|0.9|
City of Kuopio|Health_promotion|BAU|costs||Add|€|0|
City of Kuopio|Health_promotion|Increase health education|costs|Year:2020;Expenditure:Health promotion campaign|Add|€|10000|
</t2b>
 
 
; Variables
* exposure: [[Training exposure]]
* health_impact: [[Training health impact]]
* costs: [[Training costs]]
 
; Analyses
* Decision analysis on each policy: Which option minimises the health risks?
* [[Value of information]] (VOI) analysis for each policy about the major variables in the model and the total VOI.


===Calculations===


==Rationale==
<rcode graphics=1
variables="name:unitcost|description:What is the unit cost of one case of disease?|type:text|default:100"
>


[[image:Causal diagram.PNG|thumb|This diagram is just a placeholder. A new file should be uploaded, because this is about another assessment.]]
library(OpasnetUtils)
library(ggplot2)


<rcode name="answer" include="
DecisionTableParser(opbase.data("Op_en5677", subset = "Decisions")) # [[Training assessment]]
page:OpasnetBaseUtils|                      name:generic|
page:Object-oriented_programming_in_Opasnet|name:answer|
page:Climate_change_policies_in_Kuopio|    name:formula|
page:Climate_education_in_Kuopio|          name:formula|
page:Market_allocation_factor|              name:formula|
page:Cost_curves_for_energy|                name:formula|
page:Energy_transformations|                name:formula|
page:Energy_balance_in_Kuopio|              name:formula|
page:Greenhouse_gas_emissions_in_Kuopio|    name:formula
">
library(OpasnetBaseUtils)
library(xtable)
n <- 5


names.Kuopio <- tidy(op_baseGetData("opasnet_base", "Op_en5461")) # Download the object names and identifiers.
objects.latest("Op_en5675", code_name = "initiate") # [[Training health impact]] health_impact
decisionmakers.Kuopio <- tidy(op_baseGetData("opasnet_base", "Op_en5583")) # Download the decisionmaker info.
objects.latest("Op_en5871", code_name = "initiate") # [[Training costs]] costs


ccph.Kuopio <- new("oassessment",  
unitcost <- Ovariable("unitcost", data = data.frame(Result = unitcost))
names = names.Kuopio,
vars = init.vars(names.Kuopio),
decisionmakers = decisionmakers.Kuopio
)


ccph.Kuopio
costs <- CheckDecisions(EvalOutput(costs))


print(ccph.Kuopio)
costs2 <- oapply(unkeep(costs, sources = TRUE), cols ="Expenditure", FUN = sum)


</rcode>
cat("Summary of exposures\n")


{{attack|# |ovariable merge must update the slot marginal as well, otherwise it will not work.|--[[User:Jouni|Jouni]] 00:19, 2 May 2012 (EEST)}}
oprint(summary(exposure))


{{comment|# |Function tidy should reshape data.frame so that Unit and Amount would make two columns instead of being in the long format.|--[[User:Jouni|Jouni]] 11:23, 1 May 2012 (EEST)}}
cat("Summary of health impacts\n")


{{comment|# |We need several pages for an assessment: the main page contains the variable list; /Probabilities contains the P(B) values; /Values contains the assessment-specific and decision-specific value judgements (whatever they are); /Decisionmakers contains the list of decisionmakers, decisions and outcomes. (Could /Values and /Decisionmakers be merged?)|--[[User:Jouni|Jouni]] 11:23, 1 May 2012 (EEST)}}
oprint(summary(health_impact), digits = 0)


{{comment|# |For each ovariable, we must include the code "formula" from the variable page. Formula includes both formula and dependencies for the variable. Then, these are used when using make.ovariable. The names should be like formula.Op_en2345 and dependencies.Op_en2345. |--[[User:Jouni|Jouni]] 11:04, 1 May 2012 (EEST)}}
cat("Summary of all costs\n")


{{attack_invalid|# |Slot "objects" is not needed, as variables are managed with their aliases as separate objects (ovariables). |--[[User:Jouni|Jouni]] 11:04, 1 May 2012 (EEST)}}
oprint(summary(costs2), digits = 0)
: {{attack|# |If they are managed as separate objects, superassignment must be used. This is highly not recommended. A list of variables is a better idea. However, now the slot is called "vars".|--[[User:Jouni|Jouni]] 11:11, 2 May 2012 (EEST)}}


{{comment|# |oassessment@decisionmakers$Value is needed but it is not quite clear how it should be used. It is some kind of scenario tool for Outcome, as different decisionmakers may have different values. Should it be an index in a value variable?|--[[User:Jouni|Jouni]] 08:55, 1 May 2012 (EEST)}}
ggplot(exposure@output, aes(x = exposureResult, colour = Year)) + geom_density() +
theme_gray(base_size = 24) +
facet_grid(Cleaning_policy ~ .)


{{comment|# |Päätöksenteon sokea piste: se mitä ihmiset eivät näe mutta eivät myöskään huomaa etteivät näe. Kuitenkin tutkimalla sitä mitä mitä ihmiset eivät näe saadaan selville asioita sokeasta pisteesta. Ymmärtämällä sokeaa pistettä voidaan keksiä asioita jotka järjestelmällisesti jäävät huomaamatta ja asioita, joilla voidaan korjata järjestelmällisiä puutteita. Avoin arviointi on tämmöinen päätöksenteon järjestelmällisten puutteiden korjausmekanismi.|--[[User:Jouni|Jouni]] 08:55, 1 May 2012 (EEST)}}
ggplot(health_impact@output, aes(x = health_impactResult, colour = Year)) + geom_density() +
theme_gray(base_size = 24) +
facet_grid(Cleaning_policy ~ Health_promotion)


===Decision variables===
ggplot(subset(costs2@output, Year == 2020), aes(x = costsResult, colour = Payer)) + geom_density() +
theme_gray(base_size = 24) +
facet_grid(Cleaning_policy ~ Health_promotion)


* Climate policy 1
ggplot(subset(costs2@output, Year == 2020), aes(x = Payer, weight = costsResult / openv$N, fill = Payer)) + geom_bar() +
* Climate policy 2...
theme_gray(base_size = 24) +
facet_grid(Cleaning_policy ~ Health_promotion)
===Indicators===


* Cardiovascular mortality
* Pulmonar mortality
* Well-being...


===Other variables===


===Assessment-specific data===
</rcode>


<t2b index="Name,Identifier,Direction" obs="Alias" unit="-">
=== Explanations of the code ===
Climate change policies in Kuopio|Op_en5466|wide|decision
Climate education in Kuopio|Op_en5582|wide|education
Cost curves for energy|Op_en5478|long|cost.curve
Energy transformations|Op_en5472|wide|transformation
Energy balance in Kuopio|Op_en5469|wide|energy.balance
Greenhouse gas emissions in Kuopio|Op_en5483|long|GHG.emission
</t2b>


===Formula===
<pre>
<rcode graphics=1
variables="name:unitcost|description:What is the unit cost of one case of disease?|type:text|default:100"
>
</pre>


<rcode include="page:OpasnetBaseUtils|name:generic" graphics="Yes" variables="
The tag above starts the R code. It turns on the graphics so that graphs can be drawn. It also asks the user to give a value for the variable ''unitcost''.
name:biofuels|description:Addition of biofuels in transportation (ktoe/a)|default:5|
name:heatsave|description:How much energy is saved from the heating of buildings, compared with 2010? (%)|default:10">
library(OpasnetBaseUtils)
library(ggplot2)
library(xtable)


cat("Loading functions and data.\n")
library(OpasnetUtils)
library(ggplot2)


city    <- "Kuopio"
In the beginning of a code, packages that are needed are loaded. These are the two most commonly used. OpasnetUtils is for all Opasnet functionalities, ggplot2 is for cool graphs.
energy  <- summary.bring("Op_en5473") # Category:Energy balance
tran    <- tidy(op_baseGetData("opasnet_base", "Op_en5472")) # Energy transformations
classes <- tidy(op_baseGetData("opasnet_base", "Op_en5476")) # Energy consumption classes


cat("Running model.\n")
DecisionTableParser(opbase.data("Op_en5677", subset = "Decisions")) # <nowiki>[[Training assessment]]</nowiki>


energy <- energy[energy$Place == city, ]
This code defines from where to take the assessment-specific decisions. In this case, they are on the page Training assessment, in a table called ''Decisions''. The page has identifier Op_en5677, which can be found from the metadata box, which is typically in the top right corner of a page.
energy$Amount <- as.numeric(energy$Amount)


# The policy changes are implemented.
objects.latest("Op_en5675", code_name = "initiate") # <nowiki>[[Training health impact]]</nowiki> health_impact
objects.latest("Op_en5871", code_name = "initiate") # <nowiki>[[Training costs]]</nowiki> costs


energy.stra <- energy
These lines fetch ready-made ovariables that are needed in this assessment. The code defining these ovariables are located on the pages mentioned. Note that # is the comment character and everything after it is ignored in the model; so it is used to put explanations for the reader within the code.
energy.stra$Amount <- ifelse(energy.stra$Transformation == "Traffic biofuel production" & energy.stra$Fuel == "Petrochemical products", energy.stra$Amount + biofuels, energy.stra$Amount)
energy.stra$Amount <- ifelse(energy.stra$Process == "Heating" & energy.stra$Use == "Output", energy$Amount * (1 - heatsave / 100), energy.stra$Amount)
energy <- rbind(data.frame(Action = "BAU", energy), data.frame(Action = "Policy", energy.stra))


#### The transformation processes are included.
unitcost <- Ovariable("unitcost", data = data.frame(Result = unitcost))


tran <- reshape(tran, idvar = c("Process", "Transformation", "Use", "Fuel"), timevar = "Observation", direction = "wide")
Unitcost was asked from the user as a value, and now it is converted to an ovariable.
colnames(tran) <- gsub("Result.", "", colnames(tran))
tran$Amount <- as.numeric(tran$Amount)


# Calculate conversion factors.
costs <- EvalOutput(costs)
factors <- merge(tran, energy, by = c("Process", "Transformation", "Use", "Fuel"))
mwh2ktoe <- 3600 / (35 * 1000) # 1 MWh = 3600 MWs / (35 MJ / kgoe * 1000 kgoe/toe)
costs2 <- oapply(unkeep(costs, sources = TRUE), cols ="Expenditure", FUN = sum)
factors$Amount.x <- factors$Amount.y / (factors$Amount.x * mwh2ktoe)


# Add conversion factors to the energy table.
Because all ovariables are connected in the model, it is enough to evaluate the last one. The model will automatically evaluate all ovariables that are causally upstream. Also, the decisions that apply to this assessment will change the results of the ovariables as necessary. Ovariable costs2 is used to summarise contents of costs for easier presentation.
energy <- merge(tran, factors, by = c("Process", "Transformation"), all.x = TRUE)
energy$Amount <- energy$Amount * energy$Amount.x
energy <- energy[!colnames(energy) %in% c("Use.y", "Fuel.y", "Unit.x", "Amount.x", "Unit.y", "Amount.y")]
colnames(energy) <- gsub(".x", "", colnames(energy))


# Convert energy values to ktoe.
cat("Summary of health impacts\n")
energy$Amount <- ifelse(energy$Unit == "MWh", energy$Amount * mwh2ktoe, energy$Amount)
energy[energy$Unit == "MWh", "Unit"] <- "ktoe"


fuels <- c("Coal and peat", "Crude oil", "Petrochemical products", "Gas", "Nuclear", "Hydro", "Geothermal solar wind", "Renewables and waste", "Electricity", "Heat")
Function cat is used to print outputs for the user.


# Categorise energy to standard energy processes and calculate sums for each process.
oprint(summary(health_impact), digits = 0)
out <- merge(energy, classes, by.x = "Process", by.y = "Result")
out <- as.data.frame(as.table(tapply(out$Amount, out[c("Class", "Fuel", "Use", "Action")], sum)))
out <- out[!is.na(out$Freq) & out$Fuel %in% fuels, ] # & out$Use == "Input", ]
print(xtable(out), type = 'html')


# NOW how do we tell the energy need in the balance sheet?
Function oprint is used to print tables for the user.


ggplot(energy[energy$Fuel == "CO2e", ], aes(x = Action, weight = Amount, fill = Process)) +geom_bar(position = "Stack")
  cat("Summary of all costs\n")
ggplot(energy[energy$Fuel == "PM2.5", ], aes(x = Action, weight = Amount, fill = Process)) +geom_bar(position = "Stack")
ggplot(energy[energy$Fuel == "Ash", ],  aes(x = Action, weight = Amount, fill = Process)) +geom_bar(position = "Stack")
oprint(summary(costs2), digits = 0)
ggplot(energy[energy$Fuel == "Heat", ],  aes(x = Action, weight = Amount, fill = Process)) +geom_bar(position = "Stack")


</rcode>
ggplot(exposure@output, aes(x = exposureResult, colour = Year)) + geom_density() +
theme_gray(base_size = 24) +
facet_grid(Cleaning_policy ~ .)


{{comment|# |This is a city-specific copy of the original code: [[Energy balance]].|--[[User:Jouni|Jouni]] 06:52, 27 January 2012 (EET)}}
Function ggplot is very effective in creating all kinds of graphs with just a few lines. It is really worth learning.


===Value variables===
ggplot(health_impact@output, aes(x = health_impactResult, colour = Year)) + geom_density() +
theme_gray(base_size = 24) +
facet_grid(Cleaning_policy ~ Health_promotion)
ggplot(subset(costs2@output, Year == 2020), aes(x = costsResult, colour = Payer)) + geom_density() +
theme_gray(base_size = 24) +
facet_grid(Cleaning_policy ~ Health_promotion)


===Analyses===
<pre>
</rcode>
</pre>


* Decision analysis on each policy: Which option minimises the health risks?
The code must always end with this tag.
* Value-of-information analysis for each policy about the major variables in the model and the total VOI.


==See also==
==See also==


{{Opasnet training}}
* [http://en.opasnet.org/en-opwiki/index.php?title=Training_assessment&oldid=25109#Rationale Descriptions of a previous structure]
*{{comment|# |Päätöksenteon sokea piste: se mitä ihmiset eivät näe mutta eivät myöskään huomaa etteivät näe. Kuitenkin tutkimalla sitä mitä mitä ihmiset eivät näe saadaan selville asioita sokeasta pisteesta. Ymmärtämällä sokeaa pistettä voidaan keksiä asioita jotka järjestelmällisesti jäävät huomaamatta ja asioita, joilla voidaan korjata järjestelmällisiä puutteita. Avoin arviointi on tämmöinen päätöksenteon järjestelmällisten puutteiden korjausmekanismi.|--[[User:Jouni|Jouni]] 08:55, 1 May 2012 (EEST)}}


==References==
==References==

Latest revision as of 20:01, 24 March 2015



This is a training assessment about an imaginary, simple case. The purpose is to illustrate assessment functionalities.

Scope

Question

What decisions are worth implementing in the training assessment?

Boundaries

  • Time: Year 2012 - 2020

Scenarios

  • Factory can reduce emissions, or continue business as usual.
  • School can increase health education, decrease it to save money, or continue business as usual.

Intended users

  • Anyone who wants to learn to make open assessments.

Participants

Answer

Conclusions

Results

Not yet available.

Rationale

The causal diagram for the training assessment.

Assessment-specific data

Decisions
Decisions(-)
ObsDecisionmakerDecisionOptionVariableCellChangeUnitAmountDescription
1FactoryCleaning_policyBAUexposureYear:2020Multiply-1
2FactoryCleaning_policyReduce emissionsexposureYear:2020Multiply-0.5
3FactoryCleaning_policyBAUcostsAdd0
4FactoryCleaning_policyReduce emissionscostsYear:2020;Expenditure:Cleaning equipment useAdd30000-40000
5City of KuopioHealth_promotionBAUhealth_impactMultiply-1
6City of KuopioHealth_promotionIncrease health educationhealth_impactMultiply-0.9
7City of KuopioHealth_promotionBAUcostsAdd0
8City of KuopioHealth_promotionIncrease health educationcostsYear:2020;Expenditure:Health promotion campaignAdd10000


Variables
Analyses
  • Decision analysis on each policy: Which option minimises the health risks?
  • Value of information (VOI) analysis for each policy about the major variables in the model and the total VOI.

Calculations

What is the unit cost of one case of disease?:

+ Show code

Explanations of the code

 <rcode graphics=1 
 	variables="name:unitcost|description:What is the unit cost of one case of disease?|type:text|default:100"
 >

The tag above starts the R code. It turns on the graphics so that graphs can be drawn. It also asks the user to give a value for the variable unitcost.

library(OpasnetUtils)
library(ggplot2)

In the beginning of a code, packages that are needed are loaded. These are the two most commonly used. OpasnetUtils is for all Opasnet functionalities, ggplot2 is for cool graphs.

DecisionTableParser(opbase.data("Op_en5677", subset = "Decisions")) # [[Training assessment]]

This code defines from where to take the assessment-specific decisions. In this case, they are on the page Training assessment, in a table called Decisions. The page has identifier Op_en5677, which can be found from the metadata box, which is typically in the top right corner of a page.

objects.latest("Op_en5675", code_name = "initiate") # [[Training health impact]] health_impact
objects.latest("Op_en5871", code_name = "initiate") # [[Training costs]] costs

These lines fetch ready-made ovariables that are needed in this assessment. The code defining these ovariables are located on the pages mentioned. Note that # is the comment character and everything after it is ignored in the model; so it is used to put explanations for the reader within the code.

unitcost <- Ovariable("unitcost", data = data.frame(Result = unitcost))

Unitcost was asked from the user as a value, and now it is converted to an ovariable.

costs <- EvalOutput(costs)

costs2 <- oapply(unkeep(costs, sources = TRUE), cols ="Expenditure", FUN = sum)

Because all ovariables are connected in the model, it is enough to evaluate the last one. The model will automatically evaluate all ovariables that are causally upstream. Also, the decisions that apply to this assessment will change the results of the ovariables as necessary. Ovariable costs2 is used to summarise contents of costs for easier presentation.

cat("Summary of health impacts\n")

Function cat is used to print outputs for the user.

oprint(summary(health_impact), digits = 0)

Function oprint is used to print tables for the user.

cat("Summary of all costs\n")

oprint(summary(costs2), digits = 0)
ggplot(exposure@output, aes(x = exposureResult, colour = Year)) + geom_density() +
	theme_gray(base_size = 24) +
	facet_grid(Cleaning_policy ~ .)

Function ggplot is very effective in creating all kinds of graphs with just a few lines. It is really worth learning.

ggplot(health_impact@output, aes(x = health_impactResult, colour = Year)) + geom_density() +
	theme_gray(base_size = 24) +
	facet_grid(Cleaning_policy ~ Health_promotion)

ggplot(subset(costs2@output, Year == 2020), aes(x = costsResult, colour = Payer)) + geom_density() +
	theme_gray(base_size = 24) +
	facet_grid(Cleaning_policy ~ Health_promotion)
 </rcode>

The code must always end with this tag.

See also

Materials and examples for training in Opasnet and open assessment
Help pages Wiki editingHow to edit wikipagesQuick reference for wiki editingDrawing graphsOpasnet policiesWatching pagesWriting formulaeWord to WikiWiki editing Advanced skills
Training assessment (examples of different objects) Training assessmentTraining exposureTraining health impactTraining costsClimate change policies and health in KuopioClimate change policies in Kuopio
Methods and concepts AssessmentVariableMethodQuestionAnswerRationaleAttributeDecisionResultObject-oriented programming in OpasnetUniversal objectStudyFormulaOpasnetBaseUtilsOpen assessmentPSSP
Terms with changed use ScopeDefinitionResultTool


  • Descriptions of a previous structure
  • ----#: . Päätöksenteon sokea piste: se mitä ihmiset eivät näe mutta eivät myöskään huomaa etteivät näe. Kuitenkin tutkimalla sitä mitä mitä ihmiset eivät näe saadaan selville asioita sokeasta pisteesta. Ymmärtämällä sokeaa pistettä voidaan keksiä asioita jotka järjestelmällisesti jäävät huomaamatta ja asioita, joilla voidaan korjata järjestelmällisiä puutteita. Avoin arviointi on tämmöinen päätöksenteon järjestelmällisten puutteiden korjausmekanismi. --Jouni 08:55, 1 May 2012 (EEST) (type: truth; paradigms: science: comment)

References


Related files

<mfanonymousfilelist></mfanonymousfilelist>