# Trace trick

The trace trick:
If $$A^T \Sigma^{-1} A$$ is a 1×1 matrix,
$$A^T \Sigma^{-1} A = \text{trace}( A^T \Sigma^{-1} A ) = \text{trace}(\Sigma^{-1} A A^T )$$

http://andreweckford.blogspot.com/2009/09/trace-tricks.html
http://nonconditional.com/2012/06/the-trace-trick-for-gaussian-log-likelihood/
http://www.cs.cmu.edu/~epxing/Class/10701-08s/recitation/gaussian.pdf

# R Markdown tip: use Insert Chunk shortcut in RStudio

I have been using R Markdown more often in RStudio to prepare reproducible documents for our statistical consulting class. For R Markdown, we have to declare the start of a coding region by typing {r labelandoptions} and the end by . This becomes tedious when there are many coding regions. Fortunately, in RStudio, there is a Insert Chunk feature (Ctrl-Alt-I on PC and Cmd-Option-I on Mac) that automatically types this. It saves so much typing!

On a side note, it’d be great if a R Markdown document could be collapsed to only R code or only markdown, perhaps hiding the other with ellipses. This would help to analyze the R code or to see the flow of the document. If any RStudio developers read this, please consider it!

# Save Rock and Roll by Fall Out Boy and smoking

I’ve been listening to Fall Out Boy’s album. The music is great. It’s a mix of pop, indie rock, and punk.

the album cover of Fall Out Boy’s Save Rock and Roll

“The cover of Save Rock and Roll features a photograph of two young boys — one wearing traditional monk robes, the other in jeans and a T-shirt, smoking a cigarette — taken by Roger Stonehouse in Burma.” from the Wikipedia article.

I like that the album cover is from Myanmar (Burma) where I was born but I am a saddened that the boy is smoking a cigarette. People of Myanmar, please don’t start smoking cigarettes! They are terrible for our health, especially our lungs with diseases such as emphysema, COPD, and lung cancer. The health care system is already the lowest in the world. We must work to raise our health!

This article says that the cigarette companies are targeting Myanmar youths with advertising. These companies should uphold their ethical obligation to educate the people of the health dangers of smoking and cease advertising to youths. The people must demand the government to regulate the advertising. We also need more people like U Tin Maung, an 89-year old who have been campaigning for six decades to educate the people about the health effects of smoking.

# R tip: read data into R from code file

Most often, we enter data from an external data file. Sometime when we have a very small dataset like from a tutorial or the r-help mailing list, it is more concise to include it as part of the R code. We can use read.table() but use text=”” instead of file=””.

I ran into this from Rui Barradas on the r-help mailing list at https://stat.ethz.ch/pipermail/r-help//2013-May/353030.html.

dat <- read.table(text = "
X     Y
0    137.659166666667
2.502    152.623333333333
4.998    162.391333333333
7.501    170.753666666667
9.997    174.877
12.499    178.4275
15.002    184.565
17.498    189.8985
20    192.6885
", header = TRUE)
dat


Output:

       X        Y
1  0.000 137.6592
2  2.502 152.6233
3  4.998 162.3913
4  7.501 170.7537
5  9.997 174.8770
6 12.499 178.4275
7 15.002 184.5650
8 17.498 189.8985
9 20.000 192.6885


# Hello world! My first blog post

I never got into blogging until… now! I remember having to write a daily journal/diary entry for  fourth grade class but I stopped that activity once I moved onto middle school. Part of me wish I continued writing a journal. With this blog, I can start that writing activity again. It will be great for the future me to look back and wonder how the past me was thinking. I am not too certain what to write about so I plan to jot down my random thoughts and notes. If you stumbled to this blog, thanks for reading my blog and I hope you enjoy it!

P.S.: To future me, thanks for reading this!