0.1 Overview

This script works through some basic representations of change: Auto-Regressive Models of Change, and Difference-Score Models of Change. These two types of models consider and answer differnet kinds of questions “Change in Interindividual Differences” or “Interindividual Differences and Intraindividual Change”.

0.2 Outline

  1. Data Preparation
  2. Auto-Regression Model
  3. Difference Score Model
  4. Conclusion

0.2.0.1 Prelim - Loading libraries used in this script.

library(psych)
library(ggplot2)

0.3 1. Data Preparation

We use two occasions of the multi-occasion WISC data for our examples.

Load the repeated measures data

############################
####### Reading in the Data
############################
#set filepath for data file
filepath <- "https://quantdev.ssri.psu.edu/sites/qdev/files/wisc3raw.csv"
#read in the .csv file using the url() function
wisc3raw <- read.csv(file=url(filepath),header=TRUE)

Subsetting to a dataset with just two occasions. We include the id, verb1 and verb6 variables.

wiscsub <- wisc3raw[,c("id","verb1","verb6")]
head(wiscsub)
id verb1 verb6
1 24.42 55.64
2 12.44 37.81
3 32.43 50.18
4 22.69 44.72
5 28.23 70.95
6 16.06 39.94

Some basic descriptives …

#descriptives
describe(wiscsub[,c("verb1","verb6")])
vars n mean sd median trimmed mad min max range skew kurtosis se
verb1 1 204 19.58505 5.807695 19.335 19.49768 5.41149 3.33 35.15 31.82 0.1301071 -0.0528376 0.4066200
verb6 2 204 43.74990 10.665051 42.545 43.45610 11.29741 17.35 72.59 55.24 0.2356459 -0.3605210 0.7467029
corr.test(wiscsub[,c("verb1","verb6")])
## Call:corr.test(x = wiscsub[, c("verb1", "verb6")])
## Correlation matrix 
##       verb1 verb6
## verb1  1.00  0.65
## verb6  0.65  1.00
## Sample Size 
## [1] 204
## Probability values (Entries above the diagonal are adjusted for multiple tests.) 
##       verb1 verb6
## verb1     0     0
## verb6     0     0
## 
##  To see confidence intervals of the correlations, print with the short=FALSE option

And some bivariate plots of the two-occasion relations.

pairs.panels(wiscsub[,c("verb1","verb6")])

We can also plot intraindividual change, by putitng time along the x-axis. This requires reshaping the data.

#reshaping wide to long
wiscsublong <- reshape(data=wiscsub[c("id","verb1","verb6")], 
                    varying=c("verb1","verb6"), 
                    timevar="grade", idvar="id", 
                    direction="long", sep="")
#sorting for convenience
wiscsublong <- wiscsublong[order(wiscsublong$id,wiscsublong$grade),]

#making intraindividual change plot
ggplot(data = wiscsublong, aes(x = grade, y = verb, group = id)) +
  geom_point() + 
  geom_line() +
  xlab("Grade") + 
  ylab("WISC Verbal Score") + ylim(0,100) +
  scale_x_continuous(breaks=seq(1,6,by=1))