running ABC inside YOSYS returns ' Warning: Detected 1 multi-output gates' - abc

When using YOSYS I call abc command:
abc -liberty mycells3.lib
mycells3.lib is a simple custom technology library based on the example library provided in YOSYS distribution where I added ADDER cell (named FAX1):
library(demo) {
cell(BUF) {
area: 6;
pin(A) { direction: input; }
pin(Y) { direction: output;
function: "A"; }
}
}
cell(XOR) {
area: 0;
pin(A) { direction: input; }
pin(B) { direction: input; }
pin(Y) { direction: output;
function: "(A^B)"; }
}
cell(AND) {
area: 10;
pin(A) { direction: input; }
pin(B) { direction: input; }
pin(Y) { direction: output;
function: "A*B"; }
}
cell(NOT) {
area: 0;
pin(A) { direction: input; }
pin(Y) { direction: output;
function: "A'"; }
}
cell(DFF) {
area: 18;
ff(IQ, IQN) { clocked_on: C;
next_state: D; }
pin(C) { direction: input;
clock: true; }
pin(D) { direction: input; }
pin(Q) { direction: output;
function: "IQ"; }
}
cell(FAX1) {
area : 10;
pin(A) {direction : input; }
pin(B) {direction : input;}
pin(C) {direction : input;}
pin(S) {direction : output;
function : "((A^B)^C)";}
pin(C) {direction : output;
function : "C^((A^C)*(B^C))";}
}
}
}
When running I receive the following warning:
ABC: Warning: Detected 1 multi-output gates (for example, "FAX1")
and indeed non of my modules use this cells (which can be caused from other reasons as well, but my question is independent of this fact).
I know that the liberty format and ABC supports multiple outputs in cells. My question is how to make the YOSYS interface to ABC to accept multiple output cells?
I know this is possible because Qflow is using ABC with liberty file containing cells with multiple output, for example, in the file "osu035_stdcells.lib" we have YC and YS as output from the same cell
/* ------------- *
* Design : FAX1 *
* ------------- */
cell (FAX1) {
area : 480;
cell_leakage_power : 0.162133;
pin(A) {
direction : input;
capacitance : 0.101702;
rise_capacitance : 0.100648;
fall_capacitance : 0.101702;
}
pin(B) {
direction : input;
capacitance : 0.0912748;
rise_capacitance : 0.0912748;
fall_capacitance : 0.0860056;
}
pin(C) {
direction : input;
capacitance : 0.064336;
rise_capacitance : 0.064336;
fall_capacitance : 0.064233;
}
pin(YC) {
direction : output;
capacitance : 0;
rise_capacitance : 0;
fall_capacitance : 0;
max_capacitance : 0.405612;
function : "(((A B)+(B C))+(C A))";
timing() {
related_pin : "A";
timing_sense : positive_unate;
cell_rise(delay_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.192937, 0.202293, 0.222417, 0.23603, 0.262001", \
"0.252032, 0.261902, 0.282854, 0.297212, 0.327113", \
"0.336688, 0.345538, 0.368228, 0.382804, 0.417572", \
"0.575869, 0.585084, 0.608065, 0.623073, 0.660902", \
"0.965229, 0.974557, 0.997456, 1.01213, 1.05025");
}
rise_transition(delay_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.0816, 0.0804, 0.0879, 0.0939, 0.1068", \
"0.1503, 0.1476, 0.1527, 0.1587, 0.1722", \
"0.2637, 0.2625, 0.2661, 0.2682, 0.2817", \
"0.606, 0.606, 0.6069, 0.6087, 0.6159", \
"1.185, 1.185, 1.185, 1.1856, 1.1886");
}
cell_fall(delay_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.212316, 0.230368, 0.271993, 0.301851, 0.392584", \
"0.274262, 0.291144, 0.334346, 0.364751, 0.461587", \
"0.355791, 0.3728, 0.417563, 0.448945, 0.550937", \
"0.569312, 0.586364, 0.631171, 0.663795, 0.770166", \
"0.910578, 0.927654, 0.972381, 1.00471, 1.11225");
}
fall_transition(delay_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.0756, 0.0777, 0.0837, 0.0891, 0.105", \
"0.1362, 0.1368, 0.1386, 0.1446, 0.162", \
"0.2247, 0.2247, 0.2292, 0.2319, 0.2487", \
"0.4911, 0.4911, 0.4917, 0.4947, 0.5031", \
"0.9528, 0.9528, 0.9528, 0.9534, 0.957");
}
}
timing() {
related_pin : "B";
timing_sense : positive_unate;
cell_rise(delay_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.201655, 0.213928, 0.238544, 0.251321, 0.282216", \
"0.259034, 0.272741, 0.300326, 0.314485, 0.347352", \
"0.344335, 0.358175, 0.387437, 0.402523, 0.438405", \
"0.584089, 0.597845, 0.62806, 0.645074, 0.683716", \
"0.97336, 0.98699, 1.01703, 1.03436, 1.07543");
}
rise_transition(delay_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.0831, 0.0819, 0.0876, 0.0897, 0.0969", \
"0.15, 0.1515, 0.1563, 0.1596, 0.1704", \
"0.2637, 0.264, 0.2691, 0.2715, 0.2832", \
"0.6066, 0.6066, 0.6081, 0.6102, 0.6186", \
"1.185, 1.185, 1.185, 1.1859, 1.1907");
}
cell_fall(delay_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.221213, 0.240731, 0.285449, 0.315389, 0.41356", \
"0.283246, 0.303871, 0.352007, 0.382508, 0.482071", \
"0.366584, 0.387835, 0.439518, 0.471404, 0.573799", \
"0.583619, 0.604617, 0.657663, 0.693503, 0.801186", \
"0.925474, 0.94676, 0.999626, 1.03604, 1.14957");
}
fall_transition(delay_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.0786, 0.0768, 0.0831, 0.0906, 0.1008", \
"0.1389, 0.1404, 0.1467, 0.1485, 0.1608", \
"0.2298, 0.2289, 0.2367, 0.2424, 0.2532", \
"0.495, 0.4953, 0.4974, 0.5025, 0.5145", \
"0.9543, 0.9549, 0.9546, 0.9561, 0.966");
}
}
timing() {
related_pin : "C";
timing_sense : positive_unate;
cell_rise(delay_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.185775, 0.210399, 0.245686, 0.266778, 0.312469", \
"0.243892, 0.27024, 0.307336, 0.328971, 0.375209", \
"0.329181, 0.355023, 0.394669, 0.415937, 0.465802", \
"0.568872, 0.594357, 0.633929, 0.655734, 0.706132", \
"0.957725, 0.98325, 1.0226, 1.04421, 1.09553");
}
rise_transition(delay_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.0852, 0.0807, 0.0921, 0.0945, 0.1008", \
"0.1524, 0.1509, 0.1548, 0.1602, 0.1707", \
"0.2637, 0.2634, 0.2685, 0.2706, 0.2817", \
"0.606, 0.606, 0.606, 0.6081, 0.6135", \
"1.1841, 1.1844, 1.1841, 1.1847, 1.188");
}
cell_fall(delay_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.203317, 0.232392, 0.29518, 0.334702, 0.453856", \
"0.264792, 0.295214, 0.360803, 0.400337, 0.521061", \
"0.348261, 0.378841, 0.445571, 0.486885, 0.609869", \
"0.565673, 0.595953, 0.662919, 0.706274, 0.83131", \
"0.90777, 0.938204, 1.00512, 1.04815, 1.17621");
}
fall_transition(delay_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.0792, 0.0765, 0.0843, 0.0912, 0.1044", \
"0.1365, 0.1401, 0.1476, 0.1494, 0.162", \
"0.2298, 0.2289, 0.2343, 0.2388, 0.2496", \
"0.4947, 0.495, 0.4965, 0.4998, 0.5079", \
"0.9543, 0.9546, 0.9546, 0.9552, 0.9612");
}
}
internal_power() {
related_pin : "A";
rise_power(energy_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"-0.007976, -0.001582, 0.046036, 0.096632, 0.303378", \
"0.003901, 0.006036, 0.053579, 0.102898, 0.293237", \
"0.004187, 0.006911, 0.054089, 0.101705, 0.286621", \
"0.002743, 0.005395, 0.051254, 0.098395, 0.279569", \
"0.001821, 0.004696, 0.050175, 0.096875, 0.276158");
}
fall_power(energy_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.751435, 0.756822, 0.815911, 0.870229, 1.07082", \
"0.753113, 0.756525, 0.814098, 0.868209, 1.05967", \
"0.752309, 0.755483, 0.812912, 0.865268, 1.05629", \
"0.751447, 0.754547, 0.811504, 0.863135, 1.04992", \
"0.751138, 0.754253, 0.811014, 0.862398, 1.04726");
}
}
internal_power() {
related_pin : "B";
rise_power(energy_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.079095, 0.071988, 0.108511, 0.145461, 0.323354", \
"0.087668, 0.081948, 0.11915, 0.154305, 0.313515", \
"0.088238, 0.082519, 0.119066, 0.154328, 0.306697", \
"0.086954, 0.081108, 0.116745, 0.152259, 0.302454", \
"0.086343, 0.080371, 0.115854, 0.151083, 0.299904");
}
fall_power(energy_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.697594, 0.691911, 0.738172, 0.776694, 0.94822", \
"0.698733, 0.693453, 0.736748, 0.780343, 0.935934", \
"0.69733, 0.692467, 0.734847, 0.777073, 0.936829", \
"0.694698, 0.690931, 0.732109, 0.774157, 0.931782", \
"0.694056, 0.690307, 0.731288, 0.773142, 0.929401");
}
}
internal_power() {
related_pin : "C";
rise_power(energy_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.163673, 0.165668, 0.189463, 0.22829, 0.390871", \
"0.165439, 0.17055, 0.197339, 0.235655, 0.382059", \
"0.166138, 0.169989, 0.199144, 0.23583, 0.377468", \
"0.166578, 0.169587, 0.197806, 0.233484, 0.371962", \
"0.166896, 0.169673, 0.197451, 0.232882, 0.369249");
}
fall_power(energy_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.583181, 0.587626, 0.631498, 0.669882, 0.82487", \
"0.585184, 0.588504, 0.631341, 0.669054, 0.811996", \
"0.585161, 0.586867, 0.628181, 0.667229, 0.810344", \
"0.582139, 0.584993, 0.625643, 0.66373, 0.805293", \
"0.581744, 0.584612, 0.625012, 0.662479, 0.802606");
}
}
}
pin(YS) {
direction : output;
capacitance : 0;
rise_capacitance : 0;
fall_capacitance : 0;
max_capacitance : 0.409456;
function : "((A^B)^C)";
timing() {
related_pin : "A";
timing_sense : non_unate;
cell_rise(delay_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.311797, 0.328706, 0.370858, 0.401209, 0.489974", \
"0.367147, 0.383417, 0.426146, 0.453648, 0.544812", \
"0.446564, 0.463136, 0.505936, 0.532612, 0.62307", \
"0.679909, 0.69597, 0.739454, 0.766625, 0.856786", \
"1.06837, 1.08444, 1.12769, 1.15482, 1.24479");
}
rise_transition(delay_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.0762, 0.0753, 0.0768, 0.0777, 0.078", \
"0.1437, 0.1443, 0.1437, 0.1428, 0.1455", \
"0.2535, 0.2544, 0.2544, 0.2538, 0.2538", \
"0.5994, 0.5994, 0.5997, 0.5997, 0.6", \
"1.1832, 1.1832, 1.1829, 1.1835, 1.1832");
}
cell_fall(delay_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.299535, 0.309958, 0.329301, 0.341262, 0.363669", \
"0.357539, 0.367622, 0.38617, 0.399449, 0.421082", \
"0.434309, 0.445615, 0.464819, 0.476385, 0.49848", \
"0.644759, 0.656249, 0.67551, 0.68687, 0.70887", \
"0.985959, 0.997573, 1.01673, 1.02809, 1.04987");
}
fall_transition(delay_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.0753, 0.0756, 0.0726, 0.0774, 0.0798", \
"0.1323, 0.1299, 0.1314, 0.1329, 0.1341", \
"0.2184, 0.2187, 0.2187, 0.2184, 0.2187", \
"0.4881, 0.4881, 0.4884, 0.4887, 0.4884", \
"0.9525, 0.9525, 0.9528, 0.9531, 0.9525");
}
}
timing() {
related_pin : "B";
timing_sense : non_unate;
cell_rise(delay_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.326354, 0.343646, 0.392103, 0.426361, 0.525078", \
"0.381898, 0.400236, 0.44672, 0.478563, 0.576663", \
"0.462937, 0.480605, 0.527821, 0.559818, 0.65523", \
"0.698543, 0.715548, 0.762286, 0.793601, 0.888746", \
"1.08749, 1.10456, 1.15106, 1.18221, 1.27704");
}
rise_transition(delay_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.0774, 0.0786, 0.0801, 0.0822, 0.0807", \
"0.1482, 0.1467, 0.1479, 0.1461, 0.1464", \
"0.2568, 0.2568, 0.2571, 0.2553, 0.2547", \
"0.6012, 0.6012, 0.6012, 0.6006, 0.6003", \
"1.1838, 1.1841, 1.1841, 1.1838, 1.1838");
}
cell_fall(delay_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.311475, 0.321628, 0.34643, 0.359418, 0.388969", \
"0.368563, 0.378796, 0.403685, 0.415647, 0.443952", \
"0.446227, 0.456405, 0.482051, 0.493458, 0.521028", \
"0.656751, 0.667049, 0.692618, 0.704328, 0.731082", \
"0.998102, 1.00844, 1.03396, 1.04592, 1.07192");
}
fall_transition(delay_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.0771, 0.0768, 0.075, 0.0765, 0.0768", \
"0.1341, 0.1341, 0.1326, 0.1314, 0.1314", \
"0.219, 0.2187, 0.2178, 0.2187, 0.2172", \
"0.4881, 0.4884, 0.4881, 0.4881, 0.4875", \
"0.9531, 0.9531, 0.9528, 0.9528, 0.9522");
}
}
timing() {
related_pin : "C";
timing_sense : non_unate;
cell_rise(delay_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.322002, 0.346854, 0.408441, 0.447656, 0.560705", \
"0.376032, 0.403646, 0.463433, 0.50045, 0.613575", \
"0.455609, 0.483999, 0.542842, 0.580766, 0.69238", \
"0.690799, 0.71776, 0.777098, 0.815784, 0.926969", \
"1.07981, 1.10678, 1.16586, 1.20454, 1.31715");
}
rise_transition(delay_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.0783, 0.0798, 0.0804, 0.0753, 0.0765", \
"0.1482, 0.1461, 0.1461, 0.1443, 0.1443", \
"0.2562, 0.2568, 0.2565, 0.2565, 0.255", \
"0.6012, 0.6012, 0.6018, 0.6021, 0.603", \
"1.1844, 1.1844, 1.1841, 1.1844, 1.1862");
}
cell_fall(delay_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.296791, 0.3165, 0.344383, 0.367168, 0.404984", \
"0.350874, 0.372846, 0.399754, 0.421069, 0.455738", \
"0.424904, 0.447341, 0.475681, 0.494426, 0.531328", \
"0.632276, 0.654496, 0.683205, 0.702501, 0.738492", \
"0.973424, 0.995389, 1.02414, 1.04363, 1.07937");
}
fall_transition(delay_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.072, 0.0708, 0.0678, 0.0759, 0.0699", \
"0.1242, 0.1236, 0.1236, 0.1236, 0.1218", \
"0.2118, 0.2118, 0.2118, 0.21, 0.2106", \
"0.4839, 0.4839, 0.4842, 0.4848, 0.4839", \
"0.9513, 0.9516, 0.9519, 0.9519, 0.9519");
}
}
internal_power() {
related_pin : "A";
rise_power(energy_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.751435, 0.756822, 0.815911, 0.870229, 1.07082", \
"0.753113, 0.756525, 0.814098, 0.868209, 1.05967", \
"0.752309, 0.755483, 0.812912, 0.865268, 1.05629", \
"0.751447, 0.754547, 0.811504, 0.863135, 1.04992", \
"0.751138, 0.754253, 0.811014, 0.862398, 1.04726");
}
fall_power(energy_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"-0.007976, -0.001582, 0.046036, 0.096632, 0.303378", \
"0.003901, 0.006036, 0.053579, 0.102898, 0.293237", \
"0.004187, 0.006911, 0.054089, 0.101705, 0.286621", \
"0.002743, 0.005395, 0.051254, 0.098395, 0.279569", \
"0.001821, 0.004696, 0.050175, 0.096875, 0.276158");
}
}
internal_power() {
related_pin : "B";
rise_power(energy_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.697594, 0.691911, 0.738172, 0.776694, 0.94822", \
"0.698733, 0.693453, 0.736748, 0.780343, 0.935934", \
"0.69733, 0.692467, 0.734847, 0.777073, 0.936829", \
"0.694698, 0.690931, 0.732109, 0.774157, 0.931782", \
"0.694056, 0.690307, 0.731288, 0.773142, 0.929401");
}
fall_power(energy_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.079095, 0.071988, 0.108511, 0.145461, 0.323354", \
"0.087668, 0.081948, 0.11915, 0.154305, 0.313515", \
"0.088238, 0.082519, 0.119066, 0.154328, 0.306697", \
"0.086954, 0.081108, 0.116745, 0.152259, 0.302454", \
"0.086343, 0.080371, 0.115854, 0.151083, 0.299904");
}
}
internal_power() {
related_pin : "C";
rise_power(energy_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.583181, 0.587626, 0.631498, 0.669882, 0.82487", \
"0.585184, 0.588504, 0.631341, 0.669054, 0.811996", \
"0.585161, 0.586867, 0.628181, 0.667229, 0.810344", \
"0.582139, 0.584993, 0.625643, 0.66373, 0.805293", \
"0.581744, 0.584612, 0.625012, 0.662479, 0.802606");
}
fall_power(energy_template_5x5) {
index_1 ("0.015, 0.04, 0.08, 0.2, 0.4");
index_2 ("0.06, 0.18, 0.42, 0.6, 1.2");
values ( \
"0.163673, 0.165668, 0.189463, 0.22829, 0.390871", \
"0.165439, 0.17055, 0.197339, 0.235655, 0.382059", \
"0.166138, 0.169989, 0.199144, 0.23583, 0.377468", \
"0.166578, 0.169587, 0.197806, 0.233484, 0.371962", \
"0.166896, 0.169673, 0.197451, 0.232882, 0.369249");
}
}
}
}

Qflow only uses ABC through yosys, and like Clifford, I am not aware of ABC being able to map gates with multiple outputs. This does not have any bearing on the fact that the standard cell library contains gates with multiple outputs. Yosys handles flip-flops with multiple outputs, but that is done outside of ABC (which is combinational only). The one way around this is to write parts of your verilog code structurally; that is, you can instantiate an adder inside a verilog source file by explicitly writing out calls to FAX and HAX. Yosys will process those as "black-box" instances, without optimization, and they will otherwise be handled normally by placement and routing.

Related

for loop a non-parametric test filtered by year and save each year's result as a data frame

I'm trying to create and print a list of data frames that are the result of the Mann-Whitney-Wilcoxon Test.
My code currently runs the Mann-Whitney-Wilcoxon Test on all the observations and compares the two data frames, ORATIOS and KFMARATIOS.
library(tidyverse)
library(devtools)
library(inspectdf)
library(readr)
library(broom)
library(knitr)
library(readxl)
library(skimr)
library(kableExtra)
list_ratio <- grep("RATIO",colnames(ORATIOS), value=TRUE)
MWU_pvalues <- unlist(Map(function(a,b) wilcox.test(a, b)$p.value, ORATIOS[list_ratio], KFMARATIOS[list_ratio]))
MWU_pvalues <- as.data.frame(MWU_pvalues) %>%
rename(`P VALUE` = MWU_pvalues)
MWU_pvalues <- tibble::rownames_to_column(MWU_pvalues, "RATIO") %>%
mutate(`Significance` = if_else(`P VALUE` > 0.05, "",
if_else(`P VALUE` <= 0.05 & `P VALUE` >= 0.01, "\\*",
if_else(`P VALUE` <= 0.01 & `P VALUE` >= 0.001, "**", "***"))))
kable(MWU_pvalues) %>%
kable_styling()
How would I create a for loop or lapply filtering on each year, running the above test, saving each result as a dataframe into a list of dataframes? I'd like to have each dataframe for each year printed using kable in my RMarkdown file.
Sample data:
ORATIOS:
structure(list(YEAR = c(2008, 2009, 2010, 2011, 2012, 2013, 2014,
2015, 2016, 2017, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015,
2016, 2017), FARM = c("D", "D", "D", "D", "D", "D", "D", "D",
"D", "D", "I", "I", "I", "I", "I", "I", "I", "I", "I", "I"),
`CURRENT RATIO` = c(0.568022785746452, 0.329854720020037,
0.832073159580644, 0.643108790851367, 25.1454874121908, 14.5975395062397,
5.12537888750377, 5.20160770260219, 7.64257374037806, 2.1580962424325,
1.31703632160198, 0.125166573684741, 0.0680923398879462,
0.100452384108057, 0.0998706900125819, 0.0907309088049343,
0.521537398114045, 0.773433351511582, 0.174099653043861,
0.0804425861373205), `WORKING CAPITAL TO GROSS FARMING INCOME` = c(-0.132573843177753,
-0.419436996986394, -0.031444400685141, -0.114022796397208,
1.22962822585944, 0.397841184148093, 0.239623650110705, 0.295681875030473,
0.502930206605254, 0.41862926754376, 0.0513905118422565,
-0.406448322702947, -0.343476652794216, -0.366684678854441,
-0.27321810774102, -0.306827980132377, -0.173010159020099,
-0.140768598200492, -0.367184395657858, -0.888263538055031
), `DEBT TO TOTAL ASSET RATIO` = c(0.0846892634197993, 0.102127561711337,
0.0750728145035032, 0.0797349374471145, 0.0122514875519798,
0.0162967044282012, 0.0165670856047258, 0.0188732833402721,
0.0150968780472965, 0.0275252089477482, 0.1123291162633,
0.151496340475165, 0.0960615511639704, 0.0985641068765839,
0.119816717131179, 0.121164074695269, 0.0970056997272376,
0.139114211255347, 0.0686657852466466, 0.17098484263781),
`DEBT TO FARM ASSET RATIO` = c(0.0935832744841849, 0.114259598684054,
0.0824723632268821, 0.08365143337564, 0.0129689938858425,
0.0191316764222117, 0.0216751963945452, 0.0225358439285237,
0.0167830935834987, 0.030821228954403, 0.140068283663094,
0.203393535891141, 0.133942894025292, 0.137887444914688,
0.17818477721901, 0.182143899668642, 0.141540075268137, 0.212926916788055,
0.0962721755129152, 0.172706971368876), `EQUITY TO ASSET RATIO` = c(0.915310736580201,
0.897872438288663, 0.924927185496497, 0.920265062552885,
0.98774851244802, 0.983703295571799, 0.983432914395274, 0.981126716659728,
0.984903121952704, 0.972474791052252, 0.8876708837367, 0.848503659524835,
0.90393844883603, 0.901435893123416, 0.880183282868821, 0.878835925304732,
0.902994300272762, 0.860885788744653, 0.931334214753353,
0.82901515736219), `DEBT TO EQUITY RATIO` = c(0.0925251502415636,
0.113743954437438, 0.0811661887343104, 0.0866434472975902,
0.0124034482437396, 0.0165666868267717, 0.0168461776723358,
0.0192363361631072, 0.0153282873318188, 0.0283042904566863,
0.126543652970169, 0.178545300040313, 0.106270013503315,
0.109341227289126, 0.13612700838927, 0.137868823072129, 0.107426702137473,
0.161594270778014, 0.0737284040024573, 0.206250562633691),
`RETURN ON FARM ASSETS` = c(0.0170145283510924, -0.00522377886147693,
0.0237250420249203, 0.00257743472229431, 0.0213365859181817,
0.0244609737360482, 0.0279373354305636, 0.0167869242322396,
0.0572363957452595, -0.00273821783417637, 0.0325678749005671,
-0.0532931806283685, 0.024215521265722, -0.0178636730481072,
0.0189254399688753, 0.00211416100547258, -0.00938005681041073,
0.0501921695586829, 0.0215269026374393, -0.0366154070757298
), `RETURN ON ASSETS` = c(0.0566608458884666, 0.0239054711694685,
0.0264084815850861, 0.00576204495548541, 0.179667366138176,
0.0246773695339781, 0.0246552659101915, 0.020526505137709,
0.0551370549195115, -5.05665725060606e-05, 0.0449112877923212,
-0.0284073208306705, 0.0249952584312144, -0.00283565027536605,
0.0360687362998932, 0.0080927754538142, -0.00331579015236834,
0.0457634829675583, 0.0229640648122328, -0.023016837706958
), `RETURN ON EQUITY` = c(0.0168221490501512, -0.00520020437367425,
0.023349291367177, 0.00266962346623839, 0.0204061503508897,
0.0211814836515069, 0.0217131742563291, 0.0143291246913213,
0.0522749822883451, -0.002514608130223, 0.0294232052511338,
-0.0467824450944562, 0.0192125442012039, -0.0141654371518756,
0.0144583817182496, 0.00160025611694793, -0.00711931632857772,
0.0380917883044123, 0.0164860113123938, -0.0437269454184399
), `FARM OPERATING PROFIT MARGIN RATIO` = c(0.113108456739495,
-0.0455472105804567, 0.199838203998892, 0.0234275923606582,
0.158472105656006, 0.183710042172317, 0.190582976791897,
0.124927655425634, 0.45847835351018, -0.0422031337055503,
0.122121670323183, -0.243017854350921, 0.11277681710057,
-0.0790679940692684, 0.076084143213901, 0.00890894198839937,
-0.0450368591167229, 0.204577659697265, 0.13619384495868,
-0.358538500350435), `ASSET TURNOVER RATIO` = c(0.0153974936379558,
-0.00466912018059027, 0.0215963943475807, 0.00245676120615052,
0.0201561446538819, 0.0208362952730876, 0.0213534502396742,
0.0140586870610039, 0.0514857932558134, -0.00244539301601691,
0.0261181226076402, -0.0396950758641658, 0.0173669574034299,
-0.0127692334904846, 0.0127260258857395, 0.00140636256526249,
-0.00642870206654449, 0.0327926792191383, 0.0153539864000432,
-0.0362503005370359), `OPERATING EXPENSE RATIO` = c(0.671535228245263,
0.773166498456329, 0.607985458258, 0.724432447012029, 0.67336000606662,
0.64796797949329, 0.589032574693052, 0.74988495257417, 0.461775664398759,
0.862141471389961, 0.672863504023624, 0.980455882037588,
0.669661413731221, 0.86690216270866, 0.670033358895902, 0.737005445439968,
0.783494244501376, 0.649760819934915, 0.706382908455109,
1.134948535946), `DEPRECIATION EXPENSE RATIO` = c(0.12660532789432,
0.132732814909818, 0.103826844188336, 0.144629676126728,
0.140059287930065, 0.157478624539652, 0.141620283491016,
0.0919194664659044, 0.0583370508964949, 0.133579109920113,
0.150646135557582, 0.183514628711121, 0.146236932328879,
0.16125312788589, 0.191531747619893, 0.197293862401247, 0.193527787561396,
0.0913809290148264, 0.0946887014018637, 0.145522583536315
), `INTEREST EXPENSE RATIO` = c(0.0887509871209225, 0.139647897214309,
0.0883494935547731, 0.107510284500585, 0.028108600347309,
0.0108433537947408, 0.0787641650240354, 0.0332679255342914,
0.0214089311945663, 0.0464825523954769, 0.0543686900956105,
0.0790473436022124, 0.0713248368393299, 0.0509127034747178,
0.0623507502703033, 0.0567917501703862, 0.068014827053951,
0.0542805913529945, 0.0627345451843474, 0.0780673808681226
), `NET FARM INCOME RATIO` = c(0.113108456739495, -0.0455472105804567,
0.199838203998892, 0.0234275923606582, 0.158472105656006,
0.183710042172317, 0.190582976791897, 0.124927655425634,
0.45847835351018, -0.0422031337055503, 0.122121670323183,
-0.243017854350921, 0.11277681710057, -0.0790679940692684,
0.076084143213901, 0.00890894198839937, -0.0450368591167229,
0.204577659697265, 0.13619384495868, -0.358538500350435)), class = c("tbl_df",
"tbl", "data.frame"), row.names = c(NA, -20L))
KFMARATIOS:
structure(list(YEAR = c(2008, 2008, 2008, 2008, 2008, 2008, 2008,
2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008,
2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008,
2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008, 2008
), FARM = c(11407100, 11484600, 11485100, 11495100, 11801800,
11806400, 11820000, 11885400, 11886000, 11897200, 11897300, 12004500,
12004501, 12303001, 12340101, 12398300, 13050001, 13700201, 13705601,
14089100, 14110900, 14130000, 14130002, 14184100, 14192300, 14330302,
14388200, 14783200, 14786200, 15094200, 15096200, 15584200, 15586100,
15682100, 15683100, 15689100, 16507002, 16580000, 16598200, 16601300
), `CURRENT RATIO` = c(-3, 0, 4.57, 15.94, 2.22, 0, 368.69, 1.86,
9.1, 3.45, 2, 0, 1.58, 6.26, 1.97, 1.54, 0, 3.39, 313.09, 5.59,
5.4, 0, 3.6, 5.78, 3.18, 207.1, 2.36, 28.31, 3.4, 3.68, 0.37,
3.5, 5.6, 13.64, 7.05, 0, 2.23, 0.89, 4.4, 1.11), `WORKING CAPITAL TO GROSS FARMING INCOME` = c(0.783990044655886,
0.939342207539837, 0.468883358203084, 0.53708199556795, 0.429230789973027,
0.856616290636639, 0.46085746623408, 0.019246546772549, 1.04338230212655,
0.318770448161572, 0.398058372857175, 0.506978780306214, 0.263816960947357,
0.4960655740923, 0.101962576323424, 0.220623464476751, 1.12676140487953,
0.533690322762107, 0.685276501922026, 0.703540899065169, 0.660869855557338,
0.71777803486123, 0.319578323479609, 0.722736340214157, 0.286630301648443,
0.818610240507597, 0.184477489966846, 0.78148168000963, 0.357891811040315,
0.289159422203956, -0.125641128630768, 0.392321597654173, 0.561996673317676,
0.353452531903466, 0.683345718597063, 0.804567295215173, 0.307398272114796,
-0.375449779668313, 0.186702574682293, -0.55737251721071), `DEBT TO TOTAL ASSET RATIO` = c(0.02,
0.07, 0.27, 0.37, 0.36, 0, 0.07, 0.37, 0.05, 0.33, 0.42, 0.08,
0.24, 0.34, 0.36, 0.51, 0.01, 0.11, 0.1, 0.07, 0.08, 0.01, 0.32,
0.14, 0.4, 0.52, 0.39, 0.06, 0.21, 0.32, 0.43, 0.52, 0.29, 0.12,
0.17, 0.1, 0.15, 0.87, 0.12, 0.69), `DEBT TO FARM ASSET RATIO` = c(0.0210960466847519,
0.0662443993261916, 0.270051570315789, 0.373240578143398, 0.359031265562519,
0, 0.0678176279710153, 0.369000587598404, 0.04831743727994, 0.33065743433488,
0.41680939549244, 0.0851067276205844, 0.245359588845858, 0.337912727823456,
0.356607488633417, 0.508663012923272, 0.0126098421632802, 0.10665178903834,
0.105106247793806, 0.0698908293989529, 0.0818483764283224, 0.00750932570017385,
0.319501072718455, 0.136757510256717, 0.400840648545665, 0.516753083750126,
0.389587948103612, 0.0577299469460252, 0.206521419569117, 0.315261383020663,
0.43256943562472, 0.520491208048298, 0.290288373137576, 0.120229338185664,
0.173192986515349, 0.104536048245734, 0.151997186500475, 0.868552025800098,
0.123958600776313, 0.692195974317741), `EQUITY TO ASSET RATIO` = c(0.98536882817945,
0.944215770167283, 0.736537746555766, 0.729860554651407, 0.642228778874089,
1, 0.94228148558872, 0.630999412401596, 0.95168256272006, 0.66934256566512,
0.592693562701164, 0.914893272379416, 0.813956784138156, 0.688995447780108,
0.725420084109645, 0.545241148972386, 0.988536562104007, 0.900124825958172,
0.90344241855196, 0.930936390469265, 0.92060316189968, 0.992490674299826,
0.758518009863028, 0.881474617998699, 0.600468426703118, 0.553595877267449,
0.667405715763261, 0.942270053053975, 0.842757601135073, 0.708413078986436,
0.56743056437528, 0.533041296742996, 0.743304732269968, 0.88511363093375,
0.831970255984885, 0.904591907651469, 0.876296809602567, 0.131447974199902,
0.890119750534961, 0.307804025682259), `DEBT TO EQUITY RATIO` = c(0.02,
0.07, 0.37, 0.6, 0.56, 0, 0.07, 0.58, 0.05, 0.49, 0.72, 0.09,
0.32, 0.51, 0.55, 1.04, 0.01, 0.12, 0.12, 0.08, 0.09, 0.01, 0.47,
0.16, 0.67, 1.07, 0.64, 0.06, 0.26, 0.46, 0.76, 1.08, 0.41, 0.14,
0.21, 0.12, 0.18, 6.61, 0.14, 2.25), `RETURN ON FARM ASSETS` = c(0.374484329540697,
0.0498819566035984, 0.181954755022922, 0.193161758267218, 0.0473627311001023,
0.327305563029612, 0.603037930741254, -0.0156737997438482, 0.10397858597475,
0.10789191406389, 0.180771277730155, 0.150007797084, 0.174196776278552,
0.120122100767257, 0.298096858936563, 0.0517125227815447, 0.111597414809764,
0.185024421154621, 0.239979711875599, 0.0808784377916965, 0.201436668181771,
0.135024051506645, 0.251851638310215, 0.103285147847268, 0.14207589091784,
0.247675592658745, 0.100067311604358, 0.308209326567443, 0.154555623216289,
0.174464204907127, 0.00457531564104158, 0.098141499884622, 0.251116584438097,
0.153198476415449, 0.183688952743912, 0.0838032420725189, 0.169288085631256,
0.0279120898963428, 0.147329195543669, 0.034801030826966), `RETURN ON ASSETS` = c(0.260063898261748,
0.0581159003954688, 0.186586004612603, 0.144217266907855, 0.0471965084015535,
0.203276288956977, 0.522691591931166, -0.0156737997438482, 0.104160943214225,
0.110451790466256, 0.178360409188664, 0.150089138729099, 0.134029707705111,
0.120565772385725, 0.229528019076799, 0.0697390623585822, 0.10198296142804,
0.192570247620748, 0.245119340816501, 0.115758491252085, 0.195889106965538,
0.138158444053898, 0.231674956423303, 0.0966027636728098, 0.141766843553559,
0.215113054221126, 0.135495862386357, 0.314351616201071, 0.133076845003381,
0.168262801476855, 0.00457531564104158, 0.0986664889666124, 0.242490501823923,
0.152124266735103, 0.201716489655936, 0.0786665142081486, 0.162659186669921,
0.0279454048764536, 0.134992616527726, 0.034801030826966), `RETURN ON EQUITY` = c(0.263580248064511,
0.0444871419402714, 0.241012793134955, 0.191549228659637, 0.0734886226747657,
0.186089113513671, 0.544673844576945, -0.0248396423765173, 0.109257634896201,
0.161190875342999, 0.298045789765326, 0.163962072531003, 0.162274234481587,
0.160460729376603, 0.31640703656353, 0.0847926292565323, 0.102628180483108,
0.192493344561337, 0.244023637469295, 0.0858503015508329, 0.212255623707772,
0.13604566269794, 0.250952374400512, 0.101551944180348, 0.235835707060263,
0.386487527831846, 0.128000474163853, 0.327092350614891, 0.139632557156543,
0.227780755169442, 0.0080632167674627, 0.165179790324242, 0.298742298993181,
0.165391606109475, 0.214205739228479, 0.084552656304169, 0.157224605882577,
0.212343248849882, 0.146717984157146, 0.113062299136044), `FARM OPERATING PROFIT MARGIN RATIO` = c(0.55,
0.18, 0.29, 0.33, 0.12, 0.46, 0.24, -0.1, 0.14, 0.23, 0.2, 0.22,
0.44, 0.25, 0.33, 0.13, 0.36, 0.44, 0.33, 0.05, 0.32, 0.16, 0.52,
0.3, 0.24, 0.35, 0.2, 0.32, 0.38, 0.29, 0.02, 0.24, 0.36, 0.25,
0.4, 0.18, 0.32, -0.01, 0.08, -0.01), `ASSET TURNOVER RATIO` = c(0.64,
0.2, 0.55, 0.58, 0.29, 0.64, 1.88, 0.39, 0.31, 0.34, 0.72, 0.58,
0.38, 0.41, 0.96, 0.38, 0.26, 0.4, 0.62, 0.41, 0.55, 0.67, 0.53,
0.29, 0.51, 0.86, 0.38, 0.94, 0.4, 0.54, 0.65, 0.49, 0.7, 0.49,
0.41, 0.3, 0.47, 0.62, 0.87, 0.79), `OPERATING EXPENSE RATIO` = c(0.29,
0.57, 0.61, 0.52, 0.69, 0.48, 0.57, 0.89, 0.64, 0.57, 0.72, 0.62,
0.45, 0.55, 0.52, 0.69, 0.49, 0.43, 0.5, 0.75, 0.53, 0.69, 0.38,
0.54, 0.6, 0.54, 0.55, 0.56, 0.5, 0.57, 0.87, 0.61, 0.54, 0.63,
0.44, 0.61, 0.56, 0.82, 0.77, 0.83), `DEPRECIATION EXPENSE RATIO` = c(0.08,
0.16, 0.01, 0.05, 0.07, 0.02, 0.03, 0.09, 0.02, 0.06, 0.03, 0.1,
0.04, 0.08, 0.06, 0.1, 0.06, 0.05, 0.03, 0.04, 0.08, 0.09, 0.04,
0.06, 0.05, 0.01, 0.11, 0.05, 0.04, 0.06, 0.05, 0.08, 0.04, 0.03,
0.06, 0.08, 0.01, 0.1, 0.05, 0.04), `INTEREST EXPENSE RATIO` = c(0.01,
0, 0.03, 0.07, 0.08, 0, 0, 0.06, 0, 0.02, 0.04, 0.01, 0.02, 0.06,
0.03, 0.06, 0, 0, 0.03, 0.01, 0.02, 0, 0.06, 0.01, 0.05, 0, 0.07,
0, 0.04, 0.01, 0.08, 0.1, 0.04, 0.02, 0.03, 0.02, 0.04, 0.04,
0.01, 0.09), `NET FARM INCOME RATIO` = c(0.62, 0.27, 0.35, 0.36,
0.16, 0.5, 0.39, -0.04, 0.34, 0.35, 0.22, 0.28, 0.49, 0.31, 0.39,
0.15, 0.45, 0.51, 0.44, 0.2, 0.37, 0.21, 0.52, 0.39, 0.29, 0.45,
0.27, 0.39, 0.43, 0.36, 0.01, 0.21, 0.37, 0.32, 0.47, 0.28, 0.38,
0.05, 0.17, 0.05)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,
-40L))
My solution is kind of convuluted but I guess it is never easy to work with list columns,
nested_oratios <- ORATIOS %>%
group_by(YEAR) %>%
nest() %>%
mutate(fake_year = 2008) %>%
ungroup()
nested_kfmaratios <- KFMARATIOS %>%
group_by(YEAR) %>%
nest() %>%
mutate(fake_year = 2008) %>%
ungroup() %>%
select(-YEAR)
nested_comb <- nested_oratios %>%
left_join(nested_kfmaratios,by = c('fake_year'),suffix = c(".oratios", ".kfmaratios")) %>%
select(-fake_year)
logic_pipe <- function(a,b) {
a <- a %>% select(contains('RATIO'))
b <- b %>% select(contains('RATIO'))
MWU_pvalues <- map2(a,b,function(a,b) wilcox.test(a, b)$p.value) %>% unlist()
MWU_pvalues <- as.data.frame(MWU_pvalues) %>%
rename(`P VALUE` = MWU_pvalues)
MWU_pvalues <- tibble::rownames_to_column(MWU_pvalues, "RATIO") %>%
mutate(`Significance` = if_else(`P VALUE` > 0.05, "",
if_else(`P VALUE` <= 0.05 & `P VALUE` >= 0.01, "\\*",
if_else(`P VALUE` <= 0.01 & `P VALUE` >= 0.001, "**", "***"))))
return(MWU_pvalues %>% as_tibble())
}
nested_comb %>%
mutate(result = map2(.x = data.oratios ,.y =data.kfmaratios,logic_pipe))
Consider the apply family with mapply and by (object-oriented wrapper to tapply) that can subset your data by year and pass into a user-defined function. Note: unlist + Map can be replaced with mapply (the underlying function of Map, its wrapper). Below demonstrates with base R where transform replaces mutate and ifelse replaces if_else:
proc_df <- function(df) {
yr <- df$YEAR[1]
MWU_pvalues <- mapply(function(a,b) wilcox.test(a, b)$p.value,
subset(ORATIOS, YEAR==yr)[list_ratio], df[list_ratio])
final_df <- transform(data.frame(ratio = names(MWU_pvalues),
p_value = unname(MWU_pvalues)),
significance = ifelse(p_value > 0.05, "",
ifelse(p_value <= 0.05 & p_value >= 0.01, "*",
ifelse(p_value <= 0.01 & p_value >= 0.001, "**", "***")
)
)
)
return(final_df)
}
df_list <- by(KFMARATIOS, KFMARATIOS$YEAR, proc_df)
Output
df_list$`2008`
# ratio p_value significance
# 1 CURRENT RATIO 0.20349856
# 2 DEBT TO TOTAL ASSET RATIO 0.39154322
# 3 DEBT TO FARM ASSET RATIO 0.52264808
# 4 EQUITY TO ASSET RATIO 0.42276423
# 5 DEBT TO EQUITY RATIO 0.39162003
# 6 FARM OPERATING PROFIT MARGIN RATIO 0.11726414
# 7 ASSET TURNOVER RATIO 0.01957554 *
# 8 OPERATING EXPENSE RATIO 0.24893798
# 9 DEPRECIATION EXPENSE RATIO 0.02588258 *
# 10 INTEREST EXPENSE RATIO 0.10127823
# 11 NET FARM INCOME RATIO 0.06262773

Calculate AUC using sensitivity and specificity values

How to calculate AUC, if I have values of sensitivity and specificity for various threshold cutoffs?
I have sensitivity and specificity values for 100 thresholds.
sensitivity: c(0.649193548387097, 0.649193548387097, 0.649193548387097, 0.649193548387097,
0.649193548387097, 0.649193548387097, 0.649193548387097, 0.646586345381526,
0.646586345381526, 0.646586345381526, 0.646586345381526, 0.646586345381526,
0.646586345381526, 0.646586345381526, 0.646586345381526, 0.646586345381526,
0.644, 0.644, 0.644, 0.644, 0.641434262948207, 0.641434262948207,
0.638888888888889, 0.638888888888889, 0.638888888888889, 0.634920634920635,
0.634920634920635, 0.634920634920635, 0.634920634920635, 0.630952380952381,
0.628458498023715, 0.624505928853755, 0.620553359683794, 0.615686274509804,
0.611764705882353, 0.607843137254902, 0.607843137254902, 0.6,
0.6, 0.59765625, 0.59375, 0.5859375, 0.58203125, 0.57421875,
0.57421875, 0.56640625, 0.562015503875969, 0.550387596899225,
0.534883720930233, 0.511627906976744, 0.5, 0.496153846153846,
0.486590038314176, 0.478927203065134, 0.46360153256705, 0.455938697318008,
0.452107279693487, 0.442748091603053, 0.425855513307985, 0.418250950570342,
0.4106463878327, 0.399239543726236, 0.390151515151515, 0.382575757575758,
0.377358490566038, 0.369811320754717, 0.362264150943396, 0.354716981132075,
0.343396226415094, 0.343396226415094, 0.339622641509434, 0.328301886792453,
0.316981132075472, 0.29811320754717, 0.294339622641509, 0.286792452830189,
0.279245283018868, 0.270676691729323, 0.255639097744361, 0.244360902255639,
0.236842105263158, 0.236842105263158, 0.229323308270677, 0.225563909774436,
0.214285714285714, 0.191729323308271, 0.184210526315789, 0.176691729323308,
0.165413533834586, 0.139097744360902, 0.139097744360902, 0.12781954887218,
0.120300751879699, 0.105263157894737, 0.075187969924812, 0.0639097744360902,
0.0601503759398496, 0.0526315789473684, 0.0413533834586466, 0.018796992481203,
0)
specificity : c(0.917961165048544, 0.920581113801453, 0.923708353452438, 0.925337186897881,
0.928743379874819, 0.930288461538462, 0.93371757925072, 0.934772182254197,
0.936272160996646, 0.937739463601533, 0.938872970391595, 0.940867906533143,
0.942435775451951, 0.944893111638955, 0.946969696969697, 0.949881796690307,
0.952290977798772, 0.953235710911667, 0.955209806694955, 0.956235294117647,
0.95815702867889, 0.95868544600939, 0.961556493202063, 0.962043111527648,
0.963951310861423, 0.965420560747664, 0.966449207828518, 0.966930600838379,
0.9674569967457, 0.967951695308871, 0.967951695308871, 0.968474733426055,
0.969401947148818, 0.969401947148818, 0.969907407407407, 0.971322849213691,
0.972735674676525, 0.973684210526316, 0.97372060857538, 0.973756906077348,
0.975598526703499, 0.977000919963201, 0.977512620468105, 0.9780119102153,
0.979405034324943, 0.981235697940503, 0.98124428179323, 0.982167352537723,
0.982632541133455, 0.982648401826484, 0.983135824977211, 0.984069185252617,
0.984993178717599, 0.985467756584923, 0.985934664246824, 0.986406887177164,
0.98733604703754, 0.98869801084991, 0.98961625282167, 0.989625620207488,
0.990081154192967, 0.990085624155025, 0.990540540540541, 0.990540540540541,
0.990995047276002, 0.991449144914491, 0.991899189918992, 0.993252361673414,
0.99370220422852, 0.993707865168539, 0.993713515940727, 0.994616419919246,
0.995513683266039, 0.996410946612831, 0.996859578286227, 0.996860986547085,
0.997311827956989, 0.997315436241611, 0.997316636851521, 0.997763864042934,
0.997763864042934, 0.998211890925346, 0.998212689901698, 0.998212689901698,
0.998212689901698, 0.998214285714286, 0.998661311914324, 0.998661311914324,
0.998661311914324, 0.999107939339875, 0.999107939339875, 0.999108337048596,
0.999108337048596, 0.999108734402852, 0.999109528049866, 0.999554962171785,
1, 1, 1, 1, 1)
threshold:
c(0, 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1,
0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2, 0.21,
0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3, 0.31, 0.32,
0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.4, 0.41, 0.42, 0.43,
0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.5, 0.51, 0.52, 0.53, 0.54,
0.55, 0.56, 0.57, 0.58, 0.59, 0.6, 0.61, 0.62, 0.63, 0.64, 0.65,
0.66, 0.67, 0.68, 0.69, 0.7, 0.71, 0.72, 0.73, 0.74, 0.75, 0.76,
0.77, 0.78, 0.79, 0.8, 0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87,
0.88, 0.89, 0.9, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98,
0.99, 1)
AUC =round(sum(specificity [1:length(threshold)]*diff(c(0, 1 - sensitivity [1:length(threshold)]))),2)
AUC= 0.95
1)Is this the correct way to find AUC?
2)If I want to plot ROC curve is this code fine?
plot((1-specificity),sensitivity ,xlab = "Sensitivity",ylab = "Specificity",type = "l")
3) Is there some formula to calculate the power of this ROC analysis. So that I know I need minimum samples to calculate AUC?

How to plot truncated distributions (truncdist) with fitdistrplus?

I am attempting to plot goodness of fit curves to truncated distributions from the fitdistrplus package using its plot function.
library(fitdistrplus)
library(truncdist)
library(truncnorm)
dataNum <- c(433.6668, 413.0450, 435.9952, 449.7559, 457.3629, 498.6187, 598.0335, 637.5611, 644.9193, 634.4843, 620.8676, 590.6622, 581.6411, 572.5022, 594.0925, 587.7293, 608.4948, 626.7594, 599.0286, 611.2966, 572.1749, 545.0071, 490.0298, 478.8484, 458.8293, 437.4878, 467.7026, 477.4094, 467.4182, 519.3056, 599.0155, 648.8603, 623.0672, 606.3737, 552.3653, 558.7612, 553.1345, 549.5961, 546.0578, 565.4582, 562.6825, 606.6225, 578.1584, 572.6201, 546.4735, 514.8147, 479.4638, 462.7702, 430.3652, 452.9671)
If I use the library(truncnorm) to fit a truncated normal distribution, everything works fine.
fit.dataNormTrunc2 <- fitdist(dataNum, "truncnorm", fix.arg=list(a=min(dataNum)), start = list(mean = mean(dataNum), sd = sd(dataNum)))
plot(fit.dataNormTrunc2)
However, if I try to use the truncdist package, only the histogram comparison plot prints without any of the other plots (e.g. qq-plot). I also get an error:
Error in qtNorm(p = c(0.01, 0.03, 0.05, 0.07, 0.09, 0.11, 0.13, 0.15, :
unused argument (p = c(0.01, 0.03, 0.05, 0.07, 0.09, 0.11, 0.13, 0.15, 0.17, 0.19, 0.21, 0.23, 0.25, 0.27, 0.29, 0.31, 0.33, 0.35, 0.37, 0.39, 0.41, 0.43, 0.45, 0.47, 0.49, 0.51, 0.53, 0.55, 0.57, 0.59, 0.61, 0.63, 0.65, 0.67, 0.69, 0.71, 0.73, 0.75, 0.77, 0.79, 0.81, 0.83, 0.85, 0.87, 0.89, 0.91, 0.93, 0.95, 0.97, 0.99))
The code used is:
dtNorm <- function(x, mean, sd) {
dtrunc(x, "norm", mean, sd, a=min(dataNum), b=Inf)
}
ptNorm <- function(x, mean, sd) {
ptrunc(x, "norm", mean, sd, a=min(dataNum), b=Inf)
}
qtNorm <- function(x, mean, sd) {
qtrunc(x, "norm", mean, sd, a=min(dataNum), b=Inf)
}
fit.dataNormTrunc <- fitdist(dataNum, "tNorm", start = c(mean=mean(dataNum), sd=sd(dataNum)))
plot(fit.dataNormTrunc)
I have also tried the truncdist approach with the lognormal functionand again the other 3 plots don't print out and I get the same error about the values not being used.

Understanding and implementing numerical integration with a quantile function in R

I need to calculate this integral below, using R:
The q_theta(x) function I managed to do in R with quantile regression (package: quantreg).
matrix=structure(c(0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09,
0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2,
0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3, 0.31,
0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.4, 0.41, 0.42,
0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.5, 0.51, 0.52, 0.53,
0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.6, 0.61, 0.62, 0.63, 0.64,
0.65, 0.66, 0.67, 0.68, 0.69, 0.7, 0.71, 0.72, 0.73, 0.74, 0.75,
0.76, 0.77, 0.78, 0.79, 0.8, 0.81, 0.82, 0.83, 0.84, 0.85, 0.86,
0.87, 0.88, 0.89, 0.9, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97,
0.98, 0.99, -22.2830664155772, -22.2830664155772, -19.9298291765612,
-18.2066426767652, -15.2657135034479, -14.921522915965, -13.5035945028536,
-13.1557269916064, -12.9495709618481, -11.6168348488161, -11.3999095021713,
-10.6962766764396, -10.0588239375837, -9.12944363439522, -8.15648778610587,
-8.04133299299019, -7.66558386420434, -7.50906566627427, -6.95626096568998,
-6.90630556403136, -6.53374879831376, -6.39324677042686, -6.20705804899049,
-6.09754765999465, -5.91272058217526, -5.75771166206242, -5.3770131257001,
-5.20892464393192, -5.07372162687422, -4.96706814289334, -4.64404095131293,
-4.1567394053577, -4.13209444755342, -3.85483644113723, -3.64855238293205,
-3.53054113507559, -3.46035383338799, -3.03155417364444, -2.93100183005178,
-2.90491824855193, -2.64056616049773, -2.51857727614607, -2.25163805172486,
-2.00934783937474, -1.89925824841417, -1.71405007411747, -1.65905834683964,
-1.47502511311988, -1.42755073292529, -1.20464216637298, -1.08574103345057,
-0.701134735371922, -0.590656010656201, -0.290335898959635, -0.0575062007348038,
0.0778328375033378, 0.165234593185889, 0.230651883848336, 0.316817885358695,
0.34841775605248, 0.516869604496075, 0.59743162507581, 0.857843937404964,
0.939734010162078, 1.12533017928147, 1.27037182428776, 1.52040854525927,
1.76577933448152, 2.07456447851822, 2.17389787235523, 2.27567786362425,
2.3850323163509, 2.55365596853891, 2.61208242890655, 2.77359226593771,
2.93275094039929, 3.07968072488942, 3.0822647851901, 3.26452177629061,
3.46223321951649, 3.66011832966054, 3.85710605543097, 4.05385887531972,
4.83943843494744, 5.05864734149161, 5.25501778319145, 5.38941130574907,
5.88571117751377, 6.5116611852713, 6.98632496342285, 7.21816245728101,
7.73244825971004, 7.80401007592906, 8.34648625541999, 9.83184090479964,
10.8324874884172, 11.3060100107816, 12.3048113953808, 13.1300123358331
), .Dim = c(99L, 2L), .Dimnames = list(NULL, c("Theta", "q(x)_(Theta)"
)))
This is my q_theta(x) function that I estimated in R. One of the question I have is:
a> If x is a standard normal distribution this integral is zero; Right?
b> Otherwise, in my case, the integral is not zero. How do I treat the q_1-Theta(x)? Its simply the sort(matrix[,"q(x)_(Theta)"],decreasing=TRUE) ?
And the integration would be:
sintegral(thau[1:50], (matrix[,"q(x)_(Theta)"][1:50] - sort(matrix[,"q(x)_(Theta)"],TRUE)[1:50])[1:50])$value
The median would be a comun point of this two functions. Right?
Thanks.
Recall your previous post Building a function by defining X and Y and then Integrating in R, we build a linear interpolation function
## note `rule = 2` to enable "extrapolation";
## otherwise `rule = 1` gives `NA` outside [0.01, 0.5]
integrand <- approxfun(mat[, 1], y, rule = 2)
Then we can perform numeric integration on [0, 0.5]:
integrate(integrand, lower = 0, upper = 0.5)
# -5.594405 with absolute error < 4e-04
Now for a>, let's have a proof first.
Note, your quantile function is not for normal distribution, so this result does not hold. You can actually verify this
quant <- approxfun(mat[, 1], mat[, 2], rule = 2)
integrate(quant, lower = 0, upper = 0.5)
# -3.737973 with absolute error < 0.00029
Compared with previous integration result -5.594405, the difference is not a factor of 2.

Using apply using multiple sources of data?

I'm still in the beginning stages of R but I've gotten a few functions down and now I'm looking for my final "project."
I've created a function that takes each of my four sources of data (different populations) and creates histograms, performs kolmogorov-smirnov tests, and then graphs any significant results for a given row. What I want to do is turn it into an apply function. However, the issue is that my function takes four variables, and I don't know a way to make apply take four sources of data.
hist_fx <- function(w,x,y,z) {
hist(w,prob=TRUE,col="green",xlim=c(-1,1),ylim=c(0,3))
lines(density(w),col="red")
abline(v=c(mean(w)),col="red")
hist(x,prob=TRUE,col="blue",xlim=c(-1,1),ylim=c(0,3))
lines(density(x),col="red")
abline(v=c(mean(x)),col="red")
hist(y,prob=TRUE,col="yellow",xlim=c(-1,1),ylim=c(0,3))
lines(density(y),col="red")
abline(v=c(mean(y)),col="red")
hist(z,prob=TRUE,col="purple",xlim=c(-1,1),ylim=c(0,3))
lines(density(z),col="red")
abline(v=c(mean(z)),col="red")
all <- c(w,x,y,z)
hist(all,prob=TRUE,xlim=c(-1,0.5),ylim=c(0,3))
lines(density(w),col="purple")
lines(density(x),col="red")
lines(density(y),col="blue")
lines(density(z),col="green")
plot(ecdf(w),col="green")
plot(ecdf(x),col="blue",add=TRUE)
plot(ecdf(y),col="red",add=TRUE)
plot(ecdf(z),col="purple",add=TRUE)
t1 <- ks.test(w,x)
print(t1)
t2 <- ks.test(w,y)
print(t2)
t3 <- ks.test(w,z)
print(t3)
if(t1$p.value < 0.05) {
plot(ecdf(w),col="green")
plot(ecdf(x),col="blue",add=TRUE)
}
if(t2p.value < 0.05) {
plot(ecdf(w),col="green")
plot(ecdf(y),col="red",add=TRUE)
}
if(t3$p.value < 0.05) {
plot(ecdf(w),col="green")
plot(ecdf(z),col="purple",add=TRUE)
}
}
I'm able to use this function with apply for one population at a time (i.e. turn hist_fx into a function of one variable). However, I can't find a way to make this work for all four populations at the same time. I've messed around with some for loops, though they haven't been successful as of yet.
One last thing that might be of use: my data is arranged such that independent variables are the rows and the dependent variables are columns. Consequently, I need to run these per row (hence my idea of a for loop).
EDIT:
Here's the dput for one of the populations:
dput(k2)
structure(c(-0.15, 0.13, 0.23, -0.23, 0.06, -0.11, 0.107, 0.06,
-0.17, 0.12, 0.06, -0.25, -0.32, 0.13, 0.06, -0.2, -0.08, 0.06,
0.12, 0.02, 0.11, -0.11, -0.15, 0.097, 0.347, -0.307, 0.097,
-0.047, 0.09, 0.01, -0.217, 0.117, 0.03, -0.3, -0.33, 0.13, 0.19,
-0.24, -0.08, -0.01, 0.15, 0.61, 0.18, -0.15, -0.103, 0.135,
0.31, -0.25, 0.157, -0.105, -0.08, 0.01, -0.165, 0.17, 0.1, -0.23,
-0.28, 0.15, 0.13, -0.14, -0.06, 0.01, 0.07, -0.02, 0.11, -0.06,
-0.123, 0.13, 0.35, -0.27, 0.165, -0.065, 0.135, 0.13, -0.17,
0.135, 0.08, -0.21, -0.25, 0.2, 0.16, -0.18, NA, -0.04, 0.05,
-0.02, 0.13, -0.14, -0.13, 0.098, 0.27, -0.193, 0.062, -0.08,
0.057, 0.028, -0.199, 0.1, 0.04, -0.24, -0.32, 0.13, 0.13, -0.15,
-0.05, 0.01, 0.08, -0.04, 0.1, -0.1, -0.14, 0.154, 0.261, -0.194,
0.1, -0.129, 0.063, 0.142, -0.136, 0.136, 0.08, -0.23, -0.24,
0.12, 0.1, -0.16, -0.06, 0.04, 0.09, -0.01, 0.04, -0.08, -0.127,
0.133, 0.337, -0.06, 0.11, -0.107, 0.16, 0.167, -0.183, 0.103,
0.05, -0.2, -0.3, 0.22, -0.01, -0.17, -0.14, 0.02, 0.07, 0.01,
0.11, -0.11, -0.155, 0.221, 0.22, -0.172, 0.09, -0.15, 0.12,
0.03, -0.153, 0.146, 0.11, -0.2, -0.24, 0.16, 0.07, -0.19, -0.1,
0.03, 0.17, 0.02, 0.09, -0.16, -0.062, 0.19, 0.269, -0.265, 0.118,
-0.11, 0.126, 0.094, -0.186, 0.151, 0.08, -0.26, -0.31, 0.13,
0.09, -0.23, -0.12, 0.05, 0.13, 0.01, 0.11, -0.14, -0.095, 0.14,
0.24, -0.46, 0.09, -0.17, 0.08, 0.01, -0.24, 0.16, 0.04, -0.38,
-0.39, 0.11, 0.06, -0.31, -0.25, 0.03, 0.21, -0.14, 0, -0.22,
-0.07, 0.148, 0.311, -0.27, 0.11, -0.055, 0.16, 0.04, -0.197,
0.064, 0.09, -0.24, -0.34, 0.17, 0.07, -0.15, -0.18, 0.03, 0.13,
0.07, 0.13, -0.08, -0.136, 0.142, 0.27, -0.257, 0.1, -0.13, 0.103,
0.064, -0.197, 0.118, 0.06, -0.29, -0.35, 0.13, 0.1, -0.19, -0.13,
0.01, 0.1, -0.01, 0.13, -0.15), .Dim = c(22L, 12L))
To further clarify, here's the format of the actual data frame:
c1 c2 c3 c4
r2 x x x
r3 x x x
r4 x x x
Each column represents a star's values for the variable on the row. As such, I want to create a histogram for each row, for each dataset.
For the values of the function, I just used those variables for simplicity's sake. w = population 1, x = population 2, y = population 3, z = population 4.
As for an example:
> hist_fx(k2[1,],n2[1,],j2[1,],g2[1,])
Two-sample Kolmogorov-Smirnov test
data: w and x
D = 1, p-value = 1.229e-05
alternative hypothesis: two-sided
Two-sample Kolmogorov-Smirnov test
data: w and y
D = 1, p-value = 1.229e-05
alternative hypothesis: two-sided
Two-sample Kolmogorov-Smirnov test
data: w and z
D = 1, p-value = 1.229e-05
alternative hypothesis: two-sided
My problem is that currently, I can only run the function one row at a time. I'd like to be able to do it for all rows. I was thinking of using apply because I've used it in a very similar context except only for one source of data.
Not quite sure of your needs but consider transposing, t() to run plots column-wise for row data. And consider using mapply(), the multivariate type of the apply family which runs an operation element-wise at the same time for equal-length objects. Even break apart the operations as running them together may only print/plot the last iteration to screen.
Transpose (data used were slight variations of posted dput matrix)
pop1 <- data.frame(t(data))
pop2 <- data.frame(t(data))
pop3 <- data.frame(t(data))
pop4 <- data.frame(t(data))
Histograms
hist_fx <- function(w,x,y,z) {
whist <- hist(w,prob=TRUE,col="green",xlim=c(-1,1),ylim=c(0,3))
lines(density(w),col="red")
abline(v=c(mean(w)),col="red")
xhist <- hist(x,prob=TRUE,col="blue",xlim=c(-1,1),ylim=c(0,3))
lines(density(x),col="red")
abline(v=c(mean(x)),col="red")
yhist <- hist(y,prob=TRUE,col="yellow",xlim=c(-1,1),ylim=c(0,3))
lines(density(y),col="red")
abline(v=c(mean(y)),col="red")
zhist <- hist(z,prob=TRUE,col="purple",xlim=c(-1,1),ylim=c(0,3))
lines(density(z),col="red")
abline(v=c(mean(z)),col="red")
}
# HISTOGRAM PLOTS FOR EACH DF COLUMN
output <- mapply(hist_fx, w=pop1, x=pop2, y=pop3, z=pop4)
Kolmogorov-Smirnov tests (using slight variations of dput data)
hist_fx <- function(w,x,y,z) {
t1 <- ks.test(w,x)
t2 <- ks.test(w,y)
t3 <- ks.test(w,z)
if(t1$p.value < 0.05) {
plot(ecdf(w),col="green")
plot(ecdf(x),col="blue",add=TRUE)
}
if(t2$p.value < 0.05) {
plot(ecdf(w),col="green")
plot(ecdf(y),col="red",add=TRUE)
}
if(t3$p.value < 0.05) {
plot(ecdf(w),col="green")
plot(ecdf(z),col="purple",add=TRUE)
}
return(c(t1, t2, t3))
}
output <- mapply(hist_fx, w=pop1, x=pop2, y=pop3, z=pop4)
output
# X1
# statistic 0.1666667
# p.value 0.9962552
# alternative "two-sided"
# method "Two-sample Kolmogorov-Smirnov test"
# data.name "w and x"
# statistic 0.25
# p.value 0.8474885
# alternative "two-sided"
# method "Two-sample Kolmogorov-Smirnov test"
# data.name "w and y"
# statistic 0.08333333
# p.value 1
# alternative "two-sided"
# method "Two-sample Kolmogorov-Smirnov test"
# data.name "w and z"
# X2
# statistic 0.25
# p.value 0.8474885
# alternative "two-sided"
# method "Two-sample Kolmogorov-Smirnov test"
# data.name "w and x"
# statistic 0.08333333
# p.value 1
# alternative "two-sided"
# method "Two-sample Kolmogorov-Smirnov test"
# data.name "w and y"
# statistic 0.1666667
# p.value 0.9962552
# alternative "two-sided"
# method "Two-sample Kolmogorov-Smirnov test"
# data.name "w and z"
# ...

Resources