Check for straight-liners with standard deviation

Updated at February 4th, 2021

There are different methods to check for outliers or low quality data in survey responses. Protobi even has a QC tool that helps you flag respondents based on pre-set conditions like straight-lining. However, there are some quality checks that are more complex and are better written out in data process. One example is using standard deviation to check for straight-liners in a battery of responses. 

In the example below, Q13 is a battery of 7-point scale questions. You could use the QC tool to perform the pre-set straight-line check. However you might consider respondents  who gave very similar responses for each question suspicious in addition to true straight-liners. 

In project Pre-calculate you can define function that calculates the standard deviation between the children of a group.


//Function used to calculate standard deviation

function std(row, kidKeys) {

    var vals = { return row[kidKey] }); 

    if (vals[0]) var res = d3.deviation(vals)

    return res;

//Groups/children for which you want to calculate std

var checks = {

    "Q13": ["Q13_1", "Q13_2", "Q13_3", "Q13_4", "Q13_5"]


//Create new "std_" variable standard deviation calculation

rows.forEach(function(row) {

    for (var key in checks) {

    row["std_"+key] = std(row, checks[key])



return rows;


The code above create a new element with std_ appended as a pre-fix.  For the distribution below the round by is [0,0.5,1,3]. 

If you click into the zero values in the standard deviation element, you should see that all those respondents were flagged in the straight-line check from the QC tool. 

If you click to drill in on respondents with a low standard deviation (e.g. 0.1 - 0.5), you can choose individual respids to check. This respondent did not straight-line, but they use the same rating for all but one of the questions in the battery. 

Advanced support

There are complex cases where you might want to flag respondents, not limited to the example in this tutorial. Contact us at to discuss your specific needs.

Was this article helpful?