

It means a change in one unit in Age will bring 0.9709 units to change in Blood pressure. Interpretation of the model # Coefficients: # Residual standard error: 17.31 on 28 degrees of freedom

lm( ) function has two attributes first is a formula where we will use “BP ~ Age” because Age is an independent variable and Blood pressure is a dependent variable and the second is data, where we will give the name of the data frame containing data which is in this case, is data frame bp. Now with the help of lm( ) function, we are going to make a linear model. We can also verify our above analysis that there is a correlation between Blood pressure and Age by taking the help of cor( ) function in R which is used to calculate the correlation between two variables. It is quite evident by the graph that the distribution on the plot is scattered in a manner that we can fit a straight line through the points.Ĭalculating the correlation between Age and Blood pressure Taking the help of ggplot2 library in R we can see that there is a correlation between Blood Pressure and Age as we can see that the increase in Age is followed by an increase in blood pressure. p <- as.ame(53)Ĭolnames(p) <- "Age" Creating a scatter plot using ggplot2 library And this data frame will be used to predict blood pressure at Age 53 after creating a linear regression model. Importing a dataset of Age vs Blood Pressure which is a CSV file using function read.csv( ) in R and storing this dataset into a data frame bp.Ĭreating data frame for predicting valuesĬreating a data frame which will store Age 53. Now we are taking a dataset of Blood pressure and Age and with the help of the data train a linear regression model in R which will be able to predict blood pressure at ages that are not present in our dataset.Įquation of the regression line in our dataset. Linear regression is basically fitting a straight line to our dataset so that we can predict future events.ī0 and B1 – Regression parameter Predicting Blood pressure using Age by Regression in R The above idea of prediction sounds magical but it’s pure statistics.

Note that we are not calculating the dependency of the dependent variable on the independent variable just the association.įor example, A firm is investing some amount of money in the marketing of a product and it has also collected sales data throughout the years now by analyzing the correlation in the marketing budget and sales data we can predict next year’s sale if the company allocate a certain amount of money to the marketing department. The two variables involved are a dependent variable which response to the change and the independent variable. Simple linear regression analysis is a technique to find the association between two variables.

Practical application of linear regression using R.Īpplication on blood pressure and age dataset. Significance of linear regression in predictive analysis.
