|
552 | 552 |
|
553 | 553 | % Get dimensions of the data |
554 | 554 | [m, n] = size (X); |
555 | | - p = n - 1; |
556 | 555 | q = size (Y, 2); |
557 | 556 | % Check that Y contains floating point numbers |
558 | 557 | if (~ any (strcmpi (class (Y), {'single', 'double'}))) |
|
564 | 563 | X = cat (2, ones (m, 1), X); |
565 | 564 | n = n + 1; |
566 | 565 | end |
| 566 | + p = n - 1; |
567 | 567 | % Check that X contains floating point numbers |
568 | 568 | if (~ any (strcmpi (class (X), {'single', 'double'}))) |
569 | 569 | error ('bootwild: X must contain single or double precision numbers.'); |
|
1453 | 1453 | %! % Run machine learning optimized ridge regression with empirical bayes |
1454 | 1454 | %! % inference. By not assigning the output to a variable, we get results |
1455 | 1455 | %! % printed to stdout. |
| 1456 | +%! fprintf ('The bootridge function is running ...\n') |
1456 | 1457 | %! bootridge ([SAT, PPVT, Raven], MAT.X, 2, 200, .05); |
1457 | 1458 | %! |
1458 | 1459 | %! % Get the output structure stored in ans from the last function call |
1459 | 1460 | %! S = ans; |
| 1461 | +%! |
1460 | 1462 |
|
1461 | 1463 | %!demo |
1462 | 1464 | %! |
|
1470 | 1472 | %! salary = [39 46 38 44 40 57 60 54 64 57 63 56 57 57 61 68 66 83 81 94 92 ... |
1471 | 1473 | %! 98 101 114 109 106 117 113 122 122]'; |
1472 | 1474 | %! |
| 1475 | +%! fprintf ('The bootridge function is running ...\n') |
1473 | 1476 | %! bootridge (salary, years); |
1474 | 1477 | %! |
1475 | 1478 | %! % We can see from the intercept that the starting starting salary is $25.2 K |
|
1488 | 1491 | %! % coding to simple contrasts, which are centered. |
1489 | 1492 | %! MAT = bootlm (score, gender, 'nboot', 0, 'display', 'off', ... |
1490 | 1493 | %! 'dim', 1, 'posthoc', 'trt_vs_ctrl'); |
| 1494 | +%! fprintf ('The bootridge function is running ...\n') |
1491 | 1495 | %! bootridge (MAT.Y, MAT.X, 2); |
1492 | 1496 | %! |
1493 | 1497 | %! % Group means |
1494 | 1498 | %! MAT = bootlm (score, gender, 'nboot', 0, 'display', 'off', 'dim', 1); |
| 1499 | +%! fprintf ('The bootridge function is running ...\n') |
1495 | 1500 | %! bootridge (MAT.Y, MAT.X, 2, [], [], MAT.L); |
1496 | 1501 |
|
1497 | 1502 | %!demo |
|
1516 | 1521 | %! 'poly', 'dim', 2, 'posthoc', 'trt_vs_ctrl', 'nboot', 0); |
1517 | 1522 | %! |
1518 | 1523 | %! % Ridge regression and bayesian analysis of posthoc comparisons |
| 1524 | +%! fprintf ('The bootridge function is running ...\n') |
1519 | 1525 | %! bootridge (MAT.Y, MAT.X, '*', 200, 0.05, MAT.L); |
1520 | 1526 | %! |
1521 | 1527 | %! % Frequentist framework: wild bootstrap of linear model, with orthogonal |
|
1526 | 1532 | %! % Ridge regression and bayesian analysis of model estimates. Note that group- |
1527 | 1533 | %! % mean Bayes Factors are NaN under the flat prior on the intercept whereas |
1528 | 1534 | %! % the contrasts we just calculated had proper Normal priors. |
| 1535 | +%! fprintf ('The bootridge function is running ...\n') |
1529 | 1536 | %! bootridge (MAT.Y, MAT.X, '*', 200, 0.05, MAT.L); |
1530 | 1537 |
|
1531 | 1538 | %!demo |
|
1552 | 1559 | %! % Ridge regression and bayesian analysis of regression coefficients |
1553 | 1560 | %! % MAT.X: column 1 is intercept, column 2 is temp (continuous), column 3 |
1554 | 1561 | %! % is species (categorical). |
| 1562 | +%! fprintf ('The bootridge function is running ...\n') |
1555 | 1563 | %! bootridge (MAT.Y, MAT.X, 3, 200, 0.05); |
1556 | 1564 |
|
1557 | 1565 | %!demo |
|
1589 | 1597 | %! % Ridge regression and bayesian analysis of regression coefficients |
1590 | 1598 | %! % MAT.X: column 1 is intercept, column 2 is temp (continuous), column 3 |
1591 | 1599 | %! % is species (categorical). |
| 1600 | +%! fprintf ('The bootridge function is running ...\n') |
1592 | 1601 | %! bootridge (MAT.Y, MAT.X, '*', 200, 0.05); |
1593 | 1602 | %! |
1594 | 1603 | %! % Now imagine the design is repeated stimulus measurements in each rodent |
|
1602 | 1611 | %! % Ridge regression and bayesian analysis of regression coefficients |
1603 | 1612 | %! % MAT.X: column 1 is intercept, column 2 is temp (continuous), column 3 |
1604 | 1613 | %! % is species (categorical). |
| 1614 | +%! fprintf ('The bootridge function is running ...\n') |
1605 | 1615 | %! bootridge (MAT.Y, MAT.X, '*', 200, 0.05); |
1606 | 1616 |
|
1607 | 1617 | %!demo |
|
1655 | 1665 | %! |
1656 | 1666 | %! % Fit a cluster-robust empirical Bayes model using our bootstrap estimate of |
1657 | 1667 | %! % the design effect and using the hypothesis matrix to define the comparisons |
| 1668 | +%! fprintf ('The bootridge function is running ...\n') |
1658 | 1669 | %! bootridge (MAT.Y, MAT.X, '*', 200, 0.05, MAT.L, DEFF); |
1659 | 1670 | %! |
1660 | 1671 | %! % Compare this to using a maximum cluster size as an upperbound for Deff |
1661 | 1672 | %! g = max (accumarray (clustid(:), 1, [], @sum)); % g is max. cluster size |
| 1673 | +%! fprintf ('The bootridge function is running ...\n') |
1662 | 1674 | %! bootridge (MAT.Y, MAT.X, '*', 200, 0.05, MAT.L, g); % Upperbound DEFF is g |
1663 | 1675 | %! |
1664 | 1676 | %! % Note: Using the empirical DEFF (~1.5) instead of the upper-bound (4.0) |
|
0 commit comments