#load package
library(readxl)
library(tidyverse)
## -- Attaching packages ----------------------------------- tidyverse 1.2.1 --
## v ggplot2 3.1.1 v purrr 0.3.2
## v tibble 2.1.1 v dplyr 0.8.0.1
## v tidyr 0.8.3 v stringr 1.4.0
## v readr 1.3.1 v forcats 0.4.0
## -- Conflicts -------------------------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(xtable)
library(kableExtra)
##
## Attaching package: 'kableExtra'
## The following object is masked from 'package:dplyr':
##
## group_rows
#Gõ lệnh hồi quy
ols <- read_excel("C:\\Users\\Windows 10\\Documents\\ols.xlsx")
reg <-lm(data=ols,DR~TobinsQ+SIZE+GRTA+NDTS+CR+ROA)
reg2 <-lm(data=ols,DR~TobinsQ^2+SIZE+GRTA+NDTS+CR+ROA)
summary(reg)
##
## Call:
## lm(formula = DR ~ TobinsQ + SIZE + GRTA + NDTS + CR + ROA, data = ols)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.50284 -0.12170 0.01323 0.12477 0.66334
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.461783 0.139304 -3.315 0.000975 ***
## TobinsQ -0.094295 0.012213 -7.721 5.17e-14 ***
## SIZE 0.038954 0.005054 7.707 5.71e-14 ***
## GRTA 0.029968 0.025585 1.171 0.241960
## NDTS 0.029737 0.023481 1.266 0.205866
## CR -0.013899 0.001360 -10.224 < 2e-16 ***
## ROA -0.368572 0.097118 -3.795 0.000163 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.1778 on 573 degrees of freedom
## Multiple R-squared: 0.4155, Adjusted R-squared: 0.4094
## F-statistic: 67.89 on 6 and 573 DF, p-value: < 2.2e-16
k1 <- xtable(reg)
kable(summary(reg)$coef, digits = 4)
| Estimate | Std. Error | t value | Pr(>|t|) | |
|---|---|---|---|---|
| (Intercept) | -0.4618 | 0.1393 | -3.3149 | 0.0010 |
| TobinsQ | -0.0943 | 0.0122 | -7.7211 | 0.0000 |
| SIZE | 0.0390 | 0.0051 | 7.7070 | 0.0000 |
| GRTA | 0.0300 | 0.0256 | 1.1713 | 0.2420 |
| NDTS | 0.0297 | 0.0235 | 1.2665 | 0.2059 |
| CR | -0.0139 | 0.0014 | -10.2236 | 0.0000 |
| ROA | -0.3686 | 0.0971 | -3.7951 | 0.0002 |
scale <-lm(data=ols,scale(DR)~0+scale(TobinsQ)+scale(SIZE)+scale(GRTA)+scale(NDTS)+scale(CR)+scale(ROA))
summary(scale)
##
## Call:
## lm(formula = scale(DR) ~ 0 + scale(TobinsQ) + scale(SIZE) + scale(GRTA) +
## scale(NDTS) + scale(CR) + scale(ROA), data = ols)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.17340 -0.52602 0.05717 0.53930 2.86710
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## scale(TobinsQ) -0.28876 0.03737 -7.728 4.92e-14 ***
## scale(SIZE) 0.25774 0.03341 7.714 5.43e-14 ***
## scale(GRTA) 0.03936 0.03358 1.172 0.241550
## scale(NDTS) 0.04148 0.03272 1.268 0.205471
## scale(CR) -0.34209 0.03343 -10.233 < 2e-16 ***
## scale(ROA) -0.14527 0.03825 -3.798 0.000161 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.7679 on 574 degrees of freedom
## Multiple R-squared: 0.4155, Adjusted R-squared: 0.4094
## F-statistic: 68 on 6 and 574 DF, p-value: < 2.2e-16
h1 <- ggplot(ols,aes(x=TobinsQ, y=DR))+geom_point()
h2 <- h1+stat_smooth(method="lm",formula = y~x+I(x^2),size=.8)
h2
h3 <- ggplot(ols,aes(x=TobinsQ,y=DR,col=San))+geom_point()+stat_smooth(method="lm",formula = y~x+I(x^2),size=.8)
h3