View source: R/stats.clim.twd.R
| clim.twd.test | R Documentation |
Performs hypothesis tests on parameters derived from clim.twd() output.
This function is designed for scenarios such as:
species comparison as a whole,
species comparison by year,
site comparison as a whole,
site comparison by year,
species-within-site comparison,
ID-wise comparisons.
The function uses the period_info table from clim.twd() and
tests selected parameters across groups such as trees, species, sites, or
species-site combinations.
clim.twd.test(
x,
tree_info = NULL,
parameter = c("lag_to_below_zero", "lag_to_max_adverse_decline", "lag_to_return_zero",
"max_adverse_decline_value", "change_end_adverse", "change_end_full_period",
"continuous_end_full_period"),
compare_by = c("tree", "species", "site", "species_site"),
within = c("all", "year", "ID"),
test_method = c("auto", "t_test", "welch_t", "wilcox", "anova", "kruskal"),
ids = NULL,
years = NULL,
months = NULL,
doy_window = NULL,
year_window = NULL,
pairwise = TRUE,
p_adjust_method = "BH",
min_n_per_group = 2
)
x |
An object of class |
tree_info |
Optional metadata table describing trees. It must contain a
column named |
parameter |
Character. Parameter from
|
compare_by |
Character. Grouping variable to compare. One of
|
within |
Character. Defines the comparison scenario:
|
test_method |
Character. One of
|
ids |
Optional numeric vector of IDs to retain before testing. |
years |
Optional numeric vector of years to retain based on
|
months |
Optional numeric vector of months (1–12) to retain based on
|
doy_window |
Optional numeric vector of length 2 defining the allowed
day-of-year window of |
year_window |
Optional numeric vector of length 2 defining the allowed
year range for |
pairwise |
Logical. If |
p_adjust_method |
Character. P-value adjustment method for pairwise tests.
Default is |
min_n_per_group |
Minimum number of non-missing observations required per
group before testing. Default is |
A list of class "clim_twd_test" containing:
Filtered test data used for the analyses.
Main test results by stratum.
Pairwise comparison table where available.
Descriptive summaries by stratum and group.
Settings used for the analysis.
rel_out <- clim.twd(
df = gf_nepa17,
Clim = ktm_rain17,
thresholdClim = "<10",
thresholdDays = ">5",
showPlot = FALSE
)
tree_info <- data.frame(
tree = c("T2", "T3"),
species = c("Pinus", "Pinus"),
site = c("Ktm", "Ktm")
)
# species comparison across all retained IDs
tst1 <- clim.twd.test(
rel_out,
tree_info = tree_info,
parameter = "max_adverse_decline_value",
compare_by = "species",
within = "all"
)
summary(tst1)
plot(tst1)
# species comparison by year
tst2 <- clim.twd.test(
rel_out,
tree_info = tree_info,
parameter = "lag_to_return_zero",
compare_by = "species",
within = "year"
)
# site comparison by year
tst3 <- clim.twd.test(
rel_out,
tree_info = tree_info,
parameter = "change_end_full_period",
compare_by = "site",
within = "year",
test_method = "kruskal"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.