如何測試同一模型中的兩個參數估計值是否顯著不同?
我有模型
y=xa×zb+e
在哪裡 y 是因變量, x 和 z 是解釋變量, a 和 b 是參數和 e 是一個錯誤術語。我有參數估計 a 和 b 以及這些估計的協方差矩陣。我如何測試是否 a 和 b 有顯著不同?
評估假設 a 和 b 不同等於檢驗原假設 a−b=0 (反對替代方案 a−b≠0 )。
以下分析假設您估計是合理的 a−b 作為U=ˆa−ˆb.
它還接受您的模型公式(通常是一個合理的公式),因為誤差是相加的(甚至可能產生負觀測值 y )——不允許我們通過取兩邊的對數來線性化它。的方差 U 可以用協方差矩陣表示 (cij) 的 (ˆa,ˆb) 作為
Var(U)=Var(ˆa−ˆb)=Var(ˆa)+Var(ˆb)−2Cov(ˆa,ˆb)=c11+c22−2c212.
什麼時候 (ˆa,ˆb) 用最小二乘估計,通常使用“t檢驗”;也就是說,分佈 t=U/√Var(U)
由Student t 分佈近似,其中 n−2 自由度(其中 n 是數據計數和 2 計算係數的數量)。不管, t 通常是任何測試的基礎。您可以執行 Z 測試(當 n 例如,很大或在擬合最大似然時)或引導它。具體來說,t 檢驗的 p 值由下式給出
p=2tn−2(−|t|)
在哪裡 tn−2 是學生 t(累積)分佈函數。它是“尾部區域”的一種表達方式:學生 t 變量(的 n−2 自由度)等於或超過檢驗統計量的大小, |t|.
更一般地,對於數字 c1, c2, 和 μ 您可以使用完全相同的方法來檢驗任何假設
H0:c1a+c2b=μ
反對雙向選擇。(這包括“對比”的特殊但普遍的情況。)使用估計的方差-協方差矩陣 (cij) 估計方差 U=c1a+c2b 並形成統計量
t=(c1ˆa+c2ˆb−μ)/√Var(U).
上述情況是這樣的 (c1,c2)=(1,−1) 和 μ=0.
**為了檢查這個建議是否正確,**我運行了以下
R
代碼來根據這個模型創建數據(帶有正態分佈的錯誤e
),擬合它們,併計算 t 多次。檢查是概率圖 t (基於假設的學生 t 分佈)緊跟對角線。這是尺寸模擬中的情節 500 在哪裡 n=5 (一個非常小的數據集,選擇是因為 t 分佈遠非正常)和 a=b=−1/2.至少在這個例子中,該過程運行良好。 考慮使用參數重新運行模擬 a, b, σ (誤差標準差),和 n 反映你的情況。
這是代碼。
# # Specify the true parameters. # set.seed(17) a <- -1/2 b <- -1/2 sigma <- 0.25 # Variance of the errors n <- 5 # Sample size n.sim <- 500 # Simulation size # # Specify the hypothesis. # H.0 <- c(1, -1) # Coefficients of `a` and `b`. mu <- 0 # # Provide x and z values in terms of their logarithms. # log.x <- log(rexp(n)) log.z <- log(rexp(n)) # # Compute y without error. # y.0 <- exp(a * log.x + b * log.z) # # Conduct a simulation to estimate the sampling distribution of the t statistic. # sim <- replicate(n.sim, { # # Add the errors. # e <- rnorm(n, 0, sigma) df <- data.frame(log.x=log.x, log.z=log.z, y.0, y=y.0 + e) # # Guess the solution. # fit.ols <- lm(log(y) ~ log.x + log.z - 1, subset(df, y > 0)) start <- coefficients(fit.ols) # Initial values of (a.hat, b.hat) # # Polish it using nonlinear least squares. # fit <- nls(y ~ exp(a * log.x + b * log.z), df, list(a=start[1], b=start[2])) # # Test a hypothesis. # cc <- vcov(fit) s <- sqrt((H.0 %*% cc %*% H.0)) (crossprod(H.0, coef(fit)) - mu) / s }) # # Display the simulation results. # summary(lm(sort(sim) ~ 0 + ppoints(length(sim)))) qqplot(qt(ppoints(length(sim)), df=n-2), sim, pch=21, bg="#00000010", col="#00000040", xlab="Student t reference value", ylab="Test statistic") abline(0:1, col="Red", lwd=2)