title: “r task 2” author: “jagadish” date: “November 18, 2015” output: html_document
input1=read.csv("C:/Users/localadmin/Desktop/vetri r task/input.csv")
View(input1)
indexes1 = sample(1:nrow(input1), size=0.7*nrow(input1))
indexes1
## [1] 7 6 13 1 22 24 27 29 17 30 16 9 23 15 11 19 25 14 2 10 28
View(indexes1)
inputtrain1=input1[indexes1,]
inputtest1=input1[-indexes1,]
nrow(input1)
## [1] 30
nrow(inputtrain1)
## [1] 21
nrow(inputtest1)
## [1] 9
cor(inputtrain1)
## Ticket.sales Stadium.Quality
## Ticket.sales 1.0000000 0.42264802
## Stadium.Quality 0.4226480 1.00000000
## Home_Team_Current.season.s.winning.percentage 0.5518482 0.19609818
## Away_Team_Current.season.s.winning.percentage 0.5236501 -0.09817119
## Distance.B.w.1.teams 0.4377773 0.36087175
## Weekend 0.2465015 0.05521576
## Free.to.air.Tv 0.1551853 -0.09571311
## X.of.promotions.provided 0.9871527 0.39271434
## Home_Team_Current.season.s.winning.percentage
## Ticket.sales 0.55184822
## Stadium.Quality 0.19609818
## Home_Team_Current.season.s.winning.percentage 1.00000000
## Away_Team_Current.season.s.winning.percentage 0.17364575
## Distance.B.w.1.teams 0.16116913
## Weekend 0.08177771
## Free.to.air.Tv -0.06399298
## X.of.promotions.provided 0.55915507
## Away_Team_Current.season.s.winning.percentage
## Ticket.sales 0.52365006
## Stadium.Quality -0.09817119
## Home_Team_Current.season.s.winning.percentage 0.17364575
## Away_Team_Current.season.s.winning.percentage 1.00000000
## Distance.B.w.1.teams 0.15134255
## Weekend -0.19303521
## Free.to.air.Tv -0.03944930
## X.of.promotions.provided 0.53312570
## Distance.B.w.1.teams
## Ticket.sales 0.4377773
## Stadium.Quality 0.3608718
## Home_Team_Current.season.s.winning.percentage 0.1611691
## Away_Team_Current.season.s.winning.percentage 0.1513425
## Distance.B.w.1.teams 1.0000000
## Weekend 0.3283176
## Free.to.air.Tv 0.2811536
## X.of.promotions.provided 0.4880455
## Weekend Free.to.air.Tv
## Ticket.sales 0.24650154 0.15518528
## Stadium.Quality 0.05521576 -0.09571311
## Home_Team_Current.season.s.winning.percentage 0.08177771 -0.06399298
## Away_Team_Current.season.s.winning.percentage -0.19303521 -0.03944930
## Distance.B.w.1.teams 0.32831762 0.28115359
## Weekend 1.00000000 0.55470020
## Free.to.air.Tv 0.55470020 1.00000000
## X.of.promotions.provided 0.23342969 0.17162672
## X.of.promotions.provided
## Ticket.sales 0.9871527
## Stadium.Quality 0.3927143
## Home_Team_Current.season.s.winning.percentage 0.5591551
## Away_Team_Current.season.s.winning.percentage 0.5331257
## Distance.B.w.1.teams 0.4880455
## Weekend 0.2334297
## Free.to.air.Tv 0.1716267
## X.of.promotions.provided 1.0000000
input12<-lm(Ticket.sales~X.of.promotions.provided,data=inputtrain1)
summary(input12)
##
## Call:
## lm(formula = Ticket.sales ~ X.of.promotions.provided, data = inputtrain1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -8083.5 -1576.1 -861.7 652.9 19751.9
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3.393e+03 1.883e+03 1.802 0.0875 .
## X.of.promotions.provided 2.362e+00 8.769e-02 26.930 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 5602 on 19 degrees of freedom
## Multiple R-squared: 0.9745, Adjusted R-squared: 0.9731
## F-statistic: 725.2 on 1 and 19 DF, p-value: < 2.2e-16
predicted1<- predict(input12, newdata=inputtest1[,-1])
predicted1
## 3 4 5 8 12 18 20
## 93569.383 92997.871 89134.263 79798.783 31829.579 37707.649 19187.833
## 21 26
## 16729.388 8331.471
original1<-inputtest1$Ticket.sales
ticketsales1<-cbind(original1,predicted1)
ticketsales1
## original1 predicted1
## 3 95460 93569.383
## 4 94856 92997.871
## 5 90764 89134.263
## 8 80883 79798.783
## 12 54730 31829.579
## 18 36324 37707.649
## 20 17600 19187.833
## 21 14861 16729.388
## 26 6969 8331.471