Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to deal with zero or near-zero mixture weights? #5

Open
pcarbo opened this issue Jan 1, 2021 · 5 comments
Open

How to deal with zero or near-zero mixture weights? #5

pcarbo opened this issue Jan 1, 2021 · 5 comments

Comments

@pcarbo
Copy link
Member

pcarbo commented Jan 1, 2021

It doesn't make much sense to update prior covariance matrices with weights that are zero, or near zero. @stephens999 @yunqiyang0215 @zouyuxin Ideas are welcome.

Here's an example (thanks to Yuxin):

set.seed(1)
dat <- readRDS("dat.rds")
f0 <- ud_init(X = as.matrix(dat$data),V = dat$S,U_scaled = list(),
              U_unconstrained = dat$Ulist,n_rank1 = 0)
res <- ud_fit(f0,control = list(unconstrained.update = "teem",
                                resid.update = "none",
                                version = "R"))
# Performing Ultimate Deconvolution on 600 x 20 matrix (udr 0.3-30, "R"):
# data points are i.i.d. (same V)
# prior covariances: 0 scaled, 0 rank-1, 10 unconstrained
# prior covariance updates: none (scaled), none (rank-1), teem (unconstrained)
# mixture weights update: em
# residual covariance update: none
# max 20 updates, conv tol 1.0e-06
# iter          log-likelihood |w - w'| |U - U'| |V - V'|
#    1 -3.0699325059934326e+04 4.65e-01 1.22e+02 0.00e+00
#    2 -3.0330311442511782e+04 9.41e-02 1.11e+02 0.00e+00
#   ...
#   19 -2.9720957242869852e+04 2.79e-05 2.27e-01 0.00e+00
#   20 -2.9720891074856361e+04 7.07e-05 4.21e-01 0.00e+00
print(round(res$w,digits = 6))
#  FLASH_1  FLASH_2  FLASH_3  FLASH_4   tFLASH    PCA_1    PCA_2    PCA_3
# 0.000000 0.000000 0.001667 0.004884 0.229977 0.000000 0.000000 0.000116
#    tPCA       XX
# 0.265002 0.498354

dat.rds.gz

@zouyuxin
Copy link
Member

zouyuxin commented Jan 2, 2021

I agree there is no need to update covariance if it has weight 0. I was thinking update ku here https://github.com/stephenslab/udr/blob/master/R/fit.R#L334 based on weight w.

@pcarbo
Copy link
Member Author

pcarbo commented Jan 2, 2021

Related to this, there is the question of whether we should prune weights that are smaller than some pre-specific threshold, e.g., 1e-8.

@yunqiyang0215
Copy link
Collaborator

yunqiyang0215 commented Jan 4, 2021 via email

@yunqiyang0215
Copy link
Collaborator

yunqiyang0215 commented Dec 28, 2021

I added two checks in the code. The idea is if weight[i] < minval (1e-15, I set for default for now), we set weight[i] == 0 and skip updating U[[i]].

  1. A check in update_mixture_weights.R to see if w[i] < minval.
  2. A check in update_prior_covariances.R. If w[i] == 0, skip updating U[[i]].

@pcarbo
Copy link
Member Author

pcarbo commented Jan 4, 2022

@yunqiyang0215 I wrote this in Slack but I'll post my comments here as well.

I would suggest defining a new control parameter, e.g., zero.threshold, with a default of, say, 1e-8, and the prior covariance matrices will not be updated when the corresponding prior weights are below this threshold.

Also there is another subtlety in your check because you are checking the prior weights w but the the update for U actually doesn't depend on w; it depends on P.

So maybe if w[i] is "too small", then we should also set the corresponding "responsibilities" P[,i] to be all zeros?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants