One of the ways to find the estimator using the ordinary least squares method is by generating random matrices, given by the formula:
B = (X’ X)^-1 X’Y
Where Y = a+bx+cw+u
, being x
and w
random vectors of size 1000 and distribution N(1,2)
.
The X
array has 3 columns, the first 1 being the second x
and the third w
, and 1000 rows. After generating this random matrix, a forcing must be performed for this procedure to be repeated 1000 times.
However, since I did not guarantee that the (X' X)
product generated an invertible array, the for gave me 1000 equal results, thus not varying the x
, w
and y
.
I'm trying to accomplish this condition by if but I'm not getting success. I would like to know if there is any command that guarantees that the array has an inverse.