![](/img/trans.png)
[英]Tukey HSD for mixed continuous and categorical variables, error: “no factors”
[英]Tukey HSD for categorical and continuous variables in R
我想對我成功完成的重要方差分析進行事后測試。
我有 5 個條件(target_onset),我想在一個名為 data_clean 的 df 中比較反應時間(key_resp.rt)。 target_onset 和 key_resp.rt 是列。
這就是我做方差分析的方法,效果很好:
cond.aov <- aov(data_clean$target_onset ~ data_clean$key_resp.rt)
summary(cond.aov)
接下來,我想看看事后測試是怎么說的,以找出這 5 個條件之間的哪些差異是顯着的。
我知道 TukeyHSD 只考慮因素。 所以我分解了我感興趣的列:
data_clean$target_onset <- factor(data_clean$target_onset)
data_clean$key_resp.rt <- factor(data_clean$key_resp.rt)
TukeyHSD(aov(data_clean$target_onset ~ data_clean$key_resp.rt))
但是,當我運行此代碼時,出現以下錯誤:
類(y)<-oldClass(x)中的錯誤:將 class“因子”添加到無效的 object 此外:警告消息:1:在 model.response(因子響應將被忽略 2: 在 Ops.factor(y, z$residuals): '-' 對因子沒有意義
任何的意見都將會有幫助。 提前致謝。
第一次編輯我錯過了你也有公式倒退的事實!
在發布aov
function之前,您需要將target_onset
作為一個因素。 您根本不想讓key_resp.rt
成為一個因素。
所以順序應該是...
data_clean$target_onset <- factor(data_clean$target_onset)
cond.aov <- aov(key_resp.rt ~ target_onset, data = data_clean)
summary(cond.aov)
TukeyHSD(cond.aov)
因變量(響應時間在波浪號的左側,獨立的分組變量在右側。
如果您沒有使條件/分組變量成為aov
factor
,它實際上使用分組列中的數字執行lm
,您可以看到它反映在cond.aov
的自由度中。
只要您已經有一個aov
object 就可以盡可能簡單地調用TukeyHSD
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.