Tony Tsai
/
Recent content on Tony TsaiHugo -- gohugo.ioen-usMon, 07 May 2018 00:00:00 +0000Setting PATH Variable for gs Command in RStudio
/blog/2018-05-07-setting-path-variable-for-gs-command-in-rstudio/
Mon, 07 May 2018 00:00:00 +0000/blog/2018-05-07-setting-path-variable-for-gs-command-in-rstudio/Update on 2018-07-05
From the discussion with Yihui Xie, if Ghostscript was installed via brew, Homebrew should automatically make symlinks to /usr/local/bin/gs which is already under the PATH. Hence there is no need to set PATH variable for gs. However, the following approach is useful for other commands that are not under the PATH.
These days I am using ImageMagick to convert multiple pdfs (or pngs) into an animation gif to demonstrate the algorithm that I proposed for estimating epidemic onset.《流感下的北京中年》与细菌耐药性
/blog/2018-02-13-%E6%B5%81%E6%84%9F%E4%B8%8B%E7%9A%84%E5%8C%97%E4%BA%AC%E4%B8%AD%E5%B9%B4%E4%B8%8E%E7%BB%86%E8%8F%8C%E8%80%90%E8%8D%AF%E6%80%A7/
Tue, 13 Feb 2018 00:00:00 +0000/blog/2018-02-13-%E6%B5%81%E6%84%9F%E4%B8%8B%E7%9A%84%E5%8C%97%E4%BA%AC%E4%B8%AD%E5%B9%B4%E4%B8%8E%E7%BB%86%E8%8F%8C%E8%80%90%E8%8D%AF%E6%80%A7/今天春节前2月12日朋友圈被《流感下的北京中年》刷屏，自己读完，一直在思考为什么一开始的感冒症状最终却走向了阴阳两隔？同时因自己的研究课题与Tips for Sharing Data When Collaborating with Other Researchers
/blog/2017-12-21-tips-for-sharing-data-when-collaborating-with-other-researchers/
Thu, 21 Dec 2017 00:00:00 +0000/blog/2017-12-21-tips-for-sharing-data-when-collaborating-with-other-researchers/Recently I have been collaborating with others on several research projects. In the process of collaboration, data exchanging is inevitable; however, for collaborators lack of rich experience in data analysis and computer skills, the way that they are sharing the data results in inefficient collaboration. Therefore, I summarize following tips for sharing data when collorating with other researchers.
First of all, please include a README file describing the data, including file contents, variable names, value formats, units etc.Detecting Non-breaking Space in R
/blog/2017-12-04-detecting-non-breaking-space-in-r/
Mon, 04 Dec 2017 00:00:00 +0000/blog/2017-12-04-detecting-non-breaking-space-in-r/Last night while I was cleaning data in R, I encountered such a weird behavior of unique() function that I once suspected that there had been something wrong with the newly updated R 3.4.3. The following is a reproducible example of my problem.
I read in a vector variable x from csv file, and printed it on R console.
x ## [1] "non-breaking space" "non-breaking space" Apparently, x contained two “identtical” elements and it should have only one unique value.pip for Different Versions of Python on macOS Sierra
/blog/2017-09-07-pip-for-different-versions-of-python-on-macos-sierra/
Thu, 07 Sep 2017 00:00:00 +0000/blog/2017-09-07-pip-for-different-versions-of-python-on-macos-sierra/Three versions of Python exist on my macOS Sierra. The first one is the original Python come with macOS. The other two are Python 2 and Python 3 installed by brew.
To load the raw Python 2 interpreter inside the terminal, type
$ python Python 2.7.10 (default, Feb 7 2017, 00:08:15) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> To load the brew-installed Python 2 interpreter inside the terminal, typeNarrative Outline of My Talk at the 10th China R Conference
/blog/2017-05-23-narrative-outline-of-my-talk-at-the-10th-china-r-conference/
Tue, 23 May 2017 00:00:00 +0000/blog/2017-05-23-narrative-outline-of-my-talk-at-the-10th-china-r-conference/The 10th China R Conference was held in Tsinghua University during May 19 - 21. I initialized the session of R in Public Health. Though it was my first time to organize a session, to invite speakers, and to host it, the session was successful. The number of audiences was more than 55 persons and beyond my expectation, and the discussions were enthusiastic. I believe that via my talk more Chinese have known the R Epidemics Consortium (RECON) and they may try to use RECON packages to facilitate their epidemics research.Derivation of Number of Infected Individuals I(a)
/blog/2017-04-22-derivation-of-number-of-infected-individuals-ia/
Sat, 22 Apr 2017 00:00:00 +0000/blog/2017-04-22-derivation-of-number-of-infected-individuals-ia/(Hens et al. 2012, 63:41) gives the formula for the total number of infective individuals \(I(a)\):
\[ \begin{equation} I(a) = \frac{\lambda}{\lambda - \nu}N(0)l(a)\left[e^{-\nu a} - e^{-\lambda a}\right], \tag{1} \end{equation} \]
which is obtained by integrating following differential equation with respect to age \(a\):
\[ \begin{equation} \frac{dI(a)}{da}=\lambda S(a) - (\nu + \mu)I(a). \tag{2} \end{equation} \]
This is also equation (4.11) in (Anderson and May 1992, 67). Here I will present the details of integration.Display Multi-line Equations and Matrix Correctly in Hugo
/blog/2017-01-05-display-multi-line-equations-and-matrix-correctly-in-hugo/
Thu, 05 Jan 2017 00:00:00 +0000/blog/2017-01-05-display-multi-line-equations-and-matrix-correctly-in-hugo/The first test case is to create a matrix consisting of following elements $$ \begin{matrix} 1 & x & x^2 1 & y & y^2 1 & z & z^2 \end{matrix} $$
but all elemments of the matrix are displayed in one line. Fortunately, this can be solved by wraping the math expression inside a <div> </div> block, which is hinted by the hugo documents of MathJax Support. besides, the blank line before <div> </div> block is necessary, otherwise the matrix would not be displayed correctly.Optimization of Disk Usage for animint
/blog/2015-08-09-optimization-of-disk-usage-for-animint/
Sun, 09 Aug 2015 00:00:00 +0000/blog/2015-08-09-optimization-of-disk-usage-for-animint/Problem The easy test for becoming a potential student of animint project for GSoC 2015 is to use animint to visualize some data from your domain of expertise, and upload your visualization to the web using animint2gist. I used animint to visualize the data from the CDC’s State-level FluView, which is a main data source of my Ph.D. influenza research. The script for generating the FluView viz can be found in AnimintTest repository.Operator for Extracting Named List Elements to Variables
/blog/2015-05-21-operator-for-extracting-named-list-elements-to-variables/
Thu, 21 May 2015 00:00:00 +0000/blog/2015-05-21-operator-for-extracting-named-list-elements-to-variables/In routine data analysis, I often need to convert list elements into variables. For exampple, when I create a function returning multiple values and I would like to use those values as variables separately, as only one object can be returned by the function, the common way to accomplish this task is that multiple values are combined as a list returned by the function, elements of interest are then extracted and assigned to variables.Resources for Influenza Research
/blog/2015-05-10-resources-for-influenza-research/
Sun, 10 May 2015 00:00:00 +0000/blog/2015-05-10-resources-for-influenza-research/Today I made a list of resources for influenza research. I will keep updating this list as my influenza research goes further. The up-to-date version can be found on my github.
Contents Infectious Diseases Epidemiology Modeling Infectious Diseases Topics and Keywords Ecology and Evolution of Influenza Seasonality of Influenza Dynamics of Influenza Influenza Transmission Influenza Forecasting Digital Detection of Influenza Databases for Influenza Research Workshops and Conferences MOOCs Contributing Topics and Keywords Influenza | Flu Pandemic (Antigenic Shift) vs.Why Does the Jackknife Estimate of Standard Error Have the Factor (n-1)/n?
/blog/2015-04-23-why-does-the-jackknife-estimate-of-standard-error-have-the-factor-n-1/n/
Thu, 23 Apr 2015 00:00:00 +0000/blog/2015-04-23-why-does-the-jackknife-estimate-of-standard-error-have-the-factor-n-1/n/Today I read 7.2 The Jackknife in Stastical Computing with R and found the explanation for why the jackknife estimate of standard error have the factor $(n-1)/n$ is unclear. I refered to An Introduction to the Bootstrap by Bradley Efron and R. J. Tibshirani, and the slides of jackknife by Rozenn Dahyot to figure out the reason. Here is my understanding for the existence of factor $(n-1)/n$.
The jackknife samples are computed by leaving out one observation $x_i$ from a sample $\mathbf{x} = (x_1, x_2, \cdots, x_n)$ at a time: $$ \mathbf{x}_{(i)} = (x_1, x_2, \cdots, x_{i-1}, x_{i+1}, \cdots, x_n) $$ for $i = 1, 2, \cdots, n$.Stratified Importance Sampling
/blog/2015-04-20-stratified-importance-sampling/
Mon, 20 Apr 2015 00:00:00 +0000/blog/2015-04-20-stratified-importance-sampling/The following R codes implement the Example 5.13 in Statistical Computing with R, and compare the estimate \(\hat{\theta}\) and \(\hat{\sigma}\) from stratified importance sampling to the results from importance sampling. The example illustrates that stratification can reduce the varinace of importance sampling estimator.
M <- 100000 # number of replicates g <- function(x) { exp(-x - log(1 + x^2)) * (x > 0) * (x < 1) } # importance sampling u <- runif(M) # f3, inverse transform method x <- -log(1 - u * (1 - exp(-1))) fg <- g(x) / (exp(-x) / (1 - exp(-1))) (theta.SIRS Model with Time Dependent Transmission Rate
/blog/2014-12-04-sirs-model-with-time-dependent-transmission-rate/
Thu, 04 Dec 2014 00:00:00 +0000/blog/2014-12-04-sirs-model-with-time-dependent-transmission-rate/1 SIRS Model The SIRS model is simply an extension of the SIR model as it allows members of the recovered class to rejoin the susceptible class at a defined rate, which integrates the impact of waning immunity following antigenic drift. Similar to the SIR model, a fixed population without births and deaths is considered in the SIRS model. The standard form of SIRS model is described as \[ \begin{equation} \begin{aligned} & \frac{dS}{dt} = fR - \frac{\beta SI}{N} \\ & \frac{dI}{dt} = \frac{\beta SI}{N} - \gamma I \\ & \frac{dR}{dt} = \gamma I - fR \end{aligned} \label{eq1} \end{equation} \] where \(f\) is the average loss of immunity rate of recovered indiviuals, and the other notations are the same as the SIR model.Gains from Paper Reading
/blog/2014-12-03-gains-from-paper-reading/
Wed, 03 Dec 2014 00:00:00 +0000/blog/2014-12-03-gains-from-paper-reading/因探究流感传染能力、存活能力与湿度的关系，今天自己将两年前读过的一篇论文（Shaman.Kohn-PNAS-2009）又翻出来重新读了一遍，Precision Difference of ode45 between R and MATLAB
/blog/2014-11-24-precision-difference-of-ode45-between-r-and-matlab/
Mon, 24 Nov 2014 00:00:00 +0000/blog/2014-11-24-precision-difference-of-ode45-between-r-and-matlab/ode45 solvers from both R and MATLAB are used to run simulations of the spread of Hong Kong flu in New York city with different initial susceptible individuals \(S\_0 =\) 790, 7900, 79000, 790000, and 7900000. The maximum infected people \(I_{max}\) under each condition is recorded for comparison. The following codes draw a figure showing the precision difference of ode45 solvers between R and MATLAB.
Imax <- data.frame(S0 = 79 * 10 ^ (1:5), R = c(57.RK4 Method for Solving SIR Model
/blog/2014-11-24-rk4-method-for-solving-sir-model/
Mon, 24 Nov 2014 00:00:00 +0000/blog/2014-11-24-rk4-method-for-solving-sir-model/My object is to rewrite the 4th order Runge-Kutta (abbreviated for RK4) method for solving the absolute humidity-driven SIRS model developed by Yang et al. (2014) in R language. The details of the SIRS model are provided in the paper.
1 RK4 1.1 Preliminary RK4 is one of the classic methods for numerical integration of ODE models. A brief introduction of RK4 refers to Wikipedia.
Consider the following initial value problem of ODE \[ \begin{equation} \begin{aligned} & \frac{dy}{dt} = f(t, y) \\ & y(t_0) = y_0 \end{aligned} \label{eq1-rk4} \end{equation} \] where \(y(t)\) is the unknown function (scalar or vector) which I would like to approximate.Problems with adduser on Ubuntu and Solutions
/blog/2014-09-30-problems-with-adduser-on-ubuntu-and-solutions/
Tue, 30 Sep 2014 00:00:00 +0000/blog/2014-09-30-problems-with-adduser-on-ubuntu-and-solutions/最近想为Ubuntu服务器增加一个用户，然后ssh远程登录使用。折腾了好久总算搞定，现将过程中遇到的问题记录下来，以便将来参考。 1. 创建新用户Commonly Used ArcGIS Tools by Myself
/blog/2014-09-21-commonly-used-arcgis-tools-by-myself/
Sun, 21 Sep 2014 00:00:00 +0000/blog/2014-09-21-commonly-used-arcgis-tools-by-myself/ArcGIS toolbox提供了丰富的工具，但只有一些是在平常的空间数据处理过程中自己会用到。即使如此，每次自己进行一个处理操作时都要再去googleHost Is Down Using curl/wget While Page Loads in Browser
/blog/2014-08-23-host-is-down-using-curl/wget-while-page-loads-in-browser/
Sat, 23 Aug 2014 00:00:00 +0000/blog/2014-08-23-host-is-down-using-curl/wget-while-page-loads-in-browser/问题描述 最近想更新自己开发的geoChina，发现在Mac上运行以下代码 library(geoChina) geocode('Tsinghua University', api = 'google', ocs = 'GCJ-02', messaging = T) 出错，返回 1 2 3 4 5 6calling http://maps.googleapis.com/maps/api/geocode/json?address=Tsinghua%20University&sensor=false ... Warning message: In readLines(connect, warn = FALSE) : unableIntroduction to git and GitHub
/blog/2014-07-13-introduction-to-git-and-github/
Sun, 13 Jul 2014 00:00:00 +0000/blog/2014-07-13-introduction-to-git-and-github/git安装 推荐Homebrew用于管理常用开源软件包在macOS上的安装和升级。Homebrew用Ruby语言开发，支持千余种开源软件在 maA Chinese Beamer for Ecophilosophy Class Presentation
/blog/2013-12-04-a-chinese-beamer-for-ecophilosophy-class-presentation/
Wed, 04 Dec 2013 00:00:00 +0000/blog/2013-12-04-a-chinese-beamer-for-ecophilosophy-class-presentation/用Beamer做英文slides已经尝试过了，做中文slides一直没有尝试过。借着研究生最后一门课程——生态哲学——课堂展示的机会，做了一Use IPv6 in an ISATAP Way
/blog/2013-06-10-use-ipv6-in-an-isatap-way/
Mon, 10 Jun 2013 00:00:00 +0000/blog/2013-06-10-use-ipv6-in-an-isatap-way/地学前沿最后一次课是和宫老师一起吃饭聊天（主要是听宫老师讲），期间宫老师提到了他写的一篇文章How to find an academic job，挂在了他在berkely的How to Connect to VMware Machine (CentOS 6.4) via SSH
/blog/2013-06-08-how-to-connect-to-vmware-machine-centos-6.4-via-ssh/
Sat, 08 Jun 2013 00:00:00 +0000/blog/2013-06-08-how-to-connect-to-vmware-machine-centos-6.4-via-ssh/之前使用CentOS虚拟机都是在GUI里操作，四年前配置的笔记本实在吃不消，非常的卡，都没有了工作的欲望。最近在做《高性能计算导论》课程作业A Beamer for Doctoral English Class Final Presentation
/blog/2013-06-07-a-beamer-for-doctoral-english-class-final-presentation/
Fri, 07 Jun 2013 00:00:00 +0000/blog/2013-06-07-a-beamer-for-doctoral-english-class-final-presentation/用Beamer做博士英语课程presentation的slides，觉得不错的朋友可以下载tex源文件研究，欢迎交流。Create Your Blog with Jekyll
/blog/2013-04-28-create-your-blog-with-jekyll/
Sun, 28 Apr 2013 00:00:00 +0000/blog/2013-04-28-create-your-blog-with-jekyll/在使用Jekyll搭建个人blog之前，确认你的PC安装有Jekyll。最简单的安装Jekyll方法是通过RubyGems，RubyGemsArchive page
/archive/
Mon, 01 Jan 0001 00:00:00 +0000/archive/Blog archiveDouban
/douban/
Mon, 01 Jan 0001 00:00:00 +0000/douban/