I am working with an insurance dataset with around 77 predictors which are all categorical with multiple categories each represented by a number for example one such variable can have 20 levels few of them are given below: " 1 High Income, expensive child 2 Very Important Provincials 3 High status seniors 4 Affluent senior apartments 5 Mixed seniors 6 Career and childcare 7 Dinki's (double income no kids) 8 Middle class families 9 Modern, complete families 10 Stable family 11 Family starters"

Now i am using the stats package prcomp() over the dataset and i am getting the following error

Error in svd(x, nu = 0) : infinite or missing values in 'x'

My ultimate objective is to reduce the predictors to around 20 from 77 and classify who will buy a new insurance policy. can anyone help please.

Thanks Dwiti

  • 1
    $\begingroup$ Doing PCA on categorical variables seems rather unusual. Could you elaborate on what you hope it will achieve? The error message seems unambiguous you have missing or infinite values in your data. $\endgroup$ – mdewey Dec 29 '16 at 9:43

For a better understanding of PCA you can read this post.

As Mdewey mentioned, PCA is not suitable for such data. The error may be because the variables are non-numeric. Regardless, you shouldn't be using PCA in this instance.

As mentioned in previous responses, you may be able to use Multiple Factor Analysis for your purposes. In R, you should be able to use the MFA function in the FactoMineR package.

Usage would be:

res <- MFA(wine, group=c(2,5,3,10,9,2), type=c("n",rep("s",5)),
ncp=5, name.group=c("orig","olf","vis","olfag","gust","ens"),

This example has mixed categorical and numerical data and is explained in detail in this video (just watch the first few mins).

  • $\begingroup$ Of course since we do not know why the OP wants to throw away four fifths of his data there may be completely different options but as you say PCA is not the way to go. $\endgroup$ – mdewey Dec 29 '16 at 13:26
  • $\begingroup$ Common sense could also be part of the approach. If variables are obviously not related to the outcome then they could be dropped by the expert/OP. $\endgroup$ – Simon Jan 1 '17 at 1:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.