Publications by Richard Zheng
Time Series Forecasting
5.1 Australian Population aus_pop = global_economy%>% filter(Country == 'Australia' & Year >= 2000)%>% select(Population) aus_pop%>% model(RW(Population ~ drift()))%>% forecast()%>% autoplot(aus_pop)+ labs(title = 'Australian Population Forecast') Bricks aus_brick = aus_production%>% na.omit()%>% select(Bricks) aus_b...
1575 sym R (7673 sym/53 pcs) 25 img
time series data analysis
2.1 a) autoplots autoplot(gafa_stock, Open) PBS %>% filter(ATC2 == "A10")%>% autoplot(Cost) autoplot(vic_elec, Temperature) pelt%>% pivot_longer(c(Hare, Lynx))%>% autoplot(value) b) # historical stock prices (USD) and volume between 2014-2018 for goog, amzn, fb and aapl # time interval is (trading) days help(gafa_stock) ## star...
999 sym R (6816 sym/31 pcs) 8 img
Time Series Decomposition
3.1 gdp_capita = global_economy%>% select(Country, Year, GDP, Population)%>% na.omit()%>% mutate(gdp_per_capita = GDP/Population) plot_gdp_capita = function(country){ gdp_capita%>% filter(Country == country)%>% ggplot(aes(x = Year, y = gdp_per_capita))+ geom_line()+ labs(title = paste('GDP per Capita of',country)...
1628 sym R (6531 sym/28 pcs) 20 img
Data624 hw4
3.1 data(Glass) head(Glass) ## RI Na Mg Al Si K Ca Ba Fe Type ## 1 1.52101 13.64 4.49 1.10 71.78 0.06 8.75 0 0.00 1 ## 2 1.51761 13.89 3.60 1.36 72.73 0.48 7.83 0 0.00 1 ## 3 1.51618 13.53 3.55 1.54 72.99 0.39 7.78 0 0.00 1 ## 4 1.51766 13.21 3.69 1.29 72.61 0.57 8.22 0 0.00 1 ## 5 1.51742 13.27 3.62 ...
1747 sym R (12905 sym/15 pcs) 4 img
Exponential Smoothing
8.1 a victorian_pigs = aus_livestock%>% filter(State=="Victoria" & Animal=="Pigs") ETS_pigs = victorian_pigs%>% model(ETS(Count~error("A") + trend("A") + season("A"))) ETS_forecast = ETS_pigs%>% forecast(h=4) ETS_forecast%>% autoplot(victorian_pigs)+ geom_line(aes(y= .fitted), col = 'red', data = augment(ETS_pigs))+ labs(...
1680 sym R (5257 sym/39 pcs) 14 img
ARIMA
9.1 a All three plots show that the variations are white noise as they are well within the confidence interval (blue dotted lines). I notice as the samples grow larger (36->360->1000), the variation from 0 grow smaller and the confidence interval also becomes more precise b The critical values are at different distances from the mean due to sam...
3147 sym R (6853 sym/54 pcs) 32 img
market basket
load dataset and transform into arules transaction format grocery = read.transactions('GroceryDataSet.csv', sep = ",") inspect(head(grocery)) ## items ## [1] {citrus fruit, ## margarine, ## ready soups, ## semi-finished bread} ## [2] {coffee, ...
175 sym R (5344 sym/9 pcs) 1 img
Tree Based Models
8.1. Recreate the simulated data from Exercise 7.2: set.seed(200) simulated <- mlbench.friedman1(200, sd = 1) simulated <- cbind(simulated$x, simulated$y) simulated <- as.data.frame(simulated) colnames(simulated)[ncol(simulated)] <- "y" (a) Fit a random forest model to all of the predictors, then estimate the variable importance scores: model...
4825 sym R (8558 sym/30 pcs) 3 img
PH Predictions
Load Packages library(tidytext) ## Warning: package 'tidytext' was built under R version 4.1.3 library(tidyverse) ## Warning: package 'tidyverse' was built under R version 4.1.3 ## -- Attaching packages --------------------------------------- tidyverse 1.3.1 -- ## v ggplot2 3.3.5 v purrr 0.3.4 ## v tibble 3.1.6 v dplyr 1.0.8 ## v t...
4855 sym R (32953 sym/184 pcs) 9 img
Non-Linear Models
library(AppliedPredictiveModeling) ## Warning: package 'AppliedPredictiveModeling' was built under R version 4.1.3 library(tidyverse) ## Warning: package 'tidyverse' was built under R version 4.1.3 ## -- Attaching packages --------------------------------------- tidyverse 1.3.1 -- ## v ggplot2 3.3.5 v purrr 0.3.4 ## v tibble 3.1.6 v d...
2297 sym R (7308 sym/42 pcs) 2 img