View source: R/predictWithCodingIndex.R
predictWithCodingIndex | R Documentation |
Look up the correct code in a coding index. We often find no code, 1 code or even more than one possible code this way.
predictWithCodingIndex(
newdata,
coding_index,
include.substrings = FALSE,
max.count.categories = Inf
)
newdata |
either a data.table created with |
coding_index |
a data.table as created with function |
include.substrings |
(default: |
max.count.categories |
(default: |
a data.table with columns id, ans, and pred.code (format is not comparable to other formats in this package.)
predictSimilarityBasedReasoning
# set up data
data(occupations)
allowed.codes <- c("71402", "71403", "63302", "83112", "83124", "83131", "83132", "83193", "83194", "-0004", "-0030")
allowed.codes.titles <- c("Office clerks and secretaries (without specialisation)-skilled tasks", "Office clerks and secretaries (without specialisation)-complex tasks", "Gastronomy occupations (without specialisation)-skilled tasks",
"Occupations in child care and child-rearing-skilled tasks", "Occupations in social work and social pedagogics-highly complex tasks", "Pedagogic specialists in social care work and special needs education-unskilled/semiskilled tasks", "Pedagogic specialists in social care work and special needs education-skilled tasks", "Supervisors in education and social work, and of pedagogic specialists in social care work", "Managers in education and social work, and of pedagogic specialists in social care work",
"Not precise enough for coding", "Student assistants")
proc.occupations <- removeFaultyAndUncodableAnswers_And_PrepareForAnalysis(occupations, colNames = c("orig_answer", "orig_code"), allowed.codes, allowed.codes.titles)
# recommended default
res <- predictWithCodingIndex(proc.occupations,
coding_index = coding_index_excerpt,
include.substrings = FALSE,
max.count.categories = Inf)
# playing around with the parameters to obtain other results
res <- predictWithCodingIndex(proc.occupations,
coding_index = coding_index_excerpt,
include.substrings = TRUE,
max.count.categories = 15)
#################################
# Analysis: Standard functions from this package won't work here.
# Absolute numbers: either nothing is predicted (nPredictedCodes = NA), or 1 or more cods are predicted
res[ , .N, by = list(nPredictedCodes = 1 + nchar(pred.code) %/% 6 )]
# Relative Numbers
res[ , .N / res[, .N], by = list(nPredictedCodes = 1 + nchar(pred.code) %/% 6 )]
# Agreement rate among answers where only a single code was predicted
res[nchar(pred.code) == 5, mean(pred.code == code)]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.