看板 R_Language 關於我們 聯絡資訊
※ 引述《solsiso (solsiso)》之銘言: : 請問 : 要對一個迴歸式 y=a+bx+e : 的係數a和b同時進行檢定 : 我採用了wald test(安裝了aod package) : 進行 H0:a=0且b=1 的檢定 : 但卻一直出現以下訊息 : Error in wald.test(Sigma = mdl_stderror[1, ], b = mdl_coef[1, ], L = ) : : One of the arguments Terms or L must be used. : 一定要有一個 L 或 Terms 的參數,可是我不知道到底如何給好,希望板上大大能 : 解惑一下,感謝!~ Terms 參數用來指定 H0 的對象。 我給你一串例子。如果你已經懂 Wald test 的話那一定馬上就會看懂。 x1 <- c(3,6,5,2,4) x2 <- c(5,3,6,7,2) y <- c(4,7,2,3,1) # define a general linear model: y = b0 + b1x1 + b2x2 + error m <- lm(y ~ x1 + x2) summary(m) require(aod) # 檢驗 H0: b0 = 0 wald.test(b = coef(m), Sigma = vcov(m), df = m$df.residual, Terms = 1) # 應該會得到和 summary(m) 中 intercept 項一樣的結果 # 檢驗 H0: b0 = -0.3 wald.test(b = coef(m), Sigma = vcov(m), df = m$df.residual, Terms = 1, H0 = -0.3) # 應該會得到很大的 p-value(因為 b0 很接近 -0.3) # 檢驗 H0: b1 = 0 wald.test(b = coef(m), Sigma = vcov(m), df = m$df.residual, Terms = 2) # 應該會得到和 summary(m) 中 x1 項一樣的結果 # 檢驗 H0: b2 = 0 wald.test(b = coef(m), Sigma = vcov(m), df = m$df.residual, Terms = 3) # 應該會得到和 summary(m) 中 x2 項一樣的結果 # 檢驗 H0: b1 = 0 且 b2 = 0 wald.test(b = coef(m), Sigma = vcov(m), df = m$df.residual, Terms = c(2,3)) # 應該會得到和 summary(m) 中最後 b1 = 0 和 b2 = 0 聯合檢驗一樣的結果 # 檢驗 H0: b0 = 0 且 b1 = 13 且 b2 = 34 wald.test(b = coef(m), Sigma = vcov(m), df = m$df.residual, Terms = c(1,2,3), H0 = c(0, 13, 34)) # 應該會得到一個很小的 p-value(因為 H0 離估計值太遠了) -- http://apansharing.blogspot.com/ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.128.117.76 ※ 編輯: andrew43 來自: 140.128.117.76 (12/11 01:24)
solsiso:感謝大大熱心回覆,但我想我是不懂WALD TEST的樣子= = 12/11 01:41
andrew43:在我的例子中 Terms 用來指定 b0 b1 b2 要不要放在 H0. 12/11 02:32
andrew43:都說這麼明了應該不會不懂吧,還是你統計學上不懂? 12/11 02:32