Australian Consumption Function from time series real prices September 1959 to September 2021

The Lone Ranger

9/14/2021

knitr::opts_chunk$set(echo = FALSE)

Consumption_model_reworked

========================================================

library(tidymodels)
## Registered S3 method overwritten by 'tune':
##   method                   from   
##   required_pkgs.model_spec parsnip
## -- Attaching packages -------------------------------------- tidymodels 0.1.3 --
## v broom        0.7.8      v recipes      0.1.16
## v dials        0.0.9      v rsample      0.0.9 
## v dplyr        1.0.7      v tibble       3.1.2 
## v ggplot2      3.3.3      v tidyr        1.1.3 
## v infer        0.5.4      v tune         0.1.5 
## v modeldata    0.1.0      v workflows    0.2.2 
## v parsnip      0.1.6      v workflowsets 0.0.2 
## v purrr        0.3.4      v yardstick    0.0.8
## -- Conflicts ----------------------------------------- tidymodels_conflicts() --
## x purrr::discard() masks scales::discard()
## x dplyr::filter()  masks stats::filter()
## x dplyr::lag()     masks stats::lag()
## x recipes::step()  masks stats::step()
## * Use tidymodels_prefer() to resolve common conflicts.
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.0 --
## v readr   1.4.0     v forcats 0.5.1
## v stringr 1.4.0
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x readr::col_factor() masks scales::col_factor()
## x purrr::discard()    masks scales::discard()
## x dplyr::filter()     masks stats::filter()
## x stringr::fixed()    masks recipes::fixed()
## x dplyr::lag()        masks stats::lag()
## x readr::spec()       masks yardstick::spec()
library(readr)
consumptionfctn_household_ABS_DATA<-read_csv("~/1.Excel/_research_resources_folder/consumptionfctn_household_ABS_DATA.csv",col_types = cols(`Series ID` = col_character()))
cons_data  <- as_tibble(consumptionfctn_household_ABS_DATA)
colnames(cons_data) <- c("d","y","c")
glimpse(cons_data)
## Rows: 248
## Columns: 3
## $ d <chr> "Sep-1959", "Dec-1959", "Mar-1960", "Jun-1960", "Sep-1960", "Dec-196~
## $ y <dbl> 3239, 3592, 2932, 2927, 3381, 3846, 3199, 2959, 3453, 3900, 3182, 31~
## $ c <dbl> 2267, 2512, 2325, 2470, 2503, 2713, 2443, 2523, 2528, 2739, 2543, 26~
#Initialize a linear regression object, linear_model
linear_model <- linear_reg() %>%
  # Set the model engine
  set_engine('lm') %>%
  # Set the model mode
  set_mode('regression')

lm_fit <- linear_model %>%
  fit(c ~ y, data = cons_data)
tidy(lm_fit)
## # A tibble: 2 x 5
##   term        estimate std.error statistic   p.value
##   <chr>          <dbl>     <dbl>     <dbl>     <dbl>
## 1 (Intercept)  824.    584.           1.41 1.60e-  1
## 2 y              0.841   0.00408    206.   1.09e-277
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'

mod<-lm(c ~ y, data = cons_data)

stargazer table

## 
## 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
Dependent variable:
c
y 0.841***
(0.004)
Constant 824.188
(584.387)
Observations 248
R2 0.994
Adjusted R2 0.994
Residual Std. Error 6,559.568 (df = 246)
F Statistic 42,622.670*** (df = 1; 246)
Note: p<0.1; p<0.05; p<0.01