Got it, that actually makes sense. Now Iβm back to the problem that I have an Integer Matrix, when I need an Abstract Matrix.
Do you really?
julia> typeof(zeros(Integer,2,2))
Matrix{Integer} (alias for Array{Integer, 2})
julia> function kandinsky(a::AbstractMatrix)
"far out"
end
kandinsky (generic function with 1 method)
julia> kandinsky(zeros(Integer,2,2))
"far out"
I canβt tell if youβre playing, I just want one working example of Holltellingβs T^2 Tests, then I can play around and make it do what I need to do.
Iβm trying to demonstrate that an Integer Matrix is accepted by a function that expects an AbstractMatrix.
I think more generally people are looking to encourage you to develop the knowledge and toolset required to figure these things out by yourself - which would include some basic knowledge of Julia as a programming language (i.e. not specific packages) so that you, for example, know what AbstractMatrix
is and how it relates to concrete types such as Matrix{Integer}
.
For this specific case, a good starting point is the docstring:
help?> OneSampleHotellingT2Test
search: OneSampleHotellingT2Test OneSampleHotellingT2
OneSampleHotellingT2Test(X::AbstractMatrix, ΞΌβ=<zero vector>)
Perform a one sample Hotelling's T^2 test of the hypothesis that the vector of column means of X is equal to ΞΌβ.
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
OneSampleHotellingT2Test(X::AbstractMatrix, Y::AbstractMatrix, ΞΌβ=<zero vector>)
Perform a paired Hotelling's T^2 test of the hypothesis that the vector of mean column differences between X and Y
is equal to ΞΌβ.
Okay so this tells us that if we pass two matrices to the function, it will test the hypothesis that the mean of each column of X
is equal to the mean of the corresponding column in Y
. Letβs try this - generate some test data:
julia> xs = hcat([rand(Normal(), 20) for _ β 1:5]...);
julia> ys = hcat([rand(Normal(1.0, 1.0), 20) for _ β 1:5]...);
So here we have five columns each, with means of 0 for xs
, and 1 for ys
. Letβs test whether they are actually equal:
julia> OneSampleHotellingT2Test(xs, ys)
One sample Hotelling's TΒ² test
------------------------------
Population details:
parameter of interest: Mean vector
value under h_0: [0.0, 0.0, 0.0, 0.0, 0.0]
point estimate: [-1.33398, -0.95276, -1.19897, -1.28494, -0.853853]
Test summary:
outcome with 95% confidence: reject h_0
one-sided p-value: <1e-05
Turns out theyβre not! You see from the output that value under h_0
is a vector of five zeros - this is the βzero vectorβ, and it just says that our null hypothesis is that the means for each of the five columns are the same, or put differently, the difference in their means is zero.
Here of course we know that the real (expected) difference is 1, so letβs test that:
julia> OneSampleHotellingT2Test(xs, ys, fill(-1.0, 5))
One sample Hotelling's TΒ² test
------------------------------
Population details:
parameter of interest: Mean vector
value under h_0: [-1.0, -1.0, -1.0, -1.0, -1.0]
point estimate: [-1.33398, -0.95276, -1.19897, -1.28494, -0.853853]
Test summary:
outcome with 95% confidence: fail to reject h_0
one-sided p-value: 0.5410
(Note Iβve tested for a difference of -1, as we are testing x-y, not y-x).
Yes, you are right, I do need to build a skillset. Thank you for reminding me to use help?> that is a habit I need to develop. Part of the problem is that Iβm not in a CompSci class, so Iβve learned the basics in bits and pieces.
So, if Iβm using a Likert Scale for a sociology survey, I would set the zero vector to [3,3], since the scale goes from 1 to 5, and if they both deviate from the same amount, in the same direction, I fail to reject the null hypothesis?
I believe many of us here donβt have a formal Computer Science background, we all learn as we go.
And it appears that you are having trouble with both the codes and statistics.
It probably is a good idea to know a bit more about the statistics portion of your problem, at-least know what to expect, before attempting to solve it in Julia.
OK, thanks, yes, Iβm thinking of holding back a bit and doing more reading, since Iβve realised Iβve got a bit over my head. I took statistics, and linear algebra, but I realise I donβt remember as much as I thought.