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
|
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2012 - Michael Baudin
// Copyright (C) 2000 - INRIA - Carlos Klimann
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
//
function [f,p]=ftuneq(varargin)
//
//This function computes the F ratio for samples of unequal
//size.
//
//"The most efficient design is to make all samples the
//same size n. However when this is nor feasible, it
//still is possible to modify the ANOVA calculations."
//Note that the definition of xbarbar is no longer
//mean(xbar), but rather a weighted average with weights
//ni. Additionally it gives (in p) the p-value of the
//computed Fischer ratio.
//
//Given a number a of samples each of them composed of n_i
//(i from 1 to a) observations this fonction computes in f
//the Fischer ratio (it is the ratio between nr times the
//variance of the means of samples and the mean of the
//variances of each sample).
//
//References: Wonacott, T.H. & Wonacott, R.J.; Introductory
//Statistics, J.Wiley & Sons, 1990.
//
//
[lhs,rhs]=argn(0)
if rhs == 0 then
error(msprintf(gettext("%s: Wrong number of input arguments: At least %d expected.\n"),"ftuneq",1))
end
data=[]
total=0
sse=0
for i=1:rhs
len(i)=size(varargin(i),"*"),
mat=matrix(varargin(i),len(i),1),
partial=sum(mat),
xbar(i)=partial/len(i),
total=total+partial,
data=[data; mat]
sse=sse+sum((mat-xbar(i)).^2)
end
xbarbar=total/sum(len)
ssa=len'*((xbar-xbarbar).^2)
msa=ssa/(rhs-1)
deglib=sum(len-1)
mse=sse/deglib
f=msa/mse
[ignored,p]=cdff("PQ",f,(rhs-1),deglib)
endfunction
|