1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
<head>
<title>Maxima Manual: Functions and Variables for stats</title>
<meta name="description" content="Maxima Manual: Functions and Variables for stats">
<meta name="keywords" content="Maxima Manual: Functions and Variables for stats">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="maxima_toc.html#Top" rel="start" title="Top">
<link href="maxima_264.html#g_t_0423_043a_0430_0437_0430_0442_0435_043b_044c-_0444_0443_043d_043a_0446_0438_0439-_0438-_043f_0435_0440_0435_043c_0435_043d_043d_044b_0445" rel="index" title="Указатель функций и переменных">
<link href="maxima_toc.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="maxima_245.html#stats_002dpkg" rel="up" title="stats-pkg">
<link href="maxima_249.html#Functions-and-Variables-for-special-distributions" rel="next" title="Functions and Variables for special distributions">
<link href="maxima_247.html#Functions-and-Variables-for-inference_005fresult" rel="previous" title="Functions and Variables for inference_result">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
body {color: black; background: white; margin-left: 8%; margin-right: 13%;
font-family: "FreeSans", sans-serif}
h1 {font-size: 150%; font-family: "FreeSans", sans-serif}
h2 {font-size: 125%; font-family: "FreeSans", sans-serif}
h3 {font-size: 100%; font-family: "FreeSans", sans-serif}
a[href] {color: rgb(0,0,255); text-decoration: none;}
a[href]:hover {background: rgb(220,220,220);}
div.textbox {border: solid; border-width: thin; padding-top: 1em;
padding-bottom: 1em; padding-left: 2em; padding-right: 2em}
div.titlebox {border: none; padding-top: 1em; padding-bottom: 1em;
padding-left: 2em; padding-right: 2em; background: rgb(200,255,255);
font-family: sans-serif}
div.synopsisbox {
border: none; padding-top: 1em; padding-bottom: 1em; padding-left: 2em;
padding-right: 2em; background: rgb(255,220,255);}
pre.example {border: 1px solid rgb(180,180,180); padding-top: 1em;
padding-bottom: 1em; padding-left: 1em; padding-right: 1em;
background-color: rgb(238,238,255)}
div.spacerbox {border: none; padding-top: 2em; padding-bottom: 2em}
div.image {margin: 0; padding: 1em; text-align: center}
div.categorybox {border: 1px solid gray; padding-top: 1em; padding-bottom: 1em;
padding-left: 1em; padding-right: 1em; background: rgb(247,242,220)}
img {max-width:80%; max-height: 80%; display: block; margin-left: auto; margin-right: auto}
-->
</style>
<link rel="icon" href="figures/favicon.ico">
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6>"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
</head>
<body lang="ru" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Functions-and-Variables-for-stats"></a>
<div class="header">
<p>
Next: <a href="maxima_249.html#Functions-and-Variables-for-special-distributions" accesskey="n" rel="next">Functions and Variables for special distributions</a>, Previous: <a href="maxima_247.html#Functions-and-Variables-for-inference_005fresult" accesskey="p" rel="previous">Functions and Variables for inference_result</a>, Up: <a href="maxima_245.html#stats_002dpkg" accesskey="u" rel="up">stats-pkg</a> [<a href="maxima_toc.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="maxima_264.html#g_t_0423_043a_0430_0437_0430_0442_0435_043b_044c-_0444_0443_043d_043a_0446_0438_0439-_0438-_043f_0435_0440_0435_043c_0435_043d_043d_044b_0445" title="Index" rel="index">Index</a>]</p>
</div>
<a name="Functions-and-Variables-for-stats-1"></a>
<h3 class="section">69.3 Functions and Variables for stats</h3>
<a name="stats_005fnumer"></a><a name="Item_003a-stats_002fdefvr_002fstats_005fnumer"></a><dl>
<dt><a name="index-stats_005fnumer"></a>Option variable: <strong>stats_numer</strong></dt>
<dd><p>Default value: <code>true</code>
</p>
<p>If <code>stats_numer</code> is <code>true</code>, inference statistical functions
return their results in floating point numbers. If it is <code>false</code>,
results are given in symbolic and rational format.
</p>
</dd></dl>
<a name="test_005fmean"></a><a name="Item_003a-stats_002fdeffn_002ftest_005fmean"></a><dl>
<dt><a name="index-test_005fmean"></a>Function: <strong>test_mean</strong> <em><br> <tt>test_mean</tt> (<var>x</var>) <br> <tt>test_mean</tt> (<var>x</var>, <var>options</var> ...)</em></dt>
<dd>
<p>This is the mean <var>t</var>-test. Argument <var>x</var> is a list or a column matrix
containing an one dimensional sample. It also performs an asymptotic test
based on the <i>Central Limit Theorem</i> if option <code>'asymptotic</code> is
<code>true</code>.
</p>
<p>Options:
</p>
<ul>
<li> <code>'mean</code>, default <code>0</code>, is the mean value to be checked.
</li><li> <code>'alternative</code>, default <code>'twosided</code>, is the alternative hypothesis;
valid values are: <code>'twosided</code>, <code>'greater</code> and <code>'less</code>.
</li><li> <code>'dev</code>, default <code>'unknown</code>, this is the value of the standard deviation when it is
known; valid values are: <code>'unknown</code> or a positive expression.
</li><li> <code>'conflevel</code>, default <code>95/100</code>, confidence level for the confidence interval; it must
be an expression which takes a value in (0,1).
</li><li> <code>'asymptotic</code>, default <code>false</code>, indicates whether it performs an exact <var>t</var>-test or
an asymptotic one based on the <i>Central Limit Theorem</i>;
valid values are <code>true</code> and <code>false</code>.
</li></ul>
<p>The output of function <code>test_mean</code> is an <code>inference_result</code> Maxima object
showing the following results:
</p>
<ol>
<li> <code>'mean_estimate</code>: the sample mean.
</li><li> <code>'conf_level</code>: confidence level selected by the user.
</li><li> <code>'conf_interval</code>: confidence interval for the population mean.
</li><li> <code>'method</code>: inference procedure.
</li><li> <code>'hypotheses</code>: null and alternative hypotheses to be tested.
</li><li> <code>'statistic</code>: value of the sample statistic used for testing the null hypothesis.
</li><li> <code>'distribution</code>: distribution of the sample statistic, together with its parameter(s).
</li><li> <code>'p_value</code>: <em>p</em>-value of the test.
</li></ol>
<p>Examples:
</p>
<p>Performs an exact <var>t</var>-test with unknown variance. The null hypothesis
is <em>H_0: mean=50</em> against the one sided alternative <em>H_1: mean<50</em>;
according to the results, the <em>p</em>-value is too great, there are no
evidence for rejecting <em>H_0</em>.
</p>
<div class="example">
<pre class="example">(%i1) load("stats")$
(%i2) data: [78,64,35,45,45,75,43,74,42,42]$
(%i3) test_mean(data,'conflevel=0.9,'alternative='less,'mean=50);
| MEAN TEST
|
| mean_estimate = 54.3
|
| conf_level = 0.9
|
| conf_interval = [minf, 61.51314273502712]
|
(%o3) | method = Exact t-test. Unknown variance.
|
| hypotheses = H0: mean = 50 , H1: mean < 50
|
| statistic = .8244705235071678
|
| distribution = [student_t, 9]
|
| p_value = .7845100411786889
</pre></div>
<p>This time Maxima performs an asymptotic test, based on the <i>Central Limit Theorem</i>.
The null hypothesis is <em>H_0: equal(mean, 50)</em> against the two sided alternative <em>H_1: not equal(mean, 50)</em>;
according to the results, the <em>p</em>-value is very small, <em>H_0</em> should be rejected in
favor of the alternative <em>H_1</em>. Note that, as indicated by the <code>Method</code> component,
this procedure should be applied to large samples.
</p>
<div class="example">
<pre class="example">(%i1) load("stats")$
(%i2) test_mean([36,118,52,87,35,256,56,178,57,57,89,34,25,98,35,
98,41,45,198,54,79,63,35,45,44,75,42,75,45,45,
45,51,123,54,151],
'asymptotic=true,'mean=50);
| MEAN TEST
|
| mean_estimate = 74.88571428571429
|
| conf_level = 0.95
|
| conf_interval = [57.72848600856194, 92.04294256286663]
|
(%o2) | method = Large sample z-test. Unknown variance.
|
| hypotheses = H0: mean = 50 , H1: mean # 50
|
| statistic = 2.842831192874313
|
| distribution = [normal, 0, 1]
|
| p_value = .004471474652002261
</pre></div>
</dd></dl>
<a name="test_005fmeans_005fdifference"></a><a name="Item_003a-stats_002fdeffn_002ftest_005fmeans_005fdifference"></a><dl>
<dt><a name="index-test_005fmeans_005fdifference"></a>Function: <strong>test_means_difference</strong> <em><br> <tt>test_means_difference</tt> (<var>x1</var>, <var>x2</var>) <br> <tt>test_means_difference</tt> (<var>x1</var>, <var>x2</var>, <var>options</var> ...)</em></dt>
<dd>
<p>This is the difference of means <var>t</var>-test for two samples.
Arguments <var>x1</var> and <var>x2</var> are lists or column matrices
containing two independent samples. In case of different unknown variances
(see options <code>'dev1</code>, <code>'dev2</code> and <code>'varequal</code> bellow),
the degrees of freedom are computed by means of the Welch approximation.
It also performs an asymptotic test
based on the <i>Central Limit Theorem</i> if option <code>'asymptotic</code> is
set to <code>true</code>.
</p>
<p>Options:
</p>
<ul>
<li> <code>'alternative</code>, default <code>'twosided</code>, is the alternative hypothesis;
valid values are: <code>'twosided</code>, <code>'greater</code> and <code>'less</code>.
</li><li> <code>'dev1</code>, default <code>'unknown</code>, this is the value of the standard deviation
of the <var>x1</var> sample when it is known; valid values are: <code>'unknown</code> or a positive expression.
</li><li> <code>'dev2</code>, default <code>'unknown</code>, this is the value of the standard deviation
of the <var>x2</var> sample when it is known; valid values are: <code>'unknown</code> or a positive expression.
</li><li> <code>'varequal</code>, default <code>false</code>, whether variances should be considered to be equal or not;
this option takes effect only when <code>'dev1</code> and/or <code>'dev2</code> are <code>'unknown</code>.
</li><li> <code>'conflevel</code>, default <code>95/100</code>, confidence level for the confidence interval; it must
be an expression which takes a value in (0,1).
</li><li> <code>'asymptotic</code>, default <code>false</code>, indicates whether it performs an exact <var>t</var>-test or
an asymptotic one based on the <i>Central Limit Theorem</i>;
valid values are <code>true</code> and <code>false</code>.
</li></ul>
<p>The output of function <code>test_means_difference</code> is an <code>inference_result</code> Maxima object
showing the following results:
</p>
<ol>
<li> <code>'diff_estimate</code>: the difference of means estimate.
</li><li> <code>'conf_level</code>: confidence level selected by the user.
</li><li> <code>'conf_interval</code>: confidence interval for the difference of means.
</li><li> <code>'method</code>: inference procedure.
</li><li> <code>'hypotheses</code>: null and alternative hypotheses to be tested.
</li><li> <code>'statistic</code>: value of the sample statistic used for testing the null hypothesis.
</li><li> <code>'distribution</code>: distribution of the sample statistic, together with its parameter(s).
</li><li> <code>'p_value</code>: <em>p</em>-value of the test.
</li></ol>
<p>Examples:
</p>
<p>The equality of means is tested with two small samples <var>x</var> and <var>y</var>,
against the alternative <em>H_1: m_1>m_2</em>, being <em>m_1</em> and <em>m_2</em>
the populations means; variances are unknown and supposed to be different.
</p>
<div class="example">
<pre class="example">(%i1) load("stats")$
(%i2) x: [20.4,62.5,61.3,44.2,11.1,23.7]$
(%i3) y: [1.2,6.9,38.7,20.4,17.2]$
(%i4) test_means_difference(x,y,'alternative='greater);
| DIFFERENCE OF MEANS TEST
|
| diff_estimate = 20.31999999999999
|
| conf_level = 0.95
|
| conf_interval = [- .04597417812882298, inf]
|
(%o4) | method = Exact t-test. Welch approx.
|
| hypotheses = H0: mean1 = mean2 , H1: mean1 > mean2
|
| statistic = 1.838004300728477
|
| distribution = [student_t, 8.62758740184604]
|
| p_value = .05032746527991905
</pre></div>
<p>The same test as before, but now variances are supposed to be
equal.
</p>
<div class="example">
<pre class="example">(%i1) load("stats")$
(%i2) x: [20.4,62.5,61.3,44.2,11.1,23.7]$
(%i3) y: matrix([1.2],[6.9],[38.7],[20.4],[17.2])$
(%i4) test_means_difference(x,y,'alternative='greater,
'varequal=true);
| DIFFERENCE OF MEANS TEST
|
| diff_estimate = 20.31999999999999
|
| conf_level = 0.95
|
| conf_interval = [- .7722627696897568, inf]
|
(%o4) | method = Exact t-test. Unknown equal variances
|
| hypotheses = H0: mean1 = mean2 , H1: mean1 > mean2
|
| statistic = 1.765996124515009
|
| distribution = [student_t, 9]
|
| p_value = .05560320992529344
</pre></div>
</dd></dl>
<a name="test_005fvariance"></a><a name="Item_003a-stats_002fdeffn_002ftest_005fvariance"></a><dl>
<dt><a name="index-test_005fvariance"></a>Function: <strong>test_variance</strong> <em><br> <tt>test_variance</tt> (<var>x</var>) <br> <tt>test_variance</tt> (<var>x</var>, <var>options</var>, ...)</em></dt>
<dd>
<p>This is the variance <var>chi^2</var>-test. Argument <var>x</var> is a list or a column matrix
containing an one dimensional sample taken from a normal population.
</p>
<p>Options:
</p>
<ul>
<li> <code>'mean</code>, default <code>'unknown</code>, is the population’s mean, when it is known.
</li><li> <code>'alternative</code>, default <code>'twosided</code>, is the alternative hypothesis;
valid values are: <code>'twosided</code>, <code>'greater</code> and <code>'less</code>.
</li><li> <code>'variance</code>, default <code>1</code>, this is the variance value (positive) to be checked.
</li><li> <code>'conflevel</code>, default <code>95/100</code>, confidence level for the confidence interval; it must
be an expression which takes a value in (0,1).
</li></ul>
<p>The output of function <code>test_variance</code> is an <code>inference_result</code> Maxima object
showing the following results:
</p>
<ol>
<li> <code>'var_estimate</code>: the sample variance.
</li><li> <code>'conf_level</code>: confidence level selected by the user.
</li><li> <code>'conf_interval</code>: confidence interval for the population variance.
</li><li> <code>'method</code>: inference procedure.
</li><li> <code>'hypotheses</code>: null and alternative hypotheses to be tested.
</li><li> <code>'statistic</code>: value of the sample statistic used for testing the null hypothesis.
</li><li> <code>'distribution</code>: distribution of the sample statistic, together with its parameter.
</li><li> <code>'p_value</code>: <em>p</em>-value of the test.
</li></ol>
<p>Examples:
</p>
<p>It is tested whether the variance of a population with unknown mean
is equal to or greater than 200.
</p>
<div class="example">
<pre class="example">(%i1) load("stats")$
(%i2) x: [203,229,215,220,223,233,208,228,209]$
(%i3) test_variance(x,'alternative='greater,'variance=200);
| VARIANCE TEST
|
| var_estimate = 110.75
|
| conf_level = 0.95
|
| conf_interval = [57.13433376937479, inf]
|
(%o3) | method = Variance Chi-square test. Unknown mean.
|
| hypotheses = H0: var = 200 , H1: var > 200
|
| statistic = 4.43
|
| distribution = [chi2, 8]
|
| p_value = .8163948512777689
</pre></div>
</dd></dl>
<a name="test_005fvariance_005fratio"></a><a name="Item_003a-stats_002fdeffn_002ftest_005fvariance_005fratio"></a><dl>
<dt><a name="index-test_005fvariance_005fratio"></a>Function: <strong>test_variance_ratio</strong> <em><br> <tt>test_variance_ratio</tt> (<var>x1</var>, <var>x2</var>) <br> <tt>test_variance_ratio</tt> (<var>x1</var>, <var>x2</var>, <var>options</var> ...)</em></dt>
<dd>
<p>This is the variance ratio <var>F</var>-test for two normal populations.
Arguments <var>x1</var> and <var>x2</var> are lists or column matrices
containing two independent samples.
</p>
<p>Options:
</p>
<ul>
<li> <code>'alternative</code>, default <code>'twosided</code>, is the alternative hypothesis;
valid values are: <code>'twosided</code>, <code>'greater</code> and <code>'less</code>.
</li><li> <code>'mean1</code>, default <code>'unknown</code>, when it is known, this is the mean of
the population from which <var>x1</var> was taken.
</li><li> <code>'mean2</code>, default <code>'unknown</code>, when it is known, this is the mean of
the population from which <var>x2</var> was taken.
</li><li> <code>'conflevel</code>, default <code>95/100</code>, confidence level for the confidence interval of the
ratio; it must be an expression which takes a value in (0,1).
</li></ul>
<p>The output of function <code>test_variance_ratio</code> is an <code>inference_result</code> Maxima object
showing the following results:
</p>
<ol>
<li> <code>'ratio_estimate</code>: the sample variance ratio.
</li><li> <code>'conf_level</code>: confidence level selected by the user.
</li><li> <code>'conf_interval</code>: confidence interval for the variance ratio.
</li><li> <code>'method</code>: inference procedure.
</li><li> <code>'hypotheses</code>: null and alternative hypotheses to be tested.
</li><li> <code>'statistic</code>: value of the sample statistic used for testing the null hypothesis.
</li><li> <code>'distribution</code>: distribution of the sample statistic, together with its parameters.
</li><li> <code>'p_value</code>: <em>p</em>-value of the test.
</li></ol>
<p>Examples:
</p>
<p>The equality of the variances of two normal populations is checked
against the alternative that the first is greater than the second.
</p>
<div class="example">
<pre class="example">(%i1) load("stats")$
(%i2) x: [20.4,62.5,61.3,44.2,11.1,23.7]$
(%i3) y: [1.2,6.9,38.7,20.4,17.2]$
(%i4) test_variance_ratio(x,y,'alternative='greater);
| VARIANCE RATIO TEST
|
| ratio_estimate = 2.316933391522034
|
| conf_level = 0.95
|
| conf_interval = [.3703504689507268, inf]
|
(%o4) | method = Variance ratio F-test. Unknown means.
|
| hypotheses = H0: var1 = var2 , H1: var1 > var2
|
| statistic = 2.316933391522034
|
| distribution = [f, 5, 4]
|
| p_value = .2179269692254457
</pre></div>
</dd></dl>
<a name="test_005fproportion"></a><a name="Item_003a-stats_002fdeffn_002ftest_005fproportion"></a><dl>
<dt><a name="index-test_005fproportion"></a>Function: <strong>test_proportion</strong> <em><br> <tt>test_proportion</tt> (<var>x</var>, <var>n</var>) <br> <tt>test_proportion</tt> (<var>x</var>, <var>n</var>, <var>options</var> ...)</em></dt>
<dd>
<p>Inferences on a proportion. Argument <var>x</var> is the number of successes
in <var>n</var> trials in a Bernoulli experiment with unknown probability.
</p>
<p>Options:
</p>
<ul>
<li> <code>'proportion</code>, default <code>1/2</code>, is the value of the proportion to be checked.
</li><li> <code>'alternative</code>, default <code>'twosided</code>, is the alternative hypothesis;
valid values are: <code>'twosided</code>, <code>'greater</code> and <code>'less</code>.
</li><li> <code>'conflevel</code>, default <code>95/100</code>, confidence level for the confidence interval; it must
be an expression which takes a value in (0,1).
</li><li> <code>'asymptotic</code>, default <code>false</code>, indicates whether it performs an exact test
based on the binomial distribution, or an asymptotic one based on the <i>Central Limit Theorem</i>;
valid values are <code>true</code> and <code>false</code>.
</li><li> <code>'correct</code>, default <code>true</code>, indicates whether Yates correction is applied or not.
</li></ul>
<p>The output of function <code>test_proportion</code> is an <code>inference_result</code> Maxima object
showing the following results:
</p>
<ol>
<li> <code>'sample_proportion</code>: the sample proportion.
</li><li> <code>'conf_level</code>: confidence level selected by the user.
</li><li> <code>'conf_interval</code>: Wilson confidence interval for the proportion.
</li><li> <code>'method</code>: inference procedure.
</li><li> <code>'hypotheses</code>: null and alternative hypotheses to be tested.
</li><li> <code>'statistic</code>: value of the sample statistic used for testing the null hypothesis.
</li><li> <code>'distribution</code>: distribution of the sample statistic, together with its parameters.
</li><li> <code>'p_value</code>: <em>p</em>-value of the test.
</li></ol>
<p>Examples:
</p>
<p>Performs an exact test. The null hypothesis
is <em>H_0: p=1/2</em> against the one sided alternative <em>H_1: p<1/2</em>.
</p>
<div class="example">
<pre class="example">(%i1) load("stats")$
(%i2) test_proportion(45, 103, alternative = less);
| PROPORTION TEST
|
| sample_proportion = .4368932038834951
|
| conf_level = 0.95
|
| conf_interval = [0, 0.522714149150231]
|
(%o2) | method = Exact binomial test.
|
| hypotheses = H0: p = 0.5 , H1: p < 0.5
|
| statistic = 45
|
| distribution = [binomial, 103, 0.5]
|
| p_value = .1184509388901454
</pre></div>
<p>A two sided asymptotic test. Confidence level is 99/100.
</p>
<div class="example">
<pre class="example">(%i1) load("stats")$
(%i2) fpprintprec:7$
(%i3) test_proportion(45, 103,
conflevel = 99/100, asymptotic=true);
| PROPORTION TEST
|
| sample_proportion = .43689
|
| conf_level = 0.99
|
| conf_interval = [.31422, .56749]
|
(%o3) | method = Asympthotic test with Yates correction.
|
| hypotheses = H0: p = 0.5 , H1: p # 0.5
|
| statistic = .43689
|
| distribution = [normal, 0.5, .048872]
|
| p_value = .19662
</pre></div>
</dd></dl>
<a name="test_005fproportions_005fdifference"></a><a name="Item_003a-stats_002fdeffn_002ftest_005fproportions_005fdifference"></a><dl>
<dt><a name="index-test_005fproportions_005fdifference"></a>Function: <strong>test_proportions_difference</strong> <em><br> <tt>test_proportions_difference</tt> (<var>x1</var>, <var>n1</var>, <var>x2</var>, <var>n2</var>) <br> <tt>test_proportions_difference</tt> (<var>x1</var>, <var>n1</var>, <var>x2</var>, <var>n2</var>, <var>options</var> …)</em></dt>
<dd>
<p>Inferences on the difference of two proportions. Argument <var>x1</var> is the number of successes
in <var>n1</var> trials in a Bernoulli experiment in the first population, and <var>x2</var> and <var>n2</var>
are the corresponding values in the second population. Samples are independent and the test
is asymptotic.
</p>
<p>Options:
</p>
<ul>
<li> <code>'alternative</code>, default <code>'twosided</code>, is the alternative hypothesis;
valid values are: <code>'twosided</code> (<code>p1 # p2</code>), <code>'greater</code> (<code>p1 > p2</code>)
and <code>'less</code> (<code>p1 < p2</code>).
</li><li> <code>'conflevel</code>, default <code>95/100</code>, confidence level for the confidence interval; it must
be an expression which takes a value in (0,1).
</li><li> <code>'correct</code>, default <code>true</code>, indicates whether Yates correction is applied or not.
</li></ul>
<p>The output of function <code>test_proportions_difference</code> is an <code>inference_result</code> Maxima object
showing the following results:
</p>
<ol>
<li> <code>'proportions</code>: list with the two sample proportions.
</li><li> <code>'conf_level</code>: confidence level selected by the user.
</li><li> <code>'conf_interval</code>: Confidence interval for the difference of proportions <code>p1 - p2</code>.
</li><li> <code>'method</code>: inference procedure and warning message in case of any of the samples sizes
is less than 10.
</li><li> <code>'hypotheses</code>: null and alternative hypotheses to be tested.
</li><li> <code>'statistic</code>: value of the sample statistic used for testing the null hypothesis.
</li><li> <code>'distribution</code>: distribution of the sample statistic, together with its parameters.
</li><li> <code>'p_value</code>: <em>p</em>-value of the test.
</li></ol>
<p>Examples:
</p>
<p>A machine produced 10 defective articles in a batch of 250.
After some maintenance work, it produces 4 defective in a batch of 150.
In order to know if the machine has improved, we test the null
hypothesis <code>H0:p1=p2</code>, against the alternative <code>H0:p1>p2</code>,
where <code>p1</code> and <code>p2</code> are the probabilities for one produced
article to be defective before and after maintenance. According to
the p value, there is not enough evidence to accept the alternative.
</p>
<div class="example">
<pre class="example">(%i1) load("stats")$
(%i2) fpprintprec:7$
(%i3) test_proportions_difference(10, 250, 4, 150,
alternative = greater);
| DIFFERENCE OF PROPORTIONS TEST
|
| proportions = [0.04, .02666667]
|
| conf_level = 0.95
|
| conf_interval = [- .02172761, 1]
|
(%o3) | method = Asymptotic test. Yates correction.
|
| hypotheses = H0: p1 = p2 , H1: p1 > p2
|
| statistic = .01333333
|
| distribution = [normal, 0, .01898069]
|
| p_value = .2411936
</pre></div>
<p>Exact standard deviation of the asymptotic normal
distribution when the data are unknown.
</p>
<div class="example">
<pre class="example">(%i1) load("stats")$
(%i2) stats_numer: false$
(%i3) sol: test_proportions_difference(x1,n1,x2,n2)$
(%i4) last(take_inference('distribution,sol));
1 1 x2 + x1
(-- + --) (x2 + x1) (1 - -------)
n2 n1 n2 + n1
(%o4) sqrt(---------------------------------)
n2 + n1
</pre></div>
</dd></dl>
<a name="test_005fsign"></a><a name="Item_003a-stats_002fdeffn_002ftest_005fsign"></a><dl>
<dt><a name="index-test_005fsign"></a>Function: <strong>test_sign</strong> <em><br> <tt>test_sign</tt> (<var>x</var>) <br> <tt>test_sign</tt> (<var>x</var>, <var>options</var> …)</em></dt>
<dd>
<p>This is the non parametric sign test for the median of a continuous population.
Argument <var>x</var> is a list or a column matrix containing an one dimensional sample.
</p>
<p>Options:
</p>
<ul>
<li> <code>'alternative</code>, default <code>'twosided</code>, is the alternative hypothesis;
valid values are: <code>'twosided</code>, <code>'greater</code> and <code>'less</code>.
</li><li> <code>'median</code>, default <code>0</code>, is the median value to be checked.
</li></ul>
<p>The output of function <code>test_sign</code> is an <code>inference_result</code> Maxima object
showing the following results:
</p>
<ol>
<li> <code>'med_estimate</code>: the sample median.
</li><li> <code>'method</code>: inference procedure.
</li><li> <code>'hypotheses</code>: null and alternative hypotheses to be tested.
</li><li> <code>'statistic</code>: value of the sample statistic used for testing the null hypothesis.
</li><li> <code>'distribution</code>: distribution of the sample statistic, together with its parameter(s).
</li><li> <code>'p_value</code>: <em>p</em>-value of the test.
</li></ol>
<p>Examples:
</p>
<p>Checks whether the population from which the sample was taken has median 6,
against the alternative <em>H_1: median > 6</em>.
</p>
<div class="example">
<pre class="example">(%i1) load("stats")$
(%i2) x: [2,0.1,7,1.8,4,2.3,5.6,7.4,5.1,6.1,6]$
(%i3) test_sign(x,'median=6,'alternative='greater);
| SIGN TEST
|
| med_estimate = 5.1
|
| method = Non parametric sign test.
|
(%o3) | hypotheses = H0: median = 6 , H1: median > 6
|
| statistic = 7
|
| distribution = [binomial, 10, 0.5]
|
| p_value = .05468749999999989
</pre></div>
</dd></dl>
<a name="test_005fsigned_005frank"></a><a name="Item_003a-stats_002fdeffn_002ftest_005fsigned_005frank"></a><dl>
<dt><a name="index-test_005fsigned_005frank"></a>Function: <strong>test_signed_rank</strong> <em><br> <tt>test_signed_rank</tt> (<var>x</var>) <br> <tt>test_signed_rank</tt> (<var>x</var>, <var>options</var> …)</em></dt>
<dd>
<p>This is the Wilcoxon signed rank test to make inferences about the median of a
continuous population. Argument <var>x</var> is a list or a column matrix
containing an one dimensional sample. Performs normal approximation if the
sample size is greater than 20, or if there are zeroes or ties.
</p>
<p>See also <code>pdf_rank_test</code> and <code>cdf_rank_test</code>
</p>
<p>Options:
</p>
<ul>
<li> <code>'median</code>, default <code>0</code>, is the median value to be checked.
</li><li> <code>'alternative</code>, default <code>'twosided</code>, is the alternative hypothesis;
valid values are: <code>'twosided</code>, <code>'greater</code> and <code>'less</code>.
</li></ul>
<p>The output of function <code>test_signed_rank</code> is an <code>inference_result</code> Maxima object
with the following results:
</p>
<ol>
<li> <code>'med_estimate</code>: the sample median.
</li><li> <code>'method</code>: inference procedure.
</li><li> <code>'hypotheses</code>: null and alternative hypotheses to be tested.
</li><li> <code>'statistic</code>: value of the sample statistic used for testing the null hypothesis.
</li><li> <code>'distribution</code>: distribution of the sample statistic, together with its parameter(s).
</li><li> <code>'p_value</code>: <em>p</em>-value of the test.
</li></ol>
<p>Examples:
</p>
<p>Checks the null hypothesis <em>H_0: median = 15</em> against the
alternative <em>H_1: median > 15</em>. This is an exact test, since
there are no ties.
</p>
<div class="example">
<pre class="example">(%i1) load("stats")$
(%i2) x: [17.1,15.9,13.7,13.4,15.5,17.6]$
(%i3) test_signed_rank(x,median=15,alternative=greater);
| SIGNED RANK TEST
|
| med_estimate = 15.7
|
| method = Exact test
|
(%o3) | hypotheses = H0: med = 15 , H1: med > 15
|
| statistic = 14
|
| distribution = [signed_rank, 6]
|
| p_value = 0.28125
</pre></div>
<p>Checks the null hypothesis <em>H_0: equal(median, 2.5)</em> against the
alternative <em>H_1: not equal(median, 2.5)</em>. This is an approximated test,
since there are ties.
</p>
<div class="example">
<pre class="example">(%i1) load("stats")$
(%i2) y:[1.9,2.3,2.6,1.9,1.6,3.3,4.2,4,2.4,2.9,1.5,3,2.9,4.2,3.1]$
(%i3) test_signed_rank(y,median=2.5);
| SIGNED RANK TEST
|
| med_estimate = 2.9
|
| method = Asymptotic test. Ties
|
(%o3) | hypotheses = H0: med = 2.5 , H1: med # 2.5
|
| statistic = 76.5
|
| distribution = [normal, 60.5, 17.58195097251724]
|
| p_value = .3628097734643669
</pre></div>
</dd></dl>
<a name="test_005frank_005fsum"></a><a name="Item_003a-stats_002fdeffn_002ftest_005frank_005fsum"></a><dl>
<dt><a name="index-test_005frank_005fsum"></a>Function: <strong>test_rank_sum</strong> <em><br> <tt>test_rank_sum</tt> (<var>x1</var>, <var>x2</var>) <br> <tt>test_rank_sum</tt> (<var>x1</var>, <var>x2</var>, <var>option</var>)</em></dt>
<dd>
<p>This is the Wilcoxon-Mann-Whitney test for comparing the medians of two
continuous populations. The first two arguments <var>x1</var> and <var>x2</var> are lists
or column matrices with the data of two independent samples. Performs normal
approximation if any of the sample sizes is greater than 10, or if there are ties.
</p>
<p>Option:
</p>
<ul>
<li> <code>'alternative</code>, default <code>'twosided</code>, is the alternative hypothesis;
valid values are: <code>'twosided</code>, <code>'greater</code> and <code>'less</code>.
</li></ul>
<p>The output of function <code>test_rank_sum</code> is an <code>inference_result</code> Maxima object
with the following results:
</p>
<ol>
<li> <code>'method</code>: inference procedure.
</li><li> <code>'hypotheses</code>: null and alternative hypotheses to be tested.
</li><li> <code>'statistic</code>: value of the sample statistic used for testing the null hypothesis.
</li><li> <code>'distribution</code>: distribution of the sample statistic, together with its parameters.
</li><li> <code>'p_value</code>: <em>p</em>-value of the test.
</li></ol>
<p>Examples:
</p>
<p>Checks whether populations have similar medians. Samples sizes
are small and an exact test is made.
</p>
<div class="example">
<pre class="example">(%i1) load("stats")$
(%i2) x:[12,15,17,38,42,10,23,35,28]$
(%i3) y:[21,18,25,14,52,65,40,43]$
(%i4) test_rank_sum(x,y);
| RANK SUM TEST
|
| method = Exact test
|
| hypotheses = H0: med1 = med2 , H1: med1 # med2
(%o4) |
| statistic = 22
|
| distribution = [rank_sum, 9, 8]
|
| p_value = .1995886466474702
</pre></div>
<p>Now, with greater samples and ties, the procedure makes
normal approximation. The alternative hypothesis is
<em>H_1: median1 < median2</em>.
</p>
<div class="example">
<pre class="example">(%i1) load("stats")$
(%i2) x: [39,42,35,13,10,23,15,20,17,27]$
(%i3) y: [20,52,66,19,41,32,44,25,14,39,43,35,19,56,27,15]$
(%i4) test_rank_sum(x,y,'alternative='less);
| RANK SUM TEST
|
| method = Asymptotic test. Ties
|
| hypotheses = H0: med1 = med2 , H1: med1 < med2
(%o4) |
| statistic = 48.5
|
| distribution = [normal, 79.5, 18.95419580097078]
|
| p_value = .05096985666598441
</pre></div>
</dd></dl>
<a name="test_005fnormality"></a><a name="Item_003a-stats_002fdeffn_002ftest_005fnormality"></a><dl>
<dt><a name="index-test_005fnormality"></a>Function: <strong>test_normality</strong> <em>(<var>x</var>)</em></dt>
<dd>
<p>Shapiro-Wilk test for normality. Argument <var>x</var> is a list of numbers, and sample
size must be greater than 2 and less or equal than 5000, otherwise, function
<code>test_normality</code> signals an error message.
</p>
<p>Reference:
</p>
<p>[1] Algorithm AS R94, Applied Statistics (1995), vol.44, no.4, 547-551
</p>
<p>The output of function <code>test_normality</code> is an <code>inference_result</code> Maxima object
with the following results:
</p>
<ol>
<li> <code>'statistic</code>: value of the <var>W</var> statistic.
</li><li> <code>'p_value</code>: <em>p</em>-value under normal assumption.
</li></ol>
<p>Examples:
</p>
<p>Checks for the normality of a population, based on a sample of size 9.
</p>
<div class="example">
<pre class="example">(%i1) load("stats")$
(%i2) x:[12,15,17,38,42,10,23,35,28]$
(%i3) test_normality(x);
| SHAPIRO - WILK TEST
|
(%o3) | statistic = .9251055695162436
|
| p_value = .4361763918860381
</pre></div>
</dd></dl>
<a name="linear_005fregression"></a><a name="Item_003a-stats_002fdeffn_002flinear_005fregression"></a><dl>
<dt><a name="index-linear_005fregression"></a>Function: <strong>linear_regression</strong> <em><br> <tt>linear_regression</tt> (<var>x</var>) <br> <tt>linear_regression</tt> (<var>x</var> <var>option</var>)</em></dt>
<dd>
<p>Multivariate linear regression,
<em>y_i = b0 + b1*x_1i + b2*x_2i + ... + bk*x_ki + u_i</em>,
where <em>u_i</em> are <em>N(0,sigma)</em> independent random variables.
Argument <var>x</var> must be a matrix with more than one column. The
last column is considered as the responses (<em>y_i</em>).
</p>
<p>Option:
</p>
<ul>
<li> <code>'conflevel</code>, default <code>95/100</code>, confidence level for the
confidence intervals; it must be an expression which takes a value
in (0,1).
</li></ul>
<p>The output of function <code>linear_regression</code> is an
<code>inference_result</code> Maxima object with the following results:
</p>
<ol>
<li> <code>'b_estimation</code>: regression coefficients estimates.
</li><li> <code>'b_covariances</code>: covariance matrix of the regression
coefficients estimates.
</li><li> <code>b_conf_int</code>: confidence intervals of the regression coefficients.
</li><li> <code>b_statistics</code>: statistics for testing coefficient.
</li><li> <code>b_p_values</code>: p-values for coefficient tests.
</li><li> <code>b_distribution</code>: probability distribution for coefficient tests.
</li><li> <code>v_estimation</code>: unbiased variance estimator.
</li><li> <code>v_conf_int</code>: variance confidence interval.
</li><li> <code>v_distribution</code>: probability distribution for variance test.
</li><li> <code>residuals</code>: residuals.
</li><li> <code>adc</code>: adjusted determination coefficient.
</li><li> <code>aic</code>: Akaike’s information criterion.
</li><li> <code>bic</code>: Bayes’s information criterion.
</li></ol>
<p>Only items 1, 4, 5, 6, 7, 8, 9 and 11 above, in this order,
are shown by default. The rest remain hidden until the user
makes use of functions <code>items_inference</code> and <code>take_inference</code>.
</p>
<p>Example:
</p>
<p>Fitting a linear model to a trivariate sample. The
last column is considered as the responses (<em>y_i</em>).
</p>
<div class="example">
<pre class="example">(%i2) load("stats")$
(%i3) X:matrix(
[58,111,64],[84,131,78],[78,158,83],
[81,147,88],[82,121,89],[102,165,99],
[85,174,101],[102,169,102])$
(%i4) fpprintprec: 4$
(%i5) res: linear_regression(X);
| LINEAR REGRESSION MODEL
|
| b_estimation = [9.054, .5203, .2397]
|
| b_statistics = [.6051, 2.246, 1.74]
|
| b_p_values = [.5715, .07466, .1423]
|
(%o5) | b_distribution = [student_t, 5]
|
| v_estimation = 35.27
|
| v_conf_int = [13.74, 212.2]
|
| v_distribution = [chi2, 5]
|
| adc = .7922
(%i6) items_inference(res);
(%o6) [b_estimation, b_covariances, b_conf_int, b_statistics,
b_p_values, b_distribution, v_estimation, v_conf_int,
v_distribution, residuals, adc, aic, bic]
(%i7) take_inference('b_covariances, res);
[ 223.9 - 1.12 - .8532 ]
[ ]
(%o7) [ - 1.12 .05367 - .02305 ]
[ ]
[ - .8532 - .02305 .01898 ]
(%i8) take_inference('bic, res);
(%o8) 30.98
(%i9) load("draw")$
(%i10) draw2d(
points_joined = true,
grid = true,
points(take_inference('residuals, res)) )$
</pre></div>
</dd></dl>
<a name="Item_003a-stats_002fnode_002fFunctions-and-Variables-for-special-distributions"></a><hr>
<div class="header">
<p>
Next: <a href="maxima_249.html#Functions-and-Variables-for-special-distributions" accesskey="n" rel="next">Functions and Variables for special distributions</a>, Previous: <a href="maxima_247.html#Functions-and-Variables-for-inference_005fresult" accesskey="p" rel="previous">Functions and Variables for inference_result</a>, Up: <a href="maxima_245.html#stats_002dpkg" accesskey="u" rel="up">stats-pkg</a> [<a href="maxima_toc.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="maxima_264.html#g_t_0423_043a_0430_0437_0430_0442_0435_043b_044c-_0444_0443_043d_043a_0446_0438_0439-_0438-_043f_0435_0440_0435_043c_0435_043d_043d_044b_0445" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>
|