In: Math
Please answer using R code!
install.packages("wooldridge")
require("wooldridge")
d1 <- data("attend")
View(attend)
Q) Draw as scatter plot of stndfnl against priGPA. Customize your plot, such as give it a title, x-axis and y-axis labels, and you may put nice color to make it pretty. Run a simple regression of stndfnl on priGPA and save regression model as reg1. Are these variables related in the direction you expected? Interpret your estimated slope and intercept coefficient? Now run a multiple regression of stndfnl on priGPA and dummy variable frosh and soph. Interpret the coefficient of soph.
R-code:
library("wooldridge")
d1=data("attend")
View(attend)
attend$stndfnl
attend$priGPA
#scatterplot of stndfnl and priceGPA
plot(attend$stndfnl,attend$priGPA)
#simple regression of stndfnl on priGPA
reg1=lm(attend$stndfnl~attend$priGPA)
reg1
#multiple regression of stndfnl on priGPA and dummy variable
frosh and soph.
lm(attend$stndfnl~attend$priGPA+attend$frosh+attend$soph)
R-output:
> library("wooldridge")
> d1=data("attend")
> #scatterplot of stndfnl and priceGPA
> plot(attend$stndfnl,attend$priGPA)
> #simple regression of stndfnl on priGPA
> reg1=lm(attend$stndfnl~attend$priGPA)
> reg1
Call:
lm(formula = attend$stndfnl ~ attend$priGPA)
Coefficients:
(Intercept) attend$priGPA
-1.6898 0.6647
> #a multiple regression of stndfnl on priGPA and dummy
variable frosh and soph.
> lm(attend$stndfnl~attend$priGPA+attend$frosh+attend$soph)
Call:
lm(formula = attend$stndfnl ~ attend$priGPA + attend$frosh +
attend$soph)
Coefficients:
(Intercept) attend$priGPA attend$frosh
attend$soph
-1.64466 0.68642 -0.05111 -0.15513
#slop and intercept of reg1 are 0.6647 and -1.6898 respectively
#coefficient of soph -0.15513