Skip to contents

Produces tests of normality (within time bin, ignoring time bin, and pooling within-time bin values) and homoscedasticity (homogeneity of variances) for each fossilized birth–death process (FBD) parameter in the posterior parameter log file.

Usage

FBD_tests1(posterior, downsample = TRUE)

Arguments

posterior

A data frame of posterior parameter estimates containing a single "Time_bin" column and one column for each FBD parameter value. Such data frame can be imported using combine_log followed by FBD_reshape.

downsample

Whether to downsample the observations to ensure Shapiro-Wilk normality tests can be run. If TRUE, observations will be dropped so that no more than 5000 observations are used for the tests on the full dataset, as required by shapiro.test. They will be dropped in evenly spaced intervals. If FALSE and there are more than 5000 observations for any test, that test will not be run.

Details

FBD_tests1() performs several tests on the posterior distributions of parameter values within and across time bins. It produces the Shapiro-Wilk test for normality using shapiro.test and the Bartlett and Fligner tests for homogeneity of variance using bartlett.test and fligner.test, respectively. Note that these tests are likely to be significant even if the observations are approximately normally distributed or have approximately equal variance; therefore, they should be supplemented with visual inspection using FBD_normality_plot.

Value

A list containing the results of the three tests with the following elements:

shapiro

A list with an element for each parameter. Each element is a data frame with a row for each time bin and the test statistic and p-value for the Shapiro-Wilk test for normality. In addition, there will be a row for an overall test, combining all observations ignoring time bin, and a test of the residuals, which combines the group-mean-centered observations (equivalent to the residuals in a regression of the parameter on time bin).

bartlett

A data frame of the Bartlett test for homogeneity of variance across time bins with a row for each parameter and the test statistic and p-value for the test.

fligner

A data frame of the Fligner test for homogeneity of variance across time bins with a row for each parameter and the test statistic and p-value for the test.

See also

vignette("fbd-params") for the use of this function as part of an analysis pipeline.

combine_log for producing a single data set of parameter posterior samples from individual parameter log files.

FBD_reshape for converting posterior parameter table from wide to long format.

FBD_normality_plot for visual assessments.

FBD_tests2 for tests of differences between parameter means.

shapiro.test, bartlett.test, and fligner.test for the statistical tests used.

Examples

# See vignette("fbd-params") for how to use this
# function as part of an analysis pipeline

data("posterior3p")

posterior3p_long <- FBD_reshape(posterior3p)

FBD_tests1(posterior3p_long)
#> $shapiro
#> $shapiro$net_speciation
#>                 parameter statistic      p-value
#> Time bin 1 net_speciation 0.9916663 1.624982e-06
#> Time bin 2 net_speciation 0.9384888 2.480773e-22
#> Time bin 3 net_speciation 0.9227161 8.116099e-25
#> Time bin 4 net_speciation 0.9898368 1.300460e-07
#> Overall    net_speciation 0.9568434 4.033827e-36
#> Residuals  net_speciation 0.9873721 9.370749e-21
#> 
#> $shapiro$relative_extinction
#>                      parameter statistic      p-value
#> Time bin 1 relative_extinction 0.8927465 1.249128e-28
#> Time bin 2 relative_extinction 0.9247265 1.597560e-24
#> Time bin 3 relative_extinction 0.8044308 2.275700e-36
#> Time bin 4 relative_extinction 0.3774844 4.955610e-54
#> Overall    relative_extinction 0.7036392 3.008792e-69
#> Residuals  relative_extinction 0.8237642 3.187737e-59
#> 
#> $shapiro$relative_fossilization
#>                         parameter statistic      p-value
#> Time bin 1 relative_fossilization 0.5763573 9.277693e-48
#> Time bin 2 relative_fossilization 0.8852625 1.887972e-29
#> Time bin 3 relative_fossilization 0.6209885 5.094795e-46
#> Time bin 4 relative_fossilization 0.4636627 1.482086e-51
#> Overall    relative_fossilization 0.5473039 5.146876e-78
#> Residuals  relative_fossilization 0.5530980 9.682903e-78
#> 
#> 
#> $bartlett
#>                parameter statistic p-value
#> 1         net_speciation  3815.464       0
#> 2    relative_extinction 18159.213       0
#> 3 relative_fossilization 25654.975       0
#> 
#> $fligner
#>                parameter statistic p-value
#> 1         net_speciation  3748.140       0
#> 2    relative_extinction 12599.843       0
#> 3 relative_fossilization  4808.545       0
#>