




Example - yearly wage of 474 bank employees
Data provided by Professor Chris Skeels in Econometrics 3 ECOM90013
\(H_{0}: \beta_{educ} = 0\)
\(H_{1}: \beta_{educ} \neq 0\)
## LM Testlm0 <- lm(LOGSAL ~ GENDER + MINORITY + JOBCAT, data = wages)e0 <- residuals(lm0)lm1 <- lm(e0 ~ EDUC + GENDER + MINORITY + JOBCAT, data = wages)e1 <- summary(lm1)e1rsq <- e1$r.squaredtest1 <- nrow(wages) * e1rsq
```{r, echo = FALSE, result = 'asis'}cat( "Under the null hypothesis with degree of freedom equal to 1,", " the test statistic is ",round(test1,4), " and critical value is ", round(qchisq(0.95,1),4))```
Under the null hypothesis with degree of freedom equal to 1 , the test statistic is 125.7683 and the critical value is 3.8415.
\(H_{0}: \beta_{educ} = 0\)
\(H_{1}: \beta_{educ} \neq 0\)
reject_h0 <- test1 > round(qchisq(0.95, 1), 4)
Since the test statistic for LM1 is `r if(reject_h0) "greater" else "smaller" ` greater than the critical, therefore we `r if(reject_h0) "" else " cannot" ` reject the null hypothesis and conclude that \(\beta_{educ}\) is `r if(reject_h0) "" else " not"` significant at 5% level.
Since the test statistic for LM1 is greater than the critical, therefore we reject the null hypothesis and conclude that \(\beta_{educ}\) is significant at 5% level.
\(H_{0} : \beta_{minority} =\)
\(\beta_{jobcat}=0\)
\(H_{1} : \beta_{minority} \neq 0\)
or \(\beta_{jobcat} \neq 0\)
lmrest <- lm(formula = LOGSAL ~ EDUC + GENDER, data = wages)e2 <- summary(lmrest)$residualslme2 <- lm(e2 ~ EDUC + GENDER + MINORITY + JOBCAT, data = wages)e2.sqr <- summary(lme2)$r.squaredtest2 <- nrow(wages) * e2.sqrprint("Under the null hypothesis with degree of freedom equal to 2")
## [1] "Under the null hypothesis with degree of freedom equal to 2"print(paste0("the test statistic is ", round(test2, 4)))
## [1] "the test statistic is 208.745"print(paste0("The critical value is ", round(qchisq(0.95, 2), 4)))
## [1] "The critical value is 5.9915"\(H_{0} : \beta_{minority} =\)
\(\beta_{jobcat}=0\)
\(H_{1} : \beta_{minority} \neq 0\)
or \(\beta_{jobcat} \neq 0\)
reject_h0.2 <- test2 > round(qchisq(0.95, 2), 4)
Since the test statistic for LM1 is `r if(reject_h0.2) "greater" else "smaller"` greater than the critical, therefore we `r if(reject_h0.2) "" else " cannot" ` reject the null hypothesis and conclude that `r if(reject_h0.2) "at least one of" else "none of" ` at least one of \(\beta_{minority}\) and \(\beta_{jobcat}\) is significant at 5% level.
Since the test statistic for LM1 is greater than the critical, therefore we reject the null hypothesis and conclude that at least one of \(\beta_{minority}\) and \(\beta_{jobcat}\) is significant at 5% level.

Bayes' Rule: \(p(\theta|Y) \propto L(\theta|Y)p(\theta)\)
The posterior distribution is proportion to the kernel of posterior distribution times the distribution of the prior distribution.
Bayes' Rule: \(p(\theta|Y) \propto L(\theta|Y)p(\theta)\)
The posterior distribution is proportion to the kernel of posterior distribution times the distribution of the prior distribution.
We have a time series for Australian real GDP from the Australian Real-Time Macroeconomic Database containing T=230 observations on the quarterly data from quarter 3 of 1959 to the last quarter of 2016.
Data provided by Tomasz Wozniak in Macroeconometrics ECOM90007
Question: "Set the parameters of the natural-conjugate prior distribution and motivate the values that you choose."
Random Walk with drift process: \(logGDP_{t}=\mu_{0}+\alpha logGDP_{t-1}+u_{t}\)
\(\alpha\)=1
\(u_{t} \sim \mathcal{N}(0,\sigma^{2})\)
\(P(\sigma^{2})\sim \mathcal{IG_{2}}(s,\nu)\)
Priors: \(\mu_{0}\), \(\alpha\), \(\sigma^2\), s, \(\nu\)
Question: "Set the parameters of the natural-conjugate prior distribution and motivate the values that you choose."
Random Walk with drift process: \(logGDP_{t}=\mu_{0}+\alpha logGDP_{t-1}+u_{t}\)
\(\alpha\)=1
\(u_{t} \sim \mathcal{N}(0,\sigma^{2})\)
\(P(\sigma^{2})\sim \mathcal{IG_{2}}(s,\nu)\)
Priors: \(\mu_{0}\), \(\alpha\), \(\sigma^2\), s, \(\nu\)

The sample mean of \(\mu_{0}\) with 5000 draws is 0.0148564 and the variance is 0.011913.
The sample mean of \(\alpha\) with 5000 draws is 0.999454 and the variance is 0.000082.
The sample mean of \(\sigma^2\) with 5000 draws is 0.017256 and the variance is 0.0000026.

The sample mean of \(\mu_{0}\) with 5000 draws is 0.0024582 and the variance is 0.001686.
The sample mean of \(\alpha\) with 5000 draws is 1.00048 and the variance is 0.000012.
The sample mean of \(\sigma^2\) with 5000 draws is 0.017258 and the variance is 0.0000026.

The sample mean of \(\mu_{0}\) with 5000 draws is 0.0114882 and the variance is 0.011913.
The sample mean of \(\alpha\) with 5000 draws is 0.999733 and the variance is 0.000082.
The sample mean of \(\sigma^2\) with 5000 draws is 0.017257 and the variance is 0.0000026.

The sample mean of \(\mu_{0}\) with 5000 draws is `r round(mean(blogau$V1),8)` and the variance is `r round(var(blogau$V1),6)` .
The sample mean of \(\alpha\) with 5000 draws is `r round(mean(blogau$V2),6)` and the variance is `r round(var(blogau$V2),8)` .
The sample mean of \(\sigma^2\) with 5000 draws is`r round(mean(blogau$sigmasq),6)` and the variance is `r round(var(blogau$sigmasq),8)` .
shh, witchcraft here. Why do I need this chunk to advance to next slide?@yihui, please send help!pdf(file="mu0plot.pdf", height=12, width=9)ggplot(data=blogau, aes(x=V1)) + geom_histogram(binwidth=0.01, colour="black", fill="white")+ ggtitle("Distribution of mu0")+ xlab("mu0") dev.off()pdf(file="mu0plot.pdf", height=12, width=9)ggplot(data=blogau, aes(x=V1)) + geom_histogram(binwidth=0.01, colour="black", fill="white")+ ggtitle("Distribution of mu0")+ xlab("mu0") dev.off()
```{r,echo=FALSE,fig.height=12,fig.width=9,dev="pdf"}ggplot(data=blogau, aes(x=V1)) + geom_histogram(binwidth=0.01, colour="black", fill="white")+ ggtitle("Distribution of mu0")+ xlab("mu0") ```Alison Hill, June 2019, R-Ladies xaringan theme:
Professor Chris Skeels, S1 2020,Econometrics ECOM90013, University of Melbourne
Guidotti, E., Ardia, D., (2020), "COVID-19 Data Hub", Journal of Open Source Software 5(51):2376, doi:10.21105/joss.02376.
Tomasz Wozniak, S1 2020, Macroeconometrics ECOM90007, University of Melbourne
R Markdown: The Definitive Guide
Workshops: Communicating with Data via R Markdown by Emi Tanaka
One R Markdown Document, Fourteen Demos by Yihui Xie
How Rmarkdown changed my life by Professor Rob J Hyndman


danyangd@student.unimelb.edu.au
https://www.linkedin.com/in/danyang-dai-7529b4152/

Keyboard shortcuts
| ↑, ←, Pg Up, k | Go to previous slide |
| ↓, →, Pg Dn, Space, j | Go to next slide |
| Home | Go to first slide |
| End | Go to last slide |
| Number + Return | Go to specific slide |
| b / m / f | Toggle blackout / mirrored / fullscreen mode |
| c | Clone slideshow |
| p | Toggle presenter mode |
| t | Restart the presentation timer |
| ?, h | Toggle this help |
| Esc | Back to slideshow |