estimate_null_correlation: Estimate null correlations

Description Usage Arguments Details Value Examples

View source: R/est_cor.R

Description

Estimates a null correlation matrix from data

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
estimate_null_correlation(
  data,
  Ulist,
  init,
  max_iter = 30,
  tol = 1,
  est_cor = TRUE,
  track_fit = FALSE,
  prior = c("nullbiased", "uniform"),
  details = FALSE,
  ...
)

Arguments

data

a mash data object, eg as created by mash_set_data

Ulist

a list of covariance matrices to use

init

the initial value for the null correlation. If it is not given, we use result from estimate_null_correlation_adhoc

max_iter

maximum number of iterations to perform

tol

convergence tolerance

est_cor

whether to estimate correlation matrix (TRUE) or the covariance matrix (FALSE)

track_fit

add an attribute trace to output that saves current values of all iterations

prior

indicates what penalty to use on the likelihood, if any

details

whether to return details of the model, if it is TRUE, the number of iterations and the value of objective functions will be returned

...

other parameters pass to mash

Details

Returns the estimated correlation matrix (or covariance matrix) among conditions under the null. The correlation (or covariance) matrix is estimated by maximum likelihood. Specifically, the unknown correlation/covariance matrix V and the unknown weights are estimated iteratively. The unknown correlation/covariance matrix V is estimated using the posterior second moment of the noise. The unknown weights pi is estimated by maximum likelihood, which is a convex problem.

Warning: This method could take some time. The estimate_null_correlation_simple gives a quick approximation for the null correlation (or covariance) matrix.

Value

the estimated correlation (or covariance) matrix and the fitted mash model

V

estimated correlation (or covariance) matrix

mash.model

fitted mash model

Examples

1
2
3
4
5
6
7
8
9
simdata = simple_sims(100,5,1)
m.1by1 = mash_1by1(mash_set_data(simdata$Bhat,simdata$Shat))
strong.subset = get_significant_results(m.1by1,0.05)
random.subset = sample(1:nrow(simdata$Bhat),20)
data.strong = mash_set_data(simdata$Bhat[strong.subset,], simdata$Shat[strong.subset,])
data.tmp = mash_set_data(simdata$Bhat[random.subset,], simdata$Shat[random.subset,])
U_pca = cov_pca(data.strong, 3)
U_ed = cov_ed(data.strong, U_pca)
Vhat = estimate_null_correlation(data.tmp, U_ed)

mashr documentation built on May 24, 2021, 1:06 a.m.