diff --git a/RBBGCMuso/R/musoMonte.R b/RBBGCMuso/R/musoMonte.R index ab5ce04..a67d6fb 100644 --- a/RBBGCMuso/R/musoMonte.R +++ b/RBBGCMuso/R/musoMonte.R @@ -76,6 +76,7 @@ musoMonte <- function(settings=NULL, preservedEpc <- matrix(nrow = (iterations +1 ), ncol = npar) preservedEpc[1,] <- origEpc colnames(preservedEpc) <- Otable[[1]][,1] + preservedEpc <- cbind(preservedEpc,rep(NA,(iterations+1))) colnames(preservedEpc)[(npar+1)] <- "y" ## Save the backupEpc, while change the settings diff --git a/RBBGCMuso/R/musoSensi.R b/RBBGCMuso/R/musoSensi.R index b69ad08..9247f9a 100644 --- a/RBBGCMuso/R/musoSensi.R +++ b/RBBGCMuso/R/musoSensi.R @@ -44,11 +44,8 @@ musoSensi <- function(monteCarloFile = NULL, varIndex = varIndex ) npar <- ncol(M)-1 + M <- M[which(!is.na(M$y)),] y <- M[,(npar+1)] - M %<>% - tbl_df() %>% - filter(.,!is.na(y)) %>% - as.data.frame() M <- apply(M[,1:npar],2,function(x){x-mean(x)}) varNames<- colnames(M)[1:npar] w <- lm(y~M)$coefficients[-1] @@ -64,12 +61,10 @@ musoSensi <- function(monteCarloFile = NULL, return(S) } else { M <- read.csv(monteCarloFile) + npar <- ncol(M)-1 + M <- M[which(!is.na(M$y)),] y <- M[,(npar+1)] - M %<>% - tbl_df() %>% - filter(.,!is.na(y)) %>% - as.data.frame() M <- apply(M[,1:npar],2,function(x){x-mean(x)}) varNames<- colnames(M)[1:npar] w <- lm(y~M)$coefficients[-1] diff --git a/RBBGCMuso/man/musoSensi.Rd b/RBBGCMuso/man/musoSensi.Rd new file mode 100644 index 0000000..87f25e2 --- /dev/null +++ b/RBBGCMuso/man/musoSensi.Rd @@ -0,0 +1,42 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/musoSensi.R +\name{musoSensi} +\alias{musoSensi} +\title{musoSensi} +\usage{ +musoSensi(monteCarloFile = NULL, parameters, settings = NULL, + inputDir = "./", outLoc = "./calib", iterations = 30, + preTag = "mount-", outputType = "moreCsv", fun = mean, varIndex = 1, + outputFile = "sensitivity.csv", plotName = "sensitivity.jpg") +} +\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{parameters}{This is a dataframe (heterogen data-matrix), which first column is the name of the parameters, the second is a numeric vector of the rownumbers of the given variable in the epc-fie, the last two column consist the endpont of the parameter-ranges, where the parameters will be randomized.} + +\item{settings}{A list of montecarlos environmental variables. It is generated by the setupMuso() function. In default the settings parameter is generated automatically.} + +\item{inputDir}{The location of the input directory, this directory must content a viable pack of all inputfiles and the executable file.} + +\item{iterations}{number of the monteCarlo run.} + +\item{preTag}{It will be the name of the output files. For example preTag-1.csv, pretag-2csv...} + +\item{outputType}{This parameter can be "oneCsv", "moreCsv", and "netCDF". If "oneCsv" is choosen the function create 1 big csv file for all of the runs, if "moreCsv" is choosen, every modell output goes to separate files, if netCDF is selected the outputs will be put in a netCDF file. The default value of the outputTypes is "moreCsv". netCDF is not implemented yet.} + +\item{fun}{If you select a variable from the possible outputs (with specify the varIndex parameter), you have to provide a function which maps to a subset of real numbers. The most frequent possibilities are: mean, min, max, var, but you can define any function for your need.} + +\item{varIndex}{This parameter specify which parameter of the output will be used. You can extract this information from the ini-files. At the output parameter specifications, the parameters order will determine this number. For example, if you have set these output parameters: 412, 874, 926, 888, and you want to use 926, you should address varIndex with 3.} + +\item{outputFile}{The filename in which the output of musoSensi function will be saved. It's default value is: "sensitivity.csv"} + +\item{plotName}{The name of the output barplot. It's default value is: "sensitivity.jpg"} + +\item{calibrationPar}{You may want to change some parameters in your epc file, before you run the modell. You have to select the appropirate modell parameters. You can refence to these with the number of the line in the epc file where the variables are. It indexes from one. You should use a vector for this, like: c(1,5,8)} +} +\description{ +This function does regression based sensitivity analysis based on the output of musoMonte. +} +\author{ +Roland Hollos +}