convert_responses_to_kernel_sign
def convert_responses_to_kernel_sign(responses)Converts dichotomous responses to the appropriate kernel sign.
Takes in an array of responses coded as either [True/False] or [0/1] and converts it into [+1 / -1] to be used during parameter estimation.
Values that are not 0 or 1 are converted into a zero which means these values do not contribute to parameter estimates. This can be used to account for missing values.
Args
responses- [n_items x n_participants] array of response values
Returns
the_sign- (2d array) sign values associated with input responses
Expand source code
def convert_responses_to_kernel_sign(responses): """Converts dichotomous responses to the appropriate kernel sign. Takes in an array of responses coded as either [True/False] or [0/1] and converts it into [+1 / -1] to be used during parameter estimation. Values that are not 0 or 1 are converted into a zero which means these values do not contribute to parameter estimates. This can be used to account for missing values. Args: responses: [n_items x n_participants] array of response values Returns: the_sign: (2d array) sign values associated with input responses """ # The default value is now 0 the_sign = np.zeros_like(responses, dtype='float') # 1 -> -1 mask = responses == 1 the_sign[mask] = -1 # 0 -> 1 mask = responses == 0 the_sign[mask] = 1 return the_sign
Last modified April 15, 2020: Adding doc strings to utility functions. (99abcbc)