DataStack {Mediana}R Documentation

DataStack object

Description

This function generates data according to the specified data model.

Usage

DataStack(data.model,
          sim.parameters)

Arguments

data.model

defines a DataModel object.

sim.parameters

defines a SimParameters object.

Value

This function generates a data stack according to the data model and the simulation parameters objetcs. The object returned by the function is a DataStack object containing:

description

a description of the object.

data.set

a list of size n.sims defined in the sim.parameters object. This list contains the data generated for each data scenario (data.scenario level) and each sample (sample level). The data generated for the ith simulation runs, the jth data scenario and the kth sample is stored in data.stack$data.set[[i]]$data.scenario[[j]]$sample[[k]] where data.stack is a DataStack object.

data.scenario.grid

a data frame indicating all data scenarios according to the DataModel object.

data.structure

a list containing the data structure according to the DataModel object.

sim.parameters

a list containing the simulation parameters according to SimParameters object.

A specific data.set of a DataStack object can be extracted using the ExtractDataStack function.

References

http://gpaux.github.io/Mediana/

See Also

See Also DataModel and SimParameters and ExtractDataStack.

Examples

## Not run: 
  # Generation of a DataStack object
  ##################################

  # Outcome parameter set 1
  outcome1.placebo = parameters(mean = 0, sd = 70)
  outcome1.treatment = parameters(mean = 40, sd = 70)

  # Outcome parameter set 2
  outcome2.placebo = parameters(mean = 0, sd = 70)
  outcome2.treatment = parameters(mean = 50, sd = 70)

  # Data model
  case.study1.data.model = DataModel() +
    OutcomeDist(outcome.dist = "NormalDist") +
    SampleSize(c(50, 55, 60, 65, 70)) +
    Sample(id = "Placebo",
           outcome.par = parameters(outcome1.placebo, outcome2.placebo)) +
    Sample(id = "Treatment",
           outcome.par = parameters(outcome1.treatment, outcome2.treatment))


  # Simulation Parameters
  case.study1.sim.parameters = SimParameters(n.sims = 1000,
                                             proc.load = 2,
                                             seed = 42938001)

  # Generate data
  case.study1.data.stack = DataStack(data.model = case.study1.data.model,
                                     sim.parameters = case.study1.sim.parameters)

  # Print the data set generated in the 100th simulation run
  # for the 2nd data scenario for both samples
  case.study1.data.stack$data.set[[100]]$data.scenario[[2]]

  # Extract the same set of data
  case.study1.extracted.data.stack = ExtractDataStack(data.stack = case.study1.data.stack,
                                                      data.scenario = 2,
                                                      simulation.run = 100)
  # The same dataset can be obtained using
  case.study1.extracted.data.stack$data.set[[1]]$data.scenario[[1]]$sample
  # A carefull attention should be paid on the index of the result.
  # As only one data.scenario has been requested
  # the result for data.scenario = 2 is now in the first position (data.scenario[[1]]).

## End(Not run)


## Not run: 
  #Use of a DataStack object in the CSE function
  ##############################################

  # Outcome parameter set 1
  outcome1.placebo = parameters(mean = 0, sd = 70)
  outcome1.treatment = parameters(mean = 40, sd = 70)

  # Outcome parameter set 2
  outcome2.placebo = parameters(mean = 0, sd = 70)
  outcome2.treatment = parameters(mean = 50, sd = 70)

  # Data model
  case.study1.data.model = DataModel() +
    OutcomeDist(outcome.dist = "NormalDist") +
    SampleSize(c(50, 55, 60, 65, 70)) +
    Sample(id = "Placebo",
           outcome.par = parameters(outcome1.placebo, outcome2.placebo)) +
    Sample(id = "Treatment",
           outcome.par = parameters(outcome1.treatment, outcome2.treatment))


  # Simulation Parameters
  case.study1.sim.parameters = SimParameters(n.sims = 1000,
                                             proc.load = 2,
                                             seed = 42938001)

  # Generate data
  case.study1.data.stack = DataStack(data.model = case.study1.data.model,
                                     sim.parameters = case.study1.sim.parameters)

  # Analysis model
  case.study1.analysis.model = AnalysisModel() +
    Test(id = "Placebo vs treatment",
         samples = samples("Placebo", "Treatment"),
         method = "TTest")

  # Evaluation model
  case.study1.evaluation.model = EvaluationModel() +
    Criterion(id = "Marginal power",
              method = "MarginalPower",
              tests = tests("Placebo vs treatment"),
              labels = c("Placebo vs treatment"),
              par = parameters(alpha = 0.025))

  # Simulation Parameters
  case.study1.sim.parameters = SimParameters(n.sims = 1000, proc.load = 2, seed = 42938001)

  # Perform clinical scenario evaluation
  case.study1.results = CSE(case.study1.data.stack,
                            case.study1.analysis.model,
                            case.study1.evaluation.model,
                            case.study1.sim.parameters)

## End(Not run)

[Package Mediana version 1.0.8 Index]