Keep the declared column order. With columns (1,x,z) and observed (x,z)=(2,−1), the row is (1,2,−1). An intercept zero would erase its coefficient.
Check your reasoning
Rows (x,z): (3,0); (−1,2). Columns (1,x,z). Repair zero intercepts.
A(1,3,0); (1,−1,2)
B(0,3,0); (0,−1,2)
C(0,1,3); (2,1,−1)
Show answer and explanation
(1,3,0); (1,−1,2)
Intercept column: all ones.
03Evaluate each supplied feature before storing it#
Evaluate each supplied feature before storing it. If h(x)=x2, then x=−2 produces row (1,4) in columns (1,h). Keep the intercept column at 1.
Check your reasoning
Record x values (−3,0,2). Columns (1,h); h=x2. Give design rows.
A(1,−3); (1,0); (1,2)
B(0,9); (0,0); (0,4)
C(1,9); (1,0); (1,4)
Show answer and explanation
(1,9); (1,0); (1,4)
h=(9,0,4); prepend 1.
Key takeaway
Use one row per observation, evaluate the declared features, and preserve the column order. The intercept column is all ones.
Encode supplied predictors and an intercept as a design matrix.
Further questions
How can a supplied QR factorization solve for the coefficient vector?
For a full-column-rank design X=QR, compute Q-transpose y and solve the upper-triangular system R beta=Q-transpose y. Preserve the design’s coefficient order.