0

Issue:

I have a data frame (called Yeo) containing six parameters with continuous values (columns 5-11)(see parameters below) and I conducted a Shapiro-Wilk test to determine whether or not the univariate samples came from a normal distribution. For each parameter, the residuals showed non-normality and it's skewed, so I want to transform my variables using both the yjPower (Yeo transformation) and the bcPower(Box Cox transformation) families to compare both transformations.

I have used this R code below before on many occassions so I know it works. However, for this data frame, I keep getting this error (see below). Unfortunately, I cannot provide a reproducible example online as the data belongs to three different organisations. I have opened an old data frame with the same parameters and my R code runs absolutely fine. I really can't figure out a solution.

Would anybody be able to please help me understand this error message below?

Many thanks if you can advise.

Error

transform=powerTransform(as.matrix(Yeo[5:11]), family= "yjPower")

Error

Error in optim(start, llik, hessian = TRUE, method = method, ...) : 
  non-finite finite-difference value [1]

#save transformed data in strand_trans to compare both
stand_trans=Yeo

stand_trans[,5]=yjPower(Yeo[,5],transform$lambda[1])
stand_trans[,6]=yjPower(Yeo[,6],transform$lambda[2])
stand_trans[,7]=yjPower(Yeo[,7],transform$lambda[3])
stand_trans[,8]=yjPower(Yeo[,8],transform$lambda[4])
stand_trans[,9]=yjPower(Yeo[,9],transform$lambda[5])
stand_trans[,10]=yjPower(Yeo[,10],transform$lambda[6])
stand_trans[,11]=yjPower(Yeo[,11],transform$lambda[7])

Parameters

'data.frame':   888 obs. of  14 variables:
 $ ID               : num  1 2 3 4 5 6 7 8 9 10 ...
 $ Year             : num  2020 2020 2020 2020 2020 2020 2020 2020 2020 2020 ...
 $ Date             : Factor w/ 19 levels "","01.09.2019",..: 19 19 19 19 19 19 19 17 17 17 ...
 $ Country          : Factor w/ 3 levels "","France","Argentina": 3 3 3 3 3 3 3 3 3 3 ...
 $ Low.Freq         : num  4209 8607 9361 9047 7979 ...
 $ High.Freq        : num  15770 18220 19853 18220 17843 ...
 $ Start.Freq       : num  4436 13945 16264 12283 12691 ...
 $ End.Freq         : num  4436 13945 16264 12283 12691 ...
 $ Peak.Freq        : num  4594 8906 11531 10781 8812 ...
 $ Center.Freq      : num  1.137 0.754 0.785 0.691 0.883 ...
 $ Delta.Freq       : num  11560 9613 10492 9173 9864 ...
Alice Hobbs
  • 1,021
  • 1
  • 15
  • 31
  • You may pass additional parameters in the variadic argument (`...`) as it is calling `optim` internally. According to the documentation `Additional arguments that used in the interative algorithm; defaults are generally adequate. For use with the bcnPower family, a convergence criterion can be set with conv=.0001 the default, and a minimum positive value of the location parameter can be set, with default gamma.min=.1.`. It is not easy to suggest a solution when there is no reproducible example. – akrun Sep 02 '22 at 17:42
  • Why are you doing this? I ask because there is a widespread but usually false notion that normality is necessary when doing regression operations. – IRTFM Sep 02 '22 at 20:31
  • I'm not doing regression, more dimension reduction. My parameters are measured in Hertz, and seconds from a spectrogram. from two different populations. My values are very wide-ranging and are measured in different units. My visual diagnostic tests and the results from the Shapiro Wilks testing point towards skewness and non-normality – Alice Hobbs Sep 03 '22 at 07:54
  • Akrun: Would you mind speaking via email? – Alice Hobbs Sep 03 '22 at 10:46
  • I tried your suggestions and this was the output. transform=powerTransform(as.matrix(Yeo[5:11]), family= "yjPower", conv=.0001, gamma.min=.1) Error in fam(Y, lambda, j = TRUE, ...) : unused arguments (conv = 1e-04, gamma.min = 0.1) – Alice Hobbs Sep 03 '22 at 11:20
  • One question: If I have values of zero in the cells, will this affect this error message? The data frame where these code works do not have any. Many thanks in advance if you can help – Alice Hobbs Sep 03 '22 at 11:25

0 Answers0