This function requires the mvtnorm package.
train_similarity_based_reasoning(
anonymized_data,
num_allowed_codes = 1291,
coding_index_w_codes,
coding_index_without_codes = NULL,
preprocessing = list(stopwords = NULL, stemming = NULL, strPreprocessing = TRUE,
removePunct = FALSE),
dist_type = c("wordwise", "substring", "fulltext"),
dist_control = list(method = "osa", weight = c(d = 1, i = 1, s = 1, t = 1)),
threshold = c(max = 3, use = 1),
simulation_control = list(n.draws = 250, check_normality = FALSE)
)
a list with components
Contains all entries from the coding index. dist = "official" if the entry stems from coding_index_w_codes and dist = selfcreated if the entry stems from coding_index_without_codes. string.prob
is used for weighting purposes (model averaging) if a new verbal answer is similar to multiple strings. unobserved.mean.theta
gives a probability (usually very low) for any category that was not observed in the training data together with this string.
mean.theta
is the probability for code
given that an incoming verbal answer is similar to string
. Only available if this code was at least a single time observed with this string (Use unobserved.mean.theta
otherwise).
Number of categories in the classification.
The input parameter stored to replicate preprocessing with incoming data.
The input parameter stored to replicate distance calculations with incoming data.
The input parameter stored to replicate distance calculations with incoming data.
The input parameter stored to replicate distance calculations with incoming data.
The input parameters controlling the Monte Carlo simulation.
surveyCountsSubstringSimilarity
or surveyCountsWordwiseSimilarity
the number of allowed codes in the target classification. There are 1286 categories in the KldB 2010 plus 5 special codes in both anonymized training data sets, so the default value is 1291.
a data.table with columns
a character vector, contains masculine job titles from the coding index.
a character vector, contains feminine job titles from the coding index.
a character vector with associated classification codes.
(not used, but automatically determined) Any words from anonymized_data$dictString
that are not found within coding_index_w_codes
belong into this character vector.
a list with elements
a character vector, use tm::stopwords("de")
for German stopwords. Only used if dist_type = "wordwise"
.
NULL
for no stemming and "de"
for stemming using the German porter stemmer. Do not use unless the job titles in coding_index_w_codes
were stemmed.
TRUE
if preprocess_string
shall be used.
TRUE
if removePunctuation
shall be used.
How to calculate similarity between entries from both coding_indices and verbal answers from the survey? Three options are currently supported. Since we use the stringdist
-function excessively, one could easily extend the functionality of this procedure to other distance metrics.
Uses the stringdist
-function directly after preprocessing to calculate distances. (the simplest approach but least useful.)
An entry from the coding index and a verbal answer are similar if the entry from the coding index is a substring of the verbal answer.
After preprocessing, split the verbal answer into words. Then calculate for each word separately the the similarity with entries from the coding index, using stringdist
. Not the complete verbal answer but only the words (0 or more) that have highest similarity are then used to determine similarity with entries from the coding index.
If dist_type = "fulltext"
or dist_type = "wordwise"
the entries from this list will be passed to stringdist
. Currently only two possible entries are supported (method = "osa", weight = c(d = 1, i = 1, s = 1, t = 1) is recommended), but one could easily extend the functionality.
A numeric vector with two elements. If dist_type = "fulltext"
or dist_type = "wordwise"
, the threshold determines up to which distance a verbal answer and an entry from the coding index are similar. The second number actually gets used. The first number is only used to speed up similarity calculations. It should be identical or larger than the second number.
a list with two components,
Number of draws from the posterior distribution to determine posterior predictive probabilities. The larger, the more precise the results will be.
We would like that the hyperprior distribution is normal. Set check_normality to TRUE to do some diagnostics about this.
Schierholz, Malte (2019): New methods for job and occupation classification. Dissertation, Mannheim. https://madoc.bib.uni-mannheim.de/50617/, pp. 206-208 and p. 268, pp. 308-320
https://github.com/malsch/occupationCoding (function trainSimilarityBasedReasoning2 is implemented here)
pretrained_models, which were created using this function.