public class QCMetrics extends Object
Modifier and Type | Field and Description |
---|---|
static int |
bootstrapIterations |
static MersenneRandom |
rng |
Constructor and Description |
---|
QCMetrics(Survey survey) |
QCMetrics(Survey survey,
boolean smoothing) |
Modifier and Type | Method and Description |
---|---|
double |
averagePathLength()
Simulates the survey for 5000 uniform random respondents and returns the average path length.
|
BreakoffByPosition |
calculateBreakoffByPosition(List<? extends SurveyResponse> responses)
Aggregates the breakoff according to the last position answered.
|
BreakoffByQuestion |
calculateBreakoffByQuestion(List<? extends SurveyResponse> responses)
Aggregates the breakoff according to which question was last answered.
|
WordingBiasStruct |
calculateWordingBiases(List<? extends SurveyResponse> responses,
double alpha)
Searches for significant wording biases observed in survey responses.
|
protected static double |
cellExpectation(int[][] contingencyTable,
int i,
int j,
int n) |
static double |
chiSquared(int[][] contingencyTable,
Object[] categoryA,
Object[] categoryB)
Returns the chi-squared statistic for the input data.
|
static double |
chiSquareTest(int df,
double testStatistic) |
ClassifiedRespondentsStruct |
classifyResponses(List<? extends SurveyResponse> responses,
Classifier classifier,
double alpha)
Classifies the input responses according to the classifier.
|
protected List<Double> |
computeMeans(SurveyResponse sr,
List<? extends SurveyResponse> responses,
Classifier classifier) |
protected static void |
computeRanks(double[] xranks,
List xs) |
protected static double |
cramersV(Map<String,IQuestionResponse> listA,
Map<String,IQuestionResponse> listB) |
boolean |
entropyClassification(SurveyResponse sr,
List<? extends SurveyResponse> responses,
double alpha)
Return true if the response is valid, on the basis of an entropy-based metric.
|
static List<Question> |
filterAnalyzable(List<Question> questionList)
Filter the list of questions for things that can be analyzed in terms of survey correctness.
|
static List<List<SurveyResponse>> |
generateBootstrapSample(List<? extends SurveyResponse> responses)
Generates the bootstrap sample for the input response and the specified number of iterations.
|
double |
getEntropyForResponse(SurveyResponse surveyResponse) |
protected static List<SurveyDatum> |
getEquivalentAnswerVariants(Question q,
SurveyDatum c)
Returns equivalent answer options (a list of survey.SurveyDatum)
|
Map<Question,Map<Question,CorrelationStruct>> |
getFrequenciesOfRandomCorrelation()
Simulates a survey of 100% random uniform respondents over sampleSize and calculates a prior on false correlation.
|
double |
getLLForResponse(SurveyResponse surveyResponse) |
double |
getMaxPossibleEntropy()
The public method used to compute the maximum number of bits needed to represent this survey.
|
static boolean |
isAnalyzable(Question question) |
boolean |
isFinalQuestion(Question question,
SurveyResponse surveyResponse) |
boolean |
logLikelihoodClassification(SurveyResponse sr,
List<? extends SurveyResponse> responses,
double alpha)
Returns true if the response is valid, on the basis of the log likelihood.
|
void |
lpoClassification(List<? extends SurveyResponse> responses,
double epsilon)
Computes the validity of the input responses, based on the "Least popular option" metric.
|
void |
makeFrequencies(List<? extends SurveyResponse> responses)
Creates a frequency map for the actual responses to the survey.
|
void |
makeProbabilities(List<? extends SurveyResponse> responses) |
static double |
mannWhitney(Question q1,
Question q2,
List<SurveyDatum> list1,
List<SurveyDatum> list2)
Mann-Whitney statistic, specialized for comparing survey questions.
|
int |
maximumPathLength() |
int |
minimumPathLength() |
protected static double |
spearmansRho(Map<String,IQuestionResponse> listA,
Map<String,IQuestionResponse> listB) |
static double |
surveyEntropy(Survey survey,
List<? extends SurveyResponse> responses)
Calculates the empirical entropy for this survey, given a set of responses.
|
public static final MersenneRandom rng
public static int bootstrapIterations
public QCMetrics(Survey survey)
public QCMetrics(Survey survey, boolean smoothing)
public int maximumPathLength()
public static boolean isAnalyzable(Question question)
public static List<Question> filterAnalyzable(List<Question> questionList)
questionList
- The list to filter.protected static List<SurveyDatum> getEquivalentAnswerVariants(Question q, SurveyDatum 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<? extends SurveyResponse> responses)
survey
- The survey these respondents answered.responses
- The list of actual or simulated responses to the survey.public double getMaxPossibleEntropy()
public int minimumPathLength()
public double averagePathLength() throws SurveyException
SurveyException
public void makeFrequencies(List<? extends SurveyResponse> responses)
responses
- The list of actual or simulated responses to the survey.public void makeProbabilities(List<? extends SurveyResponse> responses)
public double getLLForResponse(SurveyResponse surveyResponse) throws SurveyException
SurveyException
public double getEntropyForResponse(SurveyResponse surveyResponse) throws SurveyException
SurveyException
public static List<List<SurveyResponse>> generateBootstrapSample(List<? extends SurveyResponse> responses)
responses
- The list of actual or simulated responses to the survey.protected List<Double> computeMeans(SurveyResponse sr, List<? extends SurveyResponse> responses, Classifier classifier) throws SurveyException
SurveyException
public boolean logLikelihoodClassification(SurveyResponse sr, List<? extends SurveyResponse> responses, double alpha) throws SurveyException
sr
- The survey response we are classifying.responses
- The list of actual or simulated responses to the surveyalpha
- The cutoff used for determining whether a likelihood is too low (a percentage of area under the curve).SurveyException
public void lpoClassification(List<? extends SurveyResponse> responses, double epsilon) throws SurveyException
responses
- epsilon
- SurveyException
public boolean entropyClassification(SurveyResponse sr, List<? extends SurveyResponse> responses, double alpha) throws SurveyException
sr
- The survey response we are classifying.responses
- The list of actual or simulated responses to the surveyalpha
- 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)
public static double chiSquared(int[][] contingencyTable, Object[] categoryA, Object[] categoryB)
contingencyTable
- categoryA
- categoryB
- public static double chiSquareTest(int df, double testStatistic)
protected static double cramersV(Map<String,IQuestionResponse> listA, Map<String,IQuestionResponse> listB)
public static double mannWhitney(Question q1, Question q2, List<SurveyDatum> list1, List<SurveyDatum> list2)
q1
- q2
- list1
- list2
- public Map<Question,Map<Question,CorrelationStruct>> getFrequenciesOfRandomCorrelation() throws SurveyException
SurveyException
public boolean isFinalQuestion(Question question, SurveyResponse surveyResponse)
public BreakoffByPosition calculateBreakoffByPosition(List<? extends SurveyResponse> responses)
responses
- The list of actual or simulated responses to the survey.public BreakoffByQuestion calculateBreakoffByQuestion(List<? extends SurveyResponse> responses)
responses
- The list of actual or simulated responses to the survey.public WordingBiasStruct calculateWordingBiases(List<? extends SurveyResponse> responses, double alpha) throws SurveyException
responses
- The list of actual or simulated responses to the survey.alpha
- The cutoff used for determining whether the bias is significant.SurveyException
public ClassifiedRespondentsStruct classifyResponses(List<? extends SurveyResponse> responses, Classifier classifier, double alpha) throws SurveyException
responses
- The list of actual or simulated responses to the survey.classifier
- The enum corresponding to the classifier type.alpha
- The cutoff used for determining whether validity is exceptionally low.SurveyException
Copyright © 2015. All rights reserved.