# How to include both dummy measure and continuous measure of one variable into regression models?

Suppose here is a market for softwares. The softwares can be free or paid, which is captured by dummy variable paid. At the same time, we have another variable, price, to measure how much the softwares are charged. Of course, price=0 refers to paid=0. The outcome variable of interest is the number of installations.

I want to see both "free vs. price effect" (the coefficient of paid) of and "marginal price effect" (the coefficient of price). Can I just include both terms into the regression model? Or must I run two separate models? Is the correlation between the two variables a concern? Why or why not?

If you believe that paid effect is exist. You should include them in a model both to rid of estimator bias, although you will suffer multicollinearity. For instance, I build the "real model" to illustrate it by simulate:

$$ins = \beta_1 + \beta_2 paid + \beta_3 price + u \\ u \sim N(0,1) \\ \beta_1 = \beta_2 = \beta_3 = 1 \\ X \sim U(-1,1) \quad price \sim \max(0,X) \quad paid \sim sign(price)$$

and I fit the data generated from the "real model" by two model form:

$$ins = \beta_1 + \beta_2 paid + \beta_3 price + u \\ ins = \beta_1 + \beta_3 price + u$$

experiment <- function(size = 100, b1 = 1, b2 = 1, b3 = 1, sigma = 1){
r <- runif(size,-1,1)
free <- r > 0
price <- r * free
u <- rnorm(size,0,sigma)
ins <- b1 + b2*free + b3*price + u
df <- data.frame(ins = ins,free = free, price = price)
mod1 <- lm(ins~free+price,data=df)
mod2 <- lm(ins~price,data=df)
return(list(mod1,mod2))
}

nums <- 1000 # the number of simulation
mods <- replicate(nums, experiment())
mods1 <- mods[seq(1,2000,2)]
mods2 <- mods[seq(2,2000,2)]
mods1b3 <- sapply(mods1,function(mod)unlist(mod)$coefficients.price) mods2b3 <- sapply(mods2,function(mod)unlist(mod)$coefficients.price)

mean(mods1b3) # output: 0.983897849329834
mean(mods2b3) # output: 2.19213258786454
sd(mods1b3) # output: 0.504819985630698
sd(mods2b3) # output: 0.327550381543426


As you can see, model without $\beta_2$ have lower sd but fatal bias to real value(2.19 to 1.0), while the bias of the model with $\beta_2$ is unsignificant(0.98 to 1.0). Thus, lower sd(0.32 to 0.50) is pointless. You need non-bias version and bear the bigger sd that should be beared.

If you were to include both variables in the model, multicollinearity could be a concern. In an OLS model, the variance of an estimated parameter $\hat\beta$ is calculated as:$$Var(\hat\beta)=\frac{\sigma^2}{SST_j(1-R^2_j)}$$

where $\sigma^2$ is the error variance, $SST_j$ is the total sample variation for an independent variable $x_j$, and $R^2_j$ is the $R^2$ regressing $x_j$ on the remaining independent variables. Generally, we want as small an $R^2_j$ value as possible, and ideally a value of 0 with no correlation between the independent variables.

In your example there won't a perfect correlation, but the high $R^2_j$ could result in variance estimates which are too large to be useful. It can be viewed as analogous to problems using small samples.

So this is basically why you might run into problems including both in the model. Note that OLS can still be applied provided the correlation is not perfect, and that the question "how much multicollinearity is acceptable?" is contentious. Whether you include both or model them separately is possibly down to the extent to which you believe they measure the same phenomenon.

Hope that helps :)