| transfo_newdata | R Documentation |
transfo.
Based on the output of transfo, transform the variables using Yeo-Johnson and/or Box-Cox transformations with the previously estimated parameters and standardization.
transfo_newdata(Xnew, transfo.out)
Xnew |
A data matrix with d columns, which contain the variables to be transformed. The number of columns and their names must be the same as those of the original data on which |
transfo.out |
The output of a call to |
Returns a matrix with transformed variables.
J. Raymaekers and P.J. Rousseeuw
J. Raymaekers and P.J. Rousseeuw (2021). Transforming variables to central normality. Machine Learning. \Sexpr[results=rd,stage=build]{tools:::Rd_expr_doi("10.1007/s10994-021-05960-5")}(link to open access pdf)
transfo
set.seed(123); tempraw <- matrix(rnorm(2000), ncol = 2) tempx <- cbind(tempraw[, 1],exp(tempraw[, 2])) tempy <- 0.5 * tempraw[, 1] + 0.5 * tempraw[, 2] + 1 x <- tempx[1:900, ] y <- tempy[1:900] tx.out <- transfo(x, type = "bestObj") tx.out$ttypes tx.out$lambdahats tx <- tx.out$Y lm.out <- lm(y ~ tx) summary(lm.out) xnew <- tempx[901:1000, ] xtnew <- transfo_newdata(xnew, tx.out) yhatnew <- tcrossprod(lm.out$coefficients, cbind(1, xtnew)) plot(tempy[901:1000], yhatnew); abline(0, 1)