sampleData: Simulate data with binary or time-to-event outcome

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/sampleData.R

Description

Simulate data with binary outcome and 10 covariates.

Usage

1
2
3
4
sampleData(n,outcome="competing.risks",
formula= ~ f(X1,2)+f(X2,-0.033)+f(X3,0.4)+f(X6,.1)+f(X7,-.1)+f(X8,.5)+f(X9,-1))
sampleDataTD(n,n.intervals=5,outcome="competing.risks",
formula= ~ f(X1,2)+f(X2,-0.033)+f(X3,0.4)+f(X6,.1)+f(X7,-.1)+f(X8,.5)+f(X9,-1))

Arguments

n

Sample size

outcome

Character vector. Response variables are generated according to keywords: "binary" = binary response, "survival" = survival response, "competing.risks" = competing risks response

formula

Specify regression coefficients

n.intervals

sampleDataTD only: the maximum number of episodes in which the covariates are updated.

Details

For the actual lava::regression parameters see the function definition.

Value

Simulated data as data.table with n rows and the following columns: Y (binary outcome), time (non-binary outcome), event (non-binary outcome), X1-X5 (binary predictors), X6-X10 (continous predictors)

Author(s)

Thomas A. Gerds <tag@biostat.ku.dk>

See Also

lvm

Examples

1
2
3
sampleData(10,outcome="binary")
sampleData(10,outcome="survival")
sampleData(10,outcome="competing.risks")

Example output

Loading required package: data.table
Loading required package: ggplot2
Loading required package: prodlim
riskRegression version 2019.01.29
          X6       X7          X8         X9        X10 X1 X2 X3 X4 X5 Y
 1: 43.26126 54.41975 -1.31656192  0.4280631  0.8278308  0  1  1  1  0 0
 2: 73.46033 56.97676 -1.05088476  1.2699616  1.7055433  0  0  1  0  1 1
 3: 84.47703 58.17082  0.91568630  0.8992377  0.2838326  0  0  0  1  1 0
 4: 65.13317 63.28768 -0.43934712 -0.2301486 -0.4491537  0  0  0  1  0 1
 5: 60.49965 58.30136 -0.51800720 -1.8353347 -1.8204171  0  1  0  1  0 1
 6: 78.80846 61.59703  1.49706728 -0.6312639  0.4730832  0  0  1  0  1 1
 7: 69.44287 60.26482  0.12412725  0.4107998 -1.1692324  0  0  0  1  1 1
 8: 53.70281 62.71734  0.14721359 -1.5298579  1.0402509  0  0  0  0  1 1
 9: 57.52662 67.82077 -0.04116106  0.9046322 -1.9131210  0  0  0  1  0 0
10: 73.66809 64.92124  0.83590609 -2.3765049 -1.0557361  1  0  0  0  1 1
          X6       X7           X8          X9        X10 X1 X2 X3 X4 X5
 1: 62.73886 60.39892  0.572367170  1.43939382  1.1913423  1  1  0  1  0
 2: 46.58818 65.06687  1.014082296 -0.65347352 -0.1517282  0  0  0  1  0
 3: 59.81752 65.46984  0.738964191 -1.92424966  0.3259249  0  0  1  1  0
 4: 39.61329 60.98097 -1.415780995  0.30910400 -0.6611805  0  0  0  0  0
 5: 59.48783 58.48176  0.003484322  1.01554619 -0.3128661  0  0  0  1  1
 6: 64.14888 60.64429 -0.130761872  0.05252993  0.5448021  0  0  0  0  1
 7: 70.53916 62.90936 -1.291744338  0.47281118  0.3764126  0  0  1  1  0
 8: 51.10188 71.36435  0.165383799 -0.50211977  0.6806166  0  0  0  0  0
 9: 79.61942 63.60446  0.546373044  1.44330330  0.2359865  0  0  1  0  0
10: 55.32831 53.11647  0.760912691  0.14254936 -1.4374489  0  0  1  0  1
    eventtime  censtime      time event
 1:  3.150281  5.625696  3.150281     1
 2:  9.351116  8.300132  8.300132     0
 3:  3.165075 12.590791  3.165075     1
 4: 73.133794 11.735324 11.735324     0
 5: 32.690129 10.911251 10.911251     0
 6:  8.326168  4.870718  4.870718     0
 7:  1.037497  2.771508  1.037497     1
 8:  3.830408 10.250596  3.830408     1
 9: 10.270212  9.888637  9.888637     0
10:  8.082886  2.878025  2.878025     0
          X6       X7          X8         X9         X10 X1 X2 X3 X4 X5
 1: 76.13932 63.01105  0.38126282  0.2738393  1.68936777  0  0  0  0  1
 2: 45.50207 58.58643  0.67521125 -0.1533599  1.11513093  0  0  0  0  1
 3: 25.88899 50.84874 -0.32866824  0.5409144  0.91353307  0  0  1  0  1
 4: 47.06805 51.14961 -0.36473810 -0.1538954 -0.43991115  0  0  0  1  0
 5: 47.09269 62.39083  0.25911222  1.4135478  1.26898409  0  0  0  0  1
 6: 57.99603 58.28538 -0.26320542  0.1652160 -0.22413437  0  0  0  1  1
 7: 35.85390 63.13258  0.08428137 -0.3496552 -0.61798265  0  0  0  0  0
 8: 47.31549 58.07272  0.95338655 -2.1115397 -1.12444315  1  0  0  1  1
 9: 47.64100 56.03244 -0.88651452  1.8161570  1.40253723  0  1  0  1  0
10: 69.40779 57.97843 -0.80122769  0.4692706 -0.08022307  1  0  0  1  1
    eventtime1 eventtime2  censtime      time event
 1:   4.739213   3.397933  7.241000  3.397933     2
 2:   8.927106  10.910481  7.063192  7.063192     0
 3:  27.314087   2.631722 12.475725  2.631722     2
 4:  26.454459  14.177088  6.739097  6.739097     0
 5:   4.593935  13.201761  9.279926  4.593935     1
 6:   9.192072   4.691564 11.171145  4.691564     2
 7:  50.921780  11.121464 19.921460 11.121464     2
 8:   3.142943  13.552942 10.758216  3.142943     1
 9:  40.215599  10.417415  9.639754  9.639754     0
10:   2.011763   4.323430 12.888018  2.011763     1

riskRegression documentation built on Jan. 13, 2021, 11:12 a.m.