Take the 2-minute tour ×
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

I have a binary variable, $X=\{0,1\}$ and I want to use this variable to predict a continuous outcome variable $y$

What regression model ought I use to estimate the predictive ability of $X$ of $y$?

I know that switching them the other way around, would allow me to use a logistic regression model but that doesn't seem applicable in this scenario.

What statistic would I use to assess the significance of this relationship?

How can I do this in R?

share|improve this question
4  
One could look at this as two completely separate questions. (1) When $X=0$, how would you predict $y$? (2) When $X=1$, how would you predict $y$? If you have a dataset of $(X,y)$ pairs, these two questions deal with disjoint subsets of the dataset--in effect, two different datasets. In each dataset $X$ does not vary. Thus each is the same question and that common question boils down to "I have a set of $y$ values. How do I predict them?" That is a standard, simple univariate problem--and it has many more solutions than those offered by regression models. –  whuber Jul 3 at 16:41
    
Just to clarify, you're looking to predict a function from (0,1) to, say, R (the reals). In other words, 0 maps to a, and 1 to b (where a and be are from the reals)? –  Mitch Jul 3 at 19:30

1 Answer 1

No problem, you can try plain vanilla OLS.

A toy example in R:

> set.seed(1235321)
> x <- c(rep(1,50), rep(0,50))
> epsilon <- rnorm(100)
> y <- 1 + 3 * x + epsilon
> coef(lm(y ~ x))
(Intercept)           x 
   1.069068    2.987035 

Of course, you'll get poor results if your "error" contains relevant omitted variables. E.g.:

> z <- runif(100, 2, 6)
> y <- 1 + 0.5 * x + 3 * z + epsilon  # y depends on x _and_ z
> coef(lm(y ~ x))                     # you omit z
(Intercept)           x 
  12.317986    1.201527 

This should be your main concern.

share|improve this answer
    
Excellent analysis. I would simply add that this assumes the distribution for the random variable is bimodal about two different means and the same variance about each. Suppose not only the mean value, but also the variance (or the shape of the distribution) changed based on x. Then I think you would have to model both populations separately as whuber suggests above, and the impact of x may not be measured with a single number. –  MikeP Jul 3 at 19:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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