# genFormula: Generate a linear formula In kgoldfeld/simstudy: Simulation of Study Data

## Description

Formulas for additive linear models can be generated with specified coefficient values and variable names.

## Usage

 `1` ```genFormula(coefs, vars) ```

## Arguments

 `coefs` A numerical vector that contains the values of the coefficients. If length(coefs) == length(vars), then no intercept is assumed. Otherwise, an intercept is assumed. `vars` A vector of strings that specify the names of the explanatory variables in the equation.

## Value

A string that represents the desired formula

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16``` ```genFormula(c(.5, 2, 4), c("A", "B", "C")) genFormula(c(.5, 2, 4), c("A", "B")) changeX <- c(7, 10) genFormula(c(.5, 2, changeX[1]), c("A", "B")) genFormula(c(.5, 2, changeX[2]), c("A", "B")) genFormula(c(.5, 2, changeX[2]), c("A", "B", "C")) newForm <- genFormula(c(-2, 1), c("A")) def1 <- defData(varname = "A", formula = 0, variance = 3, dist = "normal") def1 <- defData(def1, varname = "B", formula = newForm, dist = "binary", link = "logit") set.seed(2001) dt <- genData(500, def1) summary(glm(B ~ A, data = dt, family = binomial)) ```

kgoldfeld/simstudy documentation built on Dec. 23, 2018, 5:33 a.m.