Maxima Function
test_means_difference (x1, x2)
test_means_difference(x1,x2,option_1,option_2,...)
This is the difference of means t-test for two samples.
Arguments x1 and x2 are lists or column matrices
containing two independent samples. In case of different unknown variances
(see options 'dev1
, 'dev2
and 'varequal
bellow),
the degrees of freedom are computed by means of the Welch approximation.
It also performs an asymptotic test
based on the Central Limit Theorem if option 'asymptotic
is
set to true
.
Options:
'alternative
, default 'twosided
, is the alternative hypothesis;
valid values are: 'twosided
, 'greater
and 'less
.
'dev1
, default 'unknown
, this is the value of the standard deviation
of the x1 sample when it is known; valid values are: 'unknown
or a positive expression.
'dev2
, default 'unknown
, this is the value of the standard deviation
of the x2 sample when it is known; valid values are: 'unknown
or a positive expression.
'varequal
, default false
, whether variances should be considered to be equal or not;
this option takes effect only when 'dev1
and/or 'dev2
are 'unknown
.
'conflevel
, default 95/100
, confidence level for the confidence interval; it must
be an expression which takes a value in (0,1).
'asymptotic
, default false
, indicates whether it performs an exact t-test or
an asymptotic one based on the Central Limit Theorem;
valid values are true
and false
.
The output of function test_means_difference
is an inference_result
Maxima object
showing the following results:
'diff_estimate
: the difference of means estimate.
'conf_level
: confidence level selected by the user.
'conf_interval
: confidence interval for the difference of means.
'method
: inference procedure.
'hypotheses
: null and alternative hypotheses to be tested.
'statistic
: value of the sample statistic used for testing the null hypothesis.
'distribution
: distribution of the sample statistic, together with its parameter(s).
'p_value
: p-value of the test.
Examples:
The equality of means is tested with two small samples x and y, against the alternative H_1: m_1>m_2, being m_1 and m_2 the populations means; variances are unknown and supposed to be different.
(%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
The same test as before, but now variances are supposed to be equal.
(%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