fitted.transreg | R Documentation |
Extracts fitted values
## S3 method for class 'transreg'
fitted(object, stack = NULL, ...)
object |
object of class 'transreg' |
stack |
character "sta" (standard stacking) or "sim" (simultaneous stacking) |
... |
(not applicable) |
Returns fitted values. The output is a numerical vector with one entry for sample.
Armin Rauschenberger, Zied Landoulsi, Mark A. van de Wiel, and Enrico Glaab (2023). "Penalised regression with multiple sets of prior effects". Bioinformatics 39(12):btad680. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1093/bioinformatics/btad680")}. (Click here to access PDF.)
Methods for objects of class [transreg]
include coef
and predict
.
#--- simulation ---
set.seed(1)
n0 <- 100; n1 <- 10000; n <- n0 + n1; p <- 500
X <- matrix(rnorm(n=n*p),nrow=n,ncol=p)
beta <- rnorm(p)
prior <- beta + rnorm(p)
y <- X %*% beta
#--- train-test split ---
foldid <- rep(c(0,1),times=c(n0,n1))
y0 <- y[foldid==0]
X0 <- X[foldid==0,]
y1 <- y[foldid==1]
X1 <- X[foldid==1,]
object <- transreg(y=y0,X=X0,prior=prior)
#--- fitted values ---
y0_hat <- fitted(object)
mean((y0-y0_hat)^2)
#--- predicted values ---
y1_hat <- predict(object,newx=X1)
mean((y1-y1_hat)^2) # increase in MSE?
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.