Learn R Programming

Renext (version 2.0-11)

barplotRenouv: Barplot for Renouv "Over Threshold" counts

Description

Barplot for "Over Threshold" counts in time blocks (usually years)

Usage

barplotRenouv(data,
                  blockname = colnames(data)[1],
                  varname = colnames(data)[2],
                  threshold = quantile(data[, varname], 0.2),
                  na.block = NULL,
                  plot = TRUE,
                  main = NULL, xlab = NULL, ylab = NULL,
                  mono = FALSE,
                  prob.theo = 0.999,
                  ...)

Arguments

data
A dataframe object containing the variables.
blockname
Name of the "block" variable (column in data). This variable should contain integers, or be of class "factor", but with integer values such as year numbers.
varname
Name of the variable (e.g. "Surge").
threshold
Only obs for which the variable exceeds threshold will be taken into account.
na.block
Values of blocks containing missing values. See the Details section.
plot
If FALSE tests are computed without producing any plot.
main
Character for main title or NULL in which case a default main title is used.
xlab
Character for x axis label or NULL in which case a default lab is used.
ylab
Character for y axis or NULL in which case a default lab is used.
mono
If FALSE barplot will have colors, else grayscale will be used.
prob.theo
The total theoretical probability corresponding to the plotted (theoretical) bars.
...
Further args to be passed to barplot.

Value

  • A list with the following objects.
  • freqfrequency table (matrix) giving observed and theoretical (Poisson) frequencies as well as a group number for the chi-square test.
  • overdispersionthe overdispersion coefficient (variance/mean ratio).
  • disp.testa list giving results of the (over)dispersion test. See the reference Yagouti and al. in the References section.
  • chisq.testa list giving results for the chis-square test of goodness-of-fit to the Poisson distribution.
  • testsa matrix with the two tests displayed in two rows.
  • For both tests, the statistic follows a chi-square distribution under the null hypothesis . The list of results contains the statistic statistic, the number of degrees of freedom df and the $p$-value p.value.

encoding

UTF-8

Details

Blocks described in the na.block are omitted in the determination of counts. The object given in the na.block is coerced to character and the same is done for values of block before comparing them to the na.block values. If block variable is of class factor with levels representing years (e.g. 1980, 1981, etc.) missing blocks can be specified either as c("1980", "1981") or as numeric c(1980, 1981).

For the chi-square test, counts for neighbouring frequency classes are grouped in order to reach a minimum frequency of 5 in each group. E.g. if we expect respectively 1.0, 3.8 and 7.0 blocks with frequency 0, 1 and 2 for events, the three counts are grouped in one group with frequency 1.0+3.8+7.0=11.8. Note that this strategy of grouping is not unique and is likely to weaken the power of the test. Before grouping, the higher class theretical probability is computed as the probability to obtain a count equal to or greater than the max value.

References

See Yagouti A., Abi-Zeid I., Ouarda, T.B.M.J. and B. Bobée{Bobee} (2001), Revue de processus ponctuels et synthèse{synthese} de tests statistiques pour le choix d'un type de processus Revue des Sciences de l'Eau, 1, pp. 323-361.

See Also

plot.Rendata

Examples

Run this code
library(Renext)
data(Brest.years)
data(Brest.years.missing)

## na.block influence
opar <- par(mfrow = c(2, 2))

bp1 <- barplotRenouv(data = Brest.years, threshold = 30,
         main = "missing periods ignored")
bp2 <- barplotRenouv(data = Brest.years, threshold = 30,
         na.block = 1992, main = "1992 missing")
bp3 <- barplotRenouv(data = Brest.years, threshold = 30,
         na.block = 1991:1993, main ="1991:1993 missing")
bp4 <- barplotRenouv(data = Brest.years, threshold = 30,
         na.block = Brest.years.missing, main = "all missing periods")

par(opar)

## threshold influence
opar <- par(mfrow = c(2,2))

thresh <- c(30, 35, 40, 50)

for (i in 1:length(thresh)) {
  bp  <- barplotRenouv(data = Brest.years, threshold = thresh[i],
                   na.block = Brest.years.missing,
                   main = paste("threshold =", thresh[i], "cm at Brest"))
}
par(opar)

Run the code above in your browser using DataLab