Learn R Programming

gettingtothebottom (version 3.2)

solutionpaths: MM Algorithm - Find the best fit lambda for a given problem based on an initial guess for lambda

Description

solutionpaths Function for finding the best fit lambda for a given problem based on an initial guess for lambda

Usage

solutionpaths(A, X, Z, omega, lambda.start, tol = 1e-04, liveupdates = FALSE, lambdaseq_length = 20)

Arguments

A
Original data matrix (no unobserved entries)
X
Data matrix (with unobserved entries)
Z
Initial model matrix
omega
Vector of unobserved entries in the data matrix X
lambda.start
Initial value for lambda
tol
(Optional) Tolerance for convergence (Default: 1e-4)
liveupdates
(Optional) Set to TRUE to view progress of comparisons. (Default: FALSE)
lambdaseq_length
(Optional) Length of lambda sequence for convergence. (Default: 20)

Examples

Run this code
# Generate a test matrix
seed <- 12345
m <- 100
n <- 100
r <- 3
T <- testmatrix(m,n,r,seed=seed)

# Add some noise to the test matrix
E <- 0.1*matrix(rnorm(m*n),m,n)
A <- T + E

# Obtain a vector of unobserved entries
temp <- makeOmega(m,n,percent=0.5)
omega <- temp$omega

# Remove unobserved entries from test matrix
X <- A
X[omega] <- NA

# Make initial model matrix Z and find initial lambda
Z <- matrix(0,m,n)
lambda.start <- init.lambda(X,omega)
lambdaseq_length=20
tol <- 1e-2

ans <- solutionpaths(A,X,Z,omega,lambda.start,tol=tol,
   liveupdates=TRUE,lambdaseq_length=lambdaseq_length)

Run the code above in your browser using DataLab