# Linear regression model mistakenly gives $R^2$ equal to 1

I'm using R to create a linear regression model from survey data about public sentiment for a new technology. I am encountering a problem where the addition of a new explanatory variable raises the model's $R^2$ value from 0.52 to precisely 1. This is absurd, but I'm new to this stuff and can't figure out what's going on.

The survey asks several questions about demographic and values and technical knowledge. These items become the explanatory variables in the model. Most are either dummy variables or likert scales that extend from 1 to 7 (meaning that for every such question, each respondent chooses a number between 1 and 7). The survey also asks respondents to what extent they'd support government investment in the new technology. That question becomes the dependent variable in the model. It is also a likert scale that extends from 1 to 7.

I'm using R's lm() function to regress the knowledge, demographics, and values variables against the support for new technology variable. The functional form is:

lm(support~demographics+values+knowledge,data=survey).


Out of about 2000 survey responses, 900 remain after NA's are discarded. I created a model comprising approximately 20 explanatory variables, with an $R^2$ value of 0.52. Then, I added in a 21st explanatory variable, and the $R^2$ jumped to 1. When I do a simple regression of only this new variable and the dependent variable, the $R^2$ is 0.67. What could be going on?

• Without a reproducible example, this isn't a programming question, this is a theoretical stats question. Either provide some sample data and the code you are running in R or consider posting to Cross Validated instead. – MrFlick Jan 30 '15 at 1:24
• Check for perfect correlations off the diagonal in your survey dataset - cor(survey[c("support","demographics","values","knowledge")]) – thelatemail Jan 30 '15 at 1:26

x1=c(1:7,0)