disp_DP_tdm {tlda} | R Documentation |
Calculate Gries's deviation of proportions for a term-document matrix
Description
This function calculates Gries's dispersion measure DP (deviation of proportions). It offers three different formulas and allows the user to choose the directionality of scaling, i.e. whether higher values denote a more even or a less even distribution. It also offers the option of calculating frequency-adjusted dispersion scores.
Usage
disp_DP_tdm(
tdm,
row_partsize = "first",
directionality = "conventional",
formula = "egbert_etal_2020",
freq_adjust = FALSE,
freq_adjust_method = "even",
unit_interval = TRUE,
digits = NULL,
verbose = TRUE,
print_scores = TRUE
)
Arguments
tdm |
A term-document matrix, where rows represent items and columns represent corpus parts; must also contain a row giving the size of the corpus parts (first or last row in the term-document matrix) |
row_partsize |
Character string indicating which row in the term-document matrix contains the size of the corpus parts. Possible values are |
directionality |
Character string indicating the directionality of scaling. See details below. Possible values are |
formula |
Character string indicating which formula to use for the calculation of DP. See details below. Possible values are |
freq_adjust |
Logical. Whether dispersion score should be adjusted for frequency (i.e. whether frequency should be 'partialed out'); default is |
freq_adjust_method |
Character string indicating which method to use for devising dispersion extremes. See details below. Possible values are |
unit_interval |
Logical. Whether frequency-adjusted scores that exceed the limits of the unit interval should be replaced by 0 and 1; default is |
digits |
Rounding: Integer value specifying the number of decimal places to retain (default: no rounding) |
verbose |
Logical. Whether additional information (on directionality, formulas, frequency adjustment) should be printed; default is |
print_scores |
Logical. Whether the dispersion scores should be printed to the console; default is |
Details
This function takes as input a term-document matrix and returns, for each item (i.e. each row) the dispersion measure DP. The rows in the matrix represent the items, and the columns the corpus parts. Importantly, the term-document matrix must include an additional row that records the size of the corpus parts. For a proper term-document matrix, which includes all items that appear in the corpus, this can be added as a column margin, which sums the frequencies in each column. If the matrix only includes a selection of items drawn from the corpus, this information cannot be derived from the matrix and must be provided as a separate row.
Directionality: DP ranges from 0 to 1. The conventional scaling of dispersion measures (see Juilland & Chang-Rodriguez 1964; Carroll 1970; Rosengren 1971) assigns higher values to more even/dispersed/balanced distributions of subfrequencies across corpus parts. This is the default. Gries (2008) uses the reverse scaling, with higher values denoting a more uneven/bursty/concentrated distribution; use
directionality = "gries"
to choose this option.Formula: Irrespective of the directionality of scaling, four formulas for DP exist in the literature (see below for details). This is because the original version proposed by Gries (2008: 415), which is commonly denoted as
DP
(and here referenced by the value"gries_2008"
) does not always reach its theoretical limits of 0 and 1. For this reason, modifications have been suggested, starting with Gries (2008: 419) himself, who referred to this version asDPnorm
. This version is not implemented in the current package, because Lijffit & Gries (2012) updatedDPnorm
to ensure that it also works as intended when corpus parts differ in size; this version is represented by the value"lijffit_gries_2012"
and often denoted using subscript notationDP_{norm}
. Finally, Egbert et al. (2020: 99) suggest a further modification to ensure proper behavior in settings where the item occurs in only one corpus part. They label this versionD_P
. In the current function, it is the default and represented by the value"egbert_etal_2020"
.Frequency adjustment: Dispersion scores can be adjusted for frequency using the min-max transformation proposed by Gries (2022: 184-191; 2024: 196-208). The frequency-adjusted score for an item considers the lowest and highest possible level of dispersion it can obtain given its overall corpus frequency as well as the number (and size) of corpus parts. The unadjusted score is then expressed relative to these endpoints, where the dispersion minimum is set to 0, and the dispersion maximum to 1 (expressed in terms of conventional scaling). The frequency-adjusted score falls between these bounds and expresses how close the observed distribution is to the theoretical maximum and minimum. This adjustment therefore requires a maximally and a minimally dispersed distribution of the item across the parts. These hypothetical extremes can be built in different ways. The method used by Gries (2022, 2024) uses a computationally expensive procedure that finds the distribution that produces the highest value on the dispersion measure of interest. The current function constructs extreme distributions in a different way, based on the distributional features pervasiveness (
"pervasive"
) or evenness ("even"
). You can choose between these with the argumentfreq_adjust_method
; the default iseven
. For details and explanations, seevignette("frequency-adjustment")
.To obtain the lowest possible level of dispersion, the occurrences are either allocated to as few corpus parts as possible (
"pervasive"
), or they are assigned to the smallest corpus part(s) ("even"
).To obtain the highest possible level of dispersion, the occurrences are either spread as broadly across corpus parts as possible (
"pervasive"
), or they are allocated to corpus parts in proportion to their size ("even"
). The choice between these methods is particularly relevant if corpus parts differ considerably in size. See documentation forfind_max_disp()
.
In the formulas given below, the following notation is used:
-
k
the number of corpus parts -
t_i
a proportional quantity; the subfrequency in parti
divided by the total number of occurrences of the item in the corpus (i.e. the sum of all subfrequencies) -
w_i
a proportional quantity; the size of corpus parti
divided by the size of the corpus (i.e. the sum of the part sizes)
The value "gries_2008"
implements the original version proposed by Gries (2008: 415). Note that while the following formula represents Gries scaling (0 = even, 1 = uneven), in the current function the directionality is controlled separately using the argument directionality
.
\frac{\sum_i^k |t_i - w_i|}{2}
(Gries 2008)
The value "lijffit_gries_2012"
implements the modified version described by Lijffit & Gries (2012). Again, the following formula represents Gries scaling (0 = even, 1 = uneven), but the directionality is handled separately in the current function. The notation min\{w_i\}
refers to the w_i
value of the smallest corpus part.
\frac{\sum_i^k |t_i - w_i|}{2} \times \frac{1}{1 - min\{w_i\}}
(Lijffijt & Gries 2012)
The value "egbert_etal_2020"
(default) selects the modification suggested by Egbert et al. (2020: 99). The following formula represents conventional scaling (0 = uneven, 1 = even). The notation min\{w_i: t_i > 0\}
refers to the w_i
value among those corpus parts that include at least one occurrence of the item.
1 - \frac{\sum_i^k |t_i - w_i|}{2} \times \frac{1}{1 - min\{w_i: t_i > 0\}}
(Egbert et al. 2020)
Value
A numeric vector the same length as the number of items in the term-document matrix
Author(s)
Lukas Soenning
References
Carroll, John B. 1970. An alternative to Juilland’s usage coefficient for lexical frequencies and a proposal for a standard frequency index. Computer Studies in the Humanities and Verbal Behaviour 3(2). 61–65. doi:10.1002/j.2333-8504.1970.tb00778.x
Egbert, Jesse, Brent Burch & Douglas Biber. 2020. Lexical dispersion and corpus design. International Journal of Corpus Linguistics 25(1). 89–115. doi:10.1075/ijcl.18010.egb
Gries, Stefan Th. 2008. Dispersions and adjusted frequencies in corpora. International Journal of Corpus Linguistics 13(4). 403–437. doi:10.1075/ijcl.13.4.02gri
Gries, Stefan Th. 2022. What do (most of) our dispersion measures measure (most)? Dispersion? Journal of Second Language Studies 5(2). 171–205. doi:10.1075/jsls.21029.gri
Gries, Stefan Th. 2024. Frequency, dispersion, association, and keyness: Revising and tupleizing corpus-linguistic measures. Amsterdam: Benjamins. doi:10.1075/scl.115
Juilland, Alphonse G. & Eugenio Chang-Rodríguez. 1964. Frequency dictionary of Spanish words. The Hague: Mouton de Gruyter. doi:10.1515/9783112415467
Lijffijt, Jefrey & Stefan Th. Gries. 2012. Correction to Stefan Th. Gries’ ‘Dispersions and adjusted frequencies in corpora’. International Journal of Corpus Linguistics 17(1). 147–149. doi:10.1075/ijcl.17.1.08lij
Rosengren, Inger. 1971. The quantitative concept of language and its relation to the structure of frequency dictionaries. Études de linguistique appliquée (Nouvelle Série) 1. 103–127.
Examples
disp_DP_tdm(
tdm = biber150_spokenBNC2014[1:20,],
row_partsize = "first",
directionality = "conventional",
formula = "gries_2008",
freq_adjust = FALSE)