public class QCMetrics extends Object
Modifier and Type | Field and Description |
---|---|
static int |
bootstrapIterations |
Constructor and Description |
---|
QCMetrics() |
Modifier and Type | Method and Description |
---|---|
static double |
averagePathLength(Survey survey) |
static BreakoffByPosition |
calculateBreakoffByPosition(Survey survey,
List<AbstractSurveyResponse> responses)
Aggregates the breakoff according to the last position answered.
|
static BreakoffByQuestion |
calculateBreakoffByQuestion(Survey survey,
List<AbstractSurveyResponse> responses)
Aggregates the breakoff according to which question was last answered.
|
static OrderBiasStruct |
calculateOrderBiases(Survey survey,
List<AbstractSurveyResponse> responses,
double alpha)
Searches for significant order biases observed in survey responses.
|
static WordingBiasStruct |
calculateWordingBiases(Survey survey,
List<AbstractSurveyResponse> responses,
double alpha)
Searches for significant wording biases observed in survey responses.
|
protected static double |
cellExpectation(int[][] contingencyTable,
int i,
int j,
int n) |
protected static double |
chiSquared(int[][] contingencyTable,
Object[] categoryA,
Object[] categoryB) |
static ClassifiedRespondentsStruct |
classifyResponses(Survey survey,
List<AbstractSurveyResponse> responses,
Classifier classifier,
boolean smoothing,
double alpha)
Classifies the input responses according to the classifier.
|
protected static void |
computeRanks(double[] xranks,
List xs) |
protected static double |
cramersV(Map<String,IQuestionResponse> listA,
Map<String,IQuestionResponse> listB) |
static boolean |
entropyClassification(Survey survey,
AbstractSurveyResponse sr,
List<AbstractSurveyResponse> responses,
boolean smoothing,
double alpha)
Return true if the response is valid, on the basis of an entropy-based metric.
|
static List<List<AbstractSurveyResponse>> |
generateBootstrapSample(List<AbstractSurveyResponse> responses,
int iterations)
Generates the bootstrap sample for the input response and the specified number of iterations.
|
static List<List<Block>> |
getDag(List<Block> blockList)
Takes in a list of Blocks; returns a list of lists of Blocks representing all possible paths through the survey.
|
static double |
getEntropyForResponse(AbstractSurveyResponse surveyResponse,
Map<String,Map<String,Double>> probabilities) |
protected static List<Component> |
getEquivalentAnswerVariants(Question q,
Component c)
Returns equivalent answer options (a list of survey.Component)
|
static Map<Question,Map<Question,CorrelationStruct>> |
getFrequenciesOfRandomCorrelation(Survey survey,
int sampleSize,
double alpha)
Simulates a survey of 100% random uniform respondents over sampleSize and calculates a prior on false correlation.
|
static double |
getLLForResponse(List<IQuestionResponse> questionResponses,
Map<String,Map<String,Double>> probabilities) |
static double |
getMaxPossibleEntropy(Survey survey)
The public method used to compute the maximum number of bits needed to represent this survey.
|
protected static List<List<Block>> |
getPaths(Survey s)
Returns paths through **blocks** in the survey.
|
static List<Question> |
getQuestions(List<Block> blockList)
Returns all questions in a block list (typically the topLevelBlocks of a Survey).
|
static boolean |
logLikelihoodClassification(Survey survey,
AbstractSurveyResponse sr,
List<AbstractSurveyResponse> responses,
boolean smoothing,
double alpha)
Returns true if the response is valid, on the basis of the log likelihood.
|
static Map<String,Map<String,Integer>> |
makeFrequencies(List<AbstractSurveyResponse> responses)
When used without the survey argument, this returns frequencies that do not calculate smoothing.
|
static Map<String,Map<String,Integer>> |
makeFrequencies(List<AbstractSurveyResponse> responses,
Survey survey)
Creates a frequency map for the actual responses to the survey.
|
protected static Map<List<Block>,List<AbstractSurveyResponse>> |
makeFrequenciesForPaths(List<List<Block>> paths,
List<AbstractSurveyResponse> responses)
Returns the counts for each path; see @etosch's blog post on the calculation.
|
static Map<String,Map<String,Double>> |
makeProbabilities(Map<String,Map<String,Integer>> frequencies) |
protected static double |
mannWhitney(Question q1,
Question q2,
List<Component> list1,
List<Component> list2) |
static int |
maximumPathLength(Survey survey) |
static int |
minimumPathLength(Survey survey) |
protected static List<Question> |
removeFreetext(List<Question> questionList) |
protected static double |
spearmansRho(Map<String,IQuestionResponse> listA,
Map<String,IQuestionResponse> listB) |
static double |
surveyEntropy(Survey survey,
List<AbstractSurveyResponse> responses)
Calculates the empirical entropy for this survey, given a set of responses.
|
public static List<List<Block>> getDag(List<Block> blockList)
blockList
- A list of blocks we would like to traverse.protected static List<List<Block>> getPaths(Survey s)
s
- The survey whose paths we want to enumerateprotected static Map<List<Block>,List<AbstractSurveyResponse>> makeFrequenciesForPaths(List<List<Block>> paths, List<AbstractSurveyResponse> responses)
paths
- The list of list of blocks through the survey; can be obtained with getPaths or getDagresponses
- The list of actual or simulated responses to the surveyprotected static List<Component> getEquivalentAnswerVariants(Question q, Component c)
q
- The question whose variants we want. If there are no variants, then a set of just this question is
returned.c
- The answer the respondent provided for this question.public static double surveyEntropy(Survey survey, List<AbstractSurveyResponse> responses)
survey
- The survey these respondents answered.responses
- The list of actual or simulated responses to the survey.public static List<Question> getQuestions(List<Block> blockList)
blockList
- A list of blocks we would like to traverse.public static double getMaxPossibleEntropy(Survey survey)
survey
- public static int minimumPathLength(Survey survey)
public static int maximumPathLength(Survey survey)
public static double averagePathLength(Survey survey) throws SurveyException
SurveyException
public static Map<String,Map<String,Integer>> makeFrequencies(List<AbstractSurveyResponse> responses)
responses
- The list of actual or simulated responses to the surveypublic static Map<String,Map<String,Integer>> makeFrequencies(List<AbstractSurveyResponse> responses, Survey survey)
responses
- The list of actual or simulated responses to the survey.survey
- The survey these respondents answered.public static Map<String,Map<String,Double>> makeProbabilities(Map<String,Map<String,Integer>> frequencies)
public static double getLLForResponse(List<IQuestionResponse> questionResponses, Map<String,Map<String,Double>> probabilities)
public static double getEntropyForResponse(AbstractSurveyResponse surveyResponse, Map<String,Map<String,Double>> probabilities)
public static List<List<AbstractSurveyResponse>> generateBootstrapSample(List<AbstractSurveyResponse> responses, int iterations)
responses
- The list of actual or simulated responses to the survey.iterations
- The number of bootstrap samples we should generate.public static boolean logLikelihoodClassification(Survey survey, AbstractSurveyResponse sr, List<AbstractSurveyResponse> responses, boolean smoothing, double alpha) throws SurveyException
survey
- The survey these respondents answered.sr
- The survey response we are classifying.responses
- The list of actual or simulated responses to the surveysmoothing
- Boolean indicating whether we should smooth our calculation of answer frequencies.alpha
- The cutoff used for determining whether a likelihood is too low (a percentage of area under the curve).SurveyException
public static boolean entropyClassification(Survey survey, AbstractSurveyResponse sr, List<AbstractSurveyResponse> responses, boolean smoothing, double alpha) throws SurveyException
survey
- The survey these respondents answered.sr
- The survey response we are classifying.responses
- The list of actual or simulated responses to the surveysmoothing
- Boolean indicating whether we should smooth our calculation of answer frequencies.alpha
- The cutoff used for determining whether a likelihood is too low (a percentage of area under the curve).SurveyException
protected static void computeRanks(double[] xranks, List xs)
protected static double spearmansRho(Map<String,IQuestionResponse> listA, Map<String,IQuestionResponse> listB)
protected static double cellExpectation(int[][] contingencyTable, int i, int j, int n)
protected static double chiSquared(int[][] contingencyTable, Object[] categoryA, Object[] categoryB)
protected static double cramersV(Map<String,IQuestionResponse> listA, Map<String,IQuestionResponse> listB)
protected static double mannWhitney(Question q1, Question q2, List<Component> list1, List<Component> list2)
public static Map<Question,Map<Question,CorrelationStruct>> getFrequenciesOfRandomCorrelation(Survey survey, int sampleSize, double alpha) throws SurveyException
survey
- The survey these respondents answered.sampleSize
- The sample size the survey writer intends to use during the full-scale study.alpha
- The cutoff used for determining correlation.SurveyException
public static BreakoffByPosition calculateBreakoffByPosition(Survey survey, List<AbstractSurveyResponse> responses)
survey
- The survey these respondents answered.responses
- The list of actual or simulated responses to the survey.public static BreakoffByQuestion calculateBreakoffByQuestion(Survey survey, List<AbstractSurveyResponse> responses)
survey
- The survey these respondents answered.responses
- The list of actual or simulated responses to the survey.public static WordingBiasStruct calculateWordingBiases(Survey survey, List<AbstractSurveyResponse> responses, double alpha) throws SurveyException
survey
- The survey these respondents answered.responses
- The list of actual or simulated responses to the survey.alpha
- The cutoff used for determining whether the bias is significant.SurveyException
public static OrderBiasStruct calculateOrderBiases(Survey survey, List<AbstractSurveyResponse> responses, double alpha) throws SurveyException
survey
- The survey these respondents answered.responses
- The list of actual or simulated responses to the survey.alpha
- The cutoff used for determining whether the bias is significant.SurveyException
public static ClassifiedRespondentsStruct classifyResponses(Survey survey, List<AbstractSurveyResponse> responses, Classifier classifier, boolean smoothing, double alpha) throws SurveyException
survey
- The survey these respondents answered.responses
- The list of actual or simulated responses to the survey.classifier
- The enum corresponding to the classifier type.smoothing
- A boolean value indicating whether the frequencies of responses should be smoothed.alpha
- The cutoff used for determining whether validity is exceptionally low.SurveyException
Copyright © 2015. All rights reserved.