Last updated: 2019-10-30
Checks: 2 0
Knit directory: SMF/
This reproducible R Markdown analysis was created with workflowr (version 1.4.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility. The version displayed above was the version of the Git repository at the time these results were generated.
Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish
or wflow_git_commit
). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:
Ignored files:
Ignored: .DS_Store
Ignored: .Rhistory
Ignored: .Rproj.user/
Ignored: analysis/.DS_Store
Untracked files:
Untracked: analysis/SmoothPMF.Rmd
Unstaged changes:
Modified: analysis/index.Rmd
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
These are the previous versions of the R Markdown and HTML files. If you’ve configured a remote Git repository (see ?wflow_git_remote
), click on the hyperlinks in the table below to view them.
File | Version | Author | Date | Message |
---|---|---|---|---|
Rmd | 0c09760 | Dongyue Xie | 2019-10-30 | wflow_publish(“analysis/trendfiltering.Rmd”) |
In a previous post, we mentioned that trend filtering is a special case of generalized lasso with \(X=I\) and due to the special band structure of \(D\), it can be refomularized into a lasso problem.
Here, I’ll show the equivalence of 0-order trend filtering and random walk dynamic linear model.
To recap, \(k\)th order Trend filter can be written as
\[\begin{equation} \hat{\alpha} = argmin_\alpha \frac{1}{2}||y-H\alpha||_2^2 +\lambda\sum_{j=k+2}^n|\alpha_j|, \end{equation}\] and \(\hat{\beta} = H\hat{\alpha}\). When \(k=0\), \[\begin{equation} H=\left[\begin{array}{cccc}{1} & {0} & {\ldots} & {0} \\ {1} & {1} & {\ldots} & {0} \\ {\vdots} & {} & {} & {} \\ {1} & {1} & {\ldots} & {1}\end{array}\right] \end{equation}\]
Random walk dynamic linear model is \[\begin{equation} \begin{split} y_t = \beta_t+\epsilon_t, \epsilon_t|\sigma_t\sim N(0,\sigma^2) \\ \beta_t-\beta_{t-1} = \alpha_t, \alpha_t\sim g(\cdot), t=2,3,...,n \\ \beta_1\sim \pi(\cdot), \end{split} \end{equation}\] where \(g(\cdot)\) is sparsity-inducing prior and \(\pi(\cdot)\) is a noninformative prior.
Hence, we can rewrite \(y_t = \beta_1+\sum_{i=2}^t\alpha_i+\epsilon_t\). Posterior of \(\beta_1\) and \(\alpha:=\{\alpha_2,...,\alpha_n\}\) is \[p(\beta_1,\alpha|y,g,\pi)\propto p(y|\beta_1,\alpha)\pi(\beta_1)g(\alpha)\]
The MAP estimator is then \[\hat{\beta}_1,\hat{\alpha} = argmax \sum_{t=1}^n (y_t-\beta_1-\sum_{i=2}^t\alpha_i)^2+\log\pi(\beta_1)+\sum_{t=2}^n \log g(\alpha_t)\]
The equivalence holds if we choose Laplace prior on \(\alpha\). Of course, we can choose any sparsity-inducing prior.
Similarly, we can show the equivalence of order \(k\geq 1\).