10
$\begingroup$

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?

$\endgroup$
2
  • 5
    $\begingroup$ 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. $\endgroup$
    – MrFlick
    Jan 30, 2015 at 1:24
  • $\begingroup$ Check for perfect correlations off the diagonal in your survey dataset - cor(survey[c("support","demographics","values","knowledge")]) $\endgroup$ Jan 30, 2015 at 1:26

1 Answer 1

14
$\begingroup$

My hunch would be that your 21st variable has led to a linear combination that perfectly explains the dependent variable. Try:

x1=c(1:7,0)
y=1:8
summary(lm(y~x1-1))

x2=c(rep(0,7),8)
summary(lm(y~x1+x2-1))
plot(x1,y)
plot(x2,y)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.