• Home
  • Lectures
  • Workshops
  • R files
  • purchase
  • Home
  • Lectures
  • Workshops
  • R files
  • purchase
INTENSIVE LONGITUDINAL ANALYSIS OF HUMAN PROCESSES
  • Home
  • Lectures
  • Workshops
  • R files
  • purchase

R Code

​We provide here code that goes along with each chapter. It allows for replication of results found in the book and also provides additional exercises to be done to further understanding of core concepts.

All files with the same title contain the same information. The PDF files are easy to read and get a sense of what the code is doing before diving in. The RMD R files can be easier for copy and pasting code when you're ready to carry the analyses out yourself.  

Data

Some of the empirical data sets used for the book have generously been shared by the researchers who collected the data. Here we provide those data sets which we've been permitted to share. Some of the code used below uses this data.

Simulated data examples are also used in the code below. In those cases, we simulate the data right there rather than provide it here - so you learn how to do some simulations, too. 

Fisher Data

Self-report data on anxiety and depression symptoms collected multiple times a day. Full description of data found in this article. 
​
The original data can be found here. We interpolated this data using a cubic spline and offer that version below. 
fisherdata.rdata
File Size: 964 kb
File Type: rdata
Download File

Borkenau Data

Self-report data collected daily on the Big 5 Personality inventory. Full description of data found in this article.
readme.txt
File Size: 0 kb
File Type: txt
Download File

Borkenau data.zip
File Size: 194 kb
File Type: zip
Download File

ADID Data

The Affective Dynamics and Individual Differences (ADID) data obtained self-reported responses 5 times a day for one month. 
readme.txt
File Size: 0 kb
File Type: txt
Download File

adidtoshare.txt
File Size: 1920 kb
File Type: txt
Download File


Chapter 1: Introduction



The focus of this book is intensive longitudinal analysis focusing on intra-individual variability across time. 
PDF
R File

Chapter 2: Ergodicity

Here we explore the assumption of ergodicity in an empirical data example - the Borkenau & Ostendorf data. Variable distributions as well as autocovariances are explored. 
PDF
R File
Ergodicity.pdf
File Size: 176 kb
File Type: pdf
Download File

Ergodicity.rmd
File Size: 6 kb
File Type: rmd
Download File


Chapter 3: P-technique

In these exercises we introduce how to generate intensive longitudinal data and explore the observed time series. The data are simulated from a measurement model. Next we conduct exploratory factor analysis on this data with lavaan using the manual approach described in the chapter as well as functions psych and nFactors. The final model is fit with lavaan. 

PDF

R File

Ptechnique.pdf
File Size: 203 kb
File Type: pdf
Download File

Ptechnique.rmd
File Size: 7 kb
File Type: rmd
Download File


Chapter 4: Vector autoregression

The "AR" files begins with simulating univariate time series data with and without linear trends. We then explore lag order with the ACF and PACF. Detrending is demonstrated. Stability and stationarity is tested, and residuals examined. 

The "VAR" files explore multivariate empirical data. The Fisher data is used here. Lag order is assessed at the univariate and multivariate levels. The VAR coefficient estimates are obtained and examined. 

PDFs

R Files

AR.pdf
File Size: 295 kb
File Type: pdf
Download File

AR.rmd
File Size: 4 kb
File Type: rmd
Download File

VAR.pdf
File Size: 163 kb
File Type: pdf
Download File

VAR.rmd
File Size: 2 kb
File Type: rmd
Download File


Chapter 5: Dynamic Factor Model

The below code files carry out estimation of dynamic factor models using quasi-maximum likelihood (quasi-ML with lavaan), model implied instrumental variables with two-stage least squares (MIIV-2SLS) using ​MIIVsem, and raw likelihood via the Kalman Filter with dynr. 

PDFs
DFM quasi ML
File Size: 182 kb
File Type: pdf
Download File

R Files
DFM quasi ML
File Size: 8 kb
File Type: rmd
Download File

DFM quasi ML Fisher data
File Size: 64 kb
File Type: pdf
Download File

DFM MIIV 2SLS
File Size: 219 kb
File Type: pdf
Download File

DFM KF with dynr
File Size: 139 kb
File Type: pdf
Download File

DFM quasi ML Fisher data.rmd
File Size: 2 kb
File Type: rmd
Download File

DFM MIIV 2SLS.rmd
File Size: 5 kb
File Type: rmd
Download File

DFM KF with dynr
File Size: 3 kb
File Type: rmd
Download File


Chapter 6: Model Specification and Search

This codes shows how to carry out data-driven searches on intensive longitudinal analyses. The results can be depicted graphically as networks. Individual-level, aggregated, and replicated approaches are presented. SVAR/uSEM, hybrid-VAR, and VAR models are used. Both simulated and empirical (Fisher) data examples are provided. 
We use ​
lavaan, gimme, and graphicalVAR R packages. 
PDFs
Simulated Data gimme gvar.pdf
File Size: 340 kb
File Type: pdf
Download File

ch6_fisher_example.pdf
File Size: 202 kb
File Type: pdf
Download File

R Files
Simulated Data gimme gvar.rmd
File Size: 340 kb
File Type: pdf
Download File


Chapter 7: Models of Intra-individual Variability with Time-varying Parameters (TVPs)

This code provides everything needed to conduct estimation of state-space models with time-varying parameters. The dynr package is used, with details pertaining to the use of this package provided in the first two files.  Random walks, integrated random walks, and VAR models are used. The generalized additive modeling approaches is also demonstrated. The final set of files shows how to check observability of state-space models with TVPs.
PDFs
TV VAR
File Size: 2868 kb
File Type: pdf
Download File

TV state space models
File Size: 404 kb
File Type: pdf
Download File

Check Observability TVP.pdf
File Size: 291 kb
File Type: pdf
Download File

R Files
tv_var_example.rmd
File Size: 16 kb
File Type: rmd
Download File

TV state space models.rmd
File Size: 25 kb
File Type: rmd
Download File

Check Observability TVP.rmd
File Size: 11 kb
File Type: rmd
Download File


Chapter 8: Control Theory Optimization of Dynamic Processes​

Here we provide code for conducting control theory analyses with dynr. Some additional functions are provided in a separate R file. Code is provided for simulating the data used. 
PDFs
Control Theory
File Size: 824 kb
File Type: pdf
Download File

R Files
Control Theory.rmd
File Size: 21 kb
File Type: rmd
Download File

controllerfunctions.r
File Size: 10 kb
File Type: r
Download File


Chapter 9: Intersection of Network Science and Intensive Longitudinal Analyses

Here we provide code for conducting community detection analysis for subsetting individuals based on their dynamic models using S-GIMME (gimme). The robustness of subgroups is evaluated using perturbR. 

​
We also demonstrate how the community detection algorithm Walktrap (via the igraph R package) can be used to complement p-technique by clustering variables that are highly correlated. These results are compared to EGAnet, which goes the extra step of regularizing the correlation matrix before conducting community detection. Simulated and Fisher data examples are used.
PDFs
S GIMME and perturbR
File Size: 221 kb
File Type: pdf
Download File

Comm Det Variables P tech
File Size: 381 kb
File Type: pdf
Download File

R Files
S GIMME and perturbR.rmd
File Size: 4 kb
File Type: rmd
Download File

Comm Det Variables P tech
File Size: 17 kb
File Type: rmd
Download File

Proudly powered by Weebly