Difference between revisions of "Training health impact"

From Testiwiki
Jump to: navigation, search
(problems with logic)
(Explanations: the whole section is outdated and removed)
 
(20 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
[[Category:Costs and valuations]]
 
[[Category:Costs and valuations]]
 
[[Category:Opasnet training]]
 
[[Category:Opasnet training]]
 +
[[Category:Contains R code]]
 
{{variable|moderator=Jouni|stub=Yes}}
 
{{variable|moderator=Jouni|stub=Yes}}
  
Line 9: Line 10:
 
== Answer ==
 
== Answer ==
  
There is no data; the answer is based on modelling only.
+
<rcode graphics=1>
  
<rcode
+
library(OpasnetUtils)
name="answer"
+
library(ggplot2)
label="Run code"
 
include="
 
page:Object-oriented_programming_in_Opasnet|name:answer|
 
page:OpasnetBaseUtils|name:generic|
 
page:Training_health_impact|name:formula
 
"
 
>
 
  
cat("Initiation successful. Now starting the model.\n")
+
objects.latest("Op_en5675", code_name = "initiate") # [[Training health impact]]
  
library(xtable)
+
health_impact <- EvalOutput(health_impact)
out <- make.ovariable(
+
 
data = 0,
+
oprint(summary(health_impact))
formula = formula.Op_en5675,
+
 
dependencies = dependencies.Op_en5675)
+
ggplot(health_impact@output, aes(x = health_impactResult, colour = Year)) +
cat("Computing training exposures.\n")
+
geom_density() +
print(out)
+
facet_grid(Trait ~ Year) +
 +
theme_grey(base_size = 24)
  
 
</rcode>
 
</rcode>
  
 +
==Rationale==
  
== Rationale ==
+
===Data===
  
=== Formula ===
+
<t2b index="Trait" obs="Result" desc="Description" unit="cases /(µg/m3) /a">
 +
Respiratory disease|20 - 30|
 +
</t2b>
  
<rcode
+
===Dependencies===
name="formula"
 
label="Initiate functions"
 
include="
 
page:Object-oriented_programming_in_Opasnet|name:answer|
 
page:OpasnetBaseUtils|name:generic|
 
page:Training_exposure|name:formula
 
"
 
variables="name:population|description:What is the size of the population|default:100000"
 
>
 
  
dependencies.Op_en5675 <- list(
+
* [[Training exposure]]
exposure = "Op_en5674", # formula.Op_en5674(dependencies.Op_en5674), # Training exposure
 
erf = data.frame(Unit = "RR per ug/m3", Result = 1.5),
 
population = population,
 
background = 100 / 100000 # cases per 100000 person-years
 
)
 
  
formula.Op_en5675 <- function(x) {
+
===Calculations===
population <- make.ovariable(x$population)
 
background <- make.ovariable(x$background)
 
exposure <- make.ovariable(x$exposure)
 
erf <- make.ovariable(x$erf)
 
cases <- population * background * exp(exposure * log(erf))
 
return(cases)
 
}
 
  
cat("Initiation successful. Now starting the model.\n")
+
<rcode label="Initiate ovariable" name="initiate">
  
library(xtable)
+
library(OpasnetUtils)
out <- make.ovariable(
 
data = "0 - 100000",
 
formula = formula.Op_en5675,
 
dependencies = dependencies.Op_en5675)
 
cat("Computing training health impact.\n")
 
  
########### update updates the sample of an ovariable based on data and function.
+
health_impact <- Ovariable("health_impact",  
setMethod(
+
dependencies = data.frame(Name = "exposure", Ident = "Op_en5674/initiate"), # [[Training exposure]] exposure
f = "update",  
+
formula = function(...) {
signature = "ovariable",
+
ERF <- Ovariable("ERF", ddata = "Op_en5675") # [[Training health impact]]
definition = function(object) {
+
colnames(ERF@data) <- gsub("[ \\.]", "_", colnames(ERF@data))
dat <- data.frame(Source = "Data", interpret(object@data))
 
dep <- object@dependencies
 
for(i in 1:length(dep)) {
 
if(class(dep[[i]]) == "ovariable") {
 
dep[[i]] <- dep[[i]]@sample
 
} else {
 
if(length(grep("Op_(en|fi)", dep[[i]])) > 0) {
 
dep[[i]] <- op_baseGetData("opasnet_base", dep[[i]])}
 
else {
 
if(class(dep[[i]]) != "data.frame" & !is.numeric(dep[[i]])) {
 
dep[[i]] <- get(dep[[i]])
 
}
 
}
 
}
 
}
 
form <- data.frame(Source = "Formula", make.ovariable(object@formula(dep))@sample)
 
object@sample <- orbind(dat, form)@sample
 
return(object)
 
}
 
)
 
  
########### make.ovariable takes a vector or data.frame and makes an ovariable out of it.
+
out <- exposure * ERF
make.ovariable <- function(
 
data,
 
formula = function(dependencies){return(dependencies)},
 
dependencies = list(x = 0))
 
{if(class(data) == "ovariable") {
 
out <- data}
 
else {
 
if(is.vector(data)) {data <- data.frame(Result = data)}
 
cat("Showing ovariable\n")
 
sample <- interpret(data)
 
print(sample)
 
out <- new("ovariable",
 
sample = sample,
 
data = data,
 
marginal = ifelse(colnames(sample) %in% c("Result", "Unit"), FALSE, TRUE),
 
formula = formula,
 
dependencies = dependencies)
 
# out <- update(out)
 
}
 
return(out)
 
}
 
  
#################### Math defines basic mathematical operations (log, exp, abs, ...) for ovariables
+
return(out)
setMethod(
 
f = "Math",
 
signature = signature(x = "ovariable"),
 
definition = function(x) {
 
x@sample$Result <- callGeneric(x@sample$Result)
 
return(x)
 
 
}
 
}
 
)
 
)
  
############ tapply of ovariables applies a function to each cell of a ragged array, that is to each (non-empty) group of
+
objects.store(health_impact)
############ values given by a unique combination of the levels of certain factors.
 
### parameters (other parameters are as in generic tapply):
 
### X an ovariable
 
  
setMethod(f = "tapply",
+
cat("Ovariable health_impact saved.\n")
signature = signature(X = "ovariable"),
 
definition = function(X, INDEX, FUN = NULL, ..., simplify = TRUE) {
 
out <- as.data.frame(as.table(tapply(X@sample$Result, INDEX, FUN, ..., simplify = TRUE)))
 
colnames(out)[colnames(out) == "Freq"] <- "Result"
 
X@sample <- out
 
print(out)
 
return(X)
 
}
 
)
 
 
 
print(out)
 
out <- update(out)
 
print(out)
 
  
 
</rcode>
 
</rcode>
 
{{attack|# |There are logical errors in the way that data and formula of a variable are used in an assessment. Think this through!|--[[User:Jouni|Jouni]] 06:48, 15 May 2012 (EEST)}}
 
  
 
==See also==
 
==See also==
Line 168: Line 75:
  
 
==Related files==
 
==Related files==
 
{{mfiles}}
 

Latest revision as of 15:48, 24 March 2015



Question

What is the health impact in the Training assessment?

Answer

+ Show code

Rationale

Data

Difference between revisions of "Training health impact"(cases /(µg/m3) /a)
ObsTraitResultDescription
1Respiratory disease20 - 30

Dependencies

Calculations

+ Show code

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


Keywords

References


Related files