This function generates data from two logistic regression trees: one with three apparent clusters (in terms of variance of the features) but a single logistic regression generating y | x, and one with a single apparent cluster but three different logistic regressions generating y | x given a categorical feature.
Arguments
- n
The number of observations to draw.
- scenario
The "no tree" scenario denotes the first scenario where there is a single logistic regression generating the data. The "tree" scenario generates data from the second data generating mechanism where there are three logistic regressions.
- visualize
Whether (TRUE) or not (FALSE) to plot the generated data.
Value
Generates and returns data according to a true logistic regression tree (if scenario = "tree") or a single regression tree (if scenario = "no tree"). Eventually plots this dataset (if visualize = TRUE).
Examples
generateData(scenario = "tree")
#> x1 x2 x3 y c
#> 1 1 1.29312972 0.643721057 0 1
#> 2 2 -0.36485511 0.183155122 1 1
#> 3 2 -0.30913079 -1.707018601 0 1
#> 4 1 0.02876639 -0.837022694 1 1
#> 5 1 0.04434113 1.578807805 1 1
#> 6 1 0.82474131 1.016525466 1 1
#> 7 1 -3.41117229 0.057749321 1 1
#> 8 1 4.02383578 -0.534571781 0 1
#> 9 2 -0.54183188 1.174266153 0 1
#> 10 2 0.32003362 1.206617424 0 1
#> 11 2 1.61151882 -2.850091235 0 1
#> 12 1 -0.99763237 1.403676429 1 1
#> 13 1 1.67092863 -0.463577255 0 1
#> 14 1 -0.36884462 0.394600015 1 1
#> 15 1 -1.76634496 -2.685887784 1 1
#> 16 1 -1.46377592 -1.182388267 1 1
#> 17 1 1.59758598 -1.699532503 0 1
#> 18 1 0.19750595 0.545478853 0 1
#> 19 1 0.73294321 -0.428831871 1 1
#> 20 2 -2.54917585 0.776503701 1 1
#> 21 1 -2.20610446 -0.154363005 1 1
#> 22 2 0.42622552 -1.461104390 1 1
#> 23 2 2.00598062 1.906008451 0 1
#> 24 1 0.35504442 1.441297181 1 1
#> 25 2 1.97744008 1.153082054 0 1
#> 26 2 0.78586468 1.553896157 0 1
#> 27 1 0.91012207 -0.710830611 0 1
#> 28 2 -0.16490351 -1.913002312 0 1
#> 29 2 0.25827257 -0.458431011 0 1
#> 30 2 -0.13549093 3.317654230 1 1
#> 31 1 2.88651501 -1.562502571 0 1
#> 32 1 1.94758914 -1.719785775 0 1
#> 33 1 1.12318690 -2.512990955 1 1
#> 34 4 0.83433649 2.288907983 1 2
#> 35 3 -0.82238590 0.831278272 1 2
#> 36 3 1.66580234 2.989665397 1 2
#> 37 4 -3.91850150 -0.231181109 1 2
#> 38 4 -0.23354066 3.846612507 1 2
#> 39 3 0.65083468 1.592998717 1 2
#> 40 3 -0.57292667 1.714042318 1 2
#> 41 4 0.63628136 1.685758265 1 2
#> 42 3 1.59465299 -0.595502240 0 2
#> 43 4 1.57306893 -1.234891726 0 2
#> 44 4 -0.05715434 -0.868326937 1 2
#> 45 3 0.72922338 2.645684066 1 2
#> 46 4 2.50932392 0.199488220 1 2
#> 47 4 -0.53154175 0.564748993 1 2
#> 48 4 1.41952183 1.708061480 1 2
#> 49 4 1.97523953 1.861894613 1 2
#> 50 3 -0.44496004 0.918136417 1 2
#> 51 3 -0.58082036 -0.644070131 1 2
#> 52 3 -1.17814898 2.040691990 1 2
#> 53 3 -1.58510530 -0.106286146 0 2
#> 54 4 -1.19331214 -0.408230526 1 2
#> 55 3 -2.63441314 -3.670020044 0 2
#> 56 4 -1.03580685 0.098229962 1 2
#> 57 3 -0.83781299 -1.647763353 0 2
#> 58 4 -0.80499499 -0.949767263 0 2
#> 59 3 0.34069070 -3.095481676 0 2
#> 60 3 1.46768238 3.973398043 1 2
#> 61 4 -0.31332398 -1.730097580 0 2
#> 62 3 -2.09911569 -0.510956814 1 2
#> 63 4 0.38780593 1.179543864 1 2
#> 64 3 -0.66269918 -1.905769665 1 2
#> 65 4 0.85289979 0.813212324 0 2
#> 66 3 3.19027569 0.112658850 0 2
#> 67 6 0.63728766 0.837771632 0 3
#> 68 6 -2.52642230 0.623109598 0 3
#> 69 6 0.37410268 -2.178449653 1 3
#> 70 5 1.60925738 1.411809183 1 3
#> 71 5 3.05905389 -0.508403808 1 3
#> 72 5 0.67418067 -0.113361371 1 3
#> 73 5 2.08772107 0.060306588 1 3
#> 74 5 0.63984982 0.186451599 1 3
#> 75 5 0.16137599 -1.497648826 1 3
#> 76 5 0.03344210 1.850085097 1 3
#> 77 5 0.90541652 0.510636731 0 3
#> 78 6 -0.39397586 -0.709053723 1 3
#> 79 6 -0.79239612 1.063129591 0 3
#> 80 5 0.28822413 -2.293438072 1 3
#> 81 6 -1.71929950 0.356138018 0 3
#> 82 6 1.26927700 -1.969221370 1 3
#> 83 5 0.12257944 1.120542881 0 3
#> 84 5 -1.95767551 -2.343777652 0 3
#> 85 5 -1.41736809 0.106580039 0 3
#> 86 6 0.68151239 -0.959302155 1 3
#> 87 5 -1.28280375 -1.267793608 1 3
#> 88 5 -0.43034283 1.012867047 0 3
#> 89 6 1.34244244 1.730063691 0 3
#> 90 5 0.10095666 -2.529757114 0 3
#> 91 6 -0.24401451 -1.354222424 1 3
#> 92 5 -1.24096525 1.976450547 0 3
#> 93 6 2.81475843 1.650284617 1 3
#> 94 6 1.14966030 1.805651759 1 3
#> 95 6 1.46993504 -2.146906165 1 3
#> 96 5 1.98267149 2.074366291 1 3
#> 97 6 -1.67956624 0.004688911 0 3
#> 98 6 0.77189973 -0.116830237 1 3
#> 99 5 -2.26364975 0.662142339 1 3
#> 100 5 2.29911222 0.193384344 1 3