Reading, Formatting, and Organizing the Panel Study of Income Dynamics (PSID)

Provides various functions for reading and preparing the Panel Study of Income Dynamics (PSID) for longitudinal analysis, including functions that read the PSID's fixed width format files directly into R, rename all of the PSID's longitudinal variables so that recurring variables have consistent names across years, simplify assembling longitudinal datasets from cross sections of the PSID Family Files, and export the resulting PSID files into file formats common among other statistical programming languages ('SAS', 'STATA', and 'SPSS').


easyPSID

Overview

CRAN package designed to simplify the task of reading the Panel Study of Income Dynamics (PSID) into R and preparing the data for analysis. Although the PSID is one of the most comprehensive longitudinal datasets for examining health and life course patterns among American families, preparing the PSID for analysis can be a difficult task. The PSID comes with no scripts for being read into R, and every wave of each PSID longitudinal variable has a unique name. For example, variables in the 1968 PSID Family File are named V1-V440 whereas variables within the 1969 PSID Family File are named V441-V1017, even though most variables in the 1969 Family Files match those in the 1968 Family File. These aspects of the PSID pose difficulties for R users who want to conduct longitudinal analyses in the PSID. easyPSID simplifies these tasks and several others.

Example

After downloading multiple waves of the PSID Packaged Data Family Files from https://simba.isr.umich.edu/, a common use of easyPSID is to unzip each wave of the family files, convert them to .rds format, rename all longitudinal variables to consistent names across years, and save the resulting renamed datasets to .rds format. The development version's cross-year reference currently covers the 1968-2023 waves. This can be done as follows (assuming the PSID files were saved into C:/PSID/Zip Files):

library(easyPSID)
unzip_all_files(
    in_direc="C:/PSID/Zip Files",
    out_direc="C:/PSID/Unzipped Files"
)
convert_to_rds(
    in_direc="C:/PSID/Unzipped Files",
    out_direc="C:/PSID/rds Files"
)
rename_fam_vars(
    in_direc="C:/PSID/rds Files",
    out_direc="C:/PSID/renamed Files"
)

convert_to_rds() expects the fixed-width ASCII .txt file and matching Stata .do definition file included in each PSID packaged-data ZIP. It does not read Stata .dta files. If you already have a .dta file, import it with a Stata reader such as haven::read_dta(), preserve the original PSID variable names, and save the resulting data frame with saveRDS() before calling a renaming function.

Installation

This package can be directly installed via CRAN with install.packages("easyPSID"). Alternatively, newest versions of this package can be installed with devtools::install_github("BrianAronson/easyPSID")

Prior to working with the easyPSID package, users will need to download packaged PSID data for the family files and cross-sectional individual file from https://simba.isr.umich.edu/.

The small files bundled under inst/extdata are excerpts used to exercise the package examples. Users must register with PSID and acquire full public-release data directly from PSID.

Function Overview

Below is a brief outline of each function in this package:

  • unzip_all_files
    • Unzips all files in the supplied directory.
  • convert_to_rds
    • Read PSID fixed width files into R and saves output in .rds format.
  • rename_fam_vars
    • Renames all variables in longitudinal family files to their names when they were first available in the dataset.
  • rename_ind_vars
    • Reshapes the cross-year Individual File to long format and gives recurring variables their earliest names while retaining ER30001 and ER30002 as stable person identifiers.
  • create_custom_panel
    • Creates a longitudinal dataset with provided family files consisting of a custom set of variables selected by the user.
  • create_extract
    • Creates a longitudinal dataset with provided family files consisting of the dataset's N most commonly reoccurring variables.
  • convert_from_rdata
    • Converts PSID .rds files to files compatible with STAT, SAS, or SPSS.
  • find_name
    • Returns the new name (via the rename_fam_vars and rename_ind_vars functions) of a specified variable.
  • find_years
    • Returns each year that a given variable is available in the PSID, and its names during those years.
  • find_description
    • Returns the description of a given variable in the PSID with the variable labels provided by the PSID.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("easyPSID")

0.1.3 by Brian Aronson, 2 months ago


Browse source code at https://github.com/cran/easyPSID


Authors: Brian Aronson [aut, cre]


Documentation:   PDF Manual  


MIT + file LICENSE license


Depends on stringr, LaF, foreign

Suggests readxl, testthat


See at CRAN