Learn R Programming

cellWise (version 2.5.3)

transfo_newdata: Transform variables based on the output of transfo.

Description

Based on the output of transfo, transform the variables using Yeo-Johnson and/or Box-Cox transformations with the previously estimated parameters and standardization.

Usage

transfo_newdata(Xnew, transfo.out)

Value

Returns a matrix with transformed variables.

Arguments

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 was run. The number of rows may be different.

transfo.out

The output of a call to transfo.

Author

J. Raymaekers and P.J. Rousseeuw

References

J. Raymaekers and P.J. Rousseeuw (2021). Transforming variables to central normality. Machine Learning. tools:::Rd_expr_doi("10.1007/s10994-021-05960-5")(link to open access pdf)

See Also

transfo

Examples

Run this code
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)

Run the code above in your browser using DataLab