r programming for psychometrics

34
DIANE TALLEY UNIVERSITY OF NORTH CAROLINA, CHAPEL HILL R Programming for Psychometrics Presented to Alpine Testing Solutions August 2013

Upload: diane-talley

Post on 27-Jan-2015

108 views

Category:

Education


5 download

DESCRIPTION

This presentation if for beginners in R and is geared toward use in psychometrics (academic, credentialing, and psychological exam development).

TRANSCRIPT

Page 1: R programming for psychometrics

D I A N E TA L L E YU N I V E R S I T Y O F N O RT H C A R O L I N A , C H A P E L

H I L L

R Programming for PsychometricsPresented to Alpine Testing Solutions August 2013

Page 2: R programming for psychometrics

Define R/perceptions of R

R in psychometrics What’s great and not so

great about R Legal defensibility and R Learning R The R environment A few tips for beginners

Page 3: R programming for psychometrics

What is R?

Implementation of the S statistical programing language (Bell Labs -Chambers, Wilkes, Becker)

Developed at University of Auckland by professors Robert Gentleman and Ross Ihaka

http://www.r-project.org/contributors.html - lists all R contributors

An object oriented language…..sort of

Page 4: R programming for psychometrics

The R Community: Perceptions from without and within

R is for hippies! …(Quote from a SAS user)

…or perhaps nerds with a quirky sense of humor using words such as Cran-tastic,

Cranberries, and useRs

Page 5: R programming for psychometrics

The R Community

Oh, and all the pirate jokes!

“R Matey”

Page 6: R programming for psychometrics

But seriously, what is R?

It has an academic following and data analytics across industries (i.e., pharma, biostats).

The commercialized side of R: Data AnalyticsRevolution Analytics

Enterprise software Possibly the SAS Enterprise version of R

Page 7: R programming for psychometrics

How is R being used in Psychometrics

I’m using the term psychometrics in reference to the field of testing (educational, credentialing, and psychology) Research

See references Mostly using simulated data and related to the use of a particular r

package (i.e., eRm for Rasch modeling) Test delivery

The Psychometric Centre at Cambridge University Concerto http://

www.psychometrics.cam.ac.uk/page/338/concerto-testing-platform.htm

What about use in practice? There’s not much evidence yet that I have found indicating R is being used to construct examinations for high stakes

testing purposes.

Page 8: R programming for psychometrics

Benefits

It’s free!Runs on multiple platforms (Windows, Unix,

MacOS)Validation/replication of analyses (assumes

commented code and documentation)Long term efficiency (using the same code for

multiple projects)

Page 9: R programming for psychometrics

Psychometric Capabilities

CTTIRTFactor AnalysisScoringTest delivery (Concerto)Survey analysisDatabase access

Page 10: R programming for psychometrics

Drawbacks

Perceptions (as they pertain to using R for high stakes testing purposes)

Open source could be a problem for use with high stakes testing projects…maybe

Challenging to learn (some say R is one of the hardest programming languages to learn)

http://www.statmethods.net/about/learningcurve.html http://datakeyword.blogspot.com/2012/10/analysis-tools-compar

ison-r-language.html

Page 11: R programming for psychometrics

R is free software and comes with

ABSOLUTELY NO WARRANTY.

What does that mean for use in psychometric

practice? Or for any practice for that matter.

Page 12: R programming for psychometrics

R and Legal Defensibility

Is the open source nature of R an issue for legal defensibility?

Page 13: R programming for psychometrics

Learning to Program in R

Page 14: R programming for psychometrics

Books

For a comprehensive list go to http://www.r-project.org/doc/bib/R-books.html

Field, A., Miles, J., & Field, Z. (2012). Discovering statistics using R. London: Sage Publications Ltd . This is great for learning how to use R in the context of

statistical tests, unless you are sensitive to Dr. Field’s non-pc sense of humor. 

Pace, L. (2012). Beginning R: An introduction to statistical programming. New York: Apress.

These two are great reference books to have on the shelf: Teetor, P. (2011). R cookbook. Sebastopol, CA: O'Reilly. Teetor, P. (2013). R graphics cookbook . Sebastopol, CA: O'Reilly.

Page 15: R programming for psychometrics

Free Online R Tutorials

http://www.statmethods.net/ Quick R – This was one of my favorites for getting star

ted. https://www.coursera.org/course/compdata

There’s a course starting in September taught by a professor at John’s Hopkins University

http://ww2.coastal.edu/kingw/statistics/R-tutorials/ http://tryr.codeschool.com/

Beware the pirate humor! http://r-statistics.net/r-tutorial.html http://www.personality-project.org/r/book/ http://www.computerworld.com/s/article/9239625/Begin

ner_s_guide_to_R_Introduction http://decisionstats.com/2013/07/18/datamind-a-new-effo

rt-to-teach-r-online-for-free-rstats/?goback=.gde_77616_member_259229553 Heavily focused on data analytics in R

Page 16: R programming for psychometrics

R Training for a Price

http://georgia-r-school.org/?goback=.gmr_77616.gde_77616_member_201820973

• Online only

http://www.revolutionanalytics.com/• Instructor led training and online (through stats.com) • Path available that leads to a credential

Page 17: R programming for psychometrics

User Groups and Blogs That I Like

LinkedIn R Project for Statistical Computing Most friendly to new users who are asking basic

questions. http://www.r-bloggers.comhttp://www.foastat.org/http://planetr.stderr.org/http://stackoverflow.com/

This is the best I’ve found for technical questions

Page 18: R programming for psychometrics

Associations

FOA – Foundation for Open-Analytic Statistics Promoting methodology and software that allows truly

reproducible research Free online journal

http://eeecon.uibk.ac.at/psychoco/ Psychometric computing

Page 19: R programming for psychometrics

Conventions and best practices

No official best practices Google’s R Style Guide is helpful

When in doubt use rseek.org (this is google with an R filter – hugely helpful!)

Page 20: R programming for psychometrics

The R Environment

Page 21: R programming for psychometrics

Installing R

http://cran.r-project.org/ Technical docs - http://developer.r-project.org/ Latest release 3.0.1 Mirrors - R isn’t housed in a single location, but across the

globe at mirror sites. Pick the one nearest you. Task View

This is an amazing reference. Packages are organized by purpose (i.e., Social Sciences, Psychometrics, Graphics).

Updates You can install new version without uninstalling old version.

Haven’t found an answer to the question of whether you should do this.

Internet based R, if you prefer http://roncloud.com –

Page 22: R programming for psychometrics

Installing Packages

Base packagesPsych packages

http://cran.r-project.org/web/views/Install once, call each time you need to use it

library() require() Or, if you are using an IDE such as Rstudio it’s as

simple as checking a boxMasking - Learn what it is and pay attention

to it!

Page 23: R programming for psychometrics

Programming Environments

Basic RSome free IDEs

Rstudio (My personal preference) -http://www.rstudio.com/ide/docs/using/source

Architect - http://www.openanalytics.eu/downloads RevolutionR -

http://www.revolutionanalytics.com/downloads/ Revolution Analytics has 3 versions, a “community”

version that is free and two that are not free

Page 24: R programming for psychometrics

Some Psychometric Packages to Start With

CTTpsychpsychometricggplot2equateplyreRMmirtsem

Page 25: R programming for psychometrics

Getting Help

R manuallibrary(help="stats")Package documentation and vignettesrseek.org

Page 26: R programming for psychometrics

A note about graphs and tables

Graphs graphics is part of basic R ggplot2 is recommended by many users and books

Tables: It’s not pretty if you are doing this using psych packages! I’m sure there’s a way to make an APA table, but I

haven’t found it yet. Applications that allow you to create reports

(pdf, word, LaTeX) Sweave knitr

Page 27: R programming for psychometrics

Writing an R program

Page 28: R programming for psychometrics

Objects and Functionsobject <- function (formal arguments)Example 1rawScores <- c(26, 42, 36, 49)Example 2mean(rawScores)

Is this all you need to know?

Page 29: R programming for psychometrics

Functions, Classes, and Object-Oriented Programming

http://developer.r-project.org/ Chambers, J. (2006) How S4 methods work. Retrieved from

http://developer.r-project.org/howMethodsWork.pdf August 1, 2013 This is a good description of how classes, methods,

objects, and functions work. It also explains how R is different from other OO languages such as Java and C++.

Venables, W. N., (2009). An introduction to R. United Kingdom: Network Theory Limited. (Also avaible online at http://www.cran.r-project.org/doc/manuals/R-intro.pdf)

Page 30: R programming for psychometrics

A few things to note…

naming objects (i.e., rawScores, raw.scores) Keep them simple Start with letter, not a number Don’t use underscores or spaces Don’t begin with caps Don’t replicate (we’ll come back to this)

R users don’t like loops. Use apply() in the plyr package – although some disagree

attach() Popular opinion is NOT to use attach. This gets to the

problem of masking if you have two objects with the same name and you attach them both, which is being called by your program?

Page 31: R programming for psychometrics

Psychometrics in R – Related Research

Chalmers, R. P. (2012). mirt: A multidimensional item response theory package for the R environment. Journal of Statistical Software, 48(6), 1-29.

Debelak, R., & Tran, U. S. (2013). Principal component analysis of smoothed tetrachoric correlation matrices as a measure of dimensionality. Educational and Psychological Measurement, 73(1), 63-77.

De Leeuw, J., & Mair, P. (2007). An introduction to the special volume of “psychometrics in R.” Journal of Statistical Software, 20(1), 1-5.

Epskamp, S., Cramer, A. O. J., Waldrop, L. J., Schmittmann, V. D., & Borsboom, D. (2012). qgraph: Network visualizations of relationships in psychometric data. Journal of Statistical Software, 48(4), 1-18.

Page 32: R programming for psychometrics

More References

Fox, J. P., Entink, R. K., & van der Linden, W. (2007). Modeling of responses and

response times with the package cirt. Journal of Statistical Software, 20(7), 1-

14.

Frick, H., Strobl, C., Leisch, F., & Zeileis, A. (2012). Flexible Rasch mixture models

with package psychomix. Journal of Statistical Software, 48(7), 1-25.

Hatzinger, R., & Dittrich, R.(2012). prefmod: An R package for modeling

preferences based on paired comparisons, rankings, or ratings. Journal of

Statistical Software, 48(10), 1-31.

Mair, P., & Hatzinger, R. (2007). Extended Rasch modeling: The eRm package for

the application of IRT models in R. Journal of statistical software, 20(9), 1-20.

Page 33: R programming for psychometrics

More References

Monecke, A., & Leisch, F. (2012). semPLS: Structural equation modeling using

partial least squares. Journal of statistical software, 48(3), 1-32.

Rosseel, Y. (2012). lavaan: An R package for structural equation modeling.

Journal of Statistical software, 48(2), 1-36.

Verhelst, N. D., Hatzinger, R., & Mair, P. (2007). The Rasch sampler. Journal of

Statistical Software, 20(4), 1-14.

Weeks, J. P. (2010). plink: An R package for linking mixed-format tests using irt-

based methods. Journal of Statistical Software, 35(12), 1-33.

Wickelmaier, Fl., Strobl, C., & Zeileis, A. (2012). Psychoco: Psychometric

computing in R. Journal of Statistical software, 48(1), 1-5.

Page 34: R programming for psychometrics

One Final Comment

R really is a community of users in support of a common cause. I have found a great deal of

passion and dedication in its users and a strong desire to help others in the common pursuit of good research. Ask questions, but be respectful

of the community and research your problems/questions before you ask them.