Difference between revisions of "Training health impact"
From Testiwiki
(problems with logic) |
(→Formula: Seems to work) |
||
Line 48: | Line 48: | ||
variables="name:population|description:What is the size of the population|default:100000" | variables="name:population|description:What is the size of the population|default:100000" | ||
> | > | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
########### update updates the sample of an ovariable based on data and function. | ########### update updates the sample of an ovariable based on data and function. | ||
Line 104: | Line 79: | ||
data, | data, | ||
formula = function(dependencies){return(dependencies)}, | formula = function(dependencies){return(dependencies)}, | ||
− | dependencies = list(x = 0)) | + | dependencies = list(x = 0) |
− | {if(class(data) == "ovariable") { | + | ) { |
− | out <- data} | + | if(class(data) == "ovariable") { |
+ | out <- data} | ||
+ | else { | ||
+ | if(is.vector(data)) {data <- data.frame(Result = data)} | ||
+ | sample <- interpret(data) | ||
+ | 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) | ||
+ | } | ||
+ | |||
+ | setGeneric("make.ovariable") # Makes make.ovariable a generic S4 function. | ||
+ | |||
+ | setMethod( | ||
+ | f = "make.ovariable", | ||
+ | signature = signature(data = "data.frame"), | ||
+ | definition = function( | ||
+ | data, | ||
+ | formula = function(dependencies){return(dependencies)}, | ||
+ | dependencies = list(x = 0) | ||
+ | ) { | ||
+ | data <- movariable(data) | ||
+ | return(data) | ||
+ | } | ||
+ | ) | ||
+ | |||
+ | ########### movariable takes a vector or data.frame and makes an ovariable out of it. It is a | ||
+ | #####copy of make.ovariable that prevents infinite recursion of S4 methods. | ||
+ | movariable <- function( | ||
+ | data, | ||
+ | formula = function(dependencies){return(dependencies)}, | ||
+ | dependencies = list(x = 0) | ||
+ | ) { | ||
+ | if(class(data) == "ovariable") { | ||
+ | out <- data} | ||
else { | else { | ||
if(is.vector(data)) {data <- data.frame(Result = data)} | if(is.vector(data)) {data <- data.frame(Result = data)} | ||
− | |||
sample <- interpret(data) | sample <- interpret(data) | ||
− | |||
out <- new("ovariable", | out <- new("ovariable", | ||
sample = sample, | sample = sample, | ||
Line 122: | Line 134: | ||
return(out) | return(out) | ||
} | } | ||
+ | |||
+ | setMethod( | ||
+ | f = "make.ovariable", | ||
+ | signature = signature(data = "list"), | ||
+ | definition = function( | ||
+ | data, | ||
+ | formula = function(dependencies){return(dependencies)}, | ||
+ | dependencies = list(x = 0) | ||
+ | ) { | ||
+ | for(i in 1:length(data)) { | ||
+ | cat("Data[[i]] ", i, "\n") | ||
+ | print(class(data[[i]])) | ||
+ | data[[i]] <- make.ovariable(data[[i]]) | ||
+ | } | ||
+ | return(data) | ||
+ | } | ||
+ | ) | ||
+ | |||
#################### Math defines basic mathematical operations (log, exp, abs, ...) for ovariables | #################### Math defines basic mathematical operations (log, exp, abs, ...) for ovariables | ||
Line 144: | Line 174: | ||
colnames(out)[colnames(out) == "Freq"] <- "Result" | colnames(out)[colnames(out) == "Freq"] <- "Result" | ||
X@sample <- out | X@sample <- out | ||
− | |||
return(X) | return(X) | ||
} | } | ||
) | ) | ||
− | + | dependencies.Op_en5675 <- list( | |
+ | exposure = "1-2", #"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) { | ||
+ | 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") | ||
+ | |||
+ | library(xtable) | ||
+ | out <- make.ovariable( | ||
+ | data = "0 - 100000", | ||
+ | formula = formula.Op_en5675, | ||
+ | dependencies = dependencies.Op_en5675) | ||
+ | cat("Computing training health impact.\n") | ||
+ | |||
+ | make.ovariable(dependencies.Op_en5675) | ||
+ | |||
out <- update(out) | out <- update(out) | ||
print(out) | print(out) |
Revision as of 10:32, 15 May 2012
This page is a variable.
The page identifier is Op_en5675 |
---|
Moderator:Jouni (see all) |
This page is a stub. You may improve it into a full page, and then a rating bar will appear here. |
Upload data
|
Contents
Question
What is the health impact in the Training assessment?
Answer
There is no data; the answer is based on modelling only.
Rationale
Formula
⇤# : There are logical errors in the way that data and formula of a variable are used in an assessment. Think this through! --Jouni 06:48, 15 May 2012 (EEST)
See also
Help pages | Wiki editing • How to edit wikipages • Quick reference for wiki editing • Drawing graphs • Opasnet policies • Watching pages • Writing formulae • Word to Wiki • Wiki editing Advanced skills |
Training assessment (examples of different objects) | Training assessment • Training exposure • Training health impact • Training costs • Climate change policies and health in Kuopio • Climate change policies in Kuopio |
Methods and concepts | Assessment • Variable • Method • Question • Answer • Rationale • Attribute • Decision • Result • Object-oriented programming in Opasnet • Universal object • Study • Formula • OpasnetBaseUtils • Open assessment • PSSP |
Terms with changed use | Scope • Definition • Result • Tool |
Keywords
References
Related files
<mfanonymousfilelist></mfanonymousfilelist>