scoreYJ: Computes the score test for Yeo and Johnson transformation

View source: R/scoreyj.R

scoreYJR Documentation

Computes the score test for Yeo and Johnson transformation

Description

Computes the score test for Yeo and Johnson transformation

Usage

scoreYJ(
  x,
  y,
  intercept = TRUE,
  la = c(-1, -0.5, 0, 0.5, 1),
  lik = FALSE,
  nocheck = FALSE,
  tukey1df = 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.

lik

likelihood for the augmented model. If true the value of the likelihood for the augmented model will be calculated and returend otherwise (default) only the value of the score test will be given

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.

tukey1df

Tukey's one degree of freedome test for non-additivity. The constructed variable is given by

w_T(\lambda)= (\hat z(\lambda) - \overline z(\lambda))^2 / 2 \overline z(\lambda)

where z(\lambda) is the transformed response, and \hat z(\lambda) are the fitted values on the transformed response. The t test on the constructed variable above provides a test from departures from the assumed linear model and is known in the literature as Tukey's one degree of freedome test for non-additivity. If tukey1df=TRUE the test is computed and returned in ScoreT else (default) the value of the test is not computed.

trace

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

...

potential further arguments passed to lower level functions.

Value

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

  • Score: score test. A vector of length length(lambda) which contains the value of the score test for each value of lambda specified in the optional input parameter la. If la is not specified, the vector will be of length 5 and contains the values of the score test for the 5 most common values of lambda.

  • ScoreT: value of the Tukey's one degree of freedome test for non-additivity. This output is produced only if tukey1df=TRUE.

  • Lik: value of the likelihood. This output is produced only if lik=TRUE.

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.

Examples


 ## Not run: 
 ##  ScoreYJ with all default options for the wool data.
 ##  Load the wool data.
 
   data(wool)
   XX <- wool
   y <- XX[, ncol(XX)]
   X <- XX[, 1:(ncol(XX)-1), drop=FALSE]

   (out <- scoreYJ(X, y))                    # call 'scoreYJ' with all default parameters
   (out <- scoreYJ(X, y, lik=TRUE))          # return the likelihood

   data(loyalty)
   head(loyalty)
   y=loyalty[, 4]
   X=loyalty[, 1:3]

   ##    la is a vector containing the values of \lambda which have to be tested
   (out <- scoreYJ(X, y, la=c(0.25, 1/3, 0.4, 0.5)))
   (out <- scoreYJ(X, y, la=c(0.25, 1/3, 0.4, 0.5), lik=TRUE))
 
## End(Not run)


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