Difference between revisions of "Training health impact"
From Testiwiki
(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 = | + | 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 <- | + | 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") | ||
− | |||
########### 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]])) { | ||
− | |||
− | |||
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
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>