pairwise_tukeyhsd() missing 1 required positional argument: 'groups'
时间: 2023-10-20 21:07:34 浏览: 121
pairwise_pairwisespillover_
`pairwise_tukeyhsd()` is a function from the `statsmodels.stats.multicomp` module that performs Tukey's honestly significant difference (HSD) test for multiple pairwise comparisons between group means. The error message you are seeing suggests that you did not provide the required argument `groups` when calling the function.
The `groups` argument should be a list or array-like object that specifies the group labels for each observation. For example, if you have three groups labeled "A", "B", and "C", and each group has 10 observations, you could create the `groups` array like this:
```python
import numpy as np
groups = np.array(["A"] * 10 + ["B"] * 10 + ["C"] * 10)
```
Then you could call `pairwise_tukeyhsd()` with your data and the `groups` argument:
```python
from statsmodels.stats.multicomp import pairwise_tukeyhsd
# data is a 1D array of numeric values
results = pairwise_tukeyhsd(data, groups)
```
Make sure that the length of your `groups` array matches the length of your data array, and that the group labels are in the correct order.
阅读全文