Skip to content

Commit

Permalink
new "meantest" behavior: try harder to handle missing values
Browse files Browse the repository at this point in the history
  • Loading branch information
AllinCottrell committed Dec 13, 2024
1 parent ea9db24 commit b44efa5
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/src/describe.c
Original file line number Diff line number Diff line change
Expand Up @@ -7014,18 +7014,20 @@ static int test_data_from_dummy (int v1, int v2,
int n2 = 0;
int t, ix, iy;

/* count the 1s in series v2 */
n2 = gretl_isdummy(dset->t1, dset->t2, dset->Z[v2]);
if (n2 < 2) {
if (!gretl_isdummy(dset->t1, dset->t2, dset->Z[v2])) {
return E_INVARG;
}

for (t=dset->t1; t<=dset->t2; t++) {
if (dset->Z[v2][t] == 0.0) {
if (na(dset->Z[v1][t])) {
continue;
} else if (dset->Z[v2][t] == 0.0) {
n1++;
} else if (dset->Z[v2][t] == 1.0) {
n2++;
}
}
if (n1 < 2) {
if (n1 < 2 || n2 < 2) {
return E_TOOFEW;
}

Expand All @@ -7038,7 +7040,9 @@ static int test_data_from_dummy (int v1, int v2,

ix = iy = 0;
for (t=dset->t1; t<=dset->t2; t++) {
if (dset->Z[v2][t] == 0.0) {
if (na(dset->Z[v1][t])) {
continue;
} else if (dset->Z[v2][t] == 0.0) {
x[ix++] = dset->Z[v1][t];
} else if (dset->Z[v2][t] == 1.0) {
y[iy++] = dset->Z[v1][t];
Expand Down

0 comments on commit b44efa5

Please sign in to comment.