LORS2: LORS2

Description Usage Arguments Value Examples

View source: R/FastLORS_Functions.R

Description

LORS2 is a function used in parameter tuning in LORS. See the parameter tuning section described in Can Yang et al. (2013). This function is adapted from the authors MATLAB implementation

Usage

1
LORS2(Y, X, L, Omega1, Omega2, B, rho, lambda, tol, maxIter = 1000)

Arguments

Y

gene expression matrix

X

matrix of SNPs

L

matrix of hidden factors

Omega1

Boolean matrix for training data

Omega2

Boolean matrix for validation data

B

a matrix of coefficients for the SNPs

rho

parameter for enforcing sparsity of coefficient matrix

lambda

parameter for enforcing low-rank structure of hidden factor matrix

tol

tolerance level for convergence

maxIter

the maximum number of iterations

Value

B

The estimated coefficients

mu

The estimated intercept

L

The estimated matrix of hidden factors

Err

The residual sum of squares on the validation set

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
##Example

#' ## Generate some data
n <- 50
p <- 200
q <- 100
k <- 10
set.seed(123)
X <- matrix(rbinom(n*p,1,0.5),n,p)
L <- matrix(rnorm(n*k),n,k) %*% t(matrix(rnorm(q*k),q,k))
B <- matrix(0, ncol(X), ncol(L))
activeSNPs <- sort(sample(c(1:nrow(B)), 20))
for(i in 1:length(activeSNPs)){
genes_influenced <- sort(sample(c(1:ncol(B)),5))
B[activeSNPs[i], genes_influenced] <- 2
}
E <- matrix(rnorm(n*q),n,q)
Y <- X %*% B + L + E

Omega0 <- !(is.na(Y))
mask <- matrix(runif(nrow(Y)*ncol(Y)) > 0.5, nrow = nrow(Y), ncol = ncol(Y))
Omega1 <- Omega0 & mask
Omega2 <- Omega0 & !mask
rho <- runif(1,3,5)
lambda <- runif(1,3,5)
tol <- 1e-4

## Usage
LORS2(Y, X, L, Omega1, Omega2, B, rho, lambda, tol)

jdrhyne2/FastLORS documentation built on March 5, 2020, 6:50 a.m.