You are on page 1of 3

❖ Practical No:06) Practical of Simple/Multiple Linear Regression.

➢ Example No:01)-Positive Regression.


> temperature<-c(50,55,60,65)
> temperature
[1] 50 55 60 65
> sales<-c(500,600,700,800)
> sales
[1] 500 600 700 800
> plot(temperature,sales)
> model<-lm(sales~temperature)
> abline(model,col=2,lwd=2)
> temperature<-data.frame(temperature=70)
> temperature
temperature
1 70
> outcome<-predict(model,temperature)
> outcome
1
900
> temperature<-data.frame(temperature=75)
> outcome<-predict(model,temperature)
> outcome
1
1000
>
➢ Output:
➢ Example No:02)-Negative Regression.
> temperature<-c(40,42,44,46)
> temperature
[1] 40 42 44 46
> teasale<-c(600,500,400,300)
> teasale
[1] 600 500 400 300
> plot(temperature,teasale)
> model<-lm(teasale~temperature)
> abline(model,col=1,lwd=2)
> temperature<-data.frame(temperature=48)
> outcome<-predict(model,temperature)
> outcome
1
200
> temperature<-data.frame(temperature=50)
> outcome<-predict(model,temperature)
> outcome
1
100
>
➢ Outcome:

You might also like