This is a good example of what happens when you take text out of context.
The passage that was added in the edited question makes a difference, but it's not quite sufficient, and it doesn't help that the notation is all over the place. I found the textbook and the relevant passages (Section 2.3, p. 10-11). Here is a quick attempt at an explanation.
The authors call X a variable (either scalar or vector) with components Xj, but later in the paragraph they refer to Xj as a variable (which I think is the correct notation). Instead of "variable" with "components", think of X as a set of p variables (in the normal sense of a variable, such as temperature, the price of shares, etc.). You can put multiple variables xi (i = 1...p) in a vector X and call each instance of X an observation. In other words, an observation is a set of measured values for all variables xi.
Assume you have made N observations. Arrange your observations in a matrix with N rows and p columns, where each row represents a single observation (an instance of X).
Now also assume that you are trying to find the relation between your input variables xi and a different set of variables yk, called dependent or response variables. In general, the variables xi and yk are measured, and the model is simply trying to extract the relation between the input and dependent variables so you can then predict the latter from the former.
As a side note, observations are usually denoted with superscripts (x(n)) and variables with subscripts (xi) so there is no confusion about which is which. xi(n) is the nth observed (measured) value of variable xi.
In your case, you have a single dependent variable y and p input variables xi (i = 1...p). Assuming that their relation is linear (note: in many cases this assumption is not justified), we can assign weights ("importance") to each variable and try to find out those weights from measurements. In your case, the weights are denoted with betai (so the "importance" of variable xi is betai; note the same subscript).
If you have N observations of your dependent variable y, then you can arrange them in a column, just like the observations for your input variables. Note that we still have a single dependent variable, so essentially y is a scalar, but the N observations of that scalar form an N-dimensional column vector.
Now multiply the N x p input matrix by the p-dimensional column vector of weights beta. What you get is a column vector of N predicted values for y (\hat{y}). The difference of the N-dimensional column vector of predicted values \hat{y} and the N-dimensional column vector y of measured values is the error (which is minimised with the least squares method).
If you have q dependent variables yi (i = 1...q), each of them would generally have its own set of weights beta. In other words, the relation between the input variables and each yi will be different. The dependent variables can also be arranged in a matrix (just like the input matrix), and its dimensionality will be N x q, where q. In that case, the beta matrix will not be a single N-dimensional column vector but an N x q matrix. Each column in the beta matrix gives the relation between the input variables and the qth dependent variable yq. In that respect, a single observation of all variables yi will be a row vector in the y matrix.
I hope that this clarifies things up a bit. In summary, the explanation in the textbook is correct, but the notation is hard to follow and at times plain misleading (as in the case of variable and component at the beginning of the section). Honestly, you can get a much more intuitive explanation of linear regression from the Wikipedia article.
Here we are modeling a single output
, soK = 1
. In that case,\hat{Y}
would be a1 x 1
vector. You could argue that this is not technically a scalar, but this is a minor point. If you are modelling more than one output,K
would be greater than1
and\hat{Y}
would be a1 x K
row vector whereK
is the number of outputs. $\endgroup$^T
is that it doesn't matter for a scalar (a
happens to be the same asa^T
whena
is a1 x 1
vector). But in principle you are right that it should beY^T
. This is kind of sloppy writing. They have also missed the^
in the last sentence - that should be\hat{\beta}
. $\endgroup$