新浪网

R语言中的Theil-Sen回归分析

拓端tecdat

关注

确定不再关注此人吗

http://tecdat.cn/?p=10080

 Theil-Sen估计器是一种在社会科学中不常用 的简单线性回归估计器  。三个步骤:

在数据中所有点之间绘制一条线

计算每条线的斜率

中位数斜率是 回归斜率

用这种方法计算斜率非常可靠。当误差呈正态分布且没有异常值时,斜率与OLS非常相似。

有几种获取截距的方法。如果 关心回归中的截距,那么知道 软件在做什么是很合理的。

当我对异常值和异方差性有担忧时,请在上方针对Theil-Sen进行简单线性回归的评论 。

我进行了一次

模拟,以了解Theil-Sen如何在异方差下与OLS比较。它是更有效的估计器。

R语言中的Theil-Sen回归分析

geom_boxplot(\n

aes(ymin = q025, lower = q25, middle = q50, upper = q75, ymax = q975), data = summarise(\n

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

q25 = quantile(Slope, .25), q50 = quantile(Slope, .5),\n

q75 = quantile(Slope, .75), q975 = quantile(Slope, .975)), stat = \"identity\") +\n

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

labs(x = \"Sample size\", y = \"Slope\",\n

title = \"Estimation of regression slope in simple linear regression under heteroscedasticity\",\n

subtitle = \"1500 replications - Population slope is 2\",\n

caption = paste(\n

\"Boxes are IQR, whiskers are middle 95% of slopes\",\n

\"Both estimators are unbiased in the long run, however, OLS has higher variability\",\n

sep = \"\\n\"\n

))\n\n\n\n"}" style="">ggplot(coefs.0, aes(x = n, colour = Estimator)) +   geom_boxplot(     aes(ymin = q025, lower = q25, middle = q50, upper = q75, ymax = q975), data = summarise(       group_by(coefs.0, n, Estimator), q025 = quantile(Slope, .025),       q25 = quantile(Slope, .25), q50 = quantile(Slope, .5),       q75 = quantile(Slope, .75), q975 = quantile(Slope, .975)), stat = "identity") +   geom_hline(yintercept = 2, linetype = 2) + scale_y_continuous(breaks = seq(1, 3, .05)) +   labs(x = "Sample size", y = "Slope",        title = "Estimation of regression slope in simple linear regression under heteroscedasticity",        subtitle = "1500 replications - Population slope is 2",        caption = paste(          "Boxes are IQR, whiskers are middle 95% of slopes",          "Both estimators are unbiased in the long run, however, OLS has higher variability",          sep = "\n"        ))

R语言中的Theil-Sen回归分析

发布于:浙江

特别声明:以上文章内容仅代表作者本人观点,不代表 新浪网观点或立场。如有关于作品内容、版权或其它问题请于作品发布后的30日内与 新浪网联系。
马布里官宣结婚396万
李刚被双开335万
诺一上法国新闻335万
月初预定2公斤金条路上4天亏4万328万
双胞胎姐妹佩佩惠惠相继离世319万
主播直播擦边卖枕头2小时场观30万312万
查看全部实时热点
请输入评论内容

举报成功

举报

请您选择举报的原因

说说你的看法

打开APP
意见/建议 反馈入口
  • TOKEN
  • 标题/昵称
  • 反馈内容

已反馈成功~

意见/建议 反馈入口
  • TOKEN
  • 标题/昵称
  • 反馈内容

已反馈成功~