scoreYJpn: Computes the score test for YJ transformation for pos and neg...

View source: R/scoreyjpn.R

scoreYJpnR Documentation

Computes the score test for YJ transformation for pos and neg observations

Description

The transformations for negative and positive responses were determined by Yeo and Johnson (2000) by imposing the smoothness condition that the second derivative of zYJ(lambda) with respect to y be smooth at y = 0. However, some authors, for example Weisberg (2005), query the physical interpretability of this constraint which is often violated in data analysis. Accordingly, Atkinson et al (2019) and (2020) extend the Yeo-Johnson transformation to allow two values of the transformations parameter: lambda N for negative observations and lambda P for non-negative ones. ScoreYJpn computes:

  • 1) the t test associated with the constructed variable computed assuming a different transformation for positive observations keeping the value of the transformation parameter for negative observations fixed. In short, we call this test 'test for positive observations'.

  • 2) the t test associated with the constructed variable computed assuming a different transformation for negative observations keeping the value of the transformation parameter for positive observations fixed. In short, we call this test 'test for negative observations'.

  • 3) the F test for the joint presence of the two constructed variables described in points 1) and 2).

Usage

scoreYJpn(
  x,
  y,
  intercept = TRUE,
  la = c(-1, -0.5, 0, 0.5, 1),
  nocheck = FALSE,
  trace = FALSE,
  ...
)

Arguments

x

An n x p data matrix (n observations and p variables). Rows of x represent observations, and columns represent variables.

Missing values (NA's) and infinite values (Inf's) are allowed, since observations (rows) with missing or infinite values will automatically be excluded from the computations.

y

Response variable. A vector with n elements that contains the response variable.

intercept

wheather to use constant term (default is intercept=TRUE

la

values of the transformation parameter for which it is necessary to compute the score test. Default value of lambda is la=c(-1, -0.5, 0, 0.5, 1), i.e., the five most common values of lambda.

nocheck

Whether to check input arguments. If nocheck=TRUE no check is performed on matrix y and matrix X. Notice that y and X are left unchanged. In other words the additional column of ones for the intercept is not added. The default is nocheck=FALSE.

trace

Whether to print intermediate results. Default is trace=FALSE.

...

potential further arguments passed to lower level functions.

Value

An S3 object of class scoreYJpn.object will be returned which is basically a list containing the following elements:

  • la: vector containing the values of lambda for which the test is computed

  • Score: Matrix of size length(lambda)-by-3 that contains the value of the score test for each value of lambda specified in optional input parameter la. The first column refers to the test for positive observations, the second column refers to the test for negative observations and the third column refers to the F test for the joint presence of the two constructed variables. If la is not specified, the number of rows of the matrix Score is equal to 5 and will contain the values of the score test for the 5 most common values of lambda.

Author(s)

FSDA team, valentin.todorov@chello.at

References

Yeo, I.K. and Johnson, R. (2000), A new family of power transformations to improve normality or symmetry, "Biometrika", Vol. 87, pp. 954-959.

Atkinson, A.C. Riani, M., Corbellini A. (2019), The analysis of transformations for profit-and-loss data, Journal of the Royal Statistical Society, Series C, "Applied Statistics", https://doi.org/10.1111/rssc.12389

Atkinson, A.C. Riani, M. and Corbellini A. (2021), The Box–Cox Transformation: Review and Extensions, "Statistical Science", Vol. 36, pp. 239-255, https://doi.org/10.1214/20-STS778

Examples


 ## Not run: 
 ##  Example in which positive and negative observations require the same lambda
     set.seed(1234)
     n <- 100
     y <- rnorm(n)
     ## Transform the value to find out if we can recover the true value of
     ## the transformation parameter.
     la <- 0.5
     ytra <- normYJ(y, la=la, inverse=TRUE)
     
     ## Start the analysis
     X <- rep(1, n)
     outSC <- scoreYJ(X, ytra, intercept=FALSE)
     outSCpn <- scoreYJpn(X, ytra, intercept=FALSE)
     la <- c(-1, -0.5, 0, 0.5, 1)
     print(cbind(la,  outSCpn$Score[,1], outSC$Score, outSCpn$Score[,2]))

     ##  Comment: if we consider the 5 most common values of lambda,
     ##  the value of the score test when lambda=0.5 is the only one which is not
     ##  significant. Both values of the score test for positive and negative
     ##  observations confirm that this value of the transformation parameter is
     ##   OK for both sides of the distribution.

 
## End(Not run)


fsdaR documentation built on May 20, 2026, 1:07 a.m.