ScoreYJpn

ScoreYJpn computes the score test for YJ transformation for pos and neg observations

Syntax

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(λ) 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 oftern violated in data analysis. Accordingly, Atkinson et al (2019) and (2020) extend the Yeo-Johnson transformation to allow two values of the transformations parameter: λN for negative observations and λ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.

example

outSC =ScoreYJpn(y, X) Ex in which positive and negative observations require the same lambda.

example

outSC =ScoreYJpn(y, X, Name, Value) Ex in which positive and negative observation require different lambdas.

Examples

expand all

  • Ex in which positive and negative observations require the same lambda.
  • rng('default')
    rng(1)
    n=100;
    y=randn(n,1);
    % Transform the value to find out if we can recover the true value of
    % the transformation parameter
    la=0.5;
    ytra=normYJ(y,[],la,'inverse',true);
    % Start the analysis
    X=ones(n,1);
    [outSC]=ScoreYJ(ytra,X,'intercept',0);
    [outSCpn]=ScoreYJpn(ytra,X,'intercept',0);
    la=[-1 -0.5 0 0.5 1]';
    disp([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.
       -1.0000   40.2357   24.1288   15.7149
       -0.5000   20.4741   14.7964    9.9619
             0    8.9009    6.9774    4.5230
        0.5000    1.3042    0.2740   -1.0664
        1.0000   -4.8797   -6.2978   -7.9574
    
    

  • Ex in which positive and negative observation require different lambdas.
  • rng(1000)
    n=100;
    y=randn(n,1);
    % Tranform in a different way positive and negative values
    lapos=0;
    ytrapos=normYJ(y(y>=0),[],lapos,'inverse',true);
    laneg=1;
    ytraneg=normYJ(y(y<0),[],laneg,'inverse',true);
    ytra=[ytrapos; ytraneg];
    % Start the analysis
    X=ones(n,1);
    [outSC]=ScoreYJ(ytra,X,'intercept',0);
    [outSCpn]=ScoreYJpn(ytra,X,'intercept',0);
    la=[-1 -0.5 0 0.5 1]';
    disp([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. However when lambda=0.5 the score test for negative
    % observations is highly significant. The difference between the test for
    % positive and the test for negative is 2.7597+0.7744=3.5341, which is very
    % large. This indicates that the two tails need a different value of the
    % transformation parameter.
       -1.0000   89.5466   39.6867   28.3433
       -0.5000   33.4110   24.9236   19.4072
             0   10.3643   11.4446   10.8674
        0.5000   -0.7744    0.8272    2.7597
        1.0000   -9.8327   -9.4050   -6.8708
    
    

    Related Examples

    expand all

  • Extended score with all default options for the wool data.
  • Load the wool data.

    XX=load('wool.txt');
    y=XX(:,end);
    X=XX(:,1:end-1);
    % Score test using the five most common values of lambda.
    % In this case (given that all observations are positive the extended
    % score test for positive observations reduces to the standard score test
    % while that for negative is equal to NaN.
    [outSc]=ScoreYJpn(y,X);

  • Extended score test using Darwin data given by Yeo and Yohnson.
  • y=[6.1, -8.4, 1.0, 2.0, 0.7, 2.9, 3.5, 5.1, 1.8, 3.6, 7.0, 3.0, 9.3, 7.5 -6.0]';
    n=length(y);
    X=ones(n,1);
    % Score and extended score test in the grid of lambda 1, 1.1, ..., 2
    la=[1:0.1:2];
    % Given that there are no explanatory variables the test must be
    % called with intercept 0
    outpn=ScoreYJpn(y,X,'intercept',0,'la',la);
    out=ScoreYJ(y,X,'intercept',0,'la',la);
    disp([la' outpn.Score(:,1) out.Score outpn.Score(:,2)])

    Input Arguments

    expand all

    y — Response variable. Vector.

    A vector with n elements that contains the response variable. It can be either a row or a column vector.

    Data Types: single| double

    X — Predictor variables. Matrix.

    Data matrix of explanatory variables (also called 'regressors') of dimension (n x p-1). Rows of X represent observations, and columns represent variables.

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

    Data Types: single| double

    Name-Value Pair Arguments

    Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

    Example: 'intercept',false , 'la',[0 0.5] , 'nocheck',1

    intercept —Indicator for constant term.true (default) | false.

    Indicator for the constant term (intercept) in the fit, specified as the comma-separated pair consisting of 'Intercept' and either true to include or false to remove the constant term from the model.

    Example: 'intercept',false

    Data Types: boolean

    la —transformation parameter.vector.

    It specifies for which values of the transformation parameter it is necessary to compute the score test. Default value of lambda is la=[-1 -0.5 0 0.5 1]; that is the five most common values of lambda

    Example: 'la',[0 0.5]

    Data Types: double

    nocheck —Check input arguments.scalar.

    If nocheck is equal to 1 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. As default nocheck=0.

    Example: 'nocheck',1

    Data Types: double

    Output Arguments

    expand all

    outSC — description Structure

    containing the following fields:

    Value Description
    Score

    score test. Matrix.

    Matrix of size length(lambda)-by-3 which contains the value of the score test for each value of lambda specfied 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 outSc.Score is equal to 5 and will contain the values of the score test for the 5 most common values of lambda.

    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. (2020), The Box-Cox Transformation: Review and Extensions, "Statistical Science", in press.

    See Also

    | |

    This page has been automatically generated by our routine publishFS