### 对称回归模型

```正交（对称，全）回归





#heights {alr3}
#Karl Pearson organized the collection of data on over 1100 families in England
#in the period 1893 to 1898. This particular data set gives the heights
# in inches of mothers and their daughters, with up to two daughters per mother.
# All daughters are at least age 18, and all mothers are younger than 65.
#Data were given in the source as a frequency table to the nearest inch.
#Rounding error has been added to remove discreteness from graph


#Davis {car} The Davis data frame has 200 rows and 5 columns. The subjects were
men and women engaged in regular exercise. There are some missing data.
# father.son {UsingR}
#1078 measurements of a father's height and his son's height

father.son {UsingR}
summary(lm(fheight~sheight,father.son))
 summary(lm(sheight~fheight,father.son))
 o1=lm(fheight~sheight,father.son)
 o2=lm(sheight~fheight,father.son)
 plot(fheight~sheight,father.son)
 s.prid=expand.grid(sheight=seq(50,90,1))

s.prid\$fheight=predict(o1,s.prid)
 s.prid2=expand.grid(fheight=s.prid\$fheight)
 s.prid2\$sheight=predict(o2,s.prid2)
 lines(fheight~sheight,s.prid,col="red")
 lines(fheight~sheight,s.prid2,col="blue")
 legend("topleft",c("fheight~sheight","sheight~fh
eight"),lty=1,col=c("red","blue"))


 如果x, y地位对等(对称)，y~x以及x~y都不合理。

orthogonal reg), reduced major reg(或impartial
reg),bisector reg(或double regression)
 Pearson给出了major axis regression (也称作
orthogonal regression) 方法, 这是一种对称回归


Reduced major axis regression
(impartial regression)：the SD line


Bisector regression (double regression):平分
y~x, x~y回归直线的夹角















ol<-function(x,y)
{
s_xy=sum((x-mean(x))*(y-mean(y)))
s_xx=sum((x-mean(x))^2)
s_yy=sum((y-mean(y))^2)
b1=s_xy/s_xx
b2=s_yy/s_xy
r=cor(x,y)
b_ol=(-(b2-1/b1)+sign(r)*sqrt(4+(b2-1/b1)^2))/2
b_sd=sign(r)*sqrt(b1*b2)
b_bi=(b1*b2-1+sqrt((1+b1^2)*(1+b2^2)))/(b1+b2)
B=list(b_xy=b1,b_yx=b2,b_ol=b_ol,b_sd=b_sd,b_bi=b_bi)
return(B)
}

IQ=c(90,92,93,95,97,98,100)
 P=c(39,42,36,45,39,45,42)











B=as.numeric(ol(IQ,P))
A=mean(P)-B*mean(IQ)
plot(IQ,P)
lines(IQ,A[1]+B[1]*IQ)
lines(IQ,A[2]+B[2]*IQ,col="purple")
lines(IQ,A[3]+B[3]*IQ,col="red")
lines(IQ,A[4]+B[4]*IQ,col="blue")
lines(IQ,A[5]+B[5]*IQ,col="green")
legend("topleft",c("x~y","y~x","ol","sd","bi"),lty=1,col=c("bla
ck","purple","red","blue","green"))

1. 异常点/标准化
 2. 中心化

1. 异常值(outlier)/标准化



2. 中心化
```