五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

R語言中的Theil-Sen回歸分析

2021-03-09 13:06 作者:拓端tecdat  | 我要投稿

原文鏈接:http://tecdat.cn/?p=10080

?

?Theil-Sen估計器是一種在社會科學中不常用 的簡單線性回歸估計器? 。三個步驟:

  • 在數(shù)據(jù)中所有點之間繪制一條線

  • 計算每條線的斜率

  • 中位數(shù)斜率是 回歸斜率

用這種方法計算斜率非常可靠。當誤差呈正態(tài)分布且沒有異常值時,斜率與OLS非常相似。?

有幾種獲取截距的方法。如果 關心回歸中的截距,那么知道 軟件在做什么是很合理的。?

當我對異常值和異方差性有擔憂時,請在上方針對Theil-Sen進行簡單線性回歸的評論 。

我進行了一次?模擬,以了解Theil-Sen如何在異方差下與OLS比較。它是更有效的估計器。

  1. library(simglm)

  2. library(ggplot2)

  3. library(dplyr)

  4. library(WRS)


  5. # Hetero

  6. nRep <- 100

  7. n.s <- c(seq(50, 300, 50), 400, 550, 750, 1000)

  8. samp.dat <- sample((1:(nRep*length(n.s))), 25)

  9. lm.coefs.0 <- matrix(ncol = 3, nrow = nRep*length(n.s))

  10. ts.coefs.0 <- matrix(ncol = 3, nrow = nRep*length(n.s))

  11. lmt.coefs.0 <- matrix(ncol = 3, nrow = nRep*length(n.s))

  12. dat.s <- list()




  13. ggplot(dat.frms.0, aes(x = age, y = sim_data)) +

  14. geom_point(shape = 1, size = .5) +

  15. geom_smooth(method = "lm", se = FALSE) +

  16. facet_wrap(~ random.sample, nrow = 5) +

  17. labs(x = "Predictor", y = "Outcome",

  18. title = "Random sample of 25 datasets from 15000 datasets for simulation",

  19. subtitle = "Heteroscedastic relationships")



仿真結果

  1. ggplot(coefs.0, aes(x = n, colour = Estimator)) +

  2. ? geom_boxplot(

  3. ? ? aes(ymin = q025, lower = q25, middle = q50, upper = q75, ymax = q975), data = summarise(

  4. ? ? ? group_by(coefs.0, n, Estimator), q025 = quantile(Slope, .025),

  5. ? ? ? q25 = quantile(Slope, .25), q50 = quantile(Slope, .5),

  6. ? ? ? q75 = quantile(Slope, .75), q975 = quantile(Slope, .975)), stat = "identity") +

  7. ? geom_hline(yintercept = 2, linetype = 2) + scale_y_continuous(breaks = seq(1, 3, .05)) +

  8. ? labs(x = "Sample size", y = "Slope",

  9. ? ? ? ?title = "Estimation of regression slope in simple linear regression under heteroscedasticity",

  10. ? ? ? ?subtitle = "1500 replications - Population slope is 2",

  11. ? ? ? ?caption = paste(

  12. ? ? ? ? ?"Boxes are IQR, whiskers are middle 95% of slopes",

  13. ? ? ? ? ?"Both estimators are unbiased in the long run, however, OLS has higher variability",

  14. ? ? ? ? ?sep = "\n"

  15. ? ? ? ?))




來自模擬的25個隨機樣本


R語言中的Theil-Sen回歸分析的評論 (共 條)

分享到微博請遵守國家法律
伊通| 龙泉市| 溧阳市| 奉新县| 韶山市| 桂林市| 汝州市| 崇左市| 华安县| 哈尔滨市| 望江县| 綦江县| 揭西县| 嘉鱼县| 松阳县| 苏州市| 遵义市| 巩义市| 龙泉市| 自治县| 驻马店市| 海宁市| 武邑县| 彭水| 江永县| 苏尼特右旗| 浪卡子县| 鹤山市| 侯马市| 民乐县| 神农架林区| 丰县| 余干县| 绵竹市| 莱州市| 旅游| 贵港市| 巢湖市| 固始县| 扶沟县| 札达县|