Question: R script for data and plots! #creating data X QUESTION 3. Consider a situation in which we know that a linear model is a correct

R script for data and plots!
#creating data
X
D
U
Y
data
# filter the results from control group and treatment group
data_treatetd %filter(D>0)
data_control %filter(D==0)
lm_treated
lm_controled
summary(lm_treated)
summary(lm_controled)
#treated plot
ggplot(data_treatetd, aes(x=X, y=Y)) + ggtitle("Treatment group") +
xlab("Data") + ylab("Error term") + geom_smooth(methode = "lm", se = FALSE)
#controled plot
ggplot(data_control, aes(x=X, y=Y)) + ggtitle("Controled group") +
xlab("Data") + ylab("Error term") + geom_smooth(methode = "lm", se = FALSE)
# Scatterplot treated group
ggplot(data_treatetd, aes(x=X, y=Y)) + ggtitle("Treatment group") +
xlab("Data") + ylab("Error term") + geom_point(color = "blue") + geom_smooth(methode= "lm")
#scatterplot controled group
ggplot(data_control, aes(x=X, y=Y)) + ggtitle("Controled group") +
xlab("Data") + ylab("Error term") + geom_point(color = "red") + geom_smooth(methode= "lm")
ggplot(NULL, aes(X,Y))+
geom_point(data = data_treatetd, aes(color ="Treatment"))+ geom_smooth(data = data_treatetd, methode= "lm")+
geom_point(data = data_control, aes(color = "Control")) + geom_smooth(data = data_control, methode= "lm")
( this is the question i am looking for an answer for)You just plotted two graphs. Explain why a simple difference in means between the treatment and control may not have given the correct answer about the effectiveness of the treatment while a regression on Yi on Di and Xi does.
QUESTION 3. Consider a situation in which we know that a linear model is a correct specification for the relationship of interest that includes three variables (Yi,,XiDi). Let Y; denote some dependent variable for individual i. Let Di denote the treatment variable. About half of the sample is treated. Di takes on the value of 1 if individual i is treated, and O otherwise. Let X denote a confounding variable for individual i. X, is a random variable with mean O and standard deviation 1. Parenthetically, do not forget to add an error term when you generate Y. The error term also has mean O and standard deviation 1. Use R to generate hypothetical data (10,000 observations) from such a model. Do the
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
