psych (version 1.0-97)

make.keys: Create a keys matrix for use by score.items or cluster.cor

Description

When scoring items by forming composite scales either from the raw data using score.items or from the correlation matrix using cluster.cor, it is necessary to create a keys matrix. This is just a short cut for doing so. The keys matrix is a nvar x nscales matrix of -1,0, 1 and defines the membership for each scale.

Usage

make.keys(nvars, keys.list, key.labels = NULL, item.labels = NULL)

Arguments

nvars
Number of variables items to be scored
keys.list
A list of the scoring keys,one element for each scale
key.labels
Labels for the scales can be specified here, or in the key.list
item.labels
Typically, just the colnames of the items data matrix.

Value

  • keysa nvars x nkeys matrix of -1, 0, or 1s describing how to score each scale. nkeys is the length of the keys.list

Details

There are two ways to create keys for the score.items function. One is to laboriously do it in a spreadsheet and then copy them into R. The other is to just specify them by item number in a list.

See Also

score.items, cluster.cor

Examples

Run this code
data(attitude)
 key.list <- list(all=c(1,2,3,4,-5,6,7),
                  first=c(1,2,3),
                  last=c(4,5,6,7))
 keys <- make.keys(7,key.list,item.labels = colnames(attitude))
 keys
 
 scores <- score.items(keys,attitude)
 scores
 
 data(bfi)
 keys.list <- list(agree=c(-1,2:5),conscientious=c(6:8,-9,-10),extraversion=c(-11,-12,13:15),neuroticism=c(16:20),openness = c(21,-22,23,24,-25))
 keys <- make.keys(25,keys.list,item.labels=colnames(bfi)[1:25])
 scores <- score.items(keys,bfi[,1:25])
 summary(scores)

Run the code above in your browser using DataCamp Workspace