Learn R Programming

prodlim (version 1.3.7)

readFormula: Read a special formula

Description

Distangle formula with special terms.

Usage

readFormula(formula, specials, specialArgumentNames, alias, unspecified = "unSpec")

Arguments

formula
A formula of the form Hist(time, event) ~ g(a) + f(b) + g(c) where f and g are examples of special functions.
specials
Names of the special functions.
specialArgumentNames
Further arguments of special functions.
alias
List of alias names for special functions
unspecified
Special function for variables that are not specialized.

Value

  • A list
  • ResponseA lhs-formula, i.e. a character-class formula where the right hand set to ~1
  • InterceptThe Intercept of the formula
  • specialFor each special name and the unspecificied name, a list with a character-class formula and specialArguments.
  • allVarsA character-class rhs-formula containing all variables of argument formula

Details

This function restricts the formula syntax to some extend. For example, it is not possible to construct variables inside the formula: This is an error: readFormula(a~b+X(I(c>4)),specials=c("X"))

Instead, one need to construct the variable data$c4 <- data$c>4 and then use

readFormula(a~b+X(c),specials=c("X"))

Examples

Run this code
readFormula(y~x+f(z),specials=c("f"),unspecified="g")

## suitable construction to serve cmprsk
qFun <- function(x){x^2}
## multiply X1 by time^2 and X2 by time:
readFormula(Hist(time,event)~cov2(X1,tf=qFun)+cov2(X2),
	    specials=c("cov2","cov1"),
	    specialArgumentNames=list("cov2"="tf"),
	    unspecified="cov1")

Run the code above in your browser using DataLab