0

For my research, I am investigating the occurrence of tail biting in pigs. I would like to calculate both the overall standard deviation of all pigs, and the within-pen standard deviation. I am not sure how the latter should be calculated. Should I first determine the SD of each pen, and then take the average of those, or is this a wrong approach? Thank you in advance.

balzy
  • 139
  • 2
    A pig has a snout, and a tail, but it doesn't have a standard deviation. Can you please be specific about what quantity you are measuring for which you calculate the standard deviation --- is the the count of the number of tail bites by that pig? What would it mean for a bite to occur when pigs are not in the same pen? Etc. – Ben Apr 25 '22 at 10:10
  • They were scored on a scale from 0 to 2 based on the severity of biting lesions. – balzy Apr 25 '22 at 10:20
  • Okay, and what do you mean by "within pen" and not. – Ben Apr 25 '22 at 10:20

1 Answers1

0

It sounds like you might be asking how to aggregate the sample standard deviations in a set of groups to get the sample standard deviation in the pooled data that combines those groups. The sample standard deviation of the pooled data is not the average of the sample standard deviations of the groups, and the actual formula is a bit more complicated than that (see e.g., O'Neill 2021).

So long as you have the sample sizes, sample means and sample standard deviations (or variances) of each group, you can compute sample the sample variance of the pooled data with the sample.decomp function in the utilities package. The method is described in the linked paper and you can also find examples of how to use the function here, here and here.

Ben
  • 124,856