203.1.5 Practice : Regression Line Fitting in R

Practice : Regression Line Fitting

Draw a scatter plot between Promotion_Budget and Passengers. Is there any any pattern between Promotion_Budget and Passengers?

Build a linear regression model on Promotion_Budget and Passengers.

If the Promotion_Budget is 650,000 how many passenger’s can be expected in that week?

Build a regression line to predict the passengers using Inter_metro_flight_ratio

Solution

Import Dataset: AirPassengers/AirPassengers.csv

air<-read.csv("R dataset\\AirPassengers\\AirPassengers.csv")

Find the correlation between Promotion_Budget and Passengers

cor(air$Passengers,air$Promotion_Budget)

## [1] 0.965851

The promotional budget and passengers the correlation is 96% which is a clear indicator of strong relationship.

Draw a scatter plot between Promotion_Budget and Passengers. Is there any any pattern between Promotion_Budget and Passengers?

plot(air$Promotion_Budget,air$Passengers)

There is a positive pattern between Promotion budget and passengers. We can see there is a very high correlation between these two variables as the promotional budget increase i.e reducing the ticket fares giving the coupons definitely number of passengers are really growing high. If a very less amount is spend on promotional budget in a particular week then the numbers of passengers are low.

Build a linear regression model on Promotion_Budget and Passengers.

For building the regression line we have to use a function called a linear model, lm is the abbreviation for linear model, then use the name of variable whose value needed to be predicted that is the number of passenger in this particular problem, use the symbol ‘~’ tilde then promotion budget which is in the dataset of Air passengers. We need to observe the code, where lm is abbreviation of linear model, Y is the number of passengers and X is the promotional budget.