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.

generateData(n = 100, scenario = "tree", visualize = FALSE)

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 -2.10006528 2.435323325 0 1 #> 2 1 0.38297558 0.168057124 1 1 #> 3 1 -3.65589542 -0.200995520 1 1 #> 4 1 -0.00835693 -2.865131202 0 1 #> 5 1 0.93232908 -0.418855862 0 1 #> 6 2 1.72261741 -0.470168967 0 1 #> 7 2 -2.73272649 1.600961818 1 1 #> 8 1 -0.37098795 0.105052275 1 1 #> 9 2 -0.36629941 -0.958684986 1 1 #> 10 1 -0.42405817 -0.074947349 1 1 #> 11 1 -0.83054908 -0.377225165 0 1 #> 12 2 0.94347306 0.667195674 1 1 #> 13 1 3.09753734 4.133126363 0 1 #> 14 2 -2.44648410 0.069797071 1 1 #> 15 1 0.76864042 0.866563604 1 1 #> 16 2 -2.79451724 0.177292312 1 1 #> 17 1 -0.78301877 -2.867580737 0 1 #> 18 1 -0.07890286 1.293129723 0 1 #> 19 1 0.81449451 -0.364855109 0 1 #> 20 2 -1.37111224 -0.309130792 0 1 #> 21 1 0.70223163 0.028766388 0 1 #> 22 2 0.54442688 0.044341131 0 1 #> 23 2 -1.95681532 0.824741313 1 1 #> 24 2 1.10666448 -3.411172285 0 1 #> 25 1 2.83275739 4.023835775 0 1 #> 26 2 -0.14616766 -0.541831883 1 1 #> 27 2 -1.40377103 0.320033625 1 1 #> 28 1 -0.02392547 1.611518823 1 1 #> 29 1 -1.24018343 -0.997632373 0 1 #> 30 1 -2.26859948 1.670928628 1 1 #> 31 1 1.40304478 -0.368844618 0 1 #> 32 1 0.26473292 -1.766344963 1 1 #> 33 1 0.36552820 -1.463775924 1 1 #> 34 4 -0.44496004 0.122579444 0 2 #> 35 4 -0.58082036 -1.957675515 0 2 #> 36 4 -1.17814898 -1.417368090 0 2 #> 37 3 -1.58510530 0.681512391 0 2 #> 38 3 -1.19331214 -1.282803751 1 2 #> 39 4 -2.63441314 -0.430342828 0 2 #> 40 4 -1.03580685 1.342442438 1 2 #> 41 3 -0.83781299 0.100956660 0 2 #> 42 3 -0.80499499 -0.244014506 1 2 #> 43 3 0.34069070 -1.240965254 0 2 #> 44 4 1.46768238 2.814758432 1 2 #> 45 3 -0.31332398 1.149660298 0 2 #> 46 4 -2.09911569 1.469935043 1 2 #> 47 3 0.38780593 1.982671487 1 2 #> 48 3 -0.66269918 -1.679566243 0 2 #> 49 3 0.85289979 0.771899728 0 2 #> 50 3 3.19027569 -2.263649754 0 2 #> 51 3 0.63728766 2.299112220 1 2 #> 52 3 -2.52642230 0.643721057 1 2 #> 53 4 0.37410268 0.183155122 1 2 #> 54 3 1.60925738 -1.707018601 0 2 #> 55 3 3.05905389 -0.837022694 0 2 #> 56 4 0.67418067 1.578807805 0 2 #> 57 4 2.08772107 1.016525466 1 2 #> 58 4 0.63984982 0.057749321 1 2 #> 59 3 0.16137599 -0.534571781 1 2 #> 60 4 0.03344210 1.174266153 1 2 #> 61 4 0.90541652 1.206617424 1 2 #> 62 3 -0.39397586 -2.850091235 0 2 #> 63 3 -0.79239612 1.403676429 1 2 #> 64 4 0.28822413 -0.463577255 1 2 #> 65 3 -1.71929950 0.394600015 0 2 #> 66 4 1.26927700 -2.685887784 0 2 #> 67 6 1.86189461 -1.969221370 1 3 #> 68 6 0.91813642 1.120542881 1 3 #> 69 6 -0.64407013 -2.343777652 0 3 #> 70 5 2.04069199 0.106580039 1 3 #> 71 5 -0.10628615 -0.959302155 1 3 #> 72 5 -0.40823053 -1.267793608 0 3 #> 73 6 -3.67002004 1.012867047 0 3 #> 74 6 0.09822996 1.730063691 0 3 #> 75 6 -1.64776335 -2.529757114 1 3 #> 76 5 -0.94976726 -1.354222424 1 3 #> 77 5 -3.09548168 1.976450547 0 3 #> 78 5 3.97339804 1.650284617 1 3 #> 79 5 -1.73009758 1.805651759 0 3 #> 80 6 -0.51095681 -2.146906165 1 3 #> 81 6 1.17954386 2.074366291 0 3 #> 82 5 -1.90576967 0.004688911 1 3 #> 83 6 0.81321232 -0.116830237 1 3 #> 84 5 0.11265885 0.662142339 0 3 #> 85 5 0.83777163 0.193384344 1 3 #> 86 6 0.62310960 -1.245321391 1 3 #> 87 5 -2.17844965 -0.755389365 0 3 #> 88 6 1.41180918 -1.790461773 1 3 #> 89 5 -0.50840381 -1.127584984 0 3 #> 90 5 -0.11336137 2.183762105 0 3 #> 91 5 0.06030659 -1.242905299 1 3 #> 92 5 0.18645160 0.434661691 1 3 #> 93 5 -1.49764883 -0.720080226 0 3 #> 94 5 1.85008510 -0.907244031 0 3 #> 95 5 0.51063673 2.190165271 1 3 #> 96 5 -0.70905372 0.224519031 0 3 #> 97 6 1.06312959 -2.149981650 1 3 #> 98 6 -2.29343807 -0.015454978 0 3 #> 99 5 0.35613802 -0.318354052 1 3 #> 100 5 1.31516599 0.936198619 1 3