Add single row to definitions table

defData( dtDefs = NULL, varname, formula, variance = 0, dist = "normal", link = "identity", id = "id" )

dtDefs | Definition data.table to be modified |
---|---|

varname | Name (string) of new variable |

formula | An R expression for mean (string) |

variance | Number |

dist | Distribution. For possibilities, see details |

link | The link function for the mean, see details |

id | A string indicating the field name for the unique record identifier |

A data.table named dtName that is an updated data definitions table

The possible data distributions are: normal, binary, binomial, poisson, noZeroPoisson, uniform, categorical, gamma, beta, nonrandom, uniformInt, negBinomial, exponential, mixture.

extVar <- 2.3 def <- defData(varname = "xNr", dist = "nonrandom", formula = 7, id = "idnum") def <- defData(def, varname = "xUni", dist = "uniform", formula = "10;20") def <- defData(def, varname = "xNorm", formula = "xNr + xUni * 2", dist = "normal", variance = 8 ) def <- defData(def, varname = "xPois", dist = "poisson", formula = "xNr - 0.2 * xUni", link = "log" ) def <- defData(def, varname = "xCat", formula = "0.3;0.2;0.5", dist = "categorical") def <- defData(def, varname = "xGamma", dist = "gamma", formula = "5+xCat", variance = 1, link = "log" ) def <- defData(def, varname = "xBin", dist = "binary", formula = "-3 + xCat", link = "logit" ) def <- defData(def, varname = "external", dist = "nonrandom", formula = "xBin * log(..extVar)" ) def#> varname formula variance dist link #> 1: xNr 7 0 nonrandom identity #> 2: xUni 10;20 0 uniform identity #> 3: xNorm xNr + xUni * 2 8 normal identity #> 4: xPois xNr - 0.2 * xUni 0 poisson log #> 5: xCat 0.3;0.2;0.5 0 categorical identity #> 6: xGamma 5+xCat 1 gamma log #> 7: xBin -3 + xCat 0 binary logit #> 8: external xBin * log(..extVar) 0 nonrandom identity