I have a dataset containing observations of wave lengths in milliseconds and the corresponding durations of noise in milliseconds. Each observation is labeled with a group (A or B) and a subject.

I want to determine if the proportions of noise in the waves of group A are greater than or equal to those in group B. To quantify the noise proportion, I have a metric called "p," which is calculated by dividing the duration of the noise by the duration of the wave.

Here's an example of my dataset:

grupo  Subject  noise(s)  length(s)  p
A      X1       1094      1520       0.719820213
A      X2       150       1852       0.081245657
...    ...      ...       ...        ...
B      X26      113906    136779     0.832774474
B      X27      83327     142258     0.585743053
B      X28      112903    147737     0.764213143

I would like to know the proper way to perform a proportion test to compare the noise proportions between group A and group B. Should I average out the "p" column for each group and then proceed with the test? If so, how can I perform this test using a statistical software or library?

Why Do I ask?

I'm facing confusion regarding the appropriate approach for conducting a proportion test in a specific scenario. Typically, when performing a proportion test, we have the counts (n) and the total sample sizes (N) for each group. However, in my case, I have individual observations represented by proportions, and I need to calculate a statistic to assess if the noise proportion differs significantly between group A and group B.

To clarify, the noise proportion is calculated by dividing the duration of the noise by the duration of the corresponding wave for each observation. It's important to note that a simple t-test comparing the mean noise durations is not appropriate because the noise duration is dependent on the wave duration. Therefore, I believe a proportion test is more suitable for this analysis.

I would greatly appreciate guidance on how to proceed in this situation. Specifically, I'm looking for suggestions on the appropriate statistical methods, and if possible, references to articles, books, or research papers that discuss similar approaches.

Thank you in advance for any insights or resources you can provide.

here is my full dataset:

df <- data.frame(
  grupo = c("A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B", "B"),
  Subject = c("X1", "X2", "X3", "X4", "X5", "X6", "X7", "X15", "X16", "X17", "X18", "X19", "X20", "X21", "X29", "X30", "X8", "X9", "X10", "X11", "X12", "X13", "X14", "X22", "X23", "X24", "X25", "X26", "X27", "X28"),
  noise = c(1094, 150, 8303, 1203, 2133, 1443, 9117, 5177, 4482, 40057, 46129, 90512, 20294, 90888, 76439, 56250, 12095, 8046, 4141, 31651, 58280, 28082, 38608, 46389, 93565, 40294, 97831, 113906, 83327, 112903),
  length = c(1520, 1852, 12478, 16241, 21720, 27199, 32678, 76510, 81989, 87468, 92947, 98426, 103905, 109384, 153216, 158695, 38157, 43636, 49115, 54594, 60073, 65552, 71031, 114863, 120342, 125821, 131300, 136779, 142258, 147737),
  p = c(0.719820213, 0.081245657, 0.665404337, 0.074051034, 0.098219923, 0.053041614, 0.278977528, 0.067662175, 0.054660867, 0.457964591, 0.496291317, 0.919593764, 0.195312579, 0.830902015, 0.498893504, 0.354454487, 0.316979866, 0.184394298, 0.084321059, 0.579747946, 0.97014446, 0.428392012, 0.54353371, 0.403864003, 0.777487753, 0.320251289, 0.745093182, 0.832774474, 0.585743053, 0.764213143)

1 Answer 1


You are making a big assumption that the proportion of "noise" to "length" should be constant over a wide range of "length" values, only differentiated by "group" membership. A simple plot shows an issue in your data that might require more attention:

ggplot(data=df,mapping=aes(x=log(length),y=log(noise),group=grupo,color=grupo)) + geom_point()+geom_smooth()

data plot

Group A has a set of much lower values than Group B. The lowest/highest "length" values in Group A are 1520 and 158695. The corresponding value in Group B are 38157 and 147737. Almost half of the Group A "length" values are lower than the lowest value in Group B. Think about why the groups differ so much in the distributions of their "length" values first.

Once you've done that there are a few ways to proceed, if your assumption is valid. Beta regression is one choice for proportion data, although I'm not sure it would be good here.

You could structure this as a binomial regression. The R glm() function allows for proportion outcomes represented "as a numerical vector with values between 0 and 1, interpreted as the proportion of successful cases (with the total number of cases given by the weights)." You could use "length" as the weights argument, with your proportions as the outcomes.

An alternative could be a regression model of "noise" as a continuous function of "length" that includes "group" as a predictor. Including an interaction term between "group" and "length" would allow for a different association between "noise" and "length" depending on "group."

It doesn't seem that your data set is large enough to distinguish the groups reliably, but these are general methods to consider for this type of data.

  • $\begingroup$ Hey EdM, Thank you so much for taking the time to write your answer and also to analyze my data we have opened up me eyes to a new way of approaching this tests thanks a million for that, just one more final question? do you think it is too crazy to treat the variable P as a continues variable a perform a z test to see if the mean P of group A is actually greater than Group B? thanks a lot $\endgroup$
    – user389105
    Commented May 30, 2023 at 15:33
  • $\begingroup$ @user389105 when proportions cover a wide range as in your data, a t-test or a z-test doesn't work well as the underlying assumption of normality doesn't hold. If you just want to compare proportions of noise/length between groups and (based on your understanding of the subject matter) you aren't worried about the differences in the length values among groups, then beta regression is more reliable and comes close to distinguishing the two groups. $\endgroup$
    – EdM
    Commented May 30, 2023 at 15:59
  • $\begingroup$ Excellent! Deeply greatful for your help I will be following your post to learn more form you thank you so much $\endgroup$
    – user389105
    Commented May 30, 2023 at 16:05

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.