PHP Класс MathPHP\Statistics\ANOVA

Показать файл Открыть проект

Открытые методы

Метод Описание
oneWay ( variadic $samples ) : array One-way ANOVA Technique used to compare means of three or more samples (using the F distribution).
twoWay ( variadic $data ) : array Two-way ANOVA Examines the influence of two different categorical independent variables on one continuous dependent variable. The two-way ANOVA not only aims at assessing the main effect of each independent variable but also if there is any interaction between them (using the F distribution).

Описание методов

oneWay() публичный статический Метод

https://en.wikipedia.org/wiki/One-way_analysis_of_variance Produces the following analysis of the data: ANOVA hypothesis test summary data | SS | df | MS | F | P | Treatment | | | | | | Error | | | | Total | | | where: Treament is between groups Error is within groups SS = Sum of squares df = Degrees of freedom MS = Mean squares F = F statistic P = P value Data summary table | N | Sum | Mean | SS | Variance | SD | SEM | 0 | | | | | | | | 1 | | | | | | | | ... | | | | | | | | Total | | | | | | | | where: Each row is the summary for a sample, numbered from 0 to m - 1 m = Number of samples N = Sample size SS = Sum of squares SD = Standard deviation SEM = Standard error of the mean Calculations Sum of Squares SST (sum of squares total) ∑⟮xᵢ − μ⟯² where: xᵢ = each element of all samples μ = mean total of all elements of all samples SSB (sum of squares between - treatment) ∑n(x - μ)² where: n = sample size x = sample mean μ = mean total of all elements of all samples SSW (sum of squares within - error) ∑∑⟮xᵢ − μ⟯² Sum of sum of squared deviations of each sample where: xᵢ = each element of the sample μ = mean of the sample Degrees of Freedom dfT (degrees of freedom for the total) mn - 1 dfB (degrees of freedom between - treatment) m - 1 dfW (degrees of freedom within - error) m(n - 1) where: m = number of samples n = number of elements in each sample Mean Squares MSB (Mean squares between - treatment) SSB / dfB MSW (Mean squares within - error) SSW / dfW Test Statistics F = MSB / MSW P = F distribution CDF above F with degrees of freedom dfB and dfW
public static oneWay ( variadic $samples ) : array
$samples variadic Samples to analyze (at least 3 or more samples)
Результат array [ ANOVA => [ treatment => [SS, df, MS, F, P], error => [SS, df, MS], total => [SS, df], ], total_summary => [n, sum, mean, SS, variance, sd, sem], data_summary => [ 0 => [n, sum, mean, SS, variance, sd, sem], 1 => [n, sum, mean, SS, variance, sd, sem], ... ] ]

twoWay() публичный статический Метод

https://en.wikipedia.org/wiki/Two-way_analysis_of_variance Produces the following analysis of the data: ANOVA hypothesis test summary data | SS | df | MS | F | P | Factor A | | | | | | Factor B | | | | | | Interaction | | | | | | Error | | | | Total | | | where: Interaction = Factor A X Factor B working together Error is within groups SS = Sum of squares df = Degrees of freedom MS = Mean squares F = F statistic P = P value Data summary tables for: Factor A Factor B Factor AB (Interaction) Total | N | Sum | Mean | SS | Variance | SD | SEM | 0 | | | | | | | | 1 | | | | | | | | ... | | | | | | | | Total | | | | | | | | where: Each row is the summary for a sample, numbered from 0 to m - 1 m = Number of samples N = Sample size SS = Sum of squares SD = Standard deviation SEM = Standard error of the mean Calculations Sum of Squares SST (sum of squares total) ∑⟮xᵢ − μ⟯² where: xᵢ = each element of all samples μ = mean total of all elements of all samples SSA, SSB (sum of squares for each factor A and B) ∑n(x - μ)² where: n = sample size x = sample mean μ = mean total of all elements of all samples SSW (sum of squares within - error) ∑∑⟮x − μ⟯² Sum of sum of squared deviations of each sample where: x = mean of each AB μ = mean of the sample SSAB (sum of squares AB - interaction) SSAB = SST - SSA - SSB - SSW; Degrees of Freedom dfT (degrees of freedom for the total) n - 1 dfA (degrees of freedom factor A) r - 1 dfB (degrees of freedom factor B) c - 1 dfAB (degrees of freedom factor AB - interaction) (r - 1)(c - 1) dfW (degrees of freedom within - error) n - rc where: n = number of samples r = number of rows (number of factor As) c = number of columns (number of factor Bs) Mean Squares MSA (Mean squares factor A) SSA / dfA MSB (Mean squares factor B) SSB / dfB MSAB (Mean squares factor AB - interaction) SSAB / dfAB MSW (Mean squares within - error) SSW / dfW F Test Statistics FA = MSA / MSW FB = MSB / MSW FAB = MSAB / MSW P values PA = F distribution CDF above FA with degrees of freedom dfA and dfW PB = F distribution CDF above FB with degrees of freedom dfA and dfW PAB = F distribution CDF above FAB with degrees of freedom dfAB and dfW Example input data for ...$data parameter: | Factor B₁ | Factor B₂ | ⋯ Factor A₁ | 4, 6, 8 | 6, 6, 9 | ⋯ Factor A₂ | 4, 8, 9 | 7, 10, 13 | ⋯ ⋮ ⋮ ⋮ ⋮
public static twoWay ( variadic $data ) : array
$data variadic Samples to analyze [ // Factor A₁ [ [4, 6, 8] // Factor B₁ [6, 6, 9] // Factor B₂ ⋮ ], // Factor A₂ [ [4, 8, 9] // Factor B₁ [7, 10, 13] // Factor B₂ ⋮ ], ... ]
Результат array [ ANOVA => [ factorA => [SS, df, MS, F, P], factorB => [SS, df, MS, F, P], factorAB => [SS, df, MS, F, P], error => [SS, df, MS], total => [SS, df], ], total_summary => [n, sum, mean, SS, variance, sd, sem], summary_factorA => [ 0 => [n, sum, mean, SS, variance, sd, sem], 1 => [n, sum, mean, SS, variance, sd, sem], ... ], summary_factorB => [ 0 => [n, sum, mean, SS, variance, sd, sem], 1 => [n, sum, mean, SS, variance, sd, sem], ... ], summary_factorAB => [ 0 => [n, sum, mean, SS, variance, sd, sem], 1 => [n, sum, mean, SS, variance, sd, sem], ... ] ]