Description Usage Arguments Value Author(s) See Also Examples
View source: R/predict.splitSelect.R
predict.splitSelect
returns the prediction for splitSelect for new data.
1 2 |
object |
An object of class splitSelect. |
newx |
A matrix with the new data. |
... |
Additional arguments for compatibility. |
A matrix with the predictions of the splitSelect
object.
Anthony-Alexander Christidis, anthony.christidis@stat.ubc.ca
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | # Setting the parameters
p <- 4
n <- 30
n.test <- 5000
beta <- rep(5,4)
rho <- 0.1
r <- 0.9
SNR <- 3
# Creating the target matrix with "kernel" set to rho
target_cor <- function(r, p){
Gamma <- diag(p)
for(i in 1:(p-1)){
for(j in (i+1):p){
Gamma[i,j] <- Gamma[j,i] <- r^(abs(i-j))
}
}
return(Gamma)
}
# AR Correlation Structure
Sigma.r <- target_cor(r, p)
Sigma.rho <- target_cor(rho, p)
sigma.epsilon <- as.numeric(sqrt((t(beta) %*% Sigma.rho %*% beta)/SNR))
# Simulate some data
x.train <- mvnfast::rmvn(30, mu=rep(0,p), sigma=Sigma.r)
y.train <- 1 + x.train %*% beta + rnorm(n=n, mean=0, sd=sigma.epsilon)
x.test <- mvnfast::rmvn(n.test, mu=rep(0,p), sigma=Sigma.rho)
y.test <- 1 + x.test %*% beta + rnorm(n.test, sd=sigma.epsilon)
# Generating the coefficients for a fixed split
split.out <- splitSelect(x.train, y.train, G=2, use.all=TRUE,
fix.partition=list(matrix(c(2,2), ncol=2, byrow=TRUE)), fix.split=NULL,
intercept=TRUE, group.model="glmnet", alphas=0)
predict(split.out, newx=x.test)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.