为什么我的线性回归拟合线看起来不对? [英] Why does my linear regression fit line look wrong?

查看:349
本文介绍了为什么我的线性回归拟合线看起来不对?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经绘制了二维直方图,可以通过线条,点等将其添加到图中. 现在,我试图在稠密点的区域应用线性回归拟合,但是我的线性回归线似乎完全偏离了应该在的位置? 为了说明这一点,我的图在左侧,同时具有最低的回归拟合和线性拟合.

I have plotted a 2-D histogram in a way that I can add to the plot with lines, points etc. Now I seek to apply a linear regression fit at the region of dense points, however my linear regression line seems totally off where it should be? To demonstrate here is my plot on the left with both a lowess regression fit and linear fit.

lines(lowess(na.omit(a),na.omit(b),iter=10),col='gray',lwd=3)

abline(lm(b[cc]~a[cc]),lwd=3)

这里a和b是我的值,cc是最密集部分(即,大多数点位于此处)内的点,即红色+黄色+蓝色.

Here a and b are my values and cc are the points within the densest parts (i.e. most points lay there), red+yellow+blue.

为什么我的回归线看起来不像右边(手绘拟合)? 如果我要绘制一条最合适的线,那会在那儿吗?

Why doesn't my regression line look more like that on the right (hand-drawn fit)? If I was plotting a line of best fit it would be there?

我有许多类似的图,但仍然得到相同的结果....

I have numerous plots similar to this but still I get the same results....

是否有其他线性回归拟合对我来说可能更好?

Are there any alternative linear regression fits that could prove to be better for me?

推荐答案

线性回归是一种将线性函数拟合到一组点(观测值)的方法,以最小化最小二乘误差.

A linear regression is a method to fit a linear function to a set of points (observations) minimizing the least-squares error.

现在想象一下您的热图,该形状指示您认为最适合垂直线的形状.只需将热图逆时针旋转10度即可.

Now imagine your heatmap indicating a shape where you would assume a vertical line fitting best. Just turn your heatmap 10 degrees counter clock-wise and you have it.

现在应该如何定义一个垂直的线性函数?确实是不可能的.

Now how would a linear function supposed to be defined which is vertical? Exactly, it is not possible.

这个小小的思想实验的结果是,您混淆了线性回归的目的,而最有可能想要的是-正如Gavin Simpson所指出的-

The result of this little thought experiment is that you confuse the purpose of linear regression and what you most likely want is - as indicated already by Gavin Simpson - the 1st principal component vector.

这篇关于为什么我的线性回归拟合线看起来不对?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆