I have a dummy variable black
where black==0
is White and black==1
is Black. I am trying to fit a linear model lm
for the black==1
category only, however running the code below gives me the incorrect coefficients. Is there a way in R to run a model with the if
statement, similar to Stata?
library(foreign)
df<-read.dta("hw4.dta")
attach(df)
black[black==0]<-NA
model3<-lm(rent~I(income^2)+income+black)