createResponse: High-level function for the response component.

createResponseR Documentation

High-level function for the response component.

Description

Create a response from a dataset and an equation.

Usage

createResponse(
  data,
  equation,
  name = getEctdColName("Response"),
  invLink,
  distribution = "normal",
  covariance,
  errStruc = "Additive",
  range,
  digits = 3,
  seed = .deriveFromMasterSeed(),
  flagName = getEctdColName("RespOmit")
)

Arguments

data

(Required) Data structure to which to add response.

equation

(Required) R function or character string for creating response. See createResponseVariable.

name

(Optional) Response variable name ("RESP" by default)

invLink

(Optional) Inverse link function for the predictor. This is an R function. No inverse link function by default

distribution

(Optional) Outcome variable distribution, one of "n" for normal, "l" for lognormal, "b" for binomial or "p" for poisson. Default is "Normal"

covariance

(Optional) Residual Error (CO)VARIANCE, passed to the addResidualError function. Missing by default, resulting in no residual error generated for the reponse

errStruc

(Optional) Function describing how to apply residual error: "Additive", "Log-Normal" or "Proportional". "Additive" is the default

range

(Optional) Range of acceptable values for created response. See parseRangeCode. Missing by default, resulting in no "range" limitation on the response

digits

(Optional) Number of digits to which to round the response (3 by default)

seed

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

flagName

(Optional) "Response Omit" Flag name ("RESPOMIT" by default)

Value

A data set containing two columns.

RESP

The actual Response

RESPOMIT

The response OMIT flag. It is named from the value of the flagName argument.

Note

In earlier versions of MSToolkit, the "Proportional" Error Structure behaved differently (it is assumed parameters passed were on the log scale)

Author(s)

Mike K Smith mstoolkit@googlemail.com

See Also

The lower-level function of the response component: createResponseVariable and addResidualError are called by createResponse.

Examples


  # example data
  myData <- expand.grid(X = 1:2, Y = 1:2, Z = 1:2)

  # added to comply with SF issue 7
  # Tue Jul 24 10:21:14 BST 2007 @431 /Internet Time/
  # function example
  out1 <- createResponse(data = myData,
                         equation = function(data) with(data, X+Y+Z),
                         covariance = 1, range = "RESP < 3", seed = 96)

  # same example using a character representation
  out2 <- createResponse(data = myData,
                         equation = "X+Y+Z",
                         covariance = 1, range = "RESP < 3", seed = 96)
  stopifnot(identical(out1, out2))


MikeKSmith/MSToolkit documentation built on Feb. 15, 2024, 5:32 p.m.