1

I am doing a factor analysis from ESS dataset. I have chosen 8 IVs and combined 3 countries to create a dataframe. (All NA values are substituted by median)

# "United Kingdom","Denmark","Poland" income #
attach(ESS.GB.DK.PL)
table(income1 <- hinctnta,useNA="ifany")
ESS.GB.DK.PL$income <- as.numeric(hinctnta)
ESS.GB.DK.PL$income [is.na(ESS.GB.DK.PL$income)] <- median(as.numeric(ESS.GB.DK.PL$income), na.rm=T)

But there is an error when i try to run the 7th variable (income): Error in solve.default(cv) : Lapack routine dgesv: system is exactly singular: U[8,8] = 0

# Duplicated the 8 variables to create a dataframe
ESS.GB.DK.PL[,582:589]<-ESS.GB.DK.PL[,574:581]
for (i in 582:589) { ESS.GB.DK.PL[,i]<- as.numeric(ESS.GB.DK.PL[,i]) }

# ~ Substitute missing values
for (i in 582:589) { ESS.GB.DK.PL[,i][is.na(ESS.GB.DK.PL[,i])]<-median(ESS.GB.DK.PL[,i],na.rm=T) }

# ~ Data Frame ******************
str(IV)
IV <- data.frame(ESS.GB.DK.PL[,582:589])
f1 <- factanal(ESS.GB.DK.PL[,582:589], factors = 2)
print(f1,digits=2,cutoff=0,sort=T)

There is no problem with the first 7 variables, i can do a factor analysis with [,582:588] , but failed with [,582:589]. so my question is how to solve the last variable - income.

  • Hi! As the error hints, the problem is a resulting matrix that is singular, so it can't be inverted. This can happen when there's collinearity, so it's a data related issue. As an aside, we wary of using `attach` in your R code, as explained here: https://stackoverflow.com/questions/10067680/why-is-it-not-advisable-to-use-attach-in-r-and-what-should-i-use-instead – Juan Bosco May 10 '22 at 16:53
  • Update1: I have tried to do factor analysis with [,583:589] which included income, it works. so does it mean i cant do all 8 variables? – ihatecoding May 10 '22 at 16:55
  • I suggest you run checks for collinearity in that subset of your data. There's a chance income is perfectly correlated with another one. – Juan Bosco May 10 '22 at 17:01

0 Answers0