#install.packages(“data.table”) #install.packages(“psych”) #install.packages(“dplyr”) #install.packages(“dataframeexplorer”) #install.packages(“tidyverse”) #install.packages(“MASS”) #install.packages(“ggplot2”) #install.packages(“DT”) #install.packages(“skimr”) #install.packages(“caret”) #install.packages(“lessR”) #install.packages(“fst”) #install.packages(“ggplot”) #install.packages(“plotly”) #install.packages(“caTools”) #install.packages(‘car’) #install.packages(“relaimpo”) #install.packages(“survival”) #install.packages(“survey”) #install.packages(“Matrix”) #install.packages(“gvlma”) #install.packages(“knitr”) #install.packages(“kableExtra”) #install.packages(“shiny”) # Load library
library(data.table)
library(psych)
library(table1)
##
## Attaching package: 'table1'
## The following objects are masked from 'package:base':
##
## units, units<-
library(explore)
##
## Attaching package: 'explore'
## The following object is masked from 'package:psych':
##
## describe
library(ggplot2)
##
## Attaching package: 'ggplot2'
## The following objects are masked from 'package:psych':
##
## %+%, alpha
library(GGally)
## Registered S3 method overwritten by 'GGally':
## method from
## +.gg ggplot2
##
## Attaching package: 'GGally'
## The following object is masked from 'package:explore':
##
## rescale01
library(gridExtra)
library(dataframeexplorer)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.0 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ lubridate 1.9.2 ✔ tibble 3.1.8
## ✔ purrr 1.0.1 ✔ tidyr 1.3.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ ggplot2::%+%() masks psych::%+%()
## ✖ ggplot2::alpha() masks psych::alpha()
## ✖ dplyr::between() masks data.table::between()
## ✖ dplyr::combine() masks gridExtra::combine()
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::first() masks data.table::first()
## ✖ lubridate::hour() masks data.table::hour()
## ✖ lubridate::isoweek() masks data.table::isoweek()
## ✖ dplyr::lag() masks stats::lag()
## ✖ dplyr::last() masks data.table::last()
## ✖ lubridate::mday() masks data.table::mday()
## ✖ lubridate::minute() masks data.table::minute()
## ✖ lubridate::month() masks data.table::month()
## ✖ lubridate::quarter() masks data.table::quarter()
## ✖ lubridate::second() masks data.table::second()
## ✖ purrr::transpose() masks data.table::transpose()
## ✖ lubridate::wday() masks data.table::wday()
## ✖ lubridate::week() masks data.table::week()
## ✖ lubridate::yday() masks data.table::yday()
## ✖ lubridate::year() masks data.table::year()
## ℹ Use the ]8;;http://conflicted.r-lib.org/conflicted package]8;; to force all conflicts to become errors
library(readxl)
library(MASS)
##
## Attaching package: 'MASS'
##
## The following object is masked from 'package:dplyr':
##
## select
library(ggplot2)
library(explore)
library(tidyverse)
library(broom)
require(ggplot2)
library(dplyr)
library(plotly)
##
## Attaching package: 'plotly'
##
## The following object is masked from 'package:MASS':
##
## select
##
## 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(rlang)
##
## Attaching package: 'rlang'
##
## The following objects are masked from 'package:purrr':
##
## %@%, flatten, flatten_chr, flatten_dbl, flatten_int, flatten_lgl,
## flatten_raw, invoke, splice
##
## The following object is masked from 'package:data.table':
##
## :=
library(car)
## Loading required package: carData
##
## Attaching package: 'car'
##
## The following object is masked from 'package:dplyr':
##
## recode
##
## The following object is masked from 'package:purrr':
##
## some
##
## The following object is masked from 'package:psych':
##
## logit
library(broom)
library(relaimpo)
## Loading required package: boot
##
## Attaching package: 'boot'
##
## The following object is masked from 'package:car':
##
## logit
##
## The following object is masked from 'package:psych':
##
## logit
##
## Loading required package: survey
## Loading required package: grid
## Loading required package: Matrix
##
## Attaching package: 'Matrix'
##
## The following objects are masked from 'package:tidyr':
##
## expand, pack, unpack
##
## Loading required package: survival
##
## Attaching package: 'survival'
##
## The following object is masked from 'package:boot':
##
## aml
##
##
## Attaching package: 'survey'
##
## The following object is masked from 'package:graphics':
##
## dotchart
##
## Loading required package: mitools
## This is the global version of package relaimpo.
##
## If you are a non-US user, a version with the interesting additional metric pmvd is available
##
## from Ulrike Groempings web site at prof.beuth-hochschule.de/groemping.
library(survival)
library(survey)
library(Matrix)
library(psych)
library(gvlma)
library(caTools)
library(nlme)
##
## Attaching package: 'nlme'
##
## The following object is masked from 'package:dplyr':
##
## collapse
library(knitr)
library(kableExtra)
##
## Attaching package: 'kableExtra'
##
## The following object is masked from 'package:dplyr':
##
## group_rows
setwd("/Users/macos/Documents/Research/Journal/Data/R/mprice")
mprice=read_xlsx("datapricestock.xlsx")
dim(mprice)
## [1] 627 12
names(mprice)
## [1] "ma" "id" "quarterly" "mp" "gdp" "atc"
## [7] "buy" "sell" "vol" "cpi" "roa" "roe"
glimpse(mprice)
## Rows: 627
## Columns: 12
## $ ma <chr> "SHS", "SHS", "SHS", "SHS", "SHS", "SHS", "SHS", "SHS", "SHS…
## $ id <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, …
## $ quarterly <chr> "2014q1", "2014q2", "2014q3", "2014q4", "2015q1", "2015q2", …
## $ mp <dbl> 3.270213, 3.373464, 3.379003, 3.373525, 3.305351, 3.238046, …
## $ gdp <dbl> 0.0506, 0.0534, 0.0607, 0.0696, 0.0612, 0.0647, 0.0687, 0.07…
## $ atc <dbl> 1.7338403, 1.3680556, 1.7738913, 1.3949382, 1.0561798, 0.979…
## $ buy <dbl> 0.0000000000, 0.0000000000, 0.0000000000, 0.0500776203, 0.00…
## $ sell <dbl> 0.0707550503, 0.1576944264, 0.0000000000, 0.0000000000, 0.00…
## $ vol <dbl> 1.2927438, 1.6177976, 1.8726927, 1.4197807, 0.5520500, 0.579…
## $ cpi <dbl> 0.0026666667, 0.0019333333, 0.0028333333, -0.0013333333, -0.…
## $ roa <dbl> 0.020941185, 0.001974712, 0.011330372, -0.006545927, 0.00375…
## $ roe <dbl> 0.084376270, 0.007726305, 0.068684805, -0.022879567, 0.01305…
str(mprice)
## tibble [627 × 12] (S3: tbl_df/tbl/data.frame)
## $ ma : chr [1:627] "SHS" "SHS" "SHS" "SHS" ...
## $ id : num [1:627] 1 1 1 1 1 1 1 1 1 1 ...
## $ quarterly: chr [1:627] "2014q1" "2014q2" "2014q3" "2014q4" ...
## $ mp : num [1:627] 3.27 3.37 3.38 3.37 3.31 ...
## $ gdp : num [1:627] 0.0506 0.0534 0.0607 0.0696 0.0612 0.0647 0.0687 0.0701 0.0548 0.0578 ...
## $ atc : num [1:627] 1.73 1.37 1.77 1.39 1.06 ...
## $ buy : num [1:627] 0 0 0 0.0501 0 ...
## $ sell : num [1:627] 0.0708 0.1577 0 0 0 ...
## $ vol : num [1:627] 1.293 1.618 1.873 1.42 0.552 ...
## $ cpi : num [1:627] 0.002667 0.001933 0.002833 -0.001333 -0.000333 ...
## $ roa : num [1:627] 0.02094 0.00197 0.01133 -0.00655 0.00376 ...
## $ roe : num [1:627] 0.08438 0.00773 0.06868 -0.02288 0.01306 ...
mprice %>% head()
## # A tibble: 6 × 12
## ma id quarterly mp gdp atc buy sell vol cpi roa
## <chr> <dbl> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 SHS 1 2014q1 3.27 0.0506 1.73 0 0.0708 1.29 2.67e-3 0.0209
## 2 SHS 1 2014q2 3.37 0.0534 1.37 0 0.158 1.62 1.93e-3 0.00197
## 3 SHS 1 2014q3 3.38 0.0607 1.77 0 0 1.87 2.83e-3 0.0113
## 4 SHS 1 2014q4 3.37 0.0696 1.39 0.0501 0 1.42 -1.33e-3 -0.00655
## 5 SHS 1 2015q1 3.31 0.0612 1.06 0 0 0.552 -3.33e-4 0.00376
## 6 SHS 1 2015q2 3.24 0.0647 0.980 0 0 0.580 2.17e-3 0.00529
## # … with 1 more variable: roe <dbl>
attach(mprice)
head(mprice)
## # A tibble: 6 × 12
## ma id quarterly mp gdp atc buy sell vol cpi roa
## <chr> <dbl> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 SHS 1 2014q1 3.27 0.0506 1.73 0 0.0708 1.29 2.67e-3 0.0209
## 2 SHS 1 2014q2 3.37 0.0534 1.37 0 0.158 1.62 1.93e-3 0.00197
## 3 SHS 1 2014q3 3.38 0.0607 1.77 0 0 1.87 2.83e-3 0.0113
## 4 SHS 1 2014q4 3.37 0.0696 1.39 0.0501 0 1.42 -1.33e-3 -0.00655
## 5 SHS 1 2015q1 3.31 0.0612 1.06 0 0 0.552 -3.33e-4 0.00376
## 6 SHS 1 2015q2 3.24 0.0647 0.980 0 0 0.580 2.17e-3 0.00529
## # … with 1 more variable: roe <dbl>
tail(mprice)
## # A tibble: 6 × 12
## ma id quarterly mp gdp atc buy sell vol cpi roa
## <chr> <dbl> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 <NA> 19 2020q4 3.88 0.0448 0.830 0 0 0.0253 6.00e-4 0.00789
## 2 <NA> 19 2021q1 3.95 0.0472 0.938 0 0 0.0557 4.37e-3 0.0116
## 3 <NA> 19 2021q2 4.00 0.0673 1.12 0 4.67e-4 0.109 1.03e-3 0.0168
## 4 <NA> 19 2021q3 4.12 -0.0602 1.30 0 0 0.124 8.33e-4 0.0146
## 5 <NA> 19 2021q4 4.16 0.0522 1.83 0 0 0.319 8.33e-4 0.00751
## 6 <NA> 19 2022q1 4.12 0.0503 1.35 0 0 0.0998 6.30e-3 0.0119
## # … with 1 more variable: roe <dbl>
mprice %>% head() %>% data.table()
## ma id quarterly mp gdp atc buy sell vol
## 1: SHS 1 2014q1 3.270213 0.0506 1.7338403 0.00000000 0.07075505 1.292744
## 2: SHS 1 2014q2 3.373464 0.0534 1.3680556 0.00000000 0.15769443 1.617798
## 3: SHS 1 2014q3 3.379003 0.0607 1.7738913 0.00000000 0.00000000 1.872693
## 4: SHS 1 2014q4 3.373525 0.0696 1.3949382 0.05007762 0.00000000 1.419781
## 5: SHS 1 2015q1 3.305351 0.0612 1.0561798 0.00000000 0.00000000 0.552050
## 6: SHS 1 2015q2 3.238046 0.0647 0.9799675 0.00000000 0.00000000 0.579740
## cpi roa roe
## 1: 0.0026666667 0.020941185 0.084376270
## 2: 0.0019333333 0.001974712 0.007726305
## 3: 0.0028333333 0.011330372 0.068684805
## 4: -0.0013333333 -0.006545927 -0.022879567
## 5: -0.0003333333 0.003756064 0.013058053
## 6: 0.0021666667 0.005294538 0.017874397
fig1 <- plot_ly(mprice, x=~id, y=~year, z=~mp)
add_lines(fig1, linetype=~id)
## Warning: plotly.js only supports 6 different linetypes
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
fig2 <- plot_ly(mprice, x=~id, y=~year, z=~gdp)
add_lines(fig2, linetype=~id)
## Warning: plotly.js only supports 6 different linetypes
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
fig3 <- plot_ly(mprice, x=~id, y=~year, z=~atc)
add_lines(fig3, linetype=~id)
## Warning: plotly.js only supports 6 different linetypes
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
fig4 <- plot_ly(mprice, x=~id, y=~year, z=~buy)
add_lines(fig4, linetype=~id)
## Warning: plotly.js only supports 6 different linetypes
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
fig5 <- plot_ly(mprice, x=~id, y=~year, z=~sell)
add_lines(fig5, linetype=~id)
## Warning: plotly.js only supports 6 different linetypes
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
fig6 <- plot_ly(mprice, x=~id, y=~year, z=~vol)
add_lines(fig6, linetype=~id)
## Warning: plotly.js only supports 6 different linetypes
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
fig7 <- plot_ly(mprice, x=~id, y=~year, z=~cpi)
add_lines(fig7, linetype=~id)
## Warning: plotly.js only supports 6 different linetypes
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
fig8 <- plot_ly(mprice, x=~id, y=~year, z=~roa)
add_lines(fig8, linetype=~id)
## Warning: plotly.js only supports 6 different linetypes
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
fig9 <- plot_ly(mprice, x=~id, y=~year, z=~roe)
add_lines(fig9, linetype=~id)
## Warning: plotly.js only supports 6 different linetypes
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
## Warning: The following are not valid linetype codes:
## 'NA'
## Valid linetypes include:
## 'solid', 'dot', 'dash', 'longdash', 'dashdot', 'longdashdot'
ggplot(mprice, aes(x=mp, y=gdp))+geom_point()+geom_smooth(method = "lm")
## `geom_smooth()` using formula = 'y ~ x'
ggplot(mprice, aes(x=mp, y=atc))+geom_point()+geom_smooth(method = "lm")
## `geom_smooth()` using formula = 'y ~ x'
ggplot(mprice, aes(x=mp, y=buy))+geom_point()+geom_smooth(method = "lm")
## `geom_smooth()` using formula = 'y ~ x'
ggplot(mprice, aes(x=mp, y=sell))+geom_point()+geom_smooth(method = "lm")
## `geom_smooth()` using formula = 'y ~ x'
ggplot(mprice, aes(x=mp, y=vol))+geom_point()+geom_smooth(method = "lm")
## `geom_smooth()` using formula = 'y ~ x'
ggplot(mprice, aes(x=mp, y=cpi))+geom_point()+geom_smooth(method = "lm")
## `geom_smooth()` using formula = 'y ~ x'
ggplot(mprice, aes(x=mp, y=roa))+geom_point()+geom_smooth(method = "lm")
## `geom_smooth()` using formula = 'y ~ x'
ggplot(mprice, aes(x=mp, y=roe))+geom_point()+geom_smooth(method = "lm")
## `geom_smooth()` using formula = 'y ~ x'
boxplot(mp~gdp,col="blue")
boxplot(mp~atc,col="green")
boxplot(mp~buy,col="red")
boxplot(mp~sell,col="yellow")
boxplot(mp~vol,col="navy")
boxplot(mp~cpi,col="purple")
boxplot(mp~roa,col="orange")
boxplot(mp~roe,col="pink")
table1(~mp+gdp+atc+buy+sell+vol+cpi+roa+roe, data=mprice)
| Overall (N=627) |
|
|---|---|
| mp | |
| Mean (SD) | 3.74 (0.350) |
| Median [Min, Max] | 3.70 [2.88, 4.63] |
| gdp | |
| Mean (SD) | 0.0558 (0.0254) |
| Median [Min, Max] | 0.0647 [-0.0602, 0.0765] |
| atc | |
| Mean (SD) | 1.27 (0.619) |
| Median [Min, Max] | 1.07 [0.105, 4.13] |
| buy | |
| Mean (SD) | 0.0152 (0.0584) |
| Median [Min, Max] | 0 [0, 0.539] |
| sell | |
| Mean (SD) | 0.0153 (0.0564) |
| Median [Min, Max] | 0 [0, 0.851] |
| vol | |
| Mean (SD) | 0.442 (0.629) |
| Median [Min, Max] | 0.191 [0.000236, 4.48] |
| cpi | |
| Mean (SD) | 0.00221 (0.00250) |
| Median [Min, Max] | 0.00237 [-0.00303, 0.00983] |
| roa | |
| Mean (SD) | 0.0123 (0.0266) |
| Median [Min, Max] | 0.00871 [-0.164, 0.265] |
| roe | |
| Mean (SD) | 0.0217 (0.0389) |
| Median [Min, Max] | 0.0152 [-0.181, 0.303] |
p1=ggplot(data=mprice, aes(x=mp, col=vol))+geom_histogram()
p2=ggplot(data=mprice, aes(x=mp, col=vol))+geom_histogram(col="white", fill="blue")
p3=ggplot(data=mprice, aes(x=mp, col=vol))+geom_histogram(aes(y=..density..), col="white", fill="blue")+geom_density(col="red")
grid.arrange(p1, p2, p3, ncol=3)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: The following aesthetics were dropped during statistical transformation: colour
## ℹ This can happen when ggplot fails to infer the correct grouping structure in
## the data.
## ℹ Did you forget to specify a `group` aesthetic or to convert a numerical
## variable into a factor?
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: The dot-dot notation (`..density..`) was deprecated in ggplot2 3.4.0.
## ℹ Please use `after_stat(density)` instead.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
model=lm(mp~gdp+atc+buy+sell+vol+cpi+roa+roe,data=mprice)
summary(model)
##
## Call:
## lm(formula = mp ~ gdp + atc + buy + sell + vol + cpi + roa +
## roe, data = mprice)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.63015 -0.20487 -0.03431 0.21052 0.68087
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.40438 0.04202 81.018 < 2e-16 ***
## gdp -1.78081 0.47149 -3.777 0.000174 ***
## atc 0.32879 0.02449 13.423 < 2e-16 ***
## buy 0.47380 0.21873 2.166 0.030683 *
## sell -0.60542 0.22814 -2.654 0.008165 **
## vol -0.07047 0.02258 -3.121 0.001888 **
## cpi 10.47317 4.58463 2.284 0.022686 *
## roa -1.04875 0.86724 -1.209 0.227012
## roe 1.70639 0.60961 2.799 0.005283 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2776 on 618 degrees of freedom
## Multiple R-squared: 0.3806, Adjusted R-squared: 0.3726
## F-statistic: 47.47 on 8 and 618 DF, p-value: < 2.2e-16
vif(model)
## gdp atc buy sell vol cpi roa roe
## 1.167011 1.864283 1.325006 1.345647 1.636108 1.067635 4.334547 4.578768
pairs.panels(mprice)
anova(model)
## Analysis of Variance Table
##
## Response: mp
## Df Sum Sq Mean Sq F value Pr(>F)
## gdp 1 5.353 5.3535 69.4607 5.056e-16 ***
## atc 1 21.072 21.0719 273.4055 < 2.2e-16 ***
## buy 1 0.056 0.0563 0.7304 0.393083
## sell 1 0.640 0.6402 8.3064 0.004088 **
## vol 1 0.791 0.7912 10.2656 0.001425 **
## cpi 1 0.332 0.3317 4.3035 0.038447 *
## roa 1 0.421 0.4213 5.4660 0.019708 *
## roe 1 0.604 0.6039 7.8353 0.005283 **
## Residuals 618 47.630 0.0771
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
res=resid(model)
hist(res)
qqnorm(res)
qqline(res)
AIC(model)
## [1] 183.2721
summary(model)
##
## Call:
## lm(formula = mp ~ gdp + atc + buy + sell + vol + cpi + roa +
## roe, data = mprice)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.63015 -0.20487 -0.03431 0.21052 0.68087
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.40438 0.04202 81.018 < 2e-16 ***
## gdp -1.78081 0.47149 -3.777 0.000174 ***
## atc 0.32879 0.02449 13.423 < 2e-16 ***
## buy 0.47380 0.21873 2.166 0.030683 *
## sell -0.60542 0.22814 -2.654 0.008165 **
## vol -0.07047 0.02258 -3.121 0.001888 **
## cpi 10.47317 4.58463 2.284 0.022686 *
## roa -1.04875 0.86724 -1.209 0.227012
## roe 1.70639 0.60961 2.799 0.005283 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2776 on 618 degrees of freedom
## Multiple R-squared: 0.3806, Adjusted R-squared: 0.3726
## F-statistic: 47.47 on 8 and 618 DF, p-value: < 2.2e-16
durbinWatsonTest(model)
## lag Autocorrelation D-W Statistic p-value
## 1 0.8097485 0.3703706 0
## Alternative hypothesis: rho != 0
outlierTest(model)
## No Studentized residuals with Bonferroni p < 0.05
## Largest |rstudent|:
## rstudent unadjusted p-value Bonferroni p
## 66 2.472397 0.01369 NA
calc.relimp(model, type=c("lmg","last","first","pratt"),rela=TRUE)
## Response variable: mp
## Total response variance: 0.1228439
## Analysis based on 627 observations
##
## 8 Regressors:
## gdp atc buy sell vol cpi roa roe
## Proportion of variance explained by model: 38.06%
## Metrics are normalized to sum to 100% (rela=TRUE).
##
## Relative importance metrics:
##
## lmg last first pratt
## gdp 0.094002342 0.061904571 1.088303e-01 0.089542131
## atc 0.636088198 0.781921324 5.224814e-01 0.881305537
## buy 0.010593236 0.020361097 6.394422e-03 0.013263670
## sell 0.010104476 0.030560068 9.911148e-05 -0.002038724
## vol 0.082418475 0.042260766 1.180406e-01 -0.091231330
## cpi 0.009598759 0.022645392 2.194589e-04 0.002326117
## roa 0.049609738 0.006345946 8.904902e-02 -0.049979078
## roe 0.107584775 0.034000836 1.548857e-01 0.156811675
##
## Average coefficients for different model sizes:
##
## 1X 2Xs 3Xs 4Xs 5Xs 6Xs
## gdp -3.63751782 -3.1702034 -2.80588711 -2.51657321 -2.280875330 -2.08417980
## atc 0.32759260 0.3274922 0.32751959 0.32761043 0.327746836 0.32795087
## buy 0.38388075 0.3585846 0.35900942 0.37312183 0.394501042 0.41965435
## sell 0.04946348 -0.1181375 -0.25471282 -0.36349593 -0.449063444 -0.51575167
## vol 0.15322851 0.1086319 0.06935854 0.03471861 0.004060501 -0.02325317
## cpi 1.66059722 4.9149399 7.11110057 8.56496476 9.499325935 10.06357699
## roa 3.14033304 1.9260998 0.96540944 0.22263332 -0.330623742 -0.71644831
## roe 2.83253727 2.6471053 2.48798672 2.34444421 2.205197702 2.05918613
## 7Xs 8Xs
## gdp -1.91823395 -1.78081131
## atc 0.32827544 0.32879480
## buy 0.44663022 0.47379881
## sell -0.56709602 -0.60541662
## vol -0.04787043 -0.07046727
## cpi 10.36000505 10.47316629
## roa -0.95171266 -1.04874531
## roe 1.89607427 1.70638876
boot <- boot.relimp(model, b=1000, type=c("lmg", "last", "first", "pratt"), rank = TRUE, diff=TRUE, rela= TRUE)
booteval.relimp(boot, typesel = c("lmg"), level=0.9, bty="perc", nodiff=T)
## Response variable: mp
## Total response variance: 0.1228439
## Analysis based on 627 observations
##
## 8 Regressors:
## gdp atc buy sell vol cpi roa roe
## Proportion of variance explained by model: 38.06%
## Metrics are normalized to sum to 100% (rela=TRUE).
##
## Relative importance metrics:
## Warning in matrix(cbind(x@lmg, x@pmvd, x@last, x@first, x@betasq, x@pratt, :
## data length differs from size of matrix: [32 != 8 x 1]
## lmg
## gdp 0.094002342
## atc 0.636088198
## buy 0.010593236
## sell 0.010104476
## vol 0.082418475
## cpi 0.009598759
## roa 0.049609738
## roe 0.107584775
##
## Average coefficients for different model sizes:
##
## 1X 2Xs 3Xs 4Xs 5Xs 6Xs
## gdp -3.63751782 -3.1702034 -2.80588711 -2.51657321 -2.280875330 -2.08417980
## atc 0.32759260 0.3274922 0.32751959 0.32761043 0.327746836 0.32795087
## buy 0.38388075 0.3585846 0.35900942 0.37312183 0.394501042 0.41965435
## sell 0.04946348 -0.1181375 -0.25471282 -0.36349593 -0.449063444 -0.51575167
## vol 0.15322851 0.1086319 0.06935854 0.03471861 0.004060501 -0.02325317
## cpi 1.66059722 4.9149399 7.11110057 8.56496476 9.499325935 10.06357699
## roa 3.14033304 1.9260998 0.96540944 0.22263332 -0.330623742 -0.71644831
## roe 2.83253727 2.6471053 2.48798672 2.34444421 2.205197702 2.05918613
## 7Xs 8Xs
## gdp -1.91823395 -1.78081131
## atc 0.32827544 0.32879480
## buy 0.44663022 0.47379881
## sell -0.56709602 -0.60541662
## vol -0.04787043 -0.07046727
## cpi 10.36000505 10.47316629
## roa -0.95171266 -1.04874531
## roe 1.89607427 1.70638876
##
##
## Confidence interval information ( 1000 bootstrap replicates, bty= perc ):
## Relative Contributions with confidence intervals:
##
## Lower Upper
## percentage 0.9 0.9 0.9
## gdp.lmg 0.0940 _BCDE___ 0.0479 0.1451
## atc.lmg 0.6361 A_______ 0.5594 0.6880
## buy.lmg 0.0106 _____FGH 0.0012 0.0340
## sell.lmg 0.0101 _____FGH 0.0035 0.0261
## vol.lmg 0.0824 _BCD____ 0.0647 0.1057
## cpi.lmg 0.0096 _____FGH 0.0024 0.0349
## roa.lmg 0.0496 ___DE___ 0.0309 0.0745
## roe.lmg 0.1076 _BCD____ 0.0695 0.1504
##
## Letters indicate the ranks covered by bootstrap CIs.
## (Rank bootstrap confidence intervals always obtained by percentile method)
## CAUTION: Bootstrap confidence intervals can be somewhat liberal.
booteval.relimp(boot)
## Response variable: mp
## Total response variance: 0.1228439
## Analysis based on 627 observations
##
## 8 Regressors:
## gdp atc buy sell vol cpi roa roe
## Proportion of variance explained by model: 38.06%
## Metrics are normalized to sum to 100% (rela=TRUE).
##
## Relative importance metrics:
##
## lmg last first pratt
## gdp 0.094002342 0.061904571 1.088303e-01 0.089542131
## atc 0.636088198 0.781921324 5.224814e-01 0.881305537
## buy 0.010593236 0.020361097 6.394422e-03 0.013263670
## sell 0.010104476 0.030560068 9.911148e-05 -0.002038724
## vol 0.082418475 0.042260766 1.180406e-01 -0.091231330
## cpi 0.009598759 0.022645392 2.194589e-04 0.002326117
## roa 0.049609738 0.006345946 8.904902e-02 -0.049979078
## roe 0.107584775 0.034000836 1.548857e-01 0.156811675
##
## Average coefficients for different model sizes:
##
## 1X 2Xs 3Xs 4Xs 5Xs 6Xs
## gdp -3.63751782 -3.1702034 -2.80588711 -2.51657321 -2.280875330 -2.08417980
## atc 0.32759260 0.3274922 0.32751959 0.32761043 0.327746836 0.32795087
## buy 0.38388075 0.3585846 0.35900942 0.37312183 0.394501042 0.41965435
## sell 0.04946348 -0.1181375 -0.25471282 -0.36349593 -0.449063444 -0.51575167
## vol 0.15322851 0.1086319 0.06935854 0.03471861 0.004060501 -0.02325317
## cpi 1.66059722 4.9149399 7.11110057 8.56496476 9.499325935 10.06357699
## roa 3.14033304 1.9260998 0.96540944 0.22263332 -0.330623742 -0.71644831
## roe 2.83253727 2.6471053 2.48798672 2.34444421 2.205197702 2.05918613
## 7Xs 8Xs
## gdp -1.91823395 -1.78081131
## atc 0.32827544 0.32879480
## buy 0.44663022 0.47379881
## sell -0.56709602 -0.60541662
## vol -0.04787043 -0.07046727
## cpi 10.36000505 10.47316629
## roa -0.95171266 -1.04874531
## roe 1.89607427 1.70638876
##
##
## Confidence interval information ( 1000 bootstrap replicates, bty= perc ):
## Relative Contributions with confidence intervals:
##
## Lower Upper
## percentage 0.95 0.95 0.95
## gdp.lmg 0.0940 _BCDE___ 0.0398 0.1572
## atc.lmg 0.6361 A_______ 0.5449 0.7010
## buy.lmg 0.0106 _____FGH 0.0008 0.0404
## sell.lmg 0.0101 _____FGH 0.0029 0.0288
## vol.lmg 0.0824 _BCDE___ 0.0599 0.1107
## cpi.lmg 0.0096 _____FGH 0.0019 0.0432
## roa.lmg 0.0496 ___DEF__ 0.0282 0.0803
## roe.lmg 0.1076 _BCD____ 0.0618 0.1598
##
## gdp.last 0.0619 _BCDEFG_ 0.0131 0.1324
## atc.last 0.7819 A_______ 0.6482 0.8678
## buy.last 0.0204 _BCDEFGH 0.0002 0.0730
## sell.last 0.0306 _BCDEFGH 0.0013 0.0792
## vol.last 0.0423 _BCDEFGH 0.0060 0.1012
## cpi.last 0.0226 _BCDEFGH 0.0006 0.0787
## roa.last 0.0063 ___DEFGH 0.0000 0.0394
## roe.last 0.0340 _BCDEFG_ 0.0018 0.0943
##
## gdp.first 0.1088 _BCDE___ 0.0512 0.1719
## atc.first 0.5225 A_______ 0.4451 0.5968
## buy.first 0.0064 _____FGH 0.0000 0.0276
## sell.first 0.0001 _____FGH 0.0000 0.0123
## vol.first 0.1180 _BCDE___ 0.0755 0.1623
## cpi.first 0.0002 _____FGH 0.0000 0.0154
## roa.first 0.0890 __CDE___ 0.0461 0.1363
## roe.first 0.1549 _BCD____ 0.1007 0.2046
##
## gdp.pratt 0.0895 _BCD____ 0.0312 0.1560
## atc.pratt 0.8813 A_______ 0.7640 0.9748
## buy.pratt 0.0133 ___DEF__ -0.0007 0.0515
## sell.pratt -0.0020 ___DEFG_ -0.0192 0.0205
## vol.pratt -0.0912 ______GH -0.1392 -0.0364
## cpi.pratt 0.0023 ___DEFG_ -0.0060 0.0327
## roa.pratt -0.0500 ___DEFGH -0.1377 0.0389
## roe.pratt 0.1568 _BC_____ 0.0312 0.3029
##
## Letters indicate the ranks covered by bootstrap CIs.
## (Rank bootstrap confidence intervals always obtained by percentile method)
## CAUTION: Bootstrap confidence intervals can be somewhat liberal.
##
##
## Differences between Relative Contributions:
##
## Lower Upper
## difference 0.95 0.95 0.95
## gdp-atc.lmg -0.5421 * -0.6428 -0.4108
## gdp-buy.lmg 0.0834 * 0.0190 0.1463
## gdp-sell.lmg 0.0839 * 0.0243 0.1452
## gdp-vol.lmg 0.0116 -0.0482 0.0835
## gdp-cpi.lmg 0.0844 * 0.0202 0.1490
## gdp-roa.lmg 0.0444 -0.0258 0.1183
## gdp-roe.lmg -0.0136 -0.0952 0.0768
## atc-buy.lmg 0.6255 * 0.5276 0.6926
## atc-sell.lmg 0.6260 * 0.5287 0.6917
## atc-vol.lmg 0.5537 * 0.4615 0.6211
## atc-cpi.lmg 0.6265 * 0.5293 0.6948
## atc-roa.lmg 0.5865 * 0.4780 0.6615
## atc-roe.lmg 0.5285 * 0.4010 0.6213
## buy-sell.lmg 0.0005 -0.0200 0.0266
## buy-vol.lmg -0.0718 * -0.1016 -0.0302
## buy-cpi.lmg 0.0010 -0.0325 0.0313
## buy-roa.lmg -0.0390 * -0.0733 -0.0042
## buy-roe.lmg -0.0970 * -0.1527 -0.0445
## sell-vol.lmg -0.0723 * -0.1014 -0.0419
## sell-cpi.lmg 0.0005 -0.0310 0.0225
## sell-roa.lmg -0.0395 * -0.0710 -0.0108
## sell-roe.lmg -0.0975 * -0.1487 -0.0461
## vol-cpi.lmg 0.0728 * 0.0306 0.1024
## vol-roa.lmg 0.0328 -0.0071 0.0716
## vol-roe.lmg -0.0252 -0.0858 0.0316
## cpi-roa.lmg -0.0400 * -0.0712 -0.0008
## cpi-roe.lmg -0.0980 * -0.1493 -0.0400
## roa-roe.lmg -0.0580 * -0.0910 -0.0241
##
## gdp-atc.last -0.7200 * -0.8442 -0.5379
## gdp-buy.last 0.0415 -0.0318 0.1160
## gdp-sell.last 0.0313 -0.0409 0.1109
## gdp-vol.last 0.0196 -0.0606 0.1043
## gdp-cpi.last 0.0393 -0.0276 0.1102
## gdp-roa.last 0.0556 -0.0041 0.1243
## gdp-roe.last 0.0279 -0.0517 0.1079
## atc-buy.last 0.7616 * 0.5942 0.8588
## atc-sell.last 0.7514 * 0.5997 0.8532
## atc-vol.last 0.7397 * 0.5949 0.8455
## atc-cpi.last 0.7593 * 0.5951 0.8572
## atc-roa.last 0.7756 * 0.6299 0.8640
## atc-roe.last 0.7479 * 0.5837 0.8519
## buy-sell.last -0.0102 -0.0521 0.0329
## buy-vol.last -0.0219 -0.0872 0.0469
## buy-cpi.last -0.0023 -0.0647 0.0512
## buy-roa.last 0.0140 -0.0298 0.0631
## buy-roe.last -0.0136 -0.0827 0.0453
## sell-vol.last -0.0117 -0.0834 0.0545
## sell-cpi.last 0.0079 -0.0549 0.0680
## sell-roa.last 0.0242 -0.0234 0.0727
## sell-roe.last -0.0034 -0.0710 0.0634
## vol-cpi.last 0.0196 -0.0514 0.0854
## vol-roa.last 0.0359 -0.0187 0.0951
## vol-roe.last 0.0083 -0.0688 0.0818
## cpi-roa.last 0.0163 -0.0263 0.0746
## cpi-roe.last -0.0114 -0.0812 0.0576
## roa-roe.last -0.0277 -0.0652 0.0002
##
## gdp-atc.first -0.4137 * -0.5179 -0.3125
## gdp-buy.first 0.1024 * 0.0357 0.1659
## gdp-sell.first 0.1087 * 0.0491 0.1694
## gdp-vol.first -0.0092 -0.0821 0.0683
## gdp-cpi.first 0.1086 * 0.0461 0.1703
## gdp-roa.first 0.0198 -0.0659 0.1087
## gdp-roe.first -0.0461 -0.1348 0.0551
## atc-buy.first 0.5161 * 0.4382 0.5864
## atc-sell.first 0.5224 * 0.4419 0.5951
## atc-vol.first 0.4044 * 0.3177 0.4976
## atc-cpi.first 0.5223 * 0.4437 0.5933
## atc-roa.first 0.4334 * 0.3214 0.5453
## atc-roe.first 0.3676 * 0.2569 0.4794
## buy-sell.first 0.0063 -0.0060 0.0252
## buy-vol.first -0.1116 * -0.1588 -0.0605
## buy-cpi.first 0.0062 -0.0103 0.0253
## buy-roa.first -0.0827 * -0.1305 -0.0350
## buy-roe.first -0.1485 * -0.1984 -0.0895
## sell-vol.first -0.1179 * -0.1603 -0.0736
## sell-cpi.first -0.0001 -0.0138 0.0103
## sell-roa.first -0.0889 * -0.1340 -0.0442
## sell-roe.first -0.1548 * -0.2032 -0.0986
## vol-cpi.first 0.1178 * 0.0723 0.1600
## vol-roa.first 0.0290 -0.0395 0.1008
## vol-roe.first -0.0368 -0.1109 0.0434
## cpi-roa.first -0.0888 * -0.1337 -0.0418
## cpi-roe.first -0.1547 * -0.2028 -0.0978
## roa-roe.first -0.0658 * -0.0999 -0.0302
##
## gdp-atc.pratt -0.7918 * -0.9249 -0.6241
## gdp-buy.pratt 0.0763 * 0.0012 0.1463
## gdp-sell.pratt 0.0916 * 0.0308 0.1579
## gdp-vol.pratt 0.1808 * 0.0939 0.2560
## gdp-cpi.pratt 0.0872 * 0.0173 0.1549
## gdp-roa.pratt 0.1395 * 0.0299 0.2391
## gdp-roe.pratt -0.0673 -0.2390 0.0860
## atc-buy.pratt 0.8680 * 0.7374 0.9635
## atc-sell.pratt 0.8833 * 0.7601 0.9770
## atc-vol.pratt 0.9725 * 0.8241 1.0955
## atc-cpi.pratt 0.8790 * 0.7486 0.9735
## atc-roa.pratt 0.9313 * 0.7877 1.0272
## atc-roe.pratt 0.7245 * 0.4964 0.9017
## buy-sell.pratt 0.0153 -0.0171 0.0662
## buy-vol.pratt 0.1045 * 0.0425 0.1631
## buy-cpi.pratt 0.0109 -0.0250 0.0506
## buy-roa.pratt 0.0632 -0.0265 0.1541
## buy-roe.pratt -0.1435 * -0.2937 -0.0140
## sell-vol.pratt 0.0892 * 0.0332 0.1420
## sell-cpi.pratt -0.0044 -0.0378 0.0201
## sell-roa.pratt 0.0479 -0.0453 0.1427
## sell-roe.pratt -0.1589 * -0.3030 -0.0267
## vol-cpi.pratt -0.0936 * -0.1449 -0.0376
## vol-roa.pratt -0.0413 -0.1469 0.0653
## vol-roe.pratt -0.2480 * -0.3907 -0.1037
## cpi-roa.pratt 0.0523 -0.0340 0.1429
## cpi-roe.pratt -0.1545 * -0.3048 -0.0167
## roa-roe.pratt -0.2068 * -0.4333 -0.0054
##
## * indicates that CI for difference does not include 0.
## CAUTION: Bootstrap confidence intervals can be somewhat liberal.
plot(booteval.relimp(boot, sort=TRUE))
temp=mprice[, c("mp", "gdp","atc", "buy","sell", "vol", "cpi", "roa", "roe")]
explore_all(temp)
calc.relimp(temp, type=c("lmg","last","first","pratt"),rela=TRUE)
## Response variable: mp
## Total response variance: 0.1228439
## Analysis based on 627 observations
##
## 8 Regressors:
## gdp atc buy sell vol cpi roa roe
## Proportion of variance explained by model: 38.06%
## Metrics are normalized to sum to 100% (rela=TRUE).
##
## Relative importance metrics:
##
## lmg last first pratt
## gdp 0.094002342 0.061904571 1.088303e-01 0.089542131
## atc 0.636088198 0.781921324 5.224814e-01 0.881305537
## buy 0.010593236 0.020361097 6.394422e-03 0.013263670
## sell 0.010104476 0.030560068 9.911148e-05 -0.002038724
## vol 0.082418475 0.042260766 1.180406e-01 -0.091231330
## cpi 0.009598759 0.022645392 2.194589e-04 0.002326117
## roa 0.049609738 0.006345946 8.904902e-02 -0.049979078
## roe 0.107584775 0.034000836 1.548857e-01 0.156811675
##
## Average coefficients for different model sizes:
##
## 1X 2Xs 3Xs 4Xs 5Xs 6Xs
## gdp -3.63751782 -3.1702034 -2.80588711 -2.51657321 -2.280875330 -2.08417980
## atc 0.32759260 0.3274922 0.32751959 0.32761043 0.327746836 0.32795087
## buy 0.38388075 0.3585846 0.35900942 0.37312183 0.394501042 0.41965435
## sell 0.04946348 -0.1181375 -0.25471282 -0.36349593 -0.449063444 -0.51575167
## vol 0.15322851 0.1086319 0.06935854 0.03471861 0.004060501 -0.02325317
## cpi 1.66059722 4.9149399 7.11110057 8.56496476 9.499325935 10.06357699
## roa 3.14033304 1.9260998 0.96540944 0.22263332 -0.330623742 -0.71644831
## roe 2.83253727 2.6471053 2.48798672 2.34444421 2.205197702 2.05918613
## 7Xs 8Xs
## gdp -1.91823395 -1.78081131
## atc 0.32827544 0.32879480
## buy 0.44663022 0.47379881
## sell -0.56709602 -0.60541662
## vol -0.04787043 -0.07046727
## cpi 10.36000505 10.47316629
## roa -0.95171266 -1.04874531
## roe 1.89607427 1.70638876
boot <- boot.relimp(temp, b=1000, type=c("lmg", "last", "first", "pratt"), rank = TRUE, diff=TRUE, rela= TRUE)
booteval.relimp(boot)
## Response variable: mp
## Total response variance: 0.1228439
## Analysis based on 627 observations
##
## 8 Regressors:
## gdp atc buy sell vol cpi roa roe
## Proportion of variance explained by model: 38.06%
## Metrics are normalized to sum to 100% (rela=TRUE).
##
## Relative importance metrics:
##
## lmg last first pratt
## gdp 0.094002342 0.061904571 1.088303e-01 0.089542131
## atc 0.636088198 0.781921324 5.224814e-01 0.881305537
## buy 0.010593236 0.020361097 6.394422e-03 0.013263670
## sell 0.010104476 0.030560068 9.911148e-05 -0.002038724
## vol 0.082418475 0.042260766 1.180406e-01 -0.091231330
## cpi 0.009598759 0.022645392 2.194589e-04 0.002326117
## roa 0.049609738 0.006345946 8.904902e-02 -0.049979078
## roe 0.107584775 0.034000836 1.548857e-01 0.156811675
##
## Average coefficients for different model sizes:
##
## 1X 2Xs 3Xs 4Xs 5Xs 6Xs
## gdp -3.63751782 -3.1702034 -2.80588711 -2.51657321 -2.280875330 -2.08417980
## atc 0.32759260 0.3274922 0.32751959 0.32761043 0.327746836 0.32795087
## buy 0.38388075 0.3585846 0.35900942 0.37312183 0.394501042 0.41965435
## sell 0.04946348 -0.1181375 -0.25471282 -0.36349593 -0.449063444 -0.51575167
## vol 0.15322851 0.1086319 0.06935854 0.03471861 0.004060501 -0.02325317
## cpi 1.66059722 4.9149399 7.11110057 8.56496476 9.499325935 10.06357699
## roa 3.14033304 1.9260998 0.96540944 0.22263332 -0.330623742 -0.71644831
## roe 2.83253727 2.6471053 2.48798672 2.34444421 2.205197702 2.05918613
## 7Xs 8Xs
## gdp -1.91823395 -1.78081131
## atc 0.32827544 0.32879480
## buy 0.44663022 0.47379881
## sell -0.56709602 -0.60541662
## vol -0.04787043 -0.07046727
## cpi 10.36000505 10.47316629
## roa -0.95171266 -1.04874531
## roe 1.89607427 1.70638876
##
##
## Confidence interval information ( 1000 bootstrap replicates, bty= perc ):
## Relative Contributions with confidence intervals:
##
## Lower Upper
## percentage 0.95 0.95 0.95
## gdp.lmg 0.0940 _BCDE___ 0.0405 0.1547
## atc.lmg 0.6361 A_______ 0.5460 0.6993
## buy.lmg 0.0106 _____FGH 0.0011 0.0400
## sell.lmg 0.0101 _____FGH 0.0023 0.0290
## vol.lmg 0.0824 _BCDE___ 0.0621 0.1110
## cpi.lmg 0.0096 _____FGH 0.0019 0.0460
## roa.lmg 0.0496 ___DEF__ 0.0297 0.0792
## roe.lmg 0.1076 _BCD____ 0.0653 0.1560
##
## gdp.last 0.0619 _BCDEFG_ 0.0141 0.1331
## atc.last 0.7819 A_______ 0.6468 0.8640
## buy.last 0.0204 _BCDEFGH 0.0003 0.0686
## sell.last 0.0306 _BCDEFGH 0.0015 0.0784
## vol.last 0.0423 _BCDEFGH 0.0064 0.0997
## cpi.last 0.0226 _BCDEFGH 0.0005 0.0813
## roa.last 0.0063 ___DEFGH 0.0000 0.0389
## roe.last 0.0340 _BCDEFGH 0.0017 0.0926
##
## gdp.first 0.1088 _BCDE___ 0.0540 0.1672
## atc.first 0.5225 A_______ 0.4490 0.5940
## buy.first 0.0064 _____FGH 0.0001 0.0289
## sell.first 0.0001 _____FGH 0.0000 0.0119
## vol.first 0.1180 _BCDE___ 0.0766 0.1614
## cpi.first 0.0002 _____FGH 0.0000 0.0188
## roa.first 0.0890 __CDE___ 0.0481 0.1357
## roe.first 0.1549 _BCD____ 0.1046 0.2010
##
## gdp.pratt 0.0895 _BC_____ 0.0305 0.1580
## atc.pratt 0.8813 A_______ 0.7653 0.9803
## buy.pratt 0.0133 ___DEF__ -0.0010 0.0498
## sell.pratt -0.0020 ___DEFG_ -0.0187 0.0208
## vol.pratt -0.0912 ______GH -0.1411 -0.0372
## cpi.pratt 0.0023 ___DEFG_ -0.0055 0.0386
## roa.pratt -0.0500 ___DEFGH -0.1286 0.0364
## roe.pratt 0.1568 _BCD____ 0.0320 0.2903
##
## Letters indicate the ranks covered by bootstrap CIs.
## (Rank bootstrap confidence intervals always obtained by percentile method)
## CAUTION: Bootstrap confidence intervals can be somewhat liberal.
##
##
## Differences between Relative Contributions:
##
## Lower Upper
## difference 0.95 0.95 0.95
## gdp-atc.lmg -0.5421 * -0.6372 -0.4142
## gdp-buy.lmg 0.0834 * 0.0211 0.1441
## gdp-sell.lmg 0.0839 * 0.0266 0.1458
## gdp-vol.lmg 0.0116 -0.0516 0.0778
## gdp-cpi.lmg 0.0844 * 0.0193 0.1472
## gdp-roa.lmg 0.0444 -0.0209 0.1112
## gdp-roe.lmg -0.0136 -0.0900 0.0706
## atc-buy.lmg 0.6255 * 0.5272 0.6882
## atc-sell.lmg 0.6260 * 0.5305 0.6877
## atc-vol.lmg 0.5537 * 0.4599 0.6219
## atc-cpi.lmg 0.6265 * 0.5212 0.6918
## atc-roa.lmg 0.5865 * 0.4769 0.6626
## atc-roe.lmg 0.5285 * 0.4000 0.6187
## buy-sell.lmg 0.0005 -0.0195 0.0280
## buy-vol.lmg -0.0718 * -0.1036 -0.0364
## buy-cpi.lmg 0.0010 -0.0338 0.0322
## buy-roa.lmg -0.0390 * -0.0685 -0.0042
## buy-roe.lmg -0.0970 * -0.1481 -0.0434
## sell-vol.lmg -0.0723 * -0.1017 -0.0439
## sell-cpi.lmg 0.0005 -0.0337 0.0215
## sell-roa.lmg -0.0395 * -0.0691 -0.0124
## sell-roe.lmg -0.0975 * -0.1470 -0.0506
## vol-cpi.lmg 0.0728 * 0.0324 0.1039
## vol-roa.lmg 0.0328 -0.0042 0.0683
## vol-roe.lmg -0.0252 -0.0827 0.0284
## cpi-roa.lmg -0.0400 * -0.0689 -0.0010
## cpi-roe.lmg -0.0980 * -0.1453 -0.0445
## roa-roe.lmg -0.0580 * -0.0893 -0.0243
##
## gdp-atc.last -0.7200 * -0.8390 -0.5425
## gdp-buy.last 0.0415 -0.0327 0.1155
## gdp-sell.last 0.0313 -0.0374 0.1118
## gdp-vol.last 0.0196 -0.0553 0.0980
## gdp-cpi.last 0.0393 -0.0311 0.1078
## gdp-roa.last 0.0556 -0.0025 0.1284
## gdp-roe.last 0.0279 -0.0474 0.1139
## atc-buy.last 0.7616 * 0.6039 0.8556
## atc-sell.last 0.7514 * 0.6012 0.8531
## atc-vol.last 0.7397 * 0.5895 0.8381
## atc-cpi.last 0.7593 * 0.5942 0.8556
## atc-roa.last 0.7756 * 0.6250 0.8597
## atc-roe.last 0.7479 * 0.5786 0.8509
## buy-sell.last -0.0102 -0.0513 0.0333
## buy-vol.last -0.0219 -0.0852 0.0447
## buy-cpi.last -0.0023 -0.0691 0.0593
## buy-roa.last 0.0140 -0.0278 0.0652
## buy-roe.last -0.0136 -0.0784 0.0506
## sell-vol.last -0.0117 -0.0850 0.0546
## sell-cpi.last 0.0079 -0.0580 0.0659
## sell-roa.last 0.0242 -0.0237 0.0717
## sell-roe.last -0.0034 -0.0748 0.0581
## vol-cpi.last 0.0196 -0.0555 0.0834
## vol-roa.last 0.0359 -0.0154 0.0928
## vol-roe.last 0.0083 -0.0695 0.0782
## cpi-roa.last 0.0163 -0.0233 0.0764
## cpi-roe.last -0.0114 -0.0693 0.0556
## roa-roe.last -0.0277 -0.0654 0.0010
##
## gdp-atc.first -0.4137 * -0.5093 -0.3101
## gdp-buy.first 0.1024 * 0.0409 0.1623
## gdp-sell.first 0.1087 * 0.0517 0.1671
## gdp-vol.first -0.0092 -0.0866 0.0660
## gdp-cpi.first 0.1086 * 0.0468 0.1659
## gdp-roa.first 0.0198 -0.0625 0.1059
## gdp-roe.first -0.0461 -0.1321 0.0477
## atc-buy.first 0.5161 * 0.4370 0.5871
## atc-sell.first 0.5224 * 0.4468 0.5940
## atc-vol.first 0.4044 * 0.3153 0.4929
## atc-cpi.first 0.5223 * 0.4473 0.5889
## atc-roa.first 0.4334 * 0.3271 0.5300
## atc-roe.first 0.3676 * 0.2598 0.4741
## buy-sell.first 0.0063 -0.0042 0.0260
## buy-vol.first -0.1116 * -0.1545 -0.0640
## buy-cpi.first 0.0062 -0.0121 0.0263
## buy-roa.first -0.0827 * -0.1280 -0.0347
## buy-roe.first -0.1485 * -0.1940 -0.0918
## sell-vol.first -0.1179 * -0.1596 -0.0732
## sell-cpi.first -0.0001 -0.0150 0.0090
## sell-roa.first -0.0889 * -0.1353 -0.0444
## sell-roe.first -0.1548 * -0.1991 -0.1026
## vol-cpi.first 0.1178 * 0.0680 0.1587
## vol-roa.first 0.0290 -0.0484 0.0987
## vol-roe.first -0.0368 -0.1153 0.0382
## cpi-roa.first -0.0888 * -0.1330 -0.0432
## cpi-roe.first -0.1547 * -0.1989 -0.0995
## roa-roe.first -0.0658 * -0.0979 -0.0301
##
## gdp-atc.pratt -0.7918 * -0.9282 -0.6355
## gdp-buy.pratt 0.0763 * 0.0066 0.1471
## gdp-sell.pratt 0.0916 * 0.0300 0.1583
## gdp-vol.pratt 0.1808 * 0.0978 0.2663
## gdp-cpi.pratt 0.0872 * 0.0200 0.1554
## gdp-roa.pratt 0.1395 * 0.0371 0.2291
## gdp-roe.pratt -0.0673 -0.2183 0.0741
## atc-buy.pratt 0.8680 * 0.7358 0.9731
## atc-sell.pratt 0.8833 * 0.7644 0.9830
## atc-vol.pratt 0.9725 * 0.8143 1.1052
## atc-cpi.pratt 0.8790 * 0.7478 0.9775
## atc-roa.pratt 0.9313 * 0.7895 1.0351
## atc-roe.pratt 0.7245 * 0.4998 0.9143
## buy-sell.pratt 0.0153 -0.0145 0.0624
## buy-vol.pratt 0.1045 * 0.0482 0.1619
## buy-cpi.pratt 0.0109 -0.0262 0.0496
## buy-roa.pratt 0.0632 -0.0232 0.1479
## buy-roe.pratt -0.1435 * -0.2752 -0.0102
## sell-vol.pratt 0.0892 * 0.0347 0.1410
## sell-cpi.pratt -0.0044 -0.0397 0.0184
## sell-roa.pratt 0.0479 -0.0393 0.1291
## sell-roe.pratt -0.1589 * -0.2974 -0.0272
## vol-cpi.pratt -0.0936 * -0.1491 -0.0423
## vol-roa.pratt -0.0413 -0.1496 0.0560
## vol-roe.pratt -0.2480 * -0.3780 -0.1168
## cpi-roa.pratt 0.0523 -0.0323 0.1339
## cpi-roe.pratt -0.1545 * -0.2829 -0.0255
## roa-roe.pratt -0.2068 -0.4167 0.0052
##
## * indicates that CI for difference does not include 0.
## CAUTION: Bootstrap confidence intervals can be somewhat liberal.
plot(booteval.relimp(boot, sort=TRUE))