I have collected data on 293 individuals. I measured the concentration of the same 7 Substances in each individual, represented by Sub1:Sub7. The concentration of these Substances may be different in individuals from different Locations. I am interested in seeing how well the Individuals can be separated based on their concentrations of these Substances. I am also interested in seeing how these Substances may be correlated with each other, as the concentration of some may effect the concentration of others. Each Individual in my data set is represented by a unique ID number. Three "nested" grouping variables (Location, State, and Region) can be used to separate these individuals. Multiple Locations are in each State, and multiple States are part of larger Regions. The broadest grouping variable is Location, which has 26 levels (26 different locations). Each Location contains roughly 10 individuals (10 IDs). The State grouping variable contains 18 levels, and the Region grouping variable contains 9 levels. I want to use these grouping variables to see the level of refinement at which the Individuals can be separated using the Substances. My data is structured like this:

Location State Region  ID Sex Sub1 Sub2 Sub3 Sub4 Sub5 Sub6 Sub7
Loc1      FL     Reg1  1   F   0.123 0.222 ect...
Loc1      FL     Reg1  2   M
Loc2      FL     Reg1  3   F
Loc2      FL     Reg1  4   F
Loc3      GA     Reg1  5   F
Loc3      GA     Reg1  6   M
Loc4      GA     Reg1  7   F
Loc4      GA     Reg1  8   M
Loc5      NC     Reg2  9   F
Loc5      NC     Reg2  10  M
Loc6      SC     Reg2  11  M
Loc6      SC     Reg2  12  F
Loc7      SC     Reg2  13  F
Loc7      SC     Reg2  14  F

I want to ensure that I do not violating any critical assumptions and still reach the full potential of my analysis. My questions are: What assumptions do I need to be concerned about? What is the appropriate kind of ANOVA to use in R (aov, anova?) and post hoc test? What would be the best classification method to use on this data, and if new individuals were added to the data set in the future (I was thinking Random forest, Bayes, or LDA)?


1 Answer 1


Firstly, there are a couple of things you need to be careful about. LDA, RF, and NBC are classifiers, so this assumes that each object (person) is assigned to a class label. Your question, however, states that you want to be able to somehow predict individuals based on concentration values, which implies a 293-class prediction problem. You didn't say you wanted to use concentration values to predict location, state, or region. This would be impossible since would only have 1 object per class label (a sparse or ill-conditioned problem).

What you could do first is determine if there is a significant difference between concentration values (for each of the 7 substances) across location, state, and region using nested ANOVA. Nested ANOVA is a telescoping-type test of mean differences for concentration values for which you assign subject IDs within regions, within states, within locations. (lookup nested ANOVA examples in R). The main questions you want to answer with ANOVA is: Does region matter, does state matter, or does location matter, where "matter" implies: Is there a significant difference in average value of concentration for one (of the 7) substances across the various regions, states, locations? As a beginner, I would recommend running nested ANOVA with one dependent variable which is set to one of the 7 substances. (that is, you need to run 7 nested ANOVA analyses). There is a way to shotgun all 7 substances into nested ANOVA at one time, but if you don't know the multivariate Hotelling Test and/or multivariate repeated/nested MANOVA, don't go there.

For correlation between concentrations of the 7 substances, you can simply run Pearson (or Spearman rank) correlation for the entire dataset, and then run correlation of the same within each region, state, or location. You don't have to do this, but it could reveal different patterns. I have never heard of a nested correlation methods.

You could also run a regression analyses instead of ANOVA by using a "panel data" approach. (lookup panel data-based regression analysis of the Boston Housing data, for which there are zip codes within neighborhoods, within counties, etc.) For R, lookup something like "panel data analysis using R". I like to use GEE regression for panel data (nested data) instead of using nested ANOVA, since I commonly run regression instead of the ANOVA (it's the same thing).

Now that we are done addressing the nested hierarchy of your data, it's important to note that LDA, RF, NBC are not nested-friendly, but rather are for straightforward unnested classification analysis. But what you could do is determine if concentration values among the 7 substances predict region, state, or location based on LDA, RF, NBC, etc., in which you use the class labels for region, state, or location as the categorical outcome you are trying to predict.

  • $\begingroup$ thank you for your input. I would like to clarify that I do want to use concentration values to predict location, state, or region. My belief is that this likely can be done at the broadest level (Region), but maybe not at the more refined levels of State and Location, at least not as accurately. Each individual is assigned the Location State and Region from which they were sampled. I want to see if these grouping variables can be predicted based on the concentrations. I will attempt to clarify this in my post\ $\endgroup$
    – Ryan
    Commented Dec 30, 2019 at 0:57
  • $\begingroup$ okay, then just try running LDA, RF, NBC with the 7 features for concentration as predictors, and either region, state, or location set as the class variable (each person will have a class label). That is, do these runs (LDA, RF, NBC) three times, once with region as the class label, once with state as the class label, and once with location as the class label. $\endgroup$
    – user32398
    Commented Dec 30, 2019 at 1:19
  • $\begingroup$ would you still suggest doing an anova first? in which case would it be appropriate to use the nested anova as previously suggested, or should I use the aov() function to see if differences do exist in each concentration (within each grouping variable) and TukeyHSD to see where those differences are? $\endgroup$
    – Ryan
    Commented Dec 30, 2019 at 4:13
  • $\begingroup$ yes, nested ANOVA should be run first. It's the only appropriate statistical analysis which can be done -- since the data are nested. Check that the histogram of each concentration is normally distributed (Shapiro-Wilk test, or Lilleifors test, or Kolmogorov-Smirnov test), and if not transform each concentraiton variable to ranks, then nested ANOVA. If you know transformations, then transform concentrations into van der Waerden scores before nested ANOVA. $\endgroup$
    – user32398
    Commented Dec 30, 2019 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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