Performs an analysis of variance (ANOVA) on the supplied data set.
The following example illustrates a single-factor ANOVA on a data set.
program example
use iso_fortran_env
use fstats
implicit none
! Local Variables
character, parameter :: tab = achar(9)
real(real64) :: x(10, 2)
type(single_factor_anova_table) :: tbl
! Define the data
x = reshape( &
[ &
3.086d3, 3.082d3, 3.069d3, 3.072d3, 3.045d3, 3.070d3, 3.079d3, &
3.050d3, 3.062d3, 3.062d3, 3.075d3, 3.061d3, 3.063d3, 3.038d3, &
3.070d3, 3.062d3, 3.070d3, 3.049d3, 3.042d3, 3.063d3 &
], &
[10, 2] &
)
! Perform the ANOVA
tbl = anova(x)
! Print out the table
print '(A)', "Description" // tab // "DOF" // tab // "Sum of Sq." // &
tab // "Variance" // tab // "F-Stat" // tab // "P-Value"
print '(AF2.0AF5.1AF5.1AF5.3AF5.3)', "Main Factor: " // tab, &
tbl%main_factor%dof, tab, &
tbl%main_factor%sum_of_squares, tab // tab, &
tbl%main_factor%variance, tab // tab, &
tbl%main_factor%f_statistic, tab, &
tbl%main_factor%probability
print '(AF3.0AF6.1AF5.1)', "Within: " // tab, &
tbl%within_factor%dof, tab, &
tbl%within_factor%sum_of_squares, tab // tab, &
tbl%within_factor%variance
print '(AF3.0AF6.1AF5.1)', "Total: " // tab // tab, &
tbl%total_dof, tab, &
tbl%total_sum_of_squares, tab // tab, &
tbl%total_variance
print '(AF6.1)', "Overall Mean: ", tbl%overall_mean
end program
The above program produces the following output.
Description DOF Sum of Sq. Variance F-Stat P-Value
Main Factor: 1. 352.8 352.8 2.147 0.160
Within: 18. 2958.2 164.3
Total: 19. 3311.0 174.3
Overall Mean: 3063.5
See Also
Performs an analysis of variance (ANOVA) on the supplied data set.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real64), | intent(in) | :: | x(:,:) |
An M-by-N matrix containing the M replications of the N test points of interest. |
A single_factor_anova_table instance containing the ANOVA results.
Performs an analysis of variance (ANOVA) on the supplied data set.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=real64), | intent(in) | :: | x(:,:,:) |
An M-by-N-by-K array containing the M replications of the N first factor results, and the K second factor results. |
A two_factor_anova_table instance containing the ANOVA results.
Performs an analysis of variance (ANOVA) on the supplied data set.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int32), | intent(in) | :: | nmodelparams |
The number of model parameters. |
||
real(kind=real64), | intent(in) | :: | ymeas(:) |
An N-element array containing the measured dependent variable data. |
||
real(kind=real64), | intent(in) | :: | ymod(:) |
An N-element array containing the modeled dependent variable data. |
||
class(errors), | intent(inout), | optional, | target | :: | err |
A mechanism for communicating errors and warnings to the caller. Possible warning and error codes are as follows. - FS_NO_ERROR: No errors encountered. - FS_ARRAY_SIZE_ERROR: Occurs if ymeas and ymod are not the same length. - FS_MEMORY_ERROR: Occurs if a memory error is encountered. |
A single_factor_anova_table instance containing the ANOVA results.
Defines an ANOVA factor result.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
real(kind=real64), | public | :: | dof |
The number of degrees of freedome. |
|||
real(kind=real64), | public | :: | f_statistic |
The F-statistic. |
|||
real(kind=real64), | public | :: | probability |
The variance probability term. |
|||
real(kind=real64), | public | :: | sum_of_squares |
The sum of the squares. |
|||
real(kind=real64), | public | :: | variance |
The estimate of variance. |
Defines a single-factor ANOVA results table.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(anova_factor), | public | :: | main_factor |
The main, or main factor, results. |
|||
real(kind=real64), | public | :: | overall_mean |
The overall mean value. |
|||
real(kind=real64), | public | :: | total_dof |
The total number of degrees of freedom. |
|||
real(kind=real64), | public | :: | total_sum_of_squares |
The total sum of squares. |
|||
real(kind=real64), | public | :: | total_variance |
The total variance estimate. |
|||
type(anova_factor), | public | :: | within_factor |
The within-treatement (error) results. |
Defines a two-factor ANOVA results table.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(anova_factor), | public | :: | interaction |
The interaction effects. |
|||
type(anova_factor), | public | :: | main_factor_1 |
The first main-factor results. |
|||
type(anova_factor), | public | :: | main_factor_2 |
The second main-factor results. |
|||
real(kind=real64), | public | :: | overall_mean |
The overall mean value. |
|||
real(kind=real64), | public | :: | total_dof |
The total number of degrees of freedom. |
|||
real(kind=real64), | public | :: | total_sum_of_squares |
The total sum of squares. |
|||
real(kind=real64), | public | :: | total_variance |
The total variance estimate. |
|||
type(anova_factor), | public | :: | within_factor |
The within (error) factor results. |