Function to construct linear predictors.
Examples
library(rsurv)
library(dplyr)
#>
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#>
#> filter, lag
#> The following objects are masked from ‘package:base’:
#>
#> intersect, setdiff, setequal, union
n <- 100
coefs <- c(1, 0.7, 2.3)
simdata <- data.frame(
age = rnorm(n),
sex = sample(c("male", "female"), size = n, replace = TRUE)
) |>
mutate(
lp = lp(~age+sex, coefs)
)
glimpse(simdata)
#> Rows: 100
#> Columns: 3
#> $ age <dbl> -1.400043517, 0.255317055, -2.437263611, -0.005571287, 0.621552721…
#> $ sex <chr> "female", "female", "male", "female", "female", "male", "male", "m…
#> $ lp <dbl> 0.01996954, 1.17872194, 1.59391547, 0.99610010, 1.43508690, 4.1038…