Last updated: 2018-07-20
workflowr checks: (Click a bullet for more information)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.
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: docs/.DS_Store
Ignored: docs/figure/.DS_Store
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. File | Version | Author | Date | Message |
---|---|---|---|---|
Rmd | 032edd6 | Jason Willwerscheid | 2018-07-20 | wflow_publish(c(“analysis/index.Rmd”, “analysis/flash_em.Rmd”, |
html | f995dbb | Jason Willwerscheid | 2018-07-20 | manual commits to remove licence |
html | c9f10b0 | Jason Willwerscheid | 2018-07-20 | Build site. |
Rmd | 4fc94bd | Jason Willwerscheid | 2018-07-20 | wflow_publish(c(“analysis/index.Rmd”, “analysis/flash_em.Rmd”)) |
html | 5487b70 | Jason Willwerscheid | 2018-07-20 | Build site. |
Rmd | 8911eb8 | Jason Willwerscheid | 2018-07-20 | wflow_publish(c(“analysis/obj_notes.Rmd”, |
html | da82b48 | Jason Willwerscheid | 2018-07-19 | Build site. |
Rmd | fb3eab9 | Jason Willwerscheid | 2018-07-19 | wflow_publish(“analysis/flash_em.Rmd”) |
html | 1a7bb47 | Jason Willwerscheid | 2018-07-19 | Build site. |
Rmd | 962e216 | Jason Willwerscheid | 2018-07-19 | wflow_publish(“analysis/flash_em.Rmd”) |
If the expression for the KL divergence derived in the previous note is correct, then it seems likely that the FLASH objective could be optimized in a more direct fashion.
I parametrize the posteriors for, respectively, the ith element of the kth loading and the jth element of the kth factor as qli∼(1−w(l)i)δ0+w(l)iN(μ(l)i,σ2(l)i) and qfj∼(1−w(f)j)δ0+w(f)jN(μ(f)j,σ2(f)j) I parametrize the priors as gli∼π(l)0δ0+(1−π(l)0)N(0,1/al) and gfj∼π(f)0δ0+(1−π(f)0)N(0,1/af)
Using the expression for KL divergence derived in the previous note, the objective can be written: ∑i,j[12logτij2π−τij2((R−kij)2−2R−kijw(l)iμ(l)iw(f)jμ(f)j+w(l)i(μ(l)2i+σ2(l)i)w(f)j(μ(f)2j+σ2(f)j))]+∑i[(1−w(l)i)logπ(l)01−w(l)i+w(l)ilog1−π(l)0w(l)i+w(l)i2(log(alσ2(l)i)−al(μ(l)2i+σ2(l)i)+1)]+∑j[(1−w(f)j)logπ(f)01−w(f)j+w(f)jlog1−π(f)0w(f)j+w(f)j2(log(afσ2(f)j)−af(μ(f)2j+σ2(f)j)+1)],
where R−kij denotes the matrix of residuals obtained by using all factor/loading pairs but the kth.
I derive an algorithm for loadings updates by differentiating with respect to each variable al, π(l)0, μ(l)1,…,μ(l)n, σ2(l)1,…,σ2(l)n, and w(l)1,…,w(l)n, and setting each result equal to zero.
The updates for the prior parameters al and π(l)0 turn out to be very simple. First, differentiating with respect to al gives ∑i[w(l)i2(1al−(μ(l)2i+σ2(l)i))] Setting this equal to zero gives al=∑iw(l)i∑iw(l)i(μ(l)2i+σ2(l)i)=∑iw(l)i∑iEql2i
Next, differentiating with respect to π(l)0 gives ∑i[1−w(l)iπ(l)0−w(l)i1−π(l)0] Setting this equal to zero gives π(l)0∑iw(l)i=(1−π(l)0)∑i(1−w(l)i)π(l)0=1n∑i(1−w(l)i)
The updates for the posterior parameters μ(l)i and σ2(l)i also turn out to be quite manageable. Differentiating with respect to μ(l)i gives ∑jτij[R−kijw(l)iw(f)jμ(f)j−w(l)iμ(l)iw(f)j(μ(f)2j+σ2(f)j)]−w(l)ialμ(l)i Setting this equal to zero gives μ(l)i=∑jτijR−kijw(f)jμ(f)jal+∑jτijw(f)j(μ(f)2j+σ2(f)j)=∑jτijR−kijEfjal+∑jτijEf2j
Next, differentiating with respect to σ2(l)i gives −12∑jτijw(l)iw(f)j(μ(f)2j+σ2(f)j)+w(l)i2σ2(l)i−w(l)ial2 Setting this equal to zero gives σ2(l)i=1al+∑jτijw(f)j(μ(f)2j+σ2(f)j)=1al+∑jτijEf2j
It remains to derive the update for w(l)i. Differentiating gives ∑jτij[R−kijμ(l)iw(f)jμ(f)j−12(μ(l)2i+σ2(l)i)w(f)j(μ(f)2j+σ2(f)j)]−logπ(l)01−w(l)i+log1−π(l)0w(l)i+12(log(alσ2(l)i)−al(μ(l)2i+σ2(l)i)+1) Setting this equal to zero gives logw(l)i1−w(l)i=log1−π(l)0π(l)0+12(log(alσ2(l)i)−al(μ(l)2i+σ2(l)i)+1)+∑jτij[R−kijμ(l)iw(f)jμ(f)j−12(μ(l)2i+σ2(l)i)w(f)j(μ(f)2j+σ2(f)j)], where the last sum can also be written ∑jτij[R−kijμ(l)iEfj−12(μ(l)2i+σ2(l)i)Ef2j]
I suggest that the loadings could be updated by
and then repeating the following two steps until convergence:
Update μ(l)1,…,μ(l)n and σ2(l)1,…,σ2(l)n, and then update w(l)1,…,w(l)n.
Update al and π(l)0.
This reproducible R Markdown analysis was created with workflowr 1.0.1