If the goal is to explain variation in the response variable that can be ascribed to variation in the explanatory variables, linear regression analysis can be apply to quantify the strength of the relationship between the response and the explanatory variables, and in particular to determine whether some explanatory variables may have no linear relationship with the response at all, or to identify which subsets of explanatory variables may contain redundant information about the response. Like all forms of regression analysis, linear regression focuses on the conditional probability distribution of the response given the values of the predictors, rather than on the joint probability distribution of all of these variables, which is the domain of multivariate analysis. Least squares linear regression, as a means of finding a good rough linear fit to a set of points was performed by Legendre (1805) and gauss (1809) for the prediction of planetary movement. Quetelet was responsible for make the procedure well-known and for use it extensively in the social sciences.
# Load Train and Test datasets # Identify feature and response variable(s) and values must be numeric and numpy arrays x_train <- input_variables_values_training_datasets y_train <- target_variables_values_training_datasets x_test <- input_variables_values_test_datasets x <- cbind(x_train,y_train) # Train the model using the training sets and check score linear <- lm(y_train ~ ., data = x) summary(linear) # Predict Output predicted= predict(linear,x_test)