score_lurn_si_29: Returns scores for the LURN SI-29 based on a dataframe of...

View source: R/score_lurn_si_29.R

score_lurn_si_29R Documentation

Returns scores for the LURN SI-29 based on a dataframe of input

Description

This function returns takes a dataframe, extracts the LURN SI-29 items, calculates the subscale scores, and returns them along with any other variables from "input" that you request.

Usage

score_lurn_si_29(
  input,
  transfer_vars = names(input),
  warn_or_stop = c("stop", "warn")
)

Arguments

input

A dataframe containing LURN SI-29 items. Other columns may also be present and will be returned by the function (if desired). The items should be numeric type (e.g., not factors, not character)

transfer_vars

A vector of variable names to be found in input. These variables will be returned in the output along with the LURN SI-29 scores.

warn_or_stop

This is set to "stop" by default, which means that any problems in the input will cause execution of the function to stop (i.e., you will receive an error). Problems in the input include any out-of-range or non-numeric data in the input. If you receive an error message, you will need to fix your input in order to proceed. If warn_or_stop is set to "warn", then warnings will notify you that non-numeric or out-of-range data are present, which are then recoded to NA with a warning message.

Details

If only a subset of variables are desired to be returned, the column names can be specified using the transfer_vars argument. Any out-of-range or non-numeric data in the input will cause an error, unless you set warn_or_stop to "warn". If warn_or_stop is set to "warn", then out-of-range or non-numeric values will be recoded to NA. Moreover, any character data will be coerced to numeric as part of the scoring.

Value

A dataframe of output containing SI-29 scores, and any variables requested in transfer_vars.

Setting up your input

You must use the recommended variables names for the LURN SI-29, which have the form SI29_Q1, SI29_Q2, etc. For item #27, there is SI29_Q27a for women (SEX = 2), and SI29_Q27b for men (SEX = 1). You can use lurn_si_29_names() to obtain a list of the recommended variable names.

Item response coding

Responses should be represented in the data starting at 0 (e.g., Item 1 should be 0, 1, 2, 3, ... and so on for all items.) This must be respected in order for this R package to score the data properly. Check the official version of the questionnaires at https://nih-lurn.org/Resources/Questionnaires. A check on your input will be conducted when you score your data. If your data appear to be mis-coded, you will receive a friendly message encouraging you to check your input.

Data type for LURN SI-29 items

We recommend that numeric type be used for the LURN SI-29 data. If your data are factors, then the function will stop and issue an error message. If you set "warn_or_stop" to "warn", the function will attempt to fix up your data and present a warning.

Setting up Sex in your input

Your input needs to contain a variable "SEX" with numeric values of "1" for male and "2" for female.

Long versus Wide longitudinal data

We recommend using long data for longitudinal datasets for scoring LURN SI data (i.e., one row per time point).

See Also

For a list of recommended variable names for the LURN SI-29, you can use this helper function: lurn_si_29_names

Examples

## Not run: 
score_lurn_si_29(some_si_29_data)

score_lurn_si_29(input = lurn_si_29_data)

## End(Not run)

jameswgriffith/lurn documentation built on July 30, 2023, 4:31 a.m.