During my failed attempt to get a PhD from the University of South Florida, my doctor friend asked me one day to build a linear regression model using a small dataset he had collected from a lab. He had measurements of these “new” chemical messengers called cytokines – so that definitely dates this story! I was supposed to use characteristics of the patients as predictors so we could see if any particular patient characteristics were associated with levels of any particular cytokine.
I remember making a model, and wondering if it was right. When I put all the covariates in, most of them were not significant. If I removed the not-significant ones, the other ones got more significant – very suspicious! Then I added interactions. Then I called my professor and asked what to do.
I’ll cut to the chase: she didn’t know what to do, either.
But she did tell me what everyone is essentially supposed to do. First, we are supposed to set up the statistical test before gathering the data. Yeah, good luck with that when dealing with real-life doctors and real-life labs. Next, before we start modeling, we create a set of rules about our model that need to be met for us to accept and select the final model. These are called “model specifications”.
Challenges with Model Specification for Regression Modeling
Jim Frost writes on his blog “Statistics by Jim” quite comprehensively about specifying models. He goes over different ways of making up these rules. For example, for linear regression models, you can pick the one with the best r-squared. Or you can just throw out all the variables with slopes with non-significant p-values.
But what’s especially awesome about Statistics by Jim’s post is that after he talks about how to make the specifications, he puts in a section titled, “Real World Complications in the Model Specification Process”. I’ll paraphrase what he says:
Sometimes the data do not behave, and other times, they behave downright badly!
…so the best laid plans can often go wrong in practice. You might feel tension between different specifications. What if two very different models have the exact same r-squared? Also, Jim points out that there are different kinds of r-squareds, so which one do you choose? What if there are two “sibling” variables who are both significant when together in a model, but ruin the rest of the model by making everything else non-significant? But you can’t just put in one or the other, because neither sibling is significant alone. This is an example of collinearity.
In other words, in real life, regression modeling can be hairy.
build your model
and publish your research paper.
Do your own statistics and publish your manuscripts quickly. Take our online courses in statistical programming in SAS and R.
SAS courses R coursesWhat to Do? Stepwise, Stepwise, Stepwise!
Over time, we’ve come to a consensus that “stepwise” model specification is a good idea. This means setting up our model specification in steps: first we do this, then we do that, then we do this other thing. It can help us figure out what covariates to keep in the model by giving us more decision points so we can filter in a batch, then filter that batch into the next batch. Much more organized, and easier to document. So that’s the good news.
The bad news is that there are different kinds of stepwise modeling, and we can’t agree on what the best one is – or even what to call each of them. I used to say what I did was “forward stepwise” modeling – that’s what I was told it was in college. In fact, that’s what I called it in when demonstrating it in my LinkedIn Learning R course on regression.
Then, later, when I was writing this book on descriptive and regression analysis in R and SAS, one of the really helpful peer-reviewers alerted me to this awesome article that actually tries three different logistic regression modeling approaches on the same dataset and compares the answers.
But the problem is that the authors use the term “forward stepwise” to mean something that I didn’t mean in my R course. This worried me, and then I asked around and found that some people do call what I did in the R course “forward stepwise”, and some call it “ambi-directional stepwise” – which, sorry, is just too too weird for me.
Another popular approach is called “backward stepwise” (also unfortunately called “backward elimination”), and the authors tested that one in their article, along with their version of “forward stepwise”, and the approach I actually use – which I guess I will just call “stepwise selection”. That’s the approach I’ve been using since being coached by my professor on that project, and it’s the one I teach to my customers and in my courses. So now I started calling it that.
Okay Great, Stepwise Selection is Best. How Do I Learn it?
If you are an R person, you can take my R course on LinkedIn Learning, and if you are a SAS person, you can take my SAS course. But if you are more of a manager type – or you just want to learn how to do model specification without actually doing any programming – take my big data study design course on LinkedIn Learning. I teach practical model specification that you can apply with real world data…
…even when data behave badly!
Rainbow logistic regression plot by Krishnavedala
Updated August 24, 2019. Some reformatting and slider added April 3, 2022.
Read all of our data science blog posts!
Scaling Rates for Public Health Communication: Why You Should Do it, and How
Scaling rates in public health is important if you want to communicate clearly with your [...]
Oct
Choosing a Journal for Your Scientific Manuscript: Tips, Tricks, and Considerations
Choosing a journal for your scientific manuscript needs to be strategic, or your publication will [...]
Oct
Problems with PRISMA: Why it Sucks, and What You Should Do About It
Problems with PRISMA? You’re not the only one. The PRISMA framework does not work well [...]
Oct
Prevent Research Misconduct, and Avoid the Drama
Prevent research misconduct, and the consequences and drama that goes with it. Use some simple, [...]
Oct
Mixed Methods Research: The Hot New Trend in Graduate School
Mixed methods research is trending now, with doctoral students and academics being pressured to do [...]
Oct
AI or Statistics – Which Modeling Approach Should You Use?
AI or statistics – two different, interrelated approaches you can use in your scientific publication. [...]
Sep
Confidence Intervals are for Estimating a Range for the True Population-level Measure
Confidence intervals (CIs) help you get a solid estimate for the true population measure. Read [...]
1 Comment
Jun
Continuous Variable? You Can Categorize it!
Continuous variable categorized can open up a world of possibilities for analysis. Read about it [...]
2 Comments
Jun
Delete if the Row Meets Criteria? Do it in SAS!
Delete if rows meet a certain criteria is a common approach to paring down a [...]
May
Chi-square Test: Insight from Using Microsoft Excel
Chi-square test is hard to grasp – but doing it in Microsoft Excel can give [...]
May
Identify Elements of Research in Scientific Literature
Identify elements in research reports, and you’ll be able to understand them much more easily. [...]
May
Design the Most Useful Time Periods for Your Conversions
Time periods are important when creating a time series visualization that actually speaks to you! [...]
Apr
Apply Weights? It’s Easy in R with the Survey Package!
Apply weights to get weighted proportions and counts! Read my blog post to learn how [...]
Nov
Make Categorical Variable Out of Continuous Variable
Make categorical variables by cutting up continuous ones. But where to put the boundaries? Get [...]
Nov
Remove Rows in R with the Subset Command
Remove rows by criteria is a common ETL operation – and my blog post shows [...]
Oct
CDC Wonder for Studying Vaccine Adverse Events: The Shameful State of US Open Government Data
CDC Wonder is an online query portal that serves as a gateway to many government [...]
Jun
AI Careers: Riding the Bubble
AI careers are not easy to navigate. Read my blog post for foolproof advice for [...]
Jun
Descriptive Analysis of Black Friday Death Count Database: Creative Classification
Descriptive analysis of Black Friday Death Count Database provides an example of how creative classification [...]
Nov
Classification Crosswalks: Strategies in Data Transformation
Classification crosswalks are easy to make, and can help you reduce cardinality in categorical variables, [...]
Nov
FAERS Data: Getting Creative with an Adverse Event Surveillance Dashboard
FAERS data are like any post-market surveillance pharmacy data – notoriously messy. But if you [...]
4 Comments
Nov
Dataset Source Documentation: Necessary for Data Science Projects with Multiple Data Sources
Dataset source documentation is good to keep when you are doing an analysis with data [...]
Nov
Joins in Base R: Alternative to SQL-like dplyr
Joins in base R must be executed properly or you will lose data. Read my [...]
Nov
NHANES Data: Pitfalls, Pranks, Possibilities, and Practical Advice
NHANES data piqued your interest? It’s not all sunshine and roses. Read my blog post [...]
Nov
Color in Visualizations: Using it to its Full Communicative Advantage
Color in visualizations of data curation and other data science documentation can be used to [...]
Oct
Defaults in PowerPoint: Setting Them Up for Data Visualizations
Defaults in PowerPoint are set up for slides – not data visualizations. Read my blog [...]
Oct
Text and Arrows in Dataviz Can Greatly Improve Understanding
Text and arrows in dataviz, if used wisely, can help your audience understand something very [...]
Oct
Shapes and Images in Dataviz: Making Choices for Optimal Communication
Shapes and images in dataviz, if chosen wisely, can greatly enhance the communicative value of [...]
Oct
Table Editing in R is Easy! Here Are a Few Tricks…
Table editing in R is easier than in SAS, because you can refer to columns, [...]
Aug
R for Logistic Regression: Example from Epidemiology and Biostatistics
R for logistic regression in health data analytics is a reasonable choice, if you know [...]
272 Comments
Aug
Connecting SAS to Other Applications: Different Strategies
Connecting SAS to other applications is often necessary, and there are many ways to do [...]
Jul
Portfolio Project Examples for Independent Data Science Projects
Portfolio project examples are sometimes needed for newbies in data science who are looking to [...]
Jul
Project Management Terminology for Public Health Data Scientists
Project management terminology is often used around epidemiologists, biostatisticians, and health data scientists, and it’s [...]
Jun
Rapid Application Development Public Health Style
“Rapid application development” (RAD) refers to an approach to designing and developing computer applications. In [...]
Jun
Understanding Legacy Data in a Relational World
Understanding legacy data is necessary if you want to analyze datasets that are extracted from [...]
Jun
Front-end Decisions Impact Back-end Data (and Your Data Science Experience!)
Front-end decisions are made when applications are designed. They are even made when you design [...]
Jun
Reducing Query Cost (and Making Better Use of Your Time)
Reducing query cost is especially important in SAS – but do you know how to [...]
Jun
Curated Datasets: Great for Data Science Portfolio Projects!
Curated datasets are useful to know about if you want to do a data science [...]
May
Statistics Trivia for Data Scientists
Statistics trivia for data scientists will refresh your memory from the courses you’ve taken – [...]
Apr
Management Tips for Data Scientists
Management tips for data scientists can be used by anyone – at work and in [...]
Mar
REDCap Mess: How it Got There, and How to Clean it Up
REDCap mess happens often in research shops, and it’s an analysis showstopper! Read my blog [...]
Mar
GitHub Beginners in Data Science: Here’s an Easy Way to Start!
GitHub beginners – even in data science – often feel intimidated when starting their GitHub [...]
Feb
ETL Pipeline Documentation: Here are my Tips and Tricks!
ETL pipeline documentation is great for team communication as well as data stewardship! Read my [...]
Feb
Benchmarking Runtime is Different in SAS Compared to Other Programs
Benchmarking runtime is different in SAS compared to other programs, where you have to request [...]
Dec
End-to-End AI Pipelines: Can Academics Be Taught How to Do Them?
End-to-end AI pipelines are being created routinely in industry, and one complaint is that academics [...]
Nov
Referring to Columns in R by Name Rather than Number has Pros and Cons
Referring to columns in R can be done using both number and field name syntax. [...]
Oct
The Paste Command in R is Great for Labels on Plots and Reports
The paste command in R is used to concatenate strings. You can leverage the paste [...]
Oct
Coloring Plots in R using Hexadecimal Codes Makes Them Fabulous!
Recoloring plots in R? Want to learn how to use an image to inspire R [...]
5 Comments
Oct
Adding Error Bars to ggplot2 Plots Can be Made Easy Through Dataframe Structure
Adding error bars to ggplot2 in R plots is easiest if you include the width [...]
Oct
AI on the Edge: What it is, and Data Storage Challenges it Poses
“AI on the edge” was a new term for me that I learned from Marc [...]
Jun
Pie Chart ggplot Style is Surprisingly Hard! Here’s How I Did it
Pie chart ggplot style is surprisingly hard to make, mainly because ggplot2 did not give [...]
5 Comments
Apr
Time Series Plots in R Using ggplot2 Are Ultimately Customizable
Time series plots in R are totally customizable using the ggplot2 package, and can come [...]
Apr
Data Curation Solution to Confusing Options in R Package UpSetR
Data curation solution that I posted recently with my blog post showing how to do [...]
Apr
Making Upset Plots with R Package UpSetR Helps Visualize Patterns of Attributes
Making upset plots with R package UpSetR is an easy way to visualize patterns of [...]
11 Comments
Apr
Making Box Plots Different Ways is Easy in R!
Making box plots in R affords you many different approaches and features. My blog post [...]
Mar
Convert CSV to RDS When Using R for Easier Data Handling
Convert CSV to RDS is what you want to do if you are working with [...]
Mar
GPower Case Example Shows How to Calculate and Document Sample Size
GPower case example shows a use-case where we needed to select an outcome measure for [...]
Feb
Querying the GHDx Database: Demonstration and Review of Application
Querying the GHDx database is challenging because of its difficult user interface, but mastering it [...]
Feb
Variable Names in SAS and R Have Different Restrictions and Rules
Variable names in SAS and R are subject to different “rules and regulations”, and these [...]
Feb
Referring to Variables in Processing Data is Different in SAS Compared to R
Referring to variables in processing is different conceptually when thinking about SAS compared to R. [...]
Jan
Counting Rows in SAS and R Use Totally Different Strategies
Counting rows in SAS and R is approached differently, because the two programs process data [...]
Jan
Native Formats in SAS and R for Data Are Different: Here’s How!
Native formats in SAS and R of data objects have different qualities – and there [...]
Jan
SAS-R Integration Example: Transform in R, Analyze in SAS!
Looking for a SAS-R integration example that uses the best of both worlds? I show [...]
Dec
Dumbbell Plot for Comparison of Rated Items: Which is Rated More Highly – Harvard or the U of MN?
Want to compare multiple rankings on two competing items – like hotels, restaurants, or colleges? [...]
2 Comments
Sep
Data for Meta-analysis Need to be Prepared a Certain Way – Here’s How
Getting data for meta-analysis together can be challenging, so I walk you through the simple [...]
Jul
Sort Order, Formats, and Operators: A Tour of The SAS Documentation Page
Get to know three of my favorite SAS documentation pages: the one with sort order, [...]
Nov
Confused when Downloading BRFSS Data? Here is a Guide
I use the datasets from the Behavioral Risk Factor Surveillance Survey (BRFSS) to demonstrate in [...]
2 Comments
Oct
Doing Surveys? Try my R Likert Plot Data Hack!
I love the Likert package in R, and use it often to visualize data. The [...]
3 Comments
Oct
I Used the R Package EpiCurve to Make an Epidemiologic Curve. Here’s How It Turned Out.
With all this talk about “flattening the curve” of the coronavirus, I thought I would [...]
Mar
Which Independent Variables Belong in a Regression Equation? We Don’t All Agree, But Here’s What I Do.
Trying to decide what independent variables belong in a regression can be daunting. My blog [...]
Aug
Trying to decide what independent variables belong in a regression can be daunting. My blog post shows you the evidence-based way I make modeling decisions about keeping independent variables.

