fix the musoSensi variance bug

This commit is contained in:
hollorol 2018-05-14 09:52:50 +02:00
parent 1de761a27c
commit d2fce92741
4 changed files with 13 additions and 8 deletions

View File

@ -17,7 +17,8 @@ Imports:
Rcpp, Rcpp,
magrittr, magrittr,
dplyr, dplyr,
ggplot2 ggplot2,
rmarkdown
LinkingTo: Rcpp LinkingTo: Rcpp
Maintainer: Roland Hollo's <hollorol@gmail.com> Maintainer: Roland Hollo's <hollorol@gmail.com>
RoxygenNote: 6.0.1 RoxygenNote: 6.0.1

View File

@ -12,6 +12,7 @@ export(musoMapping)
export(musoMonte) export(musoMonte)
export(musoRandomizer) export(musoRandomizer)
export(musoSensi) export(musoSensi)
export(paramSweepŰ)
export(plotMuso) export(plotMuso)
export(rungetMuso) export(rungetMuso)
export(setupMuso) export(setupMuso)

View File

@ -25,7 +25,7 @@ musoSensi <- function(monteCarloFile = NULL,
settings = NULL, settings = NULL,
parametersFromFile=FALSE, parametersFromFile=FALSE,
inputDir = "./", inputDir = "./",
outLoc = "./calib", outLoc = "./calib",
iterations = 30, iterations = 30,
preTag = "mont-", preTag = "mont-",
outputType = "moreCsv", outputType = "moreCsv",
@ -56,11 +56,13 @@ musoSensi <- function(monteCarloFile = NULL,
varNames<- colnames(M)[1:npar] varNames<- colnames(M)[1:npar]
w <- lm(y~M)$coefficients[-1] w <- lm(y~M)$coefficients[-1]
Sv <- apply(M,2,var) Sv <- apply(M,2,var)
overalVar <- sum(Sv^2*w^2) overalVar <- sum(Sv*w^2)
S=numeric(npar) S=numeric(npar)
for(i in 1:npar){ for(i in 1:npar){
S[i] <- ((w[i]^2*Sv[i]^2)/overalVar)*100 S[i] <- ((w[i]^2*Sv[i])/(overalVar))*100
} }
S <- round(S) S <- round(S)
names(S)<-varNames names(S)<-varNames
write.csv(file = outputFile, x = S) write.csv(file = outputFile, x = S)

View File

@ -4,10 +4,11 @@
\alias{musoSensi} \alias{musoSensi}
\title{musoSensi} \title{musoSensi}
\usage{ \usage{
musoSensi(monteCarloFile = NULL, parameters, settings = NULL, musoSensi(monteCarloFile = NULL, parameters = NULL, settings = NULL,
inputDir = "./", outLoc = "./calib", iterations = 30, parametersFromFile = FALSE, inputDir = "./", outLoc = "./calib",
preTag = "mont-", outputType = "moreCsv", fun = mean, varIndex = 1, iterations = 30, preTag = "mont-", outputType = "moreCsv", fun = mean,
outputFile = "sensitivity.csv", plotName = "sensitivity") varIndex = 1, outputFile = "sensitivity.csv",
plotName = "sensitivity.png", plotTitle = "Sensitivity", dpi = 300)
} }
\arguments{ \arguments{
\item{monteCarloFile}{If you run musoMonte function previously, you did not have to rerun the monteCarlo, just provide the preservedEpc.csv file with its path. If you do not set this parameter, musoSensi will fun the musoMonte function to get all of the information.} \item{monteCarloFile}{If you run musoMonte function previously, you did not have to rerun the monteCarlo, just provide the preservedEpc.csv file with its path. If you do not set this parameter, musoSensi will fun the musoMonte function to get all of the information.}