Reconstruct a n by p matrix given n by k basis functions or predictors. The reconstruction can be regularized. # norm( x - uv^t ) # d/dv ... leads to ( -u, x - uv^t ) # u^t u v^t - u^t x

smoothMatrixPrediction(
  x,
  basisDf,
  modelFormula = as.formula(" x ~ ."),
  iterations = 10,
  gamma = 0.000001,
  sparsenessQuantile = 0.5,
  positivity = c("positive", "negative", "either"),
  smoothingMatrix = NA,
  repeatedMeasures = NA,
  rowWeights = NA,
  LRR = NA,
  doOrth = FALSE,
  verbose = FALSE
)

Arguments

x

input matrix to be predicted.

basisDf

data frame for basis predictors

modelFormula

a formula object which has, on the left, the variable x and the prediction formula on the right.

iterations

number of gradient descent iterations

gamma

step size for gradient descent

sparsenessQuantile

quantile to control sparseness - higher is sparser.

positivity

restrict to positive or negative solution (beta) weights. choices are positive, negative or either as expressed as a string.

smoothingMatrix

allows parameter smoothing, should be square and same size as input matrix

repeatedMeasures

list of repeated measurement identifiers. this will allow estimates of per identifier intercept.

rowWeights

vectors of weights with size n (assumes diagonal covariance)

LRR

integer value sets rank for fast version exploiting matrix approximation

doOrth

boolean enforce gram-schmidt orthonormality

verbose

boolean option

Value

matrix of size p by k is output

Examples

if (FALSE) { mask = getMask( antsImageRead( getANTsRData( 'r16' ) ) ) spatmat = t( imageDomainToSpatialMatrix( mask, mask ) ) smoomat = knnSmoothingMatrix( spatmat, k = 5, sigma = 1.0 ) mat <- matrix(rnorm(sum(mask)*50),ncol=sum(mask),nrow=50) mat[ 1:25,100:10000]=mat[ 1:25,100:10000]+1 age = rnorm( 1:nrow(mat)) for ( i in c( 5000:6000, 10000:11000, 16000:17000 ) ){ mat[ , i ] = age*0.1 + mat[,i] } gen = c( rep("M",25), rep("F",12 ) , rep("T",13 ) ) repmeas = rep( c("A","B","C","D","E","F","G"), nrow( mat ) )[1:nrow(mat)] mydf = data.frame( age = scale( age ), gen = gen ) fit = smoothMatrixPrediction( x=mat, basisDf=mydf, iterations = 10, gamma = 1.e-6, sparsenessQuantile = 0.5, smoothingMatrix = smoomat, repeatedMeasures=repmeas, verbose=T ) tt = mat %*% fit$v print( cor.test( mydf$age, tt[,1] ) ) print( cor.test( fit$u[,"genM"], tt[,2] ) ) vimg = makeImage( mask, (fit$v[,1] ) ); print(range(vimg)*10) plot( mask, vimg, window.overlay=range(abs(vimg))) vimg = makeImage( mask, (fit$v[,2] ) ); print(range(vimg)*10) plot( mask, vimg, window.overlay=range(abs(vimg))) }