maxima.bat.in must be configured to maxima.bat.
[maxima.git] / share / stats / rtest_stats.mac
blob335c1f1100c4c421d6fec8a06e2eb6a33adfe758
1 (kill (all),
2  load (stats),
3  save_tolerance : float_approx_equal_tolerance,
4  float_approx_equal_tolerance : 1e-8,
5  0);
6 0;
8 test_mean([78,64,35,45,45,75,43,74,42,42],
9           'conflevel=0.9,
10           'alternative='less,
11           'mean=50);
12 inference_result("MEAN TEST",
13                         [[mean_estimate,54.3],[conf_level,0.9],
14                          [conf_interval,[minf,61.51314273502712]],
15                          [method,"Exact t-test. Unknown variance."],
16                          [hypotheses,
17                           "H0: mean = 50 , H1: mean < 50"],
18                          [statistic,.8244705235071678],
19                          [distribution,[student_t,9]],
20                          [p_value,.7845100411786889]],[1,2,3,4,5,6,7,8]);
24 test_means_difference([20.4,62.5,61.3,44.2,11.1,23.7],
25                [1.2,6.9,38.7,20.4,17.2],
26                'alternative='greater);
27 inference_result("DIFFERENCE OF MEANS TEST",
28                         [[diff_estimate,20.31999999999999],[conf_level,0.95],
29                          [conf_interval,[-.04597417812882298,inf]],
30                          [method,"Exact t-test. Welch approx."],
31                          [hypotheses,"H0: mean1 = mean2 , H1: mean1 > mean2"],
32                          [statistic,1.838004300728477],
33                          [distribution,[student_t,8.62758740184604]],
34                          [p_value,.05032746527991905]],[1,2,3,4,5,6,7,8]);
38 test_variance([203,229,215,220,223,233,208,228,209],
39               'alternative='greater,
40               'variance=200);
41 inference_result("VARIANCE TEST",
42                         [[var_estimate,110.75],[conf_level,0.95],
43                          [conf_interval,[57.13433376937479,inf]],
44                          [method,
45                           "Variance Chi-square test. Unknown mean."],
46                          [hypotheses,
47                           "H0: var = 200 , H1: var > 200"],
48                          [statistic,4.43],[distribution,[chi2,8]],
49                          [p_value,.8163948512777689]],[1,2,3,4,5,6,7,8]);
54 test_variance_ratio([20.4,62.5,61.3,44.2,11.1,23.7],
55                     [1.2,6.9,38.7,20.4,17.2],
56                     'alternative='greater);
57 inference_result("VARIANCE RATIO TEST",
58                         [[ratio_estimate,2.316933391522034],[conf_level,0.95],
59                          [conf_interval,[.3703504689507268,inf]],
60                          [method,
61                           "Variance ratio F-test. Unknown means."],
62                          [hypotheses,"H0: var1 = var2 , H1: var1 > var2"],
63                          [statistic,2.316933391522034],[distribution,[f,5,4]],
64                          [p_value,.2179269692254457]],[1,2,3,4,5,6,7,8]);
69 test_sign([2,0.1,7,1.8,4,2.3,5.6,7.4,5.1,6.1,6],
70           'median=6,
71           'alternative='greater);
72 inference_result("SIGN TEST",
73                         [[med_estimate,5.1],
74                          [method,"Non parametric sign test."],
75                          [hypotheses,
76                           "H0: median = 6 , H1: median > 6"],
77                          [statistic,7],[distribution,[binomial,10,0.5]],
78                          [p_value,.05468749999999989]],[1,2,3,4,5,6]);
83 test_signed_rank([17.1,15.9,13.7,13.4,15.5,17.6],
84                  'median=15,
85                  'alternative=greater);
86 inference_result("SIGNED RANK TEST",
87                         [[med_estimate,15.7],[method,"Exact test"],
88                          [hypotheses,
89                           "H0: med = 15 , H1: med > 15"],
90                          [statistic,14],[distribution,[signed_rank,6]],
91                          [p_value,0.28125]],[1,2,3,4,5,6]);
95 test_rank_sum([12,15,17,38,42,10,23,35,28],
96               [21,18,25,14,52,65,40,43],
97               'alternative='less);
98 inference_result("RANK SUM TEST",
99                         [[method,"Exact test"],
100                          [hypotheses,"H0: med1 = med2 , H1: med1 < med2"],
101                          [statistic,22],[distribution,[rank_sum,9,8]],
102                          [p_value,0.0997943233237351]],[1,2,3,4,5]);
106 test_normality([12,15,17,38,42,10,23,35,28]);
107 inference_result("SHAPIRO - WILK TEST",
108                         [[statistic,.9251055695162436],
109                          [p_value,.4361763918860381]],[1,2]);
113 z:simple_linear_regression(matrix([125,140.7],[130,155.1],[135,160.3],[140,167.2],[145,169.8]),
114                     'conflevel=0.99);
115 inference_result("SIMPLE LINEAR REGRESSION",
116                        [[model,1.405999999999985*x-31.18999999999804],
117                         [means,[135.0,158.62]],
118                         [variances,[50.0,106.9896000000008]],
119                         [correlation,.9611685255255155],
120                         [adc,.8984599126145604],
121                         [a_estimation,-31.18999999999804],
122                         [a_conf_int,[-215.2179151598772,152.8379151598812]],
123                         [b_estimation,1.405999999999985],
124                         [b_conf_int,[.04469633662525307,2.767303663374718]],
125                         [hypotheses,"H0: b = 0 ,H1: b # 0"],
126                         [statistic,6.032686683658114],
127                         [distribution,[student_t,3]],
128                         [p_value,.009131954735741799],
129                         [v_estimation,13.57966666666665],
130                         [v_conf_int,[3.173274925102496,568.0143894218797]],
131                         [cond_mean_conf_int,
132                          [1.405999999999985*x
133                            -21.52410081697646*(0.004*(135.0-x)^2+0.2)^0.5
134                            -31.18999999999804,
135                           1.405999999999985*x
136                            +21.52410081697646*(0.004*(135.0-x)^2+0.2)^0.5
137                            -31.18999999999804]],
138                         [new_pred_conf_int,
139                          [1.405999999999985*x
140                            -21.52410081697646*(0.004*(135.0-x)^2+1.2)^0.5
141                            -31.18999999999804,
142                           1.405999999999985*x
143                            +21.52410081697646*(0.004*(135.0-x)^2+1.2)^0.5
144                            -31.18999999999804]],
145                         [residuals,
146                          [[144.5600000000001,-3.860000000000156],
147                           [151.5900000000001,3.509999999999906],
148                           [158.62,1.680000000000007],
149                           [165.6499999999999,1.550000000000068],
150                           [172.6799999999999,-2.879999999999853]]]],
151                        [1,4,14,9,10,11,12,13]);
155 take_inference('model,z), 'x=133;
156 155.808;
160 take_inference('means,z);
161 [135.0,158.62];
165 take_inference('new_pred_conf_int,z), 'x=133;
166 [132.0728595995113,179.5431404004887];
168 (float_approx_equal_tolerance : save_tolerance, 0);