predict.smle | R Documentation |
For a model object of class 'smle'
or 'selection'
, this function returns the predicted response values after re-fitting the model using glm
.
## S3 method for class 'smle' predict(object, newdata = NULL, type = c("link", "response", "terms"), ...) ## S3 method for class 'selection' predict(object, newdata = NULL, type = c("link", "response", "terms"), ...)
object |
A |
newdata |
Matrix of new values for the features at which predictions are to be made. If omitted, the fitted linear predictors are used. |
type |
The type of prediction required by |
... |
Further arguments passed to |
A prediction vector with length equal to the number of rows of newdata
.
set.seed(1) Data_sim <- Gen_Data(n = 420, p = 1000, sigma = 0.5, family = "gaussian") train_X <- Data_sim$X[1:400,]; test_X <- Data_sim$X[401:420,] train_Y <- Data_sim$Y[1:400]; test_Y <- Data_sim$Y[401:420] fit1 <- SMLE(Y = train_Y, X = train_X, family = "gaussian", k = 10) #Fitted responses vs true responses in training data predict(fit1)[1:10] train_Y[1:10] #Predicted responses vs true responses in testing data predict(fit1, newdata = test_X) test_Y
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.