library(AER)
## Loading required package: car
## Loading required package: carData
## Loading required package: lmtest
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Loading required package: sandwich
## Loading required package: survival
library(dynlm)
## Warning: package 'dynlm' was built under R version 3.5.3
library(forecast)
library(readxl)
library(stargazer)
## 
## Please cite as:
##  Hlavac, Marek (2018). stargazer: Well-Formatted Regression and Summary Statistics Tables.
##  R package version 5.2.2. https://CRAN.R-project.org/package=stargazer
library(scales)
library(xts)
## Warning: package 'xts' was built under R version 3.5.3
library(quantmod)
## Loading required package: TTR
## Version 0.4-0 included new data defaults. See ?getSymbols.
library(urca)

R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

# load US macroeconomic data
library(tidyverse)
## -- Attaching packages --------------------------------- tidyverse 1.2.1 --
## v ggplot2 3.1.0     v purrr   0.2.5
## v tibble  2.1.3     v dplyr   0.8.3
## v tidyr   0.8.2     v stringr 1.3.1
## v readr   1.3.1     v forcats 0.3.0
## Warning: package 'tibble' was built under R version 3.5.3
## Warning: package 'dplyr' was built under R version 3.5.3
## -- Conflicts ------------------------------------ tidyverse_conflicts() --
## x readr::col_factor() masks scales::col_factor()
## x purrr::discard()    masks scales::discard()
## x dplyr::filter()     masks stats::filter()
## x dplyr::first()      masks xts::first()
## x dplyr::lag()        masks stats::lag()
## x dplyr::last()       masks xts::last()
## x dplyr::recode()     masks car::recode()
## x purrr::some()       masks car::some()
library(quantmod)
setwd("C:/Users/hp/OneDrive - Higher Education Commission/Econometric Analysis")
USMacroSWQ<-read_xlsx("UsMacro_Quarterly.xlsx")
USMacroSWQ$Date<- with(USMacroSWQ, sprintf("%d-%02d", Year, Quarter))

Including Plots

You can also embed plots, for example:

GDP<-ts(USMacroSWQ$RealGDP,frequency = 4,start = c(1947,1))
plot(GDP)

USMacroSWQ
## # A tibble: 252 x 5
##     Year Quarter RealGDP TBillRate Date   
##    <dbl>   <dbl>   <dbl>     <dbl> <chr>  
##  1  1947       1   1772.     0.38  1947-01
##  2  1947       2   1769.     0.38  1947-02
##  3  1947       3   1768.     0.737 1947-03
##  4  1947       4   1795.     0.907 1947-04
##  5  1948       1   1823.     0.99  1948-01
##  6  1948       2   1857.     1     1948-02
##  7  1948       3   1867.     1.05  1948-03
##  8  1948       4   1870.     1.14  1948-04
##  9  1949       1   1844.     1.17  1949-01
## 10  1949       2   1837.     1.17  1949-02
## # ... with 242 more rows
theme_set(theme_minimal())
p1<-ggplot(USMacroSWQ)+aes(x=Year,y=RealGDP)+geom_line(color ="#00AFBB", size = 1)

library(ggthemes)
## Warning: package 'ggthemes' was built under R version 3.5.3
p1+theme_economist()

p1+theme_wsj()

##install.packages("ggthemes")
ggplot(USMacroSWQ)+aes(x=Year,y=TBillRate)+geom_line(color ="#00AFBB", size = 1)

library(readr)

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.