"No one is harder on a talented person than the person themselves" - Linda Wilkinson ; "Trust your guts and don't follow the herd" ; "Validate direction not destination" ;

March 19, 2016

Data Science Tip Day#7 - Interaction Variables

This post is using interaction variables while performing linear regression

For illustration purpose lets construct some datasets with a three vectors (y,x,z)


y = c(seq(1,200,by=2))
x = c(seq(1,404,by=4))
z = c(seq(100,200,by=1))
#x*z is new interaction variable
p = x*z
model = lm(y~x+p)
#Validating the model
plot(model$fitted.values, model$residual.values)
#Has some pattern (Failure - Not convincing representation)
hist(model$residuals)
#Left skewed Histogram of normal distribution (ok ok)

Happy Learning!!!

No comments: