Creating the Reltrad Variable in the General Social Survey Using R

Haven’t you always wanted an easy to access R script to create the famous reltrad religious categorizaton in the General Social Survey? Well, today is your lucky day.

The measure of religious affiliation described in (Steensland et al. 2000), otherwise known as reltrad, remains the most popular way to categorize people religiously in the United States. Early development of the measure was done by Corwin Smidt, Bud Kellstedt and James Guth during their annual seminars on measuring religion offered at Calvin College. The reltrad crowd continues to think their measure is pretty good (Woodberry et al. 2012). A reltrad for African Americans has been developed - this is required reading for those who use reltrad in their research (Shelton and Cobb 2017).

Up until now, the code to create the reltrad variable from the General Social Survey has only been available in Stata. Stata code for reltrad is available from Lifeway Research.

I am providing an R translation of the code. I apply this to the 1972-2016 GSS combined data file.

This code takes a GSS datafile and then recodes religious affiliation into the reltrad scheme created by Steensland et al. It breaks the US population into Conservative Protestant, Mainline Protestant, Black Protestant, Jewish, Other, and Non-Affiliated.

I’ve written this code in vanilla R, but resorted to the car package for easier recoding. The code is pretty well commented, but tweet at me or email me if you have questions.

The original R source code for the reltrad recoding can be accessed from GitHub here.

#Not run
#Get the GSS data, import into a temp file and unzip
#read in the GSS data
#Convert to R data format
#Save
library(dplyr)
temp <- tempfile()
download.file("http://gss.norc.org/documents/stata/GSS_stata.zip",temp)
unzip(temp, files="GSS7216_R4.DTA",exdir = "OrigData")
unlink(temp);rm(temp)
gss = haven::read_dta("OrigData/GSS7216_R4.DTA")
save(gss, file = file)
#Load the data
load(file)
#
#Get the variables we want, this is a huge dataset.
gss =  gss %>% select(relig, other, race, denom, year, attend, id, wtss)
save(gss, file=file)

Now, here is the full code to create reltrad in R. The data is hosted on my github account and downloaded directly from there. Feel free to fork this code and add your own file path.

library(car)
library(tidyverse)
library(descr) #Get the rocking CrossTable Function! Weighted! crosstab
#This is where the R dataset will live:
urldata = url("https://github.com/thebigbird/academic/raw/master/static/files/gss7216.data")
#
load(urldata)
#recode into 5 major categories of religious affiliation
# 1) Protestant [Ask DENOM] 1371    47.8
# 2) Catholic
# 3) Jewish 
# 4) None   
# 5) Other (specify)
# 6) Buddhism
# 7) Hinduism
# 8) Other Eastern religion
# 9) Muslim/Islam
# 10) Orthodox Christian
# 11) Christian
# 12) Native American
# 13) Inter-/non-denominational
# 98) Don't know
# 99) No answer
gss$xaffil = car::recode(gss$relig, "1=1;2=4;3=5;4=9;5:10=6;11=1;12=6;13=1")
gss$xaffil = as.factor(gss$xaffil)
levels(gss$xaffil) = c("prot", "cath", "jew", "other", "nonaf")

# The following code breaks down religious groups by evangelicals, black
# Protestants, mainline, liberal and conservative nontraditional,
# and Protestant nondenomination/no denomination.

#####Black Protestants
#Create a racial indicator
gss$black = ifelse(gss$race == "black", 1, 0)
gss$white = ifelse(gss$race == "white", 1, 0)
#Take the "other" Protestant denominations and pull out the 
#historical Black denominations, e.g. COGIC
gss$xbp = gss$other
gss$xbp = ifelse(gss$xbp %in% c(7, 14, 15, 21, 37, 38, 56, 78, 79, 85, 86, 87, 88, 98, 103, 104, 128, 133), 1, 0)
#National baptists and AME, AMEZ
gss$xbp = ifelse(gss$denom %in% c(12, 13, 20, 21), 1, gss$xbp)
#Blacks in certain denoms get recoded as Black Protestant
#Other baptist, amer. baptist, south. bap, other Methodists
gss$xbp[gss$black == 1] = ifelse(gss$denom[gss$black == 1] %in%
                                   c(10, 11, 18, 23, 13, 14), 1, gss$xbp[gss$black == 1])
#Black missionary baptists
gss$xbp[gss$black == 1] = ifelse(gss$other[gss$black == 1] %in%
                                   c(93), 1, gss$xbp[gss$black == 1])

#Evangelical Protestants#
#Recode the evangelicals in the other variable
gss$xev=gss$other
evother=c(2, 3, 5, 6, 9, 10, 12, 13, 16, 18, 20, 22, 24, 26, 27, 28, 31, 32, 34, 35, 36, 39, 41, 42, 43, 45, 47,51, 52, 53, 55, 57, 63, 65, 66, 67, 68, 69, 76, 77, 83,
          84, 90, 91, 92, 94, 97, 100, 101, 102, 106, 107, 108, 109, 110, 111, 112, 115, 116, 117, 118, 120, 121, 122, 124, 125, 127, 129, 131, 132, 134, 135, 138, 139, 140, 146)
gss$xev=ifelse(gss$xev %in% evother,1,0)
#Cons Lutherans, cons presbyterians
gss$xev=ifelse(gss$denom %in% c(32,33,34,42), 1, gss$xev)
#White baptists, white other methodists
gss$xev[gss$black==0]=ifelse(gss$denom[gss$black==0] %in% 
                               c(10,18,15,23,14),1,gss$xev[gss$black==0])
#Missionary baptist
gss$xev[gss$black==0]=ifelse(as.numeric(gss$other[gss$black==0]) %in%
                               c(93),1,gss$xev[gss$black==0])

# Mainline Protestants
#The other category
gss$xml = gss$other
mpother=c(1,8,19,23,25,40, 44, 46, 48, 49, 50, 54, 70, 71, 72, 73, 81, 89, 96, 99, 105, 119, 148)
gss$xml=ifelse(gss$xml %in% mpother,1,0) 
#The denom category
gss$xml = ifelse(gss$denom %in% 
                   c(30, 50, 35, 31, 38, 40, 48, 43, 22, 41),1,gss$xml)
#Mainline baptist denom and methodists - if the R is white, they get coded mainline
gss$xml[gss$black==0] = ifelse(gss$denom[gss$denom[gss$black==0]] %in%
                                 c(11, 28),1,gss$xml[gss$black==0])

#Catholics
gss$xcath = gss$other 
#Polish National Church and Catholic
gss$xcath = ifelse(gss$denom %in% c(123, 28),1,0)
#People who say that they are other get coded zero
gss$xcath=ifelse(gss$xaffil=="cath", 1, gss$xcath) 

#Jews
gss$xjew=0 
gss$xjew=ifelse(gss$xaffil=="jew",1,0)

#Adherents of other religions.
gss$xother = gss$other
gss$xother = ifelse(gss$xother %in% 
                      c(11, 17, 29, 30, 33, 58, 59, 60, 61, 62, 64, 74, 75, 80, 82,
                        95, 113, 114, 130, 136, 141, 145),1,0)
#Adds others from main religious recoding
gss$xother=ifelse(gss$xaffil=="other" & gss$xev==0,1,0)

#Unaffiliateds/Nonaffiliateds
gss$xnonaff=0
gss$xnonaff[gss$xaffil=="nonaf"]=1

#The recodes non-denoms based on their attendance 
#Non active Don't Know Protestants coded to nonaffil
gss$xprotdk = ifelse(gss$denom == 70,1,0)
gss$xprotdk[gss$xprotdk == 1 & gss$attend >= 4] = 0
#Active Don't Know Protestants coded to evangelicals
gss$xnonaff[gss$xprotdk]=1
gss$xev[gss$xprotdk == 1 & gss$attend >= 4] = 1

#All these folks get coded evangelical
gss$reltrad = factor(NA, levels=c("Conservative Protestant",
                                  "Mainline Protestant",
                                  "Black Protestant",
                                  "Roman Catholic",
                                  "Other",
                                  "None"))
gss$reltrad[gss$xev==1]="Conservative Protestant"
gss$reltrad[gss$xml==1]="Mainline Protestant"
gss$reltrad[gss$xbp==1]="Black Protestant"
gss$reltrad[gss$xcath==1]="Roman Catholic"
gss$reltrad[gss$xother==1]="Other"
gss$reltrad[gss$xnonaff==1]="None"
save(gss,file="gss7216_reltrad.data")
gss$year = as.factor(gss$year)

The following table looks at how the religious composition of the US has changed over time. This uses the very useful wrapper crosstab( ) for the CrossTable( ) function in the package descr. It allows you to make weighted crosstabs easily and prettily. In subsequent posts, I will have some fun with ggplot to visual these data.

print(
  crosstab(gss$year,gss$reltrad,
           weight = gss$wtss, prop.c = T, prop.r = T, prop.t = F, 
           total.c = F, plot = F))
##    Cell Contents 
## |-------------------------|
## |                   Count | 
## |             Row Percent | 
## |          Column Percent | 
## |-------------------------|
## 
## =========================================================================
##             gss$reltrad
## gss$year    Cnsrvtv P   Mnln Prts   Blck Prts   Rmn Cthlc   Other    None
## -------------------------------------------------------------------------
## 1972             325         427          11         645      27      84 
##                 21.4%       28.1%        0.7%       42.5%    1.8%    5.5%
##                  2.6%        2.6%        1.1%        3.6%    1.6%    1.2%
## -------------------------------------------------------------------------
## 1973             317         368          17         586      30      96 
##                 22.4%       26.0%        1.2%       41.4%    2.1%    6.8%
##                  2.5%        2.3%        1.7%        3.3%    1.8%    1.3%
## -------------------------------------------------------------------------
## 1974             322         392           7         566       8     101 
##                 23.1%       28.1%        0.5%       40.5%    0.6%    7.2%
##                  2.5%        2.4%        0.7%        3.2%    0.5%    1.4%
## -------------------------------------------------------------------------
## 1975             309         427          14         538      14     113 
##                 21.8%       30.2%        1.0%       38.0%    1.0%    8.0%
##                  2.4%        2.6%        1.4%        3.0%    0.8%    1.6%
## -------------------------------------------------------------------------
## 1976             303         415          11         552      15     114 
##                 21.5%       29.4%        0.8%       39.1%    1.1%    8.1%
##                  2.4%        2.6%        1.1%        3.1%    0.9%    1.6%
## -------------------------------------------------------------------------
## 1977             324         419          10         566      18      93 
##                 22.7%       29.3%        0.7%       39.6%    1.3%    6.5%
##                  2.6%        2.6%        1.0%        3.2%    1.1%    1.3%
## -------------------------------------------------------------------------
## 1978             318         414          10         574      17     119 
##                 21.9%       28.5%        0.7%       39.5%    1.2%    8.2%
##                  2.5%        2.5%        1.0%        3.2%    1.0%    1.6%
## -------------------------------------------------------------------------
## 1980             307         398           9         532      30     105 
##                 22.2%       28.8%        0.7%       38.5%    2.2%    7.6%
##                  2.4%        2.4%        0.9%        3.0%    1.8%    1.5%
## -------------------------------------------------------------------------
## 1982             478         465          32         609      21     132 
##                 27.5%       26.8%        1.8%       35.1%    1.2%    7.6%
##                  3.8%        2.9%        3.2%        3.4%    1.2%    1.8%
## -------------------------------------------------------------------------
## 1983             303         463          10         586      26     117 
##                 20.1%       30.8%        0.7%       38.9%    1.7%    7.8%
##                  2.4%        2.8%        1.0%        3.3%    1.5%    1.6%
## -------------------------------------------------------------------------
## 1984             321         486          34         393      20     107 
##                 23.6%       35.7%        2.5%       28.9%    1.5%    7.9%
##                  2.5%        3.0%        3.4%        2.2%    1.2%    1.5%
## -------------------------------------------------------------------------
## 1985             364         479          30         433      25     109 
##                 25.3%       33.3%        2.1%       30.1%    1.7%    7.6%
##                  2.9%        2.9%        3.0%        2.4%    1.5%    1.5%
## -------------------------------------------------------------------------
## 1986             337         471          29         398      31      98 
##                 24.7%       34.5%        2.1%       29.2%    2.3%    7.2%
##                  2.7%        2.9%        2.9%        2.2%    1.8%    1.4%
## -------------------------------------------------------------------------
## 1987             498         551          98         396      40     121 
##                 29.2%       32.3%        5.8%       23.2%    2.3%    7.1%
##                  3.9%        3.4%        9.8%        2.2%    2.4%    1.7%
## -------------------------------------------------------------------------
## 1988             340         445          27         399      42     118 
##                 24.8%       32.5%        2.0%       29.1%    3.1%    8.6%
##                  2.7%        2.7%        2.7%        2.2%    2.5%    1.6%
## -------------------------------------------------------------------------
## 1989             342         480          34         403      34     120 
##                 24.2%       34.0%        2.4%       28.5%    2.4%    8.5%
##                  2.7%        3.0%        3.4%        2.3%    2.0%    1.7%
## -------------------------------------------------------------------------
## 1990             258         469          34         343      42     109 
##                 20.6%       37.4%        2.7%       27.3%    3.3%    8.7%
##                  2.0%        2.9%        3.4%        1.9%    2.5%    1.5%
## -------------------------------------------------------------------------
## 1991             322         524          42         398      29     102 
##                 22.7%       37.0%        3.0%       28.1%    2.0%    7.2%
##                  2.5%        3.2%        4.2%        2.2%    1.7%    1.4%
## -------------------------------------------------------------------------
## 1993             376         498          35         374      42     146 
##                 25.6%       33.9%        2.4%       25.4%    2.9%    9.9%
##                  3.0%        3.1%        3.5%        2.1%    2.5%    2.0%
## -------------------------------------------------------------------------
## 1994             714         840          39         791     115     274 
##                 25.7%       30.3%        1.4%       28.5%    4.1%    9.9%
##                  5.6%        5.2%        3.9%        4.4%    6.8%    3.8%
## -------------------------------------------------------------------------
## 1996             685         778          45         708     143     339 
##                 25.4%       28.8%        1.7%       26.2%    5.3%   12.6%
##                  5.4%        4.8%        4.5%        4.0%    8.5%    4.7%
## -------------------------------------------------------------------------
## 1998             629         674          52         735      70     396 
##                 24.6%       26.4%        2.0%       28.8%    2.7%   15.5%
##                  5.0%        4.1%        5.2%        4.1%    4.2%    5.5%
## -------------------------------------------------------------------------
## 2000             591         673          66         709      96     398 
##                 23.3%       26.6%        2.6%       28.0%    3.8%   15.7%
##                  4.7%        4.1%        6.6%        4.0%    5.7%    5.5%
## -------------------------------------------------------------------------
## 2002             501         703          56         707      91     379 
##                 20.6%       28.8%        2.3%       29.0%    3.7%   15.6%
##                  3.9%        4.3%        5.6%        4.0%    5.4%    5.2%
## -------------------------------------------------------------------------
## 2004             521         655          39         721     113     394 
##                 21.3%       26.8%        1.6%       29.5%    4.6%   16.1%
##                  4.1%        4.0%        3.9%        4.0%    6.7%    5.5%
## -------------------------------------------------------------------------
## 2006             792        1018          82        1247     128     711 
##                 19.9%       25.6%        2.1%       31.3%    3.2%   17.9%
##                  6.2%        6.3%        8.2%        7.0%    7.6%    9.8%
## -------------------------------------------------------------------------
## 2008             341         469          23         535      62     338 
##                 19.3%       26.5%        1.3%       30.3%    3.5%   19.1%
##                  2.7%        2.9%        2.3%        3.0%    3.7%    4.7%
## -------------------------------------------------------------------------
## 2010             368         414          23         538      70     365 
##                 20.7%       23.3%        1.3%       30.3%    3.9%   20.5%
##                  2.9%        2.5%        2.3%        3.0%    4.2%    5.1%
## -------------------------------------------------------------------------
## 2012             309         414          14         496      82     388 
##                 18.1%       24.3%        0.8%       29.1%    4.8%   22.8%
##                  2.4%        2.5%        1.4%        2.8%    4.9%    5.4%
## -------------------------------------------------------------------------
## 2014             351         506          33         657      97     520 
##                 16.2%       23.4%        1.5%       30.4%    4.5%   24.0%
##                  2.8%        3.1%        3.3%        3.7%    5.8%    7.2%
## -------------------------------------------------------------------------
## 2016             437         533          29         689     107     618 
##                 18.1%       22.1%        1.2%       28.6%    4.4%   25.6%
##                  3.4%        3.3%        2.9%        3.9%    6.4%    8.6%
## =========================================================================

References

Shelton, Jason E., and Ryon J. Cobb. 2017. “Black Reltrad: Measuring Religious Diversity and Commonality Among African Americans.” Journal for the Scientific Study of Religion 56 (4): 737–64. https://doi.org/10/gfgw25.

Steensland, B., L. D. Robinson, W. B. Wilcox, J. Z. Park, M. D. Regnerus, and R. D. Woodberry. 2000. “The Measure of American Religion: Toward Improving the State of the Art.” Social Forces 79 (1): 291–318. https://doi.org/10/db9hrh.

Woodberry, R. D., J. Z. Park, L. A. Kellstedt, M. D. Regnerus, and B. Steensland. 2012. “The Measure of American Religious Traditions: Theoretical and Measurement Considerations.” Social Forces 91 (1): 65–73. https://doi.org/10.1093/sf/sos121.