martinctc / rwa

Package for running Relative Weights Analysis in R
https://martinctc.github.io/rwa
12 stars 8 forks source link

Negative eigenvalues - do not get results #10

Closed Tepico closed 9 months ago

Tepico commented 3 years ago

I have data set with one Y and 16 predictor variables. By running the rwa function I got not get an output. After looking into the code I get some negative eigenvalues which force the next step sqrt(eigenvalues) to crash. Can someone please help to fix this issue?

The data is attached.

RWA.xlsx

martinctc commented 3 years ago

Thanks for the issue @Tepico - it's rather unusual and I don't have an immediate response. I can look at it this week with the data you shared. Can you confirm whether you just got no output, or whether you got an error message? Also, were you using the GitHub development version or the version from CRAN?

Tepico commented 3 years ago

Hi @martinctc I got an error message that "In sqrt(D) : NaNs are created". I got an output for the correlation matrices but the other tables are filled with: NaN. As mentioned, tis happens after taking the squaroot of a negative eigenvalue. I'm unsing the CRAN version.

stonid commented 3 years ago

Hi @Tepico, Do you have missing data? If so, that may be the problem. The default method for this function is pairwise deletion. In some instances, that can lead to a correlation matrix that is not positive definite. To solve this, you could run listwise deletion on your data prior to running the function (e.g. na.omit(df)). If missing data was the culprit, this should fix it.

gitkomodo commented 2 years ago

In another issue @martinctc links to a paper by Tonidandel and LeBreton stating 'this package merely implements what they set up originally'. In that paper I'm reading: "Let us assume that X is an N x J matrix in standard score form with at least as many rows (subjects) as columns (predictors)."

I didn't dive into (all) details, but my first guess would be that the data attached to this issue doesn't match with this assumption as it has 16 predictors and only 5 rows. If this is the problem it may be advisable to check for this assumption in the core function and issue a warning/error if it is not fulfilled.

martinctc commented 9 months ago

Closing this due to inactivity - thank you for the discussion!