Skip to main content
deleted 139 characters in body
Source Link

Of course, econometricians prefer slightly different notation, but let’s just ignore them. — Do you know what econometricians use as a contraceptive? — Their personalities! (Don’t worry, I can say that, I am an econometrician...)

Of course, econometricians prefer slightly different notation, but let’s just ignore them. — Do you know what econometricians use as a contraceptive? — Their personalities! (Don’t worry, I can say that, I am an econometrician...)

Of course, econometricians prefer slightly different notation, but let’s just ignore them.

Clarified example
Source Link

A matrix of values. The first column is always Y[1], ..., Y[n], the second column is X1[1], ..., X1[n], the next one is X2[1], ..., X2[n] etc. The column of ones is not givenThe column of ones is not given (as in real datasets), but you have to add it first in order to estimatebut you have to add it first in order to estimate beta0 (as in real models).

  1. [[4,5,6],[1,2,3]] → output: [3,1]. Explanation: X = [[1,1,1], [1,2,3]], X'X = [[3,6],[6,14]], inverse(X'X) = [[2.333,-1],[-1,0.5]], X'Y = [15, 32], and inverse(X'X)⋅X'Y=[3, 1]
  2. [[5.5,4.1,10.5,7.7,6.6,7.2],[1.9,0.4,5.6,3.3,3.8,1.7],[4.2,2.2,3.2,3.2,2.5,6.6]] → output: [2.1171050,1.1351122,0.4539268].
  3. [[1,-2,3,-4],[1,2,3,4],[1,2,3,4.000001]] → output: [-1.3219977,6657598.3906250,-6657597.3945312] or S (any code for a computationally singular system).
  4. [[1,2,3,4,5]] → output: 3.

A matrix of values. The first column is always Y[1], ..., Y[n], the second column is X1[1], ..., X1[n], the next one is X2[1], ..., X2[n] etc. The column of ones is not given (as in real datasets), but you have to add it first in order to estimate beta0 (as in real models).

  1. [[4,5,6],[1,2,3]] → output: [3,1].
  2. [[5.5,4.1,10.5,7.7,6.6,7.2],[1.9,0.4,5.6,3.3,3.8,1.7],[4.2,2.2,3.2,3.2,2.5,6.6]] → output: [2.1171050,1.1351122,0.4539268].
  3. [[1,-2,3,-4],[1,2,3,4],[1,2,3,4.000001]] → output: [-1.3219977,6657598.3906250,-6657597.3945312] or S (any code for a computationally singular system).
  4. [[1,2,3,4,5]] → output: 3.

A matrix of values. The first column is always Y[1], ..., Y[n], the second column is X1[1], ..., X1[n], the next one is X2[1], ..., X2[n] etc. The column of ones is not given (as in real datasets), but you have to add it first in order to estimate beta0 (as in real models).

  1. [[4,5,6],[1,2,3]] → output: [3,1]. Explanation: X = [[1,1,1], [1,2,3]], X'X = [[3,6],[6,14]], inverse(X'X) = [[2.333,-1],[-1,0.5]], X'Y = [15, 32], and inverse(X'X)⋅X'Y=[3, 1]
  2. [[5.5,4.1,10.5,7.7,6.6,7.2],[1.9,0.4,5.6,3.3,3.8,1.7],[4.2,2.2,3.2,3.2,2.5,6.6]] → output: [2.1171050,1.1351122,0.4539268].
  3. [[1,-2,3,-4],[1,2,3,4],[1,2,3,4.000001]] → output: [-1.3219977,6657598.3906250,-6657597.3945312] or S (any code for a computationally singular system).
  4. [[1,2,3,4,5]] → output: 3.
Clarified formulae
Source Link

where Y is the first column of the input matrix and X is a matrix made of of a column of ones and remaining columns. This solution can be obtained via many numerical methods (matrix inversion, QR decomposition, Cholesky decomposition etc.), so pick your favourite!

A matrix of values. The first column is always Y[1], ..., Y[n], the second column is X1[1], ..., X1[n], the next one is X2[1], ..., X2[n] etc. The column of ones is not given (as in real datasets), but you have to add it first in order to estimate beta0 (as in real models).

NB. In statistics, regressing on a constant is widely used. This means that the model is Y = b0 + U, and the OLS estimate of b0 is the sample average of Y. In this case, the input is just a matrix with one column, Y, and it is regressed on a column of ones.

where Y is the first column of the input matrix and X is a matrix made of remaining columns. This solution can be obtained via many numerical methods (matrix inversion, QR decomposition, Cholesky decomposition etc.), so pick your favourite!

A matrix of values. The first column is always Y[1], ..., Y[n], the second column is X1[1], ..., X1[n], the next one is X2[1], ..., X2[n] etc.

NB. In statistics, regressing on a constant is widely used. This means that the model is Y = b0 + U, and the OLS estimate of b0 is the sample average of Y. In this case, the input is just a matrix with one column, Y.

where Y is the first column of the input matrix and X is a matrix made of a column of ones and remaining columns. This solution can be obtained via many numerical methods (matrix inversion, QR decomposition, Cholesky decomposition etc.), so pick your favourite!

A matrix of values. The first column is always Y[1], ..., Y[n], the second column is X1[1], ..., X1[n], the next one is X2[1], ..., X2[n] etc. The column of ones is not given (as in real datasets), but you have to add it first in order to estimate beta0 (as in real models).

NB. In statistics, regressing on a constant is widely used. This means that the model is Y = b0 + U, and the OLS estimate of b0 is the sample average of Y. In this case, the input is just a matrix with one column, Y, and it is regressed on a column of ones.

Tweeted twitter.com/StackCodeGolf/status/1043560742606331905
Added mathjax
Source Link
Mr. Xcoder
  • 42.5k
  • 9
  • 81
  • 214
Loading
Clarified rules
Source Link
Loading
Added a rule
Source Link
Loading
Added a section
Source Link
Loading
Source Link
Loading