# NOT RUN {
# Fit example TPLS data with a TPLS model
# Load example data (included with package).
X = TPLSdat$X
Y = TPLSdat$Y
# Fit the model, with default options (50 components, no observation weights)
TPLSmdl <- TPLS(X,Y)
# Make in-sample prediction at threshold of 0.5 and at all possible components
pred <- TPLSpredict(TPLSmdl,1:50,0.5,X)
# Look at the correlation between prediction and Y.
# This is in-sample prediction. Ergo, the model with most components will have the highest
# predictive correlation. In practice, you should choose the number of components and
# threshold using cross-validation. See example for TPLS_cv
cor(Y,pred)
# Extract the predictor for a model with 25 PLS components and threshold at 0.7 (just cuz)
betamap <- makePredictor(TPLSmdl,25,0.5)
# This is the intercept
betamap$bias
# These are the coefficients for the original variables
betamap$betamap
# }
Run the code above in your browser using DataLab