'I got NaN for my p value table and I don't know why
I am trying to perform a three way mixed anova on a dataset caled "data". The thing is that I am running into some warning messages and when trying to calculate the F and p value it says NaN when the hand factor is involved which is weird. Any idea of what I did do wrong ?
I got RT, a continuous variable and hand, condition and age group as independent variables here is the dataset Thank you for your help
By the way I am using the library rstatix
I tried to replicate the code I saw on this webpage
elevene=data %>%
group_by(condition, hand) %>%
levene_test(RT ~ Age_group)
#Warning messages:
1: Problem while computing `data =
map(.data$data, .f, ...)`.
i group coerced to factor.
2: Problem while computing `data =
map(.data$data, .f, ...)`.
i group coerced to factor.
3: Problem while computing `data =
map(.data$data, .f, ...)`.
i group coerced to factor.
4: Problem while computing `data =
map(.data$data, .f, ...)`.
i group coerced to factor.
res.aov <- anova_test(
data = data, dv = Performance, wid = subject,
between = Age_group, within = c(condition, hand)
)
get_anova_table(res.aov)
#ANOVA Table (type III tests)
Effect DFn DFd F
1 Age_group 1 27 3.721
2 condition 1 27 1.468
3 hand 1 27 NaN
4 Age_group:condition 1 27 0.010
5 Age_group:hand 1 27 NaN
6 condition:hand 1 27 NaN
7 Age_group:condition:hand 1 27 NaN
p p<.05 ges
1 0.064 0.06600
2 0.236 0.02600
3 NaN <NA> 0.00000
4 0.921 0.00018
5 NaN <NA> 0.00000
6 NaN <NA> 0.00000
7 NaN <NA> 0.00000
Since the data said is relatively small I included it
structure(list(subject = c("y0003", "y0004", "y0005", "y0006",
"y0007", "y0008", "y0009", "y0011", "y0012", "y0013", "y0014",
"y0015", "y0016", "y0017", "y0018", "D1000", "D2000", "D4000",
"D5000", "D6000", "D7000", "D8000", "D9000", "D1100", "D1200",
"D1300", "D1400", "D1500", "D1700", "y0003", "y0004", "y0005",
"y0006", "y0007", "y0008", "y0009", "y0011", "y0012", "y0013",
"y0014", "y0015", "y0016", "y0017", "y0018", "D1000", "D2000",
"D4000", "D5000", "D6000", "D7000", "D8000", "D9000", "D1100",
"D1200", "D1300", "D1400", "D1500", "D1700", "y0003", "y0004",
"y0005", "y0006", "y0007", "y0008", "y0009", "y0011", "y0012",
"y0013", "y0014", "y0015", "y0016", "y0017", "y0018", "D1000",
"D2000", "D4000", "D5000", "D6000", "D7000", "D8000", "D9000",
"D1100", "D1200", "D1300", "D1400", "D1500", "D1700", "y0003",
"y0004", "y0005", "y0006", "y0007", "y0008", "y0009", "y0011",
"y0012", "y0013", "y0014", "y0015", "y0016", "y0017", "y0018",
"D1000", "D2000", "D4000", "D5000", "D6000", "D7000", "D8000",
"D9000", "D1100", "D1200", "D1300", "D1400", "D1500", "D1700"
), RT = c(0.168084009090909, 0.337482125, 0.329126908333333,
0.204090458333333, 0.177707966666667, 0.370760008333333, 0.1610848,
0.255529958333333, 0.209783408333333, 0.381877583333333, 0.304084016666667,
0.231889275, 0.263728241666667, 0.247181708333333, 0.37353315,
0.186161308333333, 0.283311325, 0.2596442, 0.27084245, 0.170801308333333,
0.1694348, 0.245855166666667, 0.142942791666667, 0.241614941666667,
0.316660141666667, 0.24722045, 0.145802241666667, 0.252675966666667,
0.163868808333333, 0.319374, 0.369382533333333, 0.308291341666667,
0.324932041666667, 0.166610375, 0.286037416666667, 0.67069075,
0.311107825, 0.181886733333333, 0.204134775, 0.465221758333333,
0.277730975, 0.199958375, 0.151343033333333, 0.266620916666667,
0.290183408333333, 0.156915175, 0.366600166666667, 0.198636325,
0.18738605, 0.268016183333333, 0.40396245, 0.137439983333333,
0.240251383333333, 0.452694691666667, 0.186107591666667, 0.184644408333333,
0.177788175, 0.231830191666667, 0.168084009090909, 0.337482125,
0.329126908333333, 0.204090458333333, 0.177707966666667, 0.370760008333333,
0.1610848, 0.255529958333333, 0.209783408333333, 0.381877583333333,
0.304084016666667, 0.231889275, 0.263728241666667, 0.247181708333333,
0.37353315, 0.186161308333333, 0.283311325, 0.2596442, 0.27084245,
0.170801308333333, 0.1694348, 0.245855166666667, 0.142942791666667,
0.241614941666667, 0.316660141666667, 0.24722045, 0.145802241666667,
0.252675966666667, 0.163868808333333, 0.319374, 0.369382533333333,
0.308291341666667, 0.324932041666667, 0.166610375, 0.286037416666667,
0.67069075, 0.311107825, 0.181886733333333, 0.204134775, 0.465221758333333,
0.277730975, 0.199958375, 0.151343033333333, 0.266620916666667,
0.290183408333333, 0.156915175, 0.366600166666667, 0.198636325,
0.18738605, 0.268016183333333, 0.40396245, 0.137439983333333,
0.240251383333333, 0.452694691666667, 0.186107591666667, 0.184644408333333,
0.177788175, 0.231830191666667), Age_group = c("Young", "Young",
"Young", "Young", "Young", "Young", "Young", "Young", "Young",
"Young", "Young", "Young", "Young", "Young", "Young", "Old",
"Old", "Old", "Old", "Old", "Old", "Old", "Old", "Old", "Old",
"Old", "Old", "Old", "Old", "Young", "Young", "Young", "Young",
"Young", "Young", "Young", "Young", "Young", "Young", "Young",
"Young", "Young", "Young", "Young", "Old", "Old", "Old", "Old",
"Old", "Old", "Old", "Old", "Old", "Old", "Old", "Old", "Old",
"Old", "Young", "Young", "Young", "Young", "Young", "Young",
"Young", "Young", "Young", "Young", "Young", "Young", "Young",
"Young", "Young", "Old", "Old", "Old", "Old", "Old", "Old", "Old",
"Old", "Old", "Old", "Old", "Old", "Old", "Old", "Young", "Young",
"Young", "Young", "Young", "Young", "Young", "Young", "Young",
"Young", "Young", "Young", "Young", "Young", "Young", "Old",
"Old", "Old", "Old", "Old", "Old", "Old", "Old", "Old", "Old",
"Old", "Old", "Old", "Old"), condition = c("asym", "asym", "asym",
"asym", "asym", "asym", "asym", "asym", "asym", "asym", "asym",
"asym", "asym", "asym", "asym", "asym", "asym", "asym", "asym",
"asym", "asym", "asym", "asym", "asym", "asym", "asym", "asym",
"asym", "asym", "sym", "sym", "sym", "sym", "sym", "sym", "sym",
"sym", "sym", "sym", "sym", "sym", "sym", "sym", "sym", "sym",
"sym", "sym", "sym", "sym", "sym", "sym", "sym", "sym", "sym",
"sym", "sym", "sym", "sym", "asym", "asym", "asym", "asym", "asym",
"asym", "asym", "asym", "asym", "asym", "asym", "asym", "asym",
"asym", "asym", "asym", "asym", "asym", "asym", "asym", "asym",
"asym", "asym", "asym", "asym", "asym", "asym", "asym", "asym",
"sym", "sym", "sym", "sym", "sym", "sym", "sym", "sym", "sym",
"sym", "sym", "sym", "sym", "sym", "sym", "sym", "sym", "sym",
"sym", "sym", "sym", "sym", "sym", "sym", "sym", "sym", "sym",
"sym", "sym"), hand = c("R", "R", "R", "R", "R", "R", "R", "R",
"R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R",
"R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R",
"R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R",
"R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "R", "L", "L",
"L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L",
"L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L",
"L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L",
"L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L", "L",
"L", "L", "L", "L")), row.names = c(NA, 116L), class = "data.frame")
Solution 1:[1]
The anova_test()
function calls the car::Anova()
function after arranging the data for it. That function is called with type = 3
, though the help page says anova_test()
defaults to type = 2
. If you look at the car::Anova
help page, it says
Be careful of type-III tests: For a traditional multifactor ANOVA model with interactions, for example, these tests will normally only be sensible when using contrasts that, for different terms, are orthogonal in the row-basis of the model, such as those produced by contr.sum, contr.poly, or contr.helmert, but not by the default contr.treatment. In a model that contains factors, numeric covariates, and interactions, main-effect tests for factors will be for differences over the origin. In contrast (pun intended), type-II tests are invariant with respect to (full-rank) contrast coding. If you don't understand this issue, then you probably shouldn't use Anova for type-III tests.
So that's a bit of a worry.
But I think the immediate cause of the NaN
values is simply that you don't have enough degrees of freedom, as @Olympia said.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | user2554330 |