why $(N-p-1)\hat\sigma^2$ have chi-squared distribution in estimate of coefficients linear least square model?

904 Views Asked by At

I was recently read The book Elements of Statistical Learning by Tibshirani et.al. this book explain that coefficients of linear model have normal distribution $\hat\beta\sim N(\beta,(X^TX)^{-1}\sigma^2)$ and estimate of $\sigma$ have $(N-p-1)\hat\sigma^2 \sim \sigma \mathcal X_{N-p-1}^2$ distribution that is chi-squared. but I don't understand why is it chi squared and why degree of freedom is $N-p-1$.(equation 3.11 on page 47)