Skip to main content
replaced http://stats.stackexchange.com/ with https://stats.stackexchange.com/
Source Link

Let's first consider the simplest case of only one predictor (independent) variable $x$. For simplicity, let both $x$ and $y$ be centered, i.e. intercept is always zero. The difference between standard OLS regression and "orthogonal" TLS regression is clearly shown on this (adapted by me) figure from the most popular answerthe most popular answer in the most popular thread on PCA:

Let's first consider the simplest case of only one predictor (independent) variable $x$. For simplicity, let both $x$ and $y$ be centered, i.e. intercept is always zero. The difference between standard OLS regression and "orthogonal" TLS regression is clearly shown on this (adapted by me) figure from the most popular answer in the most popular thread on PCA:

Let's first consider the simplest case of only one predictor (independent) variable $x$. For simplicity, let both $x$ and $y$ be centered, i.e. intercept is always zero. The difference between standard OLS regression and "orthogonal" TLS regression is clearly shown on this (adapted by me) figure from the most popular answer in the most popular thread on PCA:

fixed a mistake in the code
Source Link
amoeba
  • 107.3k
  • 36
  • 321
  • 346
 v = pca([x y]);    //# x and y are centered column vectors
 beta = v(1,2,1)/v(1,1);
 v <- prcomp(cbind(x,y))$rotation
 beta <- v[1v[2,2]1]/v[1,1]
 v = pca([x y]);    //# x and y are centered column vectors
 beta = v(1,2)/v(1,1);
 v <- prcomp(cbind(x,y))$rotation
 beta <- v[1,2]/v[1,1]
 v = pca([x y]);    //# x and y are centered column vectors
 beta = v(2,1)/v(1,1);
 v <- prcomp(cbind(x,y))$rotation
 beta <- v[2,1]/v[1,1]
forgot minuses
Source Link
amoeba
  • 107.3k
  • 36
  • 321
  • 346
 v = pca([X y]);    //# X is a centered n-times-p matrix, y is n-times-1 column vector
 beta = -v(1:end-1,end)/v(end,end);
 v <- prcomp(cbind(X,y))$rotation
 beta <- -v[-ncol(v),ncol(v)] / v[ncol(v),ncol(v)]
 v = pca([X y]);    //# X is a centered n-times-p matrix, y is n-times-1 column vector
 beta = v(1:end-1,end)/v(end,end);
 v <- prcomp(cbind(X,y))$rotation
 beta <- v[-ncol(v),ncol(v)] / v[ncol(v),ncol(v)]
 v = pca([X y]);    //# X is a centered n-times-p matrix, y is n-times-1 column vector
 beta = -v(1:end-1,end)/v(end,end);
 v <- prcomp(cbind(X,y))$rotation
 beta <- -v[-ncol(v),ncol(v)] / v[ncol(v),ncol(v)]
clarified about covariance matrix
Source Link
amoeba
  • 107.3k
  • 36
  • 321
  • 346
Loading
clarified one bit
Source Link
amoeba
  • 107.3k
  • 36
  • 321
  • 346
Loading
ldots
Source Link
amoeba
  • 107.3k
  • 36
  • 321
  • 346
Loading
closed form solution
Source Link
amoeba
  • 107.3k
  • 36
  • 321
  • 346
Loading
sanity check
Source Link
amoeba
  • 107.3k
  • 36
  • 321
  • 346
Loading
how to compute the intercept
Source Link
amoeba
  • 107.3k
  • 36
  • 321
  • 346
Loading
Source Link
amoeba
  • 107.3k
  • 36
  • 321
  • 346
Loading