ECON 3209 · Week 3, Lecture 2 · Kerala Agricultural University
Autumn 2026
By the end of this lecture, you will be able to:
np.linalg.solve()Ordinary least squares can be written as:
\[\hat{\beta} = (X'X)^{-1}X'y\]
X are explanatory variables.T gives the transposenp.dot() computes the dot product of two vectors@ is Python’s matrix multiplication operatorprice × quantity across cropsnp.linalg.solve(A, b) solves Ax = bsolve() is usually preferred to inv() for equationsxWhen you understand matrices, regression output becomes less mysterious and more interpretable.
Use NumPy to solve the system:
x + 2y = 1003x - y = 40Then print the values of x and y.
Bonus: compute the determinant of the coefficient matrix.
@ and np.dot() perform key linear algebra operationsnp.linalg.solve() is the standard way to solve linear systemsECON 3209 — Kerala Agricultural University