elianachristou / fquantdr

GNU General Public License v3.0
0 stars 0 forks source link

`rigpower` Fails With Complex Eigenvalues #83

Open AustinMichael2418 opened 2 months ago

AustinMichael2418 commented 2 months ago

While working on test data, I found that when fcqs is run on the real data from the Dropbox, it results in complex eigenvalues in rigpower, resulting in an error in eval.

This is the code I ran to analyze the data:

load("./fmri.data.com.Rdata")

n = dim(fmri.data.com)[1]
ntx = dim(fmri.data.com)[2]
p = dim(fmri.data.com)[3]

tt = seq(0, 1, length = ntx)
NYU_phenotypic = read.csv("./NYU_phenotypic.csv", sep = ";")
y = NYU_phenotypic[, "ADHD.Index"][which(NYU_phenotypic[, "DX"] == 1 & NYU_phenotypic[, "ADHD.Index"] != -999 & NYU_phenotypic[, "QC_Rest_1"] != "N/A")]
nbasis = 15
d_tau = 2
tau = 0.1
Xc = fmri.data.com
res = fquantdr::fcqs(Xc, y, tt, nbasis, tau, d_tau)

And this gives the error, Error in max(eval) : invalid 'type' (complex) of argument

The error can be found here:

https://github.com/elianachristou/fquantdr/blob/main/R/rigpower.R#L63

Precious' pull request, #82 , should provide a temporary fix preventing the error from showing up, but additional consideration should likely be taken to determine why complex eigenvalues appear and how to deal with these, whether by finding the real part as Precious did, finding the magnitude, or otherwise modifying the eigenvalues before they are used.

astitz13 commented 2 months ago

First off, sorry for using my other old account for creating this issue, but in addition to this error, sonf throws The number of observations of y (72) should be greater than the number or predictors of xfd (116). I am not sure if this should be a check on the data or if there is simply not enough data to run FCQS on the data set reliably.

elianachristou commented 2 months ago

The first issue is resolved: add the symmetric = T option on the eigenvalue decomposition. As far as the second comment, you are right. Since we are performing dimension reduction, I don't think we need n > p. I will look more into it though.