2
$\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$

migrated from stackoverflow.com Jan 30 '15 at 4:05

This question came from our site for professional and enthusiast programmers.

  • 3
    $\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 '15 at 1:24
  • $\begingroup$ Check for perfect correlations off the diagonal in your survey dataset - cor(survey[c("support","demographics","values","knowledge")]) $\endgroup$ – thelatemail Jan 30 '15 at 1:26
6
$\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, privacy policy and cookie policy

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