I have a dataset containing multiple proportions that add up to 1. I am interested in the change of these proportions along a gradient (see below for example data).
gradient <- 1:99 A1 <- gradient * 0.005 A2 <- gradient * 0.004 A3 <- 1 - (A1 + A2) df <- data.frame(gradient = gradient, A1 = A1, A2 = A2, A3 = A3) require(ggplot2) require(reshape2) dfm <- melt(df, id = "gradient") ggplot(dfm, aes(x = gradient, y = value, fill = variable)) + geom_area()
Additional information: It need not be necessarily linear, I did this just for easiness of the example. The original counts from which these proportions are calculated are also available. The real dataset contains more variable adding up to 1 (e.g. B1, B2 & B3, C1 to C4, etc) - so a hint for a multivariate solution is would be also helpful... But for now I'll stick on the univariate side of statistics.
Question: How can one analyze such kind of data? I've read a little bit around, and perhaps a multinomial model or a glm is suited? - If I run 3 (or 2) glms, how can I incorporate the constraint that the predicted values sum up to 1? I don't want to only plot such kind of data, I also want to do a deeper regression like analysis. I preferably want to use R - how can I do this in R?