3.1 Kolej Gpa’sının Belirleyicileri
library(wooldridge)
data(gpa1)
library(rmarkdown)
paged_table(gpa1)
coklureg <- lm(colGPA~ hsGPA+ACT,data = gpa1)
summary(coklureg)
##
## Call:
## lm(formula = colGPA ~ hsGPA + ACT, data = gpa1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.85442 -0.24666 -0.02614 0.28127 0.85357
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.286328 0.340822 3.774 0.000238 ***
## hsGPA 0.453456 0.095813 4.733 5.42e-06 ***
## ACT 0.009426 0.010777 0.875 0.383297
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.3403 on 138 degrees of freedom
## Multiple R-squared: 0.1764, Adjusted R-squared: 0.1645
## F-statistic: 14.78 on 2 and 138 DF, p-value: 1.526e-06
basitreg <- lm(colGPA~ACT,data = gpa1)
summary(basitreg)
##
## Call:
## lm(formula = colGPA ~ ACT, data = gpa1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.85251 -0.25251 -0.04426 0.26400 0.89336
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.40298 0.26420 9.095 8.8e-16 ***
## ACT 0.02706 0.01086 2.491 0.0139 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.3656 on 139 degrees of freedom
## Multiple R-squared: 0.04275, Adjusted R-squared: 0.03586
## F-statistic: 6.207 on 1 and 139 DF, p-value: 0.0139
plot(gpa1$ACT,gpa1$colGPA)
abline(basitreg)

library(plotly)
## Zorunlu paket yükleniyor: ggplot2
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(reshape2)
cf.mod <- coef(coklureg)
hsGPA <- seq(min(gpa1$hsGPA),max(gpa1$hsGPA),length.out=50)
ACT <- seq(min(gpa1$ACT),max(gpa1$ACT),length.out=50)
colGPA <- t(outer(hsGPA, ACT, function(x,y) cf.mod[1]+cf.mod[2]*x+cf.mod[3]*y))
p <- plot_ly(x=~hsGPA, y=~ACT, z=~colGPA,type="surface") %>%
add_trace(data=gpa1, x=gpa1$hsGPA, y=gpa1$ACT, z=gpa1$colGPA, mode="markers", type="scatter3d", opacity=0.5)
p