Confirm the vectors are present, run the model using lm, extract
the residuals using residuals function.
Confirming the residuals are normally distributed
Since the p-value is more than 0.05, we cannot reject the null
hypothesis. The null hypothesis for this test is the residuals are
normally distributed. This is same as Anderson-Darling test.
Confirming constant variance.
for this is
heteroskedascticity (which means variance is not constant). We
run bptest, for which the null hypothesis is that the variance is constant (homoskedastic).
Note that I have used bptest from lmtest package. Here again we will reject the null if p less than 0.05
The residuals do not exhibit constant variance.
Confirming that there is no Serial or Auto Correlation
Here again the p-value is less than 0.05 and therefore we reject the null hypothesis. The null hypothesis
for this test is that there is no auto-correlation.
To learn more about these tests, kindly visit wiki or bing it.
Loading libraries as needed
try require as shown.
if require is not successful, then load the lmtest as
follows and then re-run require command as above. Use
Packages menu at the top to install a package.
Normality of the Residuals: Visual Verification
The residuals can be extracted as follows:
And the following plot is generated. If the
points deviate from the line, then the
points are not from Normal Distribution.