Take the 2-minute tour ×
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

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()

enter image description here

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 (eg. 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 dont 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?

share|improve this question
    
The command proprcspline in Stata might be what you're looking for (I know you want to use R, but maybe this could be a starting point): proprcspline computes a restricted cubic spline smooth of proportions of observations in each category of yvar given xvar, and graphs them as a stacked area plot. Optionally, these smoothed proportions can be adjusted for a set of control variables (cvars). –  andrea Mar 6 '12 at 13:02
    
Could you elaborate on what "interested in" means? Do you merely want to plot the proportions against gradient? Or do you have a deeper analysis in mind? If so, what is its nature--what precisely do you hope to learn from these data? Also, do you have the original counts available (which would be good) or only the proportions? Could you say a little more about what these data consist of and how they are collected? –  whuber Mar 12 '12 at 21:39
1  
@whuber: I want to do a deeper analysis with this data. My hypothesis is the proportions will change with the gradient. The counts are also available. –  EDi Mar 12 '12 at 22:21
1  
Sounds like you have compositional data. I don't know a lot about it, but Aitchison's work is the place to start. There's a package, compositions, on CRAN. –  Aaron Mar 13 '12 at 2:40
add comment

2 Answers 2

up vote 8 down vote accepted
+50

In one dimension, this sounds like a job for beta regression (with or without variable dispersion). This is a regression model with beta-distributed dependent variable, naturally 0-1 constrained. An R package is betareg and a paper describing its use is here.
For more than two proportions the usual extension of the Beta distribution leads to Dirichlet regression. An R package DirichletReg is available, described e.g. here.

There are some reasons not to use logit links and multinomial logistic regression for true compositional data, mostly to do with what strong assumptions they imply for the variance. However, if your data are all actually normalised counts (abundances?), those assumptions may be correct and Peter's suggestion would probably be the way to go.

share|improve this answer
    
Thank you for the links, i'll have a look at them. DirichletReg looks promising! For example Slide 3 of your link: "If the ‘probability’ of answering in a certain cateogory is spread across the choices, a Dirichlet approach is more informative." . Because i did not know how to do this with mlogit, because the choices need not to be unique. Also a good way of graphical respresentation - haven't thought about that... –  EDi Mar 8 '12 at 14:42
    
For graphics you might find the R functions splineplot and cdplot helpful. Indeed if you just wanted the fitted lines and didn't need a lot of regression machinery then you could probably coax cdplot into giving you the relevant curves (it's only density underneath) –  conjugateprior Mar 8 '12 at 21:27
    
Sorry, I meant to type spineplot above, obviously. –  conjugateprior Mar 9 '12 at 13:29
add comment

I am not sure exactly what you are trying to find out, but what about a multinomial logistic regression with gradient as the independent variable?

In R, one way to do this is the mlogit function in the mlogit library. See this vignette

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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