Difference between revisions of "Training health impact"

From Testiwiki
Jump to: navigation, search
(update does not work here, otherwise promising)
(problems with logic)
Line 25: Line 25:
 
library(xtable)
 
library(xtable)
 
out <- make.ovariable(
 
out <- make.ovariable(
data = NULL,
+
data = 0,
 
formula = formula.Op_en5675,
 
formula = formula.Op_en5675,
 
dependencies = dependencies.Op_en5675)
 
dependencies = dependencies.Op_en5675)
Line 50: Line 50:
  
 
dependencies.Op_en5675 <- list(
 
dependencies.Op_en5675 <- list(
exposure = formula.Op_en5674(dependencies.Op_en5674), # Training exposure
+
exposure = "Op_en5674", # formula.Op_en5674(dependencies.Op_en5674), # Training exposure
 
erf = data.frame(Unit = "RR per ug/m3", Result = 1.5),
 
erf = data.frame(Unit = "RR per ug/m3", Result = 1.5),
 
population = population,
 
population = population,
Line 57: Line 57:
  
 
formula.Op_en5675 <- function(x) {
 
formula.Op_en5675 <- function(x) {
cases <- x@population * x@background * exp(x@exposure * ln(x@erf))
+
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)
 
return(cases)
 
}
 
}
Line 69: Line 73:
 
dependencies = dependencies.Op_en5675)
 
dependencies = dependencies.Op_en5675)
 
cat("Computing training health impact.\n")
 
cat("Computing training health impact.\n")
print(out)
 
  
 
########### 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 86: Line 89:
 
else {
 
else {
 
if(class(dep[[i]]) != "data.frame" & !is.numeric(dep[[i]])) {
 
if(class(dep[[i]]) != "data.frame" & !is.numeric(dep[[i]])) {
print(dep[[i]])
 
print(class(dep[[i]]))
 
 
dep[[i]] <- get(dep[[i]])
 
dep[[i]] <- get(dep[[i]])
 
}
 
}
Line 99: Line 100:
 
)
 
)
  
 +
########### make.ovariable takes a vector or data.frame and makes an ovariable out of it.
 +
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
 +
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
 +
############ 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",
 +
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)
 
out <- update(out)
 
print(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==

Revision as of 03:48, 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>