0

My goal is to do a non-negative PCA using nsprcopm() (version 0.5.1.2 ) on my data and extract the values of PCs. I do it as follows in R version 3.5.0:

nnpca <- nsprcomp(mydata[,10:16], center = T, scale. = T, nneg = T)

The key is that I need to enforce non-negativity (because in the next step I will be using glm(..., family = Gamma()), and glm does not accept negative values with Gamma)

The problem is that nsprcopm() produces negative values for PCs. Here is a snapshot of the nnpca$x: enter image description here

Any idea??! Is this is a bug for nsprcomp() or what? Am I missing something?!

deeep
  • 33
  • 5
  • 1
    Please provide data for a [reproducible example](https://stackoverflow.com/a/5963610/2359523), although if this is more stats than coding, may do better at [CrossValidated](https://stats.stackexchange.com/). – Anonymous coward Sep 25 '18 at 16:50

1 Answers1

0

I found the issue, and just put it here for future reference if anybody encounters similar problem:

The problem arises from the argument center = T. When True, nsprcomp tries to shift all PCs so that they are around the center of coordinate. This will inevitably make some PCs negative (even though the original values are positive).

It can be overcome by center = F

deeep
  • 33
  • 5