I'm interested in using multiple factor analysis to analyze data collected from ceramic sherds. The data is pretty complicated, containing both continuous variables (vessel rim diameter, vessel wall thickness) and grouped categorical variables (presence or absence of base- and over- glazes on the vessel interior and exterior). After scaling and centering the continuous variables, my data looks something like this:
row.names RimDiameter SherdThickness2cmBelowRim BGIBrown BGIclear...
23 -1.05924698 0.1160736 0 1...
56 0.15586427 -0.7386500 1 0...
Using FactoMineR, I tried running MFA as follows:
sherdMFA = MFA(cleanRimGlaze[,-1], group=c(2,17,13,1,1),
type=c("s",rep("n",4)), ncp=5,
name.group=c("RimDiamThickness","BGI","BGE","LI", "LE"))
but it produces this error
Error in MFA(cleanRimGlaze[, -1], group = c(2, 17, 13, 1, 1), type = c("s", :
not convenient group definition
I can't figure out how to fix this error.
Looking at the MFA example on the the FactoMineR website, it seems that MFA is built to handle categorical variables as factors, and converting my dummy variables to factor levels might solve the group definition problem. I have tried this (see my painfully slow learning in the comments), but MFA expects more than two factors per column, so dummy variables seem not to be the desired input. However, because in my data it's possible for multiple glazes to be present, it seems weird to have separate factors for "brown", "clear", and "clear and brown". Am I right in thinking that it's better to use dichotomous variables for presence/absence, and simply mark presence for both brown and clear? Is there a way to run MFA in FactoMineR with categorical variables as dummy variables? Or maybe even a more appropriate statistical analysis?
Fixed several errors as follows:
- Ditched the [,-1] because it was causing the "not convenient group definition" error.
- Converted qualitative columns to factors with two levels to fix the "factors are not defined in the qualitative groups" error.
- Removed qualitative columns which contained only one of the two factors to fix the " Error in contrasts<-(tmp, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels " error that popped up.
And now MFA runs. I'm still curious about people's opinions on the appropriateness of multiple factor analysis for such data.
My sample (around 300 lustreware sherds from a much larger number excavated in the 1930's) contained 81 rim sherds. For these sherds, rim diameter was estimated, thickness of sherd 2 cm below rim was measured, and presence or absence of difference colored glazes was measured on the interior and exterior of the sherds (for example, opaque blue, transparent blue, white, clear, lustre, turquoise, no glaze visible).
Because certain interior-exterior combinations seemed common, like white glaze on the interior and blue glaze on the exterior with lustre overglaze on both, it seemed reasonable to have both "Base Glaze Interior Blue" and "Base Glaze Exterior Blue" variables, as well as "Over Glaze Interior" and "Over Glaze Exterior" variables for lustre. This amounts to 20 variables and a row.names for the sherd identifiers. 20 variables to a sample size of 81 seemed to scrape by as acceptable for such analysis, although obviously a larger sample size would be desirable (I'm looking at Sample size and subject to item ratio in principal components analysis for this, but you might know more recent work it). There is a lot more ceramic material available, so any hypotheses developed based on this smaller sample could be tested with more data collection.
I chose MFA because the data mixes continuous and categorical variables. As far as groups go, it seemed like a good idea to combine all of the presence/absence for the base glazes on the interior together, and those on the exterior together. By analogy, the presence of lustre overglaze on interior and exterior each were assigned a group, and finally the highly correlated estimated rim diameter and sherd thickness also got their own group (making 1 continuous group and 4 categorical groups). My first thought was PCA, but the categorical glaze data, while convertible to dummy variables, breaks the normal distribution assumption upon which PCA is predicated. I looked at Latent Class Analysis too, but that didn't seem suited to the continuous data of the rim diameter and sherd thickness variables. MFA seemed capable of handling both, and acknowledging the real groups present in the data collected.
Many thanks to @dcarlson for his clarifying questions.
contrasts<-(*tmp*, value = contr.funs[1 + isOF[nn]]) : contrasts can be applied only to factors with 2 or more levels – AlexB Dec 22 '12 at 22:11