기본 콘텐츠로 건너뛰기

라벨이 residual인 게시물 표시

[matplotlib]quiver()함수

[Linear Analysis] 최소제곱법에 의한 수학적 모형

최소제곱법에 의한 수학적 모형 관련된 내용 최소제곱해 y=f(x)를 따르는 데이터에 대해 생각해 봅니다. $$(x_1, y_2),\, (x_2, y_2), \, \cdot, \, (x_n, y_n)$$ 위 데이터의 패턴을 찾는 것은 f(x)의 함수를 찾는 것과 같습니다. 이러한 함수를 수학적 모형이라 합니다. 이러한 함수의 몇가지 예를 나타내면 다음과 같습니다. 직선: y=ax+b 2차 다항식: y=a+bx+cx 2 3차 다항식: y=a+bx+cx 2 +dx 3 x1=symbols("x1") f=2+3*x1+4*x1**2+5*x1**3 df=f.diff(x1) ddf=df.diff(x1) x=np.linspace(-10, 10, 100) y1=[f.subs(x1, i) for i in x] y2=[df.subs(x1, i) for i in x] y3=[ddf.subs(x1, i) for i in x] fig, ax=plt.subplots(figsize=(4,3)) ax.plot(x, y1, color="r", label=r"$y=dx^{3} + cx^{2} + b x + a$") ax.plot(x, y2, color="b", label=r"$y=c x^{2} + b x + a$") ax.plot(x, y3, color="g", label=r"$y=b x + a$") ax.legend( bbox_to_anchor=(0.8,1)) ax.set_xlabel("x", loc="right") ax.set_ylabel("y", loc="top") ax.set_ylim(-200, 200) ax.spines['left'].set_position(("data", 0)) ax.spines['bottom...

[data analysis] 회귀모델의 오차에 대해

회귀모델의 오차(Error, Residual)에 대해 관련된 내용 자기상관분석(Autocorrelation Analysis) 오차제곱평균(Mean of Square Error) 오차의 분산 생성된 회귀모형은 통계적으로 검정(test)할 필요가 있으며 검정의 주요한 객체는 식 1과 같이 계산되는 관찰치와 추정치의 차이인 오차(error)가 됩니다. \begin{align} e & = y − (b_0+ b_1x)\\ &=y − \hat{y}\\& e: \text{오차 또는 잔차}\\ &\hat{y}: \text{추정치}\end{align} (식 1) 회귀모형의 오차는 다음의 전제조건을 갖습니다. 정규분포를 따르는 확률변수 오차항의 등분산성(homoscedastic) 시점이 다른 오차들 사이에 자기상관 (autocorrelation) 없음 설명변수들은 정규 분포를 따르는 확률변수이므로 그 반응변수와 추정치 사이에서 발생되는 오차 역시 정규분포를 따르는 확률 변수가 됩니다. 이것은 오차를 인위적으로 조정할 수 없다는 의미입니다. 동일한 자료에서 다양한 회귀모형이 가능합니다. 즉, 다양한 회귀계수들이 존재하므로 표 1에서 나타낸 것과 같이 1개의 샘플(설명변수와 반응변수의 1쌍)에서 생성되는 다양한 추정치들에 대한 분포를 생성할 수 있습니다. 표 1 다양한 회귀계수들의 영향 설명변수 반응변수 추정치 오차들 분포 x 1 y 1 p 11 , p 12 , … e 11 (= y 1 -p 11 ), e 12 , … e 1,bar , σ e1 x 2 y 2 p 21 , p 22 , … e 21 , e 22 , … e 2,bar , σ e2 ⋮ ⋮ ⋮ ⋮ ⋮ 표 1에서 나타낸 것과 같이 샘플당 다양한 추정치에 의한 오차분포를 형성하며 그 분포의 분산은 회귀계수에 의해 결정됩니다. 회귀계수는 모든 샘플들에 동일하게 적용되므로 모든 샘플의 오차분포들은 동일한 분산을 가질 것입니다. 그러므로 회귀...

Autocorrelation & Mean of Square Error

Contents Autocorrelation analysis Mean of Square Error Residual(Error) The generated regression model needs to be statistically tested, and the main object in the test is an error, the difference between the observations and estimates calculated by Equation 1. $$\begin{align}\tag{1}\text{e}&=y-(b_0+b_1x)\\&=y-\hat{y} \end{align}$$ Errors in the regression model have the following prerequisites: Probability variables that follow a normal distribution Because independent variables are probabilities that follow a normal distribution, the error between the response and the estimate is also a probability variable that follows a normal distribution. This means that the error cannot be artificially adjusted. Homoscedastic of error terms Various regression models are possible, as shown in Figure 1. This means that you can configure the probability distribution for the regression coefficients. This distribution has means and variances. The mean of this distrib...