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 2012. A reltrad for African Americans has been developed - this is required reading for those who use reltrad in their research Shelton 2017.

Up until now, the code to create the reltrad variable from the General Social Survey has only been available in PDF. Stata code for reltrad is available from Lifeway Research. Lifeway also published R code. Ryan Burge has Stata code up on Github:

Here, I am providing a link to my repository with an R translation of the code that is more reproducible. I apply this to the 1972-2016 GSS combined data file. Note that I do incorporate the corrections suggested by [@stetzerReltradCodingProblems2016].

Using Kieran Healy’s gssr package, the sample code loads the gss datafile, dumps the oversamples, and then calls the function I’ve written (now mostly in dplyr) to create a reltrad variable. The lives here.

After the code is run, the results can be quickly tabulated. The following plot looks at how the religious composition of the US has changed over time.

knitr::opts_chunk$set(echo = TRUE, message = F, fig.path = "static")
#Create a Figure for GSS attendanc= over time
#Plot the proportions over time
#See my github for the code to make these data

#Cut by generation
gss = gss %>% 
  mutate(year = as.numeric(as.character(year))) %>%
  mutate(birthyr = year - age) %>%
  mutate(age_cat = cut(birthyr, c(0,1928,1945,1965,1981,1997,2020)))

levels(gss$age_cat) = c("Great","Silent","Boomer","GenX","Millenial","GenZ")

#Calculate weighted proportions
#Create survey object using svyr
gss_svy <- gss %>% as_survey_design(1, weight = wtssall,
                                    variables = c(year, reltrad, age_cat))

#Now calculate proportions
out = gss_svy %>% 
  group_by(year, reltrad) %>%
  summarize(prop = survey_mean(na.rm=T, proportion = T)) %>%

#A nice set o' colors
scFill = scale_color_manual(values = 

plotout = ggplot(data = out, 
                     color = reltrad,
                     group = reltrad)) +
  geom_ribbon(aes(ymin = prop - 1.96*prop_se,
                  ymax = prop + 1.96*prop_se),
                  color = "white",
                  alpha = .2, fill = "grey") +
  geom_point() +
  geom_line() +
  ylab("Proportion of US Population Identifying As...") +
  xlab("") +
  labs(title = "Religious Affiliation in the United States",
       subtitle = "General Social Survey",
       caption = "David Eagle / Data:",
       color = "Religious Tradition")+
  theme_minimal() + scFill +
  theme(axis.text.x = element_text(angle = 70, hjust = 1)) +
  ggtitle("Religious Affiliation in the United States 1972-2018")
#ggsave(plotout,"Output/reltradGSS.png", width = 12, height=5, dpi="retina")



David E. Eagle, Ph.D.
David E. Eagle, Ph.D.
Assistant Research Professor

My research interests include the sociology of religion, theological education, and racial inequality.