Jump starting the psych package–a guide for the impatient

You have installed psych (section 2) and you want to use it without reading much more. What should you do?

  1. Activate the psych package: r library(psych)
  2. Input your data (section 3.1). Go to your friendly text editor or data manipulation program (e.g., Excel) and copy the data to the clipboard. Include a first line that has the variable labels. Paste it into psych using the read.clipboard.tab command: r myData <- read.clipboard.tab()
  3. Make sure that what you just read is right. Describe it (section 3.2) and perhaps look at the first and last few lines: ```r describe(myData) headTail(myData) ````
  4. Look at the patterns in the data. If you have fewer than about 10 variables, look at the SPLOM (Scatter Plot Matrix) of the data using pairs.panels (section 3.3.1) Even better, use the outlier to detect outliers. r pairs.panels(myData) outlier(myData)
  5. Note that you have some weird subjects, probably due to data entry errors. Either edit the data by hand (use the edit command) or just scrub the data (section 3.2.2). r cleaned <- scrub(myData, max=9) #e.g., change anything great than 9 to NA
  6. Graph the data with error bars for each variable (section 3.3.3). r error.bars(myData)
  7. Find the correlations of all of your data.

    • Descriptively (just the values) (section 3.3.7) r r <- lowerCor(myData)
    • Graphically (section 3.3.8) r corPlot(r)
    • Inferentially (the values, the ns, and the p values) (section 3.4) r corr.test(myData)
  8. Test for the number of factors in your data using parallel analysis (fa.parallel, section 4.4.2) or Very Simple Structure (vss, 4.4.1). r fa.parallel(myData) vss(myData)

  9. Factor analyze (see section 4.1) the data with a specified number of factors (the default is 1), the default method is minimum residual, the default rotation for more than one factor is oblimin. There are many more possibilities (see sections 4.1.1-4.1.3). Compare the solution to a hierarchical cluster analysis using the ICLUST algorithm [@revelle1979hierarchical] (see section 4.1.6). Also consider a hierarchical factor solution to find coefficient $\omega$ (see 4.1.5). r fa(myData) iclust(myData) omega(myData) If you prefer to do a principal components analysis you may use the principal function. The default is one component. r principal(myData)

  10. Some people like to find coefficient $/alpha$ as an estimate of reliability. This may be done for a single scale using the alpha function (see 5.1). Perhaps more useful is the ability to create several scales as unweighted averages of specified items using the scoreItems function (see 5.4) and to find various estimates of internal consistency for these scales, find their intercorrelations, and find scores for all the subjects. r alpha(myData) #score all of the items as part of one scale. myKeys <- make.keys(nvar=20, list(first = c(1,-3,5,-7,8:10), second=c(2,4,-6,11:15,-16))) my.scores <- scoreItems(myKeys,myData) #form several scales my.scores #show the highlights of the results

At this point you have had a chance to see the highlights of the psych package and to do some basic (and advanced) data analysis. You might find reading this entire vignette helpful to get a broader understanding of what can be done in R using the psych. Remember that the help command (?) is available for every function. Try running the examples for each help page.

Overview of this and related documents

Getting started {#started}

Basic data analysis

Data input from the clipboard

References



frenchja/psych documentation built on May 16, 2019, 2:49 p.m.