input <- read.csv("C:/Users/localadmin/Downloads/input.csv")
View(input)
P<-head(input, 21)
s <- input[c(22:30),]
cor(P)
## Ticket.sales Stadium.Quality
## Ticket.sales 1.0000000 0.2419721
## Stadium.Quality 0.2419721 1.0000000
## Home_Team_Current.season.s.winning.percentage 0.5112595 0.1015776
## Away_Team_Current.season.s.winning.percentage 0.2121532 -0.2368883
## Distance.B.w.1.teams 0.2747518 0.1715792
## Weekend 0.3639809 -0.1851993
## Free.to.air.Tv 0.3455727 -0.3052570
## X.of.promotions.provided 0.9667682 0.1628325
## Home_Team_Current.season.s.winning.percentage
## Ticket.sales 0.51125954
## Stadium.Quality 0.10157764
## Home_Team_Current.season.s.winning.percentage 1.00000000
## Away_Team_Current.season.s.winning.percentage 0.09114916
## Distance.B.w.1.teams -0.15762890
## Weekend -0.22342133
## Free.to.air.Tv 0.02932318
## X.of.promotions.provided 0.52848833
## Away_Team_Current.season.s.winning.percentage
## Ticket.sales 0.21215319
## Stadium.Quality -0.23688833
## Home_Team_Current.season.s.winning.percentage 0.09114916
## Away_Team_Current.season.s.winning.percentage 1.00000000
## Distance.B.w.1.teams 0.26745150
## Weekend 0.19237116
## Free.to.air.Tv 0.01221097
## X.of.promotions.provided 0.20772176
## Distance.B.w.1.teams
## Ticket.sales 0.2747518
## Stadium.Quality 0.1715792
## Home_Team_Current.season.s.winning.percentage -0.1576289
## Away_Team_Current.season.s.winning.percentage 0.2674515
## Distance.B.w.1.teams 1.0000000
## Weekend 0.3206036
## Free.to.air.Tv 0.1833685
## X.of.promotions.provided 0.3506260
## Weekend Free.to.air.Tv
## Ticket.sales 0.3639809 0.34557268
## Stadium.Quality -0.1851993 -0.30525697
## Home_Team_Current.season.s.winning.percentage -0.2234213 0.02932318
## Away_Team_Current.season.s.winning.percentage 0.1923712 0.01221097
## Distance.B.w.1.teams 0.3206036 0.18336846
## Weekend 1.0000000 0.45226702
## Free.to.air.Tv 0.4522670 1.00000000
## X.of.promotions.provided 0.3929980 0.39169132
## X.of.promotions.provided
## Ticket.sales 0.9667682
## Stadium.Quality 0.1628325
## Home_Team_Current.season.s.winning.percentage 0.5284883
## Away_Team_Current.season.s.winning.percentage 0.2077218
## Distance.B.w.1.teams 0.3506260
## Weekend 0.3929980
## Free.to.air.Tv 0.3916913
## X.of.promotions.provided 1.0000000
L<-lm(Ticket.sales~X.of.promotions.provided,data=P)
summary(L)
##
## Call:
## lm(formula = Ticket.sales ~ X.of.promotions.provided, data = P)
##
## Residuals:
## Min 1Q Median 3Q Max
## -8609.4 -4208.7 -403.4 1848.1 19776.1
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 7965.434 3675.534 2.167 0.0431 *
## X.of.promotions.provided 2.241 0.136 16.483 1.04e-12 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7334 on 19 degrees of freedom
## Multiple R-squared: 0.9346, Adjusted R-squared: 0.9312
## F-statistic: 271.7 on 1 and 19 DF, p-value: 1.036e-12
pre<-predict(L,newdata=s[,-1])
pre
## 22 23 24 25 26 27 28
## 16534.237 14593.200 13806.475 11847.507 12652.163 11589.748 10316.643
## 29 30
## 9917.677 10525.092
s$Ticket.sales
## [1] 10061 9858 8686 7873 6969 5390 4769 3960 3807
myTrain <- input[sample(1:nrow(input), 0.7*nrow(input)),]
myTest<- input[-sample(1:nrow(input), 0.7*nrow(input)),]
cor(myTrain)
## Ticket.sales Stadium.Quality
## Ticket.sales 1.0000000 0.43064982
## Stadium.Quality 0.4306498 1.00000000
## Home_Team_Current.season.s.winning.percentage 0.5272892 0.08432209
## Away_Team_Current.season.s.winning.percentage 0.6116149 0.12857940
## Distance.B.w.1.teams 0.3444225 0.28338955
## Weekend 0.3591333 0.17960530
## Free.to.air.Tv 0.2510682 0.06110296
## X.of.promotions.provided 0.9963348 0.44154066
## Home_Team_Current.season.s.winning.percentage
## Ticket.sales 0.52728920
## Stadium.Quality 0.08432209
## Home_Team_Current.season.s.winning.percentage 1.00000000
## Away_Team_Current.season.s.winning.percentage 0.30996059
## Distance.B.w.1.teams 0.24459803
## Weekend 0.06123724
## Free.to.air.Tv 0.05000000
## X.of.promotions.provided 0.52308807
## Away_Team_Current.season.s.winning.percentage
## Ticket.sales 0.61161486
## Stadium.Quality 0.12857940
## Home_Team_Current.season.s.winning.percentage 0.30996059
## Away_Team_Current.season.s.winning.percentage 1.00000000
## Distance.B.w.1.teams 0.06228234
## Weekend -0.16778901
## Free.to.air.Tv -0.08219949
## X.of.promotions.provided 0.59752582
## Distance.B.w.1.teams
## Ticket.sales 0.34442245
## Stadium.Quality 0.28338955
## Home_Team_Current.season.s.winning.percentage 0.24459803
## Away_Team_Current.season.s.winning.percentage 0.06228234
## Distance.B.w.1.teams 1.00000000
## Weekend 0.36610222
## Free.to.air.Tv 0.20362411
## X.of.promotions.provided 0.35832172
## Weekend Free.to.air.Tv
## Ticket.sales 0.35913334 0.25106815
## Stadium.Quality 0.17960530 0.06110296
## Home_Team_Current.season.s.winning.percentage 0.06123724 0.05000000
## Away_Team_Current.season.s.winning.percentage -0.16778901 -0.08219949
## Distance.B.w.1.teams 0.36610222 0.20362411
## Weekend 1.00000000 0.61237244
## Free.to.air.Tv 0.61237244 1.00000000
## X.of.promotions.provided 0.36659211 0.24330855
## X.of.promotions.provided
## Ticket.sales 0.9963348
## Stadium.Quality 0.4415407
## Home_Team_Current.season.s.winning.percentage 0.5230881
## Away_Team_Current.season.s.winning.percentage 0.5975258
## Distance.B.w.1.teams 0.3583217
## Weekend 0.3665921
## Free.to.air.Tv 0.2433086
## X.of.promotions.provided 1.0000000
lin<- lm(Ticket.sales~X.of.promotions.provided,data=myTrain)
summary(lin)
##
## Call:
## lm(formula = Ticket.sales ~ X.of.promotions.provided, data = myTrain)
##
## Residuals:
## Min 1Q Median 3Q Max
## -7746.1 -342.7 43.6 1464.5 6854.5
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.936e+03 1.044e+03 1.854 0.0793 .
## X.of.promotions.provided 2.395e+00 4.717e-02 50.771 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3121 on 19 degrees of freedom
## Multiple R-squared: 0.9927, Adjusted R-squared: 0.9923
## F-statistic: 2578 on 1 and 19 DF, p-value: < 2.2e-16
pred<-predict(lin,newdata = myTest[,-1])
pred
## 1 8 10 15 18 20 21
## 90894.457 79418.084 81547.152 47053.370 36733.735 17952.909 15459.815
## 26 29
## 6943.541 4021.760
myTest$Ticket.sales
## [1] 97749 80883 73870 47097 36324 17600 14861 6969 3960