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