Learn R Programming

SFSI (version 1.2.0)

Methods_SSI: SSI methods

Description

Useful methods for retrieving, summarizing and visualizing important results from an object of the class 'SSI'

Usage

# S3 method for SSI
coef(object, ..., df=NULL, i=NULL)

# S3 method for SSI fitted(object, ...)

# S3 method for SSI summary(object, ...) # S3 method for SSI plot(..., py=c("accuracy","MSE"), nbreaks.x=6)

Value

Method fitted returns a matrix with the predicted values for each individual in the testing set (in rows) for each value of lambda (in columns).

Method coef (list of matrices) returns the regression coefficients for each testing set individual (elements of the list). Each matrix contains the coefficients for each value of lambda (in rows) associated to each training set individual (in columns). If tst is specified, the elements of the list will correspond only to the testing individuals given in tst. If df is specified, only the coefficients for the lambda associated to df are returned as a 'matrix' with testing individuals in rows.

Method summary returns a list object containing:

  • lambda: (vector) sequence of values of lambda used in the coefficients' estimation.

  • df: (vector) degrees of freedom (across testing individuals) at each solution associated to each value of lambda.

  • accuracy: (vector) correlation between observed and predicted values associated to each value of lambda.

  • MSE: (vector) mean squared error associated to each value of lambda.

  • optCOR: (vector) summary of the SSI with maximum accuracy.

  • optMSE: (vector) summary of the SSI with minimum MSE.

Method plot creates a plot of either accuracy or MSE versus the (average across testing individuals) number of predictors (with non-zero regression coefficient) and versus lambda.

Arguments

object

An object of the class 'SSI'

...

Arguments to be passed:

  • One or more objects of the class 'SSI' (for method plot)

  • Other arguments for method plot: 'xlab', 'ylab', 'main', 'lwd', 'xlim', 'ylim'

  • An optional vector of observations y (with a similar heritability as the one declared in 'SSI' function) for methods summary, plot, and fitted

df

(numeric) Average (across testing individuals) number of non-zero regression coefficients

i

(integer vector) Index testing elements (stored in object$tst) to be considered. Default i=NULL will consider all elements in object$tst

py

(character) Either 'accuracy' (correlation between observed and predicted values) or 'MSE' (mean squared error) to plot in the y-axis

nbreaks.x

(integer) Number of breaks in the x-axis

Author

Marco Lopez-Cruz (maraloc@gmail.com) and Gustavo de los Campos

Examples

Run this code
  require(SFSI)
  data(wheatHTP)
  
  index = which(Y$trial %in% 1:6)   # Use only a subset of data
  Y = Y[index,]
  M = scale(M[index,])/sqrt(ncol(M))  # Subset and scale markers
  G = tcrossprod(M)                   # Genomic relationship matrix
  y = as.vector(scale(Y[,"E1"]))      # Scale response variable
  
  # Training and testing sets
  tst = which(Y$trial == 2)
  trn = which(Y$trial != 2)
  
  fm1 = SSI(y,K=G,theta=1,b=0,tst=tst,trn=trn)
  
  uHat = fitted(fm1)                # Predicted values for each testing element
  out = summary(fm1)                # Useful function to get results
  corTST = out$accuracy             # Testing set accuracy (correlation cor(y,yHat))
  out$optCOR                        # SSI with maximum accuracy
  out$optMSE                        # SSI with minimum MSE
  B = coef(fm1)                     # Regression coefficients for all tst
  B = coef(fm1, i=1)                # Regression coefficients for first tst (tst[1])
  B = coef(fm1, df=10)              # Regression coefficients for which df=10
  plot(fm1,main=expression('corr('*y[obs]*','*y[pred]*') vs sparsity'))   
  plot(fm1,py="MSE",ylab='Mean Square Error', xlab='Sparsity')     
  

Run the code above in your browser using DataLab