samplr: generates a Latin hypercube based on inputs provided in an...

View source: R/samplr.R

samplrR Documentation

generates a Latin hypercube based on inputs provided in an Excel spreadsheet.

Description

facilitates the generation of a Latin hypercube for a set of variables based on inputs specified in a spreadsheet table.

Usage

samplr(
  myfilename = NULL,
  mytestspervariable = 10,
  myseed = 12345L,
  mymaxsweeps = 4,
  myeps = 0.01,
  mydup = 5,
  mypop = 1000,
  mygen = 8,
  mypmut = 0.1,
  mygraphsize = 1000,
  mypch = 19,
  mycol = "blue",
  mycex = 0.5
)

Arguments

myfilename

is the name of the input Excel file

mytestspervariable

the number of tests per variable in the input file

myseed

the random number seed to be used

mymaxsweeps

see lhs package documentation

myeps

see lhs package documentation

mydup

see lhs package documentation

mypop

see lhs package documentation

mygen

see lhs package documentation

mypmut

see lhs package documentation

mygraphsize

pixel dimension to be used for scatter graph matrices. see "width" and "height" in png grDevices.

mypch

see "pch" in par graphics

mycol

see "col" in par graphics

mycex

see "cex" in par graphics

Details

The spreadsheet should have only one sheet with the following columns and one row for each variable to be simulated:

  • Index (numeric)

  • Variable (character)

  • codename (character)

  • Base (numeric)

  • Minimum (numeric)

  • Mode (numeric)

  • Maximum (numeric)

  • Distribution (character) - Uniform, Triangular, or PERT.

  • Shape (numeric) - only needed if distribution is "PERT"

Six types of optimisation algorithm are tested:

  • randomLHS

  • optimumLHS

  • maximinLHS

  • improvedLHS

  • geneticsLHS - genetic algorithm with "S" criterium

  • geneticmLHS - genetic algorithm with "Maximin" criterium

The algorithm that minimises the maximum correlation ("max_corr") is selected to produce the recommended Latin hypercube. The details of the selected algorithm and the other algorithms tested are added to the sheet "optimisation_summary" of the results workbook.

Examples

myinputfile <- system.file("extdata", "risk_variable_distributions.xlsx", package = "humblr")
mytest1 <- samplr(myinputfile, mytestspervariable = 10, myseed = 12345L, mymaxsweeps = 4, myeps = 0.01, mydup = 5, mypop = 1000, mygen = 8, mypmut = 0.1, mygraphsize = 1000, mypch = 19, mycol = "blue", mycex = 0.5)
mytest1


alexmitrani/humblr documentation built on April 4, 2022, 8:29 a.m.