predict.pls | R Documentation |
Predict Y based on new observations.
## S3 method for class 'pls' predict(object, x_test = NULL, z_test, ...)
object |
fitted partially linear single-index model, which could be obtained by |
x_test |
input matrix (linear covariates of test set). |
z_test |
input matrix (nonlinear covariates of test set). |
... |
additional arguments. plsim.MAVE, or plsim.est, or plsim.vs.soft. |
y_hat |
prediction. |
n = 50 sigma = 0.1 alpha = matrix(1, 2, 1) alpha = alpha/norm(alpha, "2") beta = matrix(4, 1, 1) x = matrix(1, n, 1) x_test = matrix(1,n,1) z = matrix(runif(n*2), n, 2) z_test = matrix(runif(n*2), n, 2) y = 4*((z%*%alpha-1/sqrt(2))^2) + x%*%beta + sigma*matrix(rnorm(n),n,1) y_test = 4*((z_test%*%alpha-1/sqrt(2))^2) + x_test%*%beta + sigma*matrix(rnorm(n),n,1) # Obtain parameters in PLSiM using Profile Least Squares Estimator fit_plsimest = plsim.est(x, z, y) preds_plsimest = predict(fit_plsimest, x_test, z_test) # Print the MSE of the Profile Least Squares Estimator method print( sum( (preds_plsimest-y_test)^2)/nrow(y_test) ) # Obtain parameters in PLSiM using Penalized Profile Least Squares Estimator fit_plsim = plsim.vs.soft(x, z, y,lambda = 0.01) preds_plsim = predict(fit_plsim, x_test, z_test) # Print the MSE of the Penalized Profile Least Squares Estimator method print( sum( (preds_plsim-y_test)^2)/nrow(y_test) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.