在图中添加最小二乘线和LMS线

发布于 2025-01-31 04:20:54 字数 377 浏览 3 评论 0原文

我已经从软件包library(rounustbase)中加载了数据集andime2,并且我有兴趣与这些数据的对数合作。

library(robustbase)
x<-log(Animals2)
plot(x, main="Plot Animals2", col="darkgreen")

现在我需要添加最小二乘线,LMS线和线路 西格尔(Siegel),使用不同的颜色。最后,我还想展示两个估计的二维密度的图。第一个图应是密度的3D可视化(我试图使用命令persp),第二个图与命令image(应用于 密度估计)。

我有点困扰,也很感激。

I have loaded the data set Animals2 from the package library (robustbase), and I am interested on working with the logarithm of these data.

library(robustbase)
x<-log(Animals2)
plot(x, main="Plot Animals2", col="darkgreen")

Now I need to add the least-squares line, the LMS line, and the line
of Siegel, by using different colours. Finally, I also wanted to show two plots with the estimated 2-dimensional densities. The first plot should be a 3D visualization of the density (I was trying to use command persp) and the second plot with the command image (applied to the
density estimate).

I am a bit stuck and would appreciate some help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如果没有 2025-02-07 04:20:54

假设mblm()可以使用Siegel模型,则可以使用以下方式:

  library(robustbase)
  library(mblm)
  data(Animals2)
  x <- log(Animals2)
  plot(x, main="Plot Animals2", col="darkgreen")
  abline(lm(brain ~ body, data=x), col="red")
  abline(MASS::lqs(brain ~ body, data=x, method="lms"), col="blue")
  abline(mblm(brain ~ body, data=x, repeated=TRUE), col="black")
  legend("topleft", c("LM", "LMS", "Siegel"), 
         col = c("red", "blue", "black"), 
         lty = c(1,1,1), 
         inset=.01)

“



d2 <- MASS::kde2d(x$body, x$brain)
persp(d2)

“”

image(d2, xlab="body", ylab="brain")

” -05-20 by reprex package (v2.0.1)

Assuming that mblm() does the Siegel model, you could use this:

  library(robustbase)
  library(mblm)
  data(Animals2)
  x <- log(Animals2)
  plot(x, main="Plot Animals2", col="darkgreen")
  abline(lm(brain ~ body, data=x), col="red")
  abline(MASS::lqs(brain ~ body, data=x, method="lms"), col="blue")
  abline(mblm(brain ~ body, data=x, repeated=TRUE), col="black")
  legend("topleft", c("LM", "LMS", "Siegel"), 
         col = c("red", "blue", "black"), 
         lty = c(1,1,1), 
         inset=.01)



d2 <- MASS::kde2d(x$body, x$brain)
persp(d2)

image(d2, xlab="body", ylab="brain")

Created on 2022-05-20 by the reprex package (v2.0.1)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文