# How to test for correlation with data that violates assumption of linearity and is not monotonic?

I have sampled 8 individuals (birds) from two regions. For each of these 16 individuals I have sampled 9 feathers that have each grown in sequential order (from 1 to 9). Next I have measure both carbon and nitrogen isotopes in each of the feather samples. I have plotted (Fig. 1) my data and in some individuals the relationship between the isotope value and feather position is linear, in some cases monotonic, and in a few cases neither.

I am looking for a non-parametric (?) method to test these three alternative hypotheses for each individual in my dataset.

H1: If the 9 sequentially grown feathers on each individual are grown in the same place under the same diet, the isotope values will be highly correlated with feather position and the regression line essentially flat.

H2: If an individual moves or changes their diet in a systematic way, the isotope values and feather position will correlated but the regression line will be either positive or negative.

H3: If the individual abruptly moves or changes their diet, the isotope values will be uncorrelated and the relationship will not be linear.

Finally, I would like to test the hypothesis that their are differences between the relationship of feather isotopes and feather position is different in individuals between the two regions.

This would more intuitive if all the data (for each individual) was linear or monotonic, but they are not. From my nascent understanding for using either a Pearson's correlation or GLM, these tests assume the data is linear, while the Spearman's assumes the data is monotonic.

Sample Data:

WW_Wing_SI <- structure(list(Individual_ID = c("WW_08A_02", "WW_08A_02", "WW_08A_02",
"WW_08A_02", "WW_08A_02", "WW_08A_02", "WW_08A_02", "WW_08A_02",
"WW_08A_02", "WW_08A_03", "WW_08A_03", "WW_08A_03", "WW_08A_03",
"WW_08A_03", "WW_08A_03", "WW_08A_03", "WW_08A_03", "WW_08A_03",
"WW_08A_04", "WW_08A_04", "WW_08A_04", "WW_08A_04", "WW_08A_04",
"WW_08A_04", "WW_08A_04", "WW_08A_04", "WW_08A_04", "WW_08A_05",
"WW_08A_05", "WW_08A_05", "WW_08A_05", "WW_08A_05", "WW_08A_05",
"WW_08A_05", "WW_08A_05", "WW_08A_05", "WW_08A_06", "WW_08A_06",
"WW_08A_06", "WW_08A_06", "WW_08A_06", "WW_08A_06", "WW_08A_06",
"WW_08A_06", "WW_08A_06", "WW_08A_08", "WW_08A_08", "WW_08A_08",
"WW_08A_08", "WW_08A_08", "WW_08A_08", "WW_08A_08", "WW_08A_08",
"WW_08A_08", "WW_08A_09", "WW_08A_09", "WW_08A_09", "WW_08A_09",
"WW_08A_09", "WW_08A_09", "WW_08A_09", "WW_08A_09", "WW_08A_09",
"WW_08A_13", "WW_08A_13", "WW_08A_13", "WW_08A_13", "WW_08A_13",
"WW_08A_13", "WW_08A_13", "WW_08A_13", "WW_08A_13", "WW_08B_02",
"WW_08B_02", "WW_08B_02", "WW_08B_02", "WW_08B_02", "WW_08B_02",
"WW_08B_02", "WW_08B_02", "WW_08B_02", "WW_08G_01", "WW_08G_01",
"WW_08G_01", "WW_08G_01", "WW_08G_01", "WW_08G_01", "WW_08G_01",
"WW_08G_01", "WW_08G_01", "WW_08G_02", "WW_08G_02", "WW_08G_02",
"WW_08G_02", "WW_08G_02", "WW_08G_02", "WW_08G_02", "WW_08G_02",
"WW_08G_02", "WW_08G_05", "WW_08G_05", "WW_08G_05", "WW_08G_05",
"WW_08G_05", "WW_08G_05", "WW_08G_05", "WW_08G_05", "WW_08G_05",
"WW_08G_07", "WW_08G_07", "WW_08G_07", "WW_08G_07", "WW_08G_07",
"WW_08G_07", "WW_08G_07", "WW_08G_07", "WW_08G_07", "WW_08I_01",
"WW_08I_01", "WW_08I_01", "WW_08I_01", "WW_08I_01", "WW_08I_01",
"WW_08I_01", "WW_08I_01", "WW_08I_01", "WW_08I_03", "WW_08I_03",
"WW_08I_03", "WW_08I_03", "WW_08I_03", "WW_08I_03", "WW_08I_03",
"WW_08I_03", "WW_08I_03", "WW_08I_07", "WW_08I_07", "WW_08I_07",
"WW_08I_07", "WW_08I_07", "WW_08I_07", "WW_08I_07", "WW_08I_07",
"WW_08I_07", "WW_08I_12", "WW_08I_12", "WW_08I_12", "WW_08I_12",
"WW_08I_12", "WW_08I_12", "WW_08I_12", "WW_08I_12", "WW_08I_12"
), Feather = c("1", "2", "3", "4", "5", "6", "7", "8", "9", "1",
"2", "3", "4", "5", "6", "7", "8", "9", "1", "2", "3", "4", "5",
"6", "7", "8", "9", "1", "2", "3", "4", "5", "6", "7", "8", "9",
"1", "2", "3", "4", "5", "6", "7", "8", "9", "1", "2", "3", "4",
"5", "6", "7", "8", "9", "1", "2", "3", "4", "5", "6", "7", "8",
"9", "1", "2", "3", "4", "5", "6", "7", "8", "9", "1", "2", "3",
"4", "5", "6", "7", "8", "9", "1", "2", "3", "4", "5", "6", "7",
"8", "9", "1", "2", "3", "4", "5", "6", "7", "8", "9", "1", "2",
"3", "4", "5", "6", "7", "8", "9", "1", "2", "3", "4", "5", "6",
"7", "8", "9", "1", "2", "3", "4", "5", "6", "7", "8", "9", "1",
"2", "3", "4", "5", "6", "7", "8", "9", "1", "2", "3", "4", "5",
"6", "7", "8", "9", "1", "2", "3", "4", "5", "6", "7", "8", "9"
), Delta13C = c(-18.67, -19.16, -20.38, -20.96, -21.61, -21.65,
-21.31, -20.8, -21.28, -20.06, -20.3, -21.21, -22.9, -22.87,
-21.13, -20.68, -20.58, -20.69, -16.54, -15.6, -16.61, -19.65,
-20.98, -21.18, -21.7, -21.18, -21.33, -20.33, -20.28, -20.58,
-20.8, -21.24, -20.94, -20.54, -21.04, -20.42, -21.28, -21.24,
-21.22, -21.2, -21.47, -21.23, -21.89, -21.89, -21.6, -23.86,
-23.95, -24, -24.16, -24.93, -24.93, -24.48, -24.17, -23.1, -21.3,
-21.44, -21.49, -21.49, -21.1, -20.84, -20.78, -21.58, -20.76,
-21.34, -24.13, -23.03, -21.77, -21.4, -21.57, -21.45, -21.32,
-21.59, -20.87, -20.95, -20.76, -20.9, -21.02, -20.84, -21.11,
-20.64, -20.11, -20.32, -20.02, -19.92, -20.05, -20.23, -20.73,
-20.91, -19.87, -19.58, -19.35, -19.38, -19.7, -19.94, -20.43,
-20.08, -20.81, -20.9, -19.24, -21.2, -21.29, -21.85, -22.22,
-22.34, -22.42, -22.69, -22.75, -22.73, -21.61, -21.42, -21.84,
-21.68, -21.79, -21.49, -21.88, -21.62, -21.54, -18.3, -18.53,
-19.55, -20.18, -20.96, -21.08, -21.5, -17.42, -13.18, -22.3,
-22.2, -22.18, -22.14, -21.55, -20.85, -23.1, -20.75, -20.9,
-21.6, -21.77, -22.17, -22.21, -22.24, -22.47, -22.19, -21.89,
-21.89, -24.12, -24.08, -24, -24.2, -24.16, -22.87, -22.51, -22.12,
-22.3), Delta15N = c(7.35, 7.27, 7.23, 7.07, 7.13, 7.38, 6.98,
6.88, 6.72, 5.72, 5.76, 5.51, 6.12, 5.8, 5.34, 5.47, 5.78, 6.2,
7.33, 7.45, 7.3, 7.19, 7.56, 7.54, 8.12, 7.71, 7.44, 9.45, 9.81,
9.7, 9.08, 8.6, 9.34, 10.38, 9.67, 10.48, 7.71, 7.76, 7.95, 7.73,
7.69, 7.24, 6.64, 6.42, 7.31, 8.26, 8.1, 8.07, 8.7, 8.98, 9.44,
7.84, 7.26, 6.05, 8.04, 7.73, 7.55, 6.77, 6.99, 6.84, 7.09, 6.78,
7.07, 6.96, 6, 5.91, 6.48, 7.06, 7.27, 8.32, 7.85, 7.45, 6.9,
6.73, 6.97, 6.67, 6.76, 6.59, 6.58, 6.42, 6.3, 11.64, 11.83,
11.66, 11.3, 11.32, 11.29, 10.91, 10.77, 11.4, 9.5, 9.55, 9.22,
8.84, 8.89, 9.14, 9.8, 9.13, 8.51, 7.7, 7.8, 8.29, 9.65, 10.25,
13.67, 14.66, 13.48, 13.76, 8.7, 8.7, 8.36, 8.11, 8.47, 8.13,
6.88, 7.21, 7.16, 14.07, 13.91, 14.07, 14.26, 13.99, 13.51, 13.77,
14.83, 15.13, 10.93, 10.85, 11.31, 11.28, 11.96, 13.41, 8.12,
12.96, 12.03, 8.16, 8.29, 8.43, 8.53, 8.1, 7.65, 7.6, 7.51, 7.38,
6.44, 6.18, 6.33, 6.49, 6.34, 8.65, 7.73, 7.13, 7.07), Region = c("South",
"South", "South", "South", "South", "South", "South", "South",
"South", "South", "South", "South", "South", "South", "South",
"South", "South", "South", "South", "South", "South", "South",
"South", "South", "South", "South", "South", "South", "South",
"South", "South", "South", "South", "South", "South", "South",
"South", "South", "South", "South", "South", "South", "South",
"South", "South", "South", "South", "South", "South", "South",
"South", "South", "South", "South", "South", "South", "South",
"South", "South", "South", "South", "South", "South", "South",
"South", "South", "South", "South", "South", "South", "South",
"South", "South", "South", "South", "South", "South", "South",
"South", "South", "South", "North", "North", "North", "North",
"North", "North", "North", "North", "North", "North", "North",
"North", "North", "North", "North", "North", "North", "North",
"North", "North", "North", "North", "North", "North", "North",
"North", "North", "North", "North", "North", "North", "North",
"North", "North", "North", "North", "North", "North", "North",
"North", "North", "North", "North", "North", "North", "North",
"North", "North", "North", "North", "North", "North", "North",
"North", "North", "North", "North", "North", "North", "North",
"North", "North", "North", "North", "North", "North", "North",
"North", "North", "North", "North", "North")), .Names = c("Individual_ID",
"Feather", "Delta13C", "Delta15N", "Region"), row.names = c(NA,
153L), class = "data.frame")


WW_Wing_SI$Feather <- as.numeric(WW_Wing_SI$Feather)
library(ggplot2)
theme_set(theme_bw())
ggplot(WW_Wing_SI,aes(Feather,Delta15N,fill=Individual,colour=Individual))+
geom_line()+geom_smooth(method="lm",formula=y~poly(x,2),linetype=2)
library(nlme)
m1 <- lmList(Delta15N~poly(Feather,2)|Individual,data=WW_Wing_SI)
summary(m1)


Looking at some of the coefficients in abbreviated form:

, , poly(Feather, 2)1

Estimate Std. Error t value Pr(>|t|)
WW_08A_08    -1.43       0.67   -2.14  4.3e-02
WW_08B_02    -0.54       0.67   -0.81  4.3e-01
WW_08G_01    -0.73       0.67   -1.09  2.9e-01
WW_08G_05     7.49       0.67   11.21  5.0e-11


At alpha=0.05, feathers A_08 and G_05 have significant linear trends. (Not really worth worrying about interpreting a linear trend in the presence of a quadratic term -- see below.)

, , poly(Feather, 2)2

Estimate Std. Error t value Pr(>|t|)
WW_08A_08    -2.03       0.67   -3.04   0.0056
WW_08B_02    -0.14       0.67   -0.21   0.8358
WW_08G_01     0.23       0.67    0.35   0.7291
WW_08G_05    -0.67       0.67   -1.00   0.3271


At alpha=0.05, feather A_08 has a significant quadratic trend.

• Do you have any suggestions how I might be able to test to see if the trends (or lack thereof) for individuals are different between groups (=Region)? Feb 8 '13 at 15:20
• I don't think using polynomial terms is a good idea, for two reasons. First, how to decide what degree to use if you really have no idea whether all the series even are non-monotonic? Second, what is the physical interpretation of a "significant quadratic trend"? How do you turn that into inferences about whether the maxima are different between groups and whether the times when they reach their maxima are different? Jun 26 '13 at 16:03
• I agree that quadratic models have lots of problems. But I would argue that it is a reasonable, simple test for non-monotonicity. The physical interpretation of a "significant quadratic trend" is "we can reject a null model of linearity in favor of the simplest model that allows non-monotonicity" Jun 26 '13 at 18:36