Learn R Programming

mtk (version 1.0)

mtk-package: MTK (Mexico ToolKit) for Sensitivity Analysis and Numerical Experiments

Description

MTK is an R package for sensitivity analysis and numerical experiments . Three examples are provided:
  • "Ishigami" model analysis with the "BasicMonteCarlo" and "Regression" methods.
  • Using the "mtk" package from a XML file.
  • "WWDM (Winter Wheat Dry Matter)" model analysis with the "Morris" methods.

To run the examples, just load the package and type respectively:

  • demo(demo1,package="mtk", ask=FALSE)
  • demo(demo2,package="mtk", ask=FALSE)
  • demo(demo3,package="mtk", ask=FALSE)

The following methods and models are available for the current release:

  • The "Fast" methods for experiments design and sensitivity index calculation. see help(Fast).
  • The "Morris" methods for experiments design and sensitivity index calculation. see help(Morris).
  • The "Sobol" methods for experiments design and sensitivity index calculation. see help(Sobol).
  • The "Monte-Carlo" methods for experiments design. see help(BasiMonteCarlo).
  • The "LHS" methods for experiments design. see help(RandLHS).
  • The "PLMM (Polynomial Linear Meta-Model)" methods for sensitivity analysis. see help(PLMM).
  • The "Regression" methods for sensitivity index calculation. see help(Regression).
  • The "Ishigami" model for model simulation. see help(Ishigami).
  • The "WWDM (Winter Wheat Dry Matter)" model for model simulation. see help(WWDM).

Arguments

References

J. Wang, H. Richard, R. Faivre, H. Monod (2013). Le package mtk, une bibliothèque R pour l'exploration numérique des modèles. In: Analyse de sensibilité et exploration de modèles : Application aux sciences de la nature et de l'environnement (R. Faivre, B. Iooss, S. Mahévas, D. Makowski, H. Monod, Eds). Editions Quae, Versailles.

Examples

Run this code

### Example 1: Sensitivity analysis of the "Ishigami" model ###

# Specify the factors to analyze:
	x1 <- make.mtkFactor(name="x1", 
	   distribName="unif", distribPara=list(min=-pi, max=pi)) 
	x2 <- make.mtkFactor(name="x2", distribName="unif", 
	   distribPara=list(min=-pi, max=pi)) 
	x3 <- make.mtkFactor(name="x3", distribName="unif", 
	   distribPara=list(min=-pi, max=pi)) 
	factors <- mtkExpFactors(list(x1,x2,x3)) 
# Build the processes:
#  1) the experimental design process with the method "Morris".
	exp1.Designer <- mtkMorrisDesigner(listParameters
			= list(r=20,type="oat",levels=4,grid.jump=2)) 

#  2) the model simulation process with the model "Ishigami".
	exp1.Evaluator <- mtkIshigamiEvaluator() 

#  3) the analysis process with the method "Morris".
	exp1.Analyser <- mtkMorrisAnalyser()

# Build the  workflow with the processes defined previously.
	exp1 <- mtkExpWorkflow(expFactors=factors, 
	 	   processesVector = c(
	    	design=exp1.Designer,
			evaluate=exp1.Evaluator, 
			analyze=exp1.Analyser)
			) 
		
# Run the workflow and reports the results.
	run(exp1)
	print(exp1)
	
# Create a new process with the analysis method «Regression». 
	exp1.AnalyserReg <- mtkRegressionAnalyser(listParameters
			=list(nboot=20)
		 )
	
# Re-analyze the model "Ishigami" with the method "Regression":
## replace the process, run the workflow and  report the results

	setProcess(exp1, exp1.AnalyserReg, "analyze")	
	run(exp1) 
	print(exp1)

### Example 2 : Sensitivity analysis from a XML file  ###

# # XML file is held in the directory of the library: "inst/extdata/"

# Specify the XML file's name
	xmlFile <- "WWDM_morris.xml"

## Find where the examples are held.
	xmlFilePath <- paste(path.package("mtk", quiet = TRUE),
			"/extdata/",xmlFile,sep = "") 
		
# Create the workflow
## 	Nota: If your XML file is local file for example "/var/tmp/X.xml",
## 	you should create the workflow as follows: 
## 	workflow <- mtkExpWorkflow(xmlFilePath="/var/tmp/X.xml")

	workflow <- mtkExpWorkflow(xmlFilePath=xmlFilePath)

# Run the workflow and report the results
	run(workflow)
	summary(workflow)

Run the code above in your browser using DataLab