performAnalysis: Runs the analysis code against one dataset

Description Usage Arguments Details Value Author(s) See Also Examples

Description

That function is iteratively called from analyzeRep to analyze a replicate dataset at each step defined by the interims.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
performAnalysis(analysisCode, 
  doses, 
  data, 
  software = c("R", "SAS"),  
  includeRows = NULL, 
  interimCol = getEctdColName("Interim"), 
  doseCol = getEctdColName("Dose"), 
  seed = .deriveFromMasterSeed(), 
  workingPath = getwd(), 
  cleanUp = TRUE, 
  tempSasDir = tempdir())

Arguments

analysisCode

(Required) Analysis code: An R function, a reference to an external R script, or a reference to an external SAS script

doses

(Required) Vector of doses for which estimates are expected

data

(Required) Input dataset on which to perform analysis

software

(Optional) Software for analysis: "R" or "SAS" (default is "R")

includeRows

(Optional) 2 column matrix specifying interims and doses to include in analysis. By default, no subsets are applied

interimCol

Interim flag column name

doseCol

Dose column name

seed

(Optional) Random number generation seed. By default, this is derived from the current random seed

workingPath

(Optional) Working directory for the analysis. The default is the current working directory

cleanUp

(Optional) Logical: Should we remove the files that have been passed in and out of SAS?

tempSasDir

Temporary Sas Directory

Details

The function tries to perform the analysis contained in the analysisCode against the data. The analysis code specified is either an external file containing code (SAS and R), or an R function (R only).

If software is set to "SAS" the analysis code is assumed to be a reference to an external SAS script. The SAS code must accept a single dataset called work.infile, and create an output dataset called work.outfile. The work.outfile dataset must be a valid "Micro Evaluation" structure as specified in the help file for checkMicroFormat. If the software is "R", the analysis code input must be either an R function or an R script. The R analysis code must also return a valid "Micro Evaluatoin" structure as specified in function checkMicroFormat

Value

The function should output a valid "Micro Evaluation" data structure as specified in the checkMicroFormat help file.

Author(s)

Mike K Smith mstoolkit@googlemail.com

See Also

checkMicroFormat

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## Not run: 
  
  # Emax example
  anaCode <- function(data){
    with( data, {
      uniDoses <- sort( unique(DOSE))
      outDf <- data.frame( DOSE = uniDoses, 
        MEAN = tapply(RESP, DOSE, mean) , 
        SE   = tapply(RESP, DOSE, sd )  )
      outDf$LOWER <- outDf$MEAN - 2 * outDf$SE
      outDf$UPPER <- outDf$MEAN + 2 * outDf$SE
      outDf$N     <- table(DOSE)[ as.character(uniDoses) ]
      outDf 
    }) 
  }
  
  # example data
  exData <- system.file( "Runit", "data", "analyseRep", "ReplicateData", "replicate0001.csv", 
  package = "MSToolkit")
  out <- performAnalysis(anaCode, data = exData, doses = c(0, 5, 25, 50, 100) )
  checkMicroFormat( out )       # Check the format of the return structure


## End(Not run)

MSToolkit documentation built on May 2, 2019, 6:30 p.m.