- More than one predictor involved in this case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#x,y,z with random predictors | |
x = 1:20 + rnorm(100,sd=3) | |
y = 1:20 + rnorm(100,sd=2) | |
z = 1:20 + rnorm(100,sd=3) | |
#correlation between x and y | |
cor(x,y) | |
#correlation between y and z | |
cor(y,z) | |
#linear regression with two variables | |
model = lm(y~x+z) | |
#Equation is | |
#(Intercept) x z | |
# 1.8885 0.3965 0.3587 | |
model | |
#y = 1.885 + 0.3965x + 0.3587z | |
err = residuals(model) | |
plot(model$fitted.values,err) | |
#This will look like normal distribution | |
hist(err) |
Happy Learning!!!
No comments:
Post a Comment