Difference between revisions of "Training health impact"

From Testiwiki
Jump to: navigation, search
(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"
 
>
 
>
 
dependencies.Op_en5675 <- list(
 
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) {
 
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")
 
  
 
########### 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)}
cat("Showing ovariable\n")
 
 
sample <- interpret(data)
 
sample <- interpret(data)
print(sample)
 
 
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
print(out)
 
 
return(X)
 
return(X)
 
}
 
}
 
)
 
)
  
print(out)
+
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



Question

What is the health impact in the Training assessment?

Answer

There is no data; the answer is based on modelling only.

+ Show code


Rationale

Formula

What is the size of the population:

+ Show code

# : 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

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

<mfanonymousfilelist></mfanonymousfilelist>