Ero sivun ”Radonin terveysvaikutukset” versioiden välillä

Opasnet Suomista
Siirry navigaatioon Siirry hakuun
(→‎Kaava: taulukko muunnettu sopivaksi analyysia varten)
(→‎Kaava: toteutettu jakaumat fraktiileista)
Rivi 11: Rivi 11:
=== Kaava ===
=== Kaava ===


<rcode>
<rcode variables="name:n|default:100" graphics="1">
library(sorvi)
library(sorvi)
library(OpasnetBaseUtils)
library(OpasnetBaseUtils)
Rivi 125: Rivi 125:
"Pohjanmaa", "Pohjanmaa", "Pohjois-Pohjanmaa", "Lappi", "Pohjois-Pohjanmaa", "Pirkanmaa",
"Pohjanmaa", "Pohjanmaa", "Pohjois-Pohjanmaa", "Lappi", "Pohjois-Pohjanmaa", "Pirkanmaa",
"Kanta-Häme", "Etelä-Pohjanmaa", "Keski-Suomi"))
"Kanta-Häme", "Etelä-Pohjanmaa", "Keski-Suomi"))
head(kunnat)
#head(kunnat)
radon <- op_baseGetData("opasnet_base", "op_fi2759")[, 3:6]
radon <- op_baseGetData("opasnet_base", "op_fi2759")[, 3:6]
radon$Result <- ifelse(is.na(radon$Result.Text), radon$Result, as.numeric(as.character(radon$Result.Text)))
radon$Result <- ifelse(is.na(radon$Result.Text), radon$Result, as.numeric(as.character(radon$Result.Text)))
radon <- radon[, 1:3]
radon <- radon[, 1:3]
colnames(radon)[3] <- "r"
colnames(radon)[3] <- "r"
head(radon)
#head(radon)
radon <- radon[substr(radon$Havainto, 1, 7) != "kaikki.", ]
radon <- radon[substr(radon$Havainto, 1, 7) != "kaikki.", ]
radon <- radon[radon$Maakunta != "Yhteensä", ]
radon <- radon[radon$Maakunta != "Yhteensä", ]
print(xtable(reshape(radon, idvar = "Maakunta", timevar = "Havainto", direction = "wide")), type = 'html')
#print(xtable(reshape(radon, idvar = "Maakunta", timevar = "Havainto", direction = "wide")), type = 'html')


radon$Talo <- ifelse(substr(radon$Havainto, 1, 3) == "pt.", "Pientalo", "Kerrostalo")
radon$Talo <- ifelse(substr(radon$Havainto, 1, 3) == "pt.", "Pientalo", "Kerrostalo")
radon$P <- ifelse(substr(radon$Havainto, 4, 10) == "ka", "Keskiarvo", "")
radon$P <- substr(radon$Havainto, 4, 10)
radon$P <- ifelse(substr(radon$Havainto, 4, 10) == "med", "Mediaani", radon$P)
#radon$P <- ifelse(substr(radon$Havainto, 4, 10) == "ka", "Keskiarvo", "")
radon$P <- ifelse(substr(radon$Havainto, 4, 10) == "max", "Maksimi", radon$P)
#radon$P <- ifelse(substr(radon$Havainto, 4, 10) == "med", "Mediaani", radon$P)
radon$P <- ifelse(substr(radon$Havainto, 4, 10) == "y200", "Yli200", radon$P)
#radon$P <- ifelse(substr(radon$Havainto, 4, 10) == "max", "Maksimi", radon$P)
radon$P <- ifelse(substr(radon$Havainto, 4, 10) == "y400", "Yli400", radon$P)
#radon$P <- ifelse(substr(radon$Havainto, 4, 10) == "y200", "Yli200", radon$P)
radon$P <- ifelse(substr(radon$Havainto, 4, 10) == "y800", "Yli800", radon$P)
#radon$P <- ifelse(substr(radon$Havainto, 4, 10) == "y400", "Yli400", radon$P)
#radon$P <- ifelse(substr(radon$Havainto, 4, 10) == "y800", "Yli800", radon$P)


head(radon)
#head(radon)
radon <- radon[, colnames(radon)!="Havainto"]
radon <- radon[, colnames(radon)!="Havainto"]
radon <- reshape(radon, idvar = c("Maakunta", "Talo"), timevar = "P", direction = "wide")
radon <- reshape(radon, idvar = c("Maakunta", "Talo"), timevar = "P", direction = "wide")
radon[is.na(radon)] <- 0
radon[is.na(radon)] <- 0
print(xtable(radon), type = 'html')
#print(xtable(radon), type = 'html')
 
j <- 2/3 # c( rep(2/3, 8), 3/4, rep(2/3, 9), 3/4, rep(2/3, 21))
X2 <- radon$r.max
for(i in 1:nrow(radon)) {X2[i] <- min(radon$r.max[i], (radon$r.med[i] + 201)/2)}
X <- data.frame(P1 = radon$r.med, P2 = X2, P3 = radon$r.max, P4 = 201, P5 = 351, P6 = 401, P7 = 601, P8 = 801)
P <- data.frame(
P1 = 50,
P2 = (50 - radon$r.y200),
P3 = (radon$r.y800)*(1-j),
P4 = (radon$r.y200 - radon$r.y400)*j,
P5 = (radon$r.y200 - radon$r.y400)*(1-j),
P6 = (radon$r.y400 - radon$r.y800)*j,
P7 = (radon$r.y400 - radon$r.y800)*(1-j),
P8 = (radon$r.y800)*j)/100
 
#X <- data.frame(P1 = radon$r.Mediaani, P2 = radon$r.Maksimi, P3 = 201, P4 = 351, P5 = 401, P6 = 601, P7 = 801)
#P <- data.frame(P1 = 50, P2 = radon$r.Yli800*(1-j), P3 = radon$r.Yli200*j, P4 = radon$r.Yli200*(1-j), P5 = radon$r.Yli400*j, P6 = radon$r.Yli400*(1-j), P7 = radon$r.Yli800*j)/100
 
Xsort <- X
for(i in 1:nrow(X)){Xsort[i, ] <- sort.int(t(X[i, ]), index.return=TRUE)[[2]]}
for(i in 1:nrow(X)){X[i, ] <- X[i, t(Xsort[i, ])]}
for(i in 1:nrow(X)){P[i, ] <- P[i, t(Xsort[i, ])]}
#head(radon)
#print(xtable(Xsort), type = 'html')
#print(xtable(P), type = 'html')
 
#head(P)
 
X$P1 <- (radon$r.ka - rowSums((X*P)[, -1])) / 0.5
#print(xtable(X), type = 'html')
#rowSums(X*P)
#rowSums(P)
intP <- P
for(i in 2:ncol(P)){intP[, i] <- rowSums(P[, 1:i])}
#intP
 
out <- data.frame()
 
for(j in 1:n){
 
radoniter <- intP[, 1]
iter <- rowSums(runif(nrow(intP), 0, 1) > intP)+1
for(i in 1:nrow(intP)){radoniter[i] <- X[i, iter[i]]}
radon2 <- data.frame(Maakunta = radon$Maakunta, Talo = radon$Talo, obs = n, Radon = radoniter)
radon2
out <- rbind(out, radon2)
}
radon2
head(out)
</rcode>
</rcode>



Versio 7. joulukuuta 2011 kello 10.15




Kysymys

Mitkä ovat radonin terveysvaikutukset Suomessa?

Vastaus

Perustelut

Kaava

n:

+ Näytä koodi

Katso myös

Viitteet


Aiheeseen liittyviä tiedostoja

<mfanonymousfilelist></mfanonymousfilelist>