summary(data)
## Ship_Mode Profit Unit_Price Shipping_Cost
## Length:264 Min. : -1766 Min. : 2.88 Min. : 0.50
## Class :character 1st Qu.: 48154 1st Qu.: 5.28 1st Qu.:74.35
## Mode :character Median :123915 Median : 40.42 Median :74.35
## Mean :125237 Mean :101.48 Mean :70.51
## 3rd Qu.:199676 3rd Qu.:120.98 3rd Qu.:74.35
## Max. :275438 Max. :500.98 Max. :74.35
## Customer_Name
## Length:264
## Class :character
## Mode :character
##
##
##
set.seed(45)
samp_mean <- function(x,i){
mean(x[i])}
BOOTSTRAP<-boot(data$Profit,samp_mean, 100)
plot(BOOTSTRAP)
boot.ci(BOOTSTRAP,type = "perc")
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 100 bootstrap replicates
##
## CALL :
## boot.ci(boot.out = BOOTSTRAP, type = "perc")
##
## Intervals :
## Level Percentile
## 95% (116054, 137222 )
## Calculations and Intervals on Original Scale
## Some percentile intervals may be unstable
Hypothesis test comparing the mean to a fixed value. I will also be stating my null and alternative hypothesis.
t.test
H0:μ=1 HA:μ≠1
t.test(data$Profit, mu = 1)
##
## One Sample t-test
##
## data: data$Profit
## t = 23.678, df = 263, p-value < 2.2e-16
## alternative hypothesis: true mean is not equal to 1
## 95 percent confidence interval:
## 114822.6 135651.5
## sample estimates:
## mean of x
## 125237
\[ t = \frac{\mu-\overline x}{SE} \]
BOOTSTRAP$t0
## [1] 125237
SE<-sd(BOOTSTRAP$t)
c(BOOTSTRAP$t0-2*SE,BOOTSTRAP$t0+2*SE)
## [1] 115591.8 134882.3
t=(3-BOOTSTRAP$t0)/SE
pt(t,100)
## [1] 1.522668e-46
mean(0 == BOOTSTRAP$t)
## [1] 0
mean(1<=BOOTSTRAP$t)
## [1] 1
Since the mean of 1<=BOOTSTRAP$t it is 0 and the inference in correct statistical terms.
data$Profit[is.na(data$Shipping_Cost)] <- 0
data$Profit
## [1] -213.25 457.81 46.71 1198.97 -4.72 782.91 93.80
## [8] 440.72 -481.04 -11.68 313.58 26.92 -5.77 -172.88
## [15] -144.55 5.76 252.66 -1766.01 -236.27 80.44 118.94
## [22] 3424.22 -213.25 457.81 46.71 1198.97 2351.23 3503.50
## [29] 4655.76 5808.03 6960.29 8112.55 9264.82 10417.08 11569.34
## [36] 12721.61 13873.87 15026.13 16178.40 17330.66 18482.92 19635.19
## [43] 20787.45 21939.71 23091.98 24244.24 25396.50 26548.77 27701.03
## [50] 28853.30 30005.56 31157.82 32310.09 33462.35 34614.61 35766.88
## [57] 36919.14 38071.40 39223.67 40375.93 41528.19 42680.46 43832.72
## [64] 44984.98 46137.25 47289.51 48441.77 49594.04 50746.30 51898.57
## [71] 53050.83 54203.09 55355.36 56507.62 57659.88 58812.15 59964.41
## [78] 61116.67 62268.94 63421.20 64573.46 65725.73 66877.99 68030.25
## [85] 69182.52 70334.78 71487.04 72639.31 73791.57 74943.84 76096.10
## [92] 77248.36 78400.63 79552.89 80705.15 81857.42 83009.68 84161.94
## [99] 85314.21 86466.47 87618.73 88771.00 89923.26 91075.52 92227.79
## [106] 93380.05 94532.31 95684.58 96836.84 97989.11 99141.37 100293.63
## [113] 101445.90 102598.16 103750.42 104902.69 106054.95 107207.21 108359.48
## [120] 109511.74 110664.00 111816.27 112968.53 114120.79 115273.06 116425.32
## [127] 117577.58 118729.85 119882.11 121034.38 122186.64 123338.90 124491.17
## [134] 125643.43 126795.69 127947.96 129100.22 130252.48 131404.75 132557.01
## [141] 133709.27 134861.54 136013.80 137166.06 138318.33 139470.59 140622.85
## [148] 141775.12 142927.38 144079.65 145231.91 146384.17 147536.44 148688.70
## [155] 149840.96 150993.23 152145.49 153297.75 154450.02 155602.28 156754.54
## [162] 157906.81 159059.07 160211.33 161363.60 162515.86 163668.12 164820.39
## [169] 165972.65 167124.92 168277.18 169429.44 170581.71 171733.97 172886.23
## [176] 174038.50 175190.76 176343.02 177495.29 178647.55 179799.81 180952.08
## [183] 182104.34 183256.60 184408.87 185561.13 186713.39 187865.66 189017.92
## [190] 190170.19 191322.45 192474.71 193626.98 194779.24 195931.50 197083.77
## [197] 198236.03 199388.29 200540.56 201692.82 202845.08 203997.35 205149.61
## [204] 206301.87 207454.14 208606.40 209758.66 210910.93 212063.19 213215.46
## [211] 214367.72 215519.98 216672.25 217824.51 218976.77 220129.04 221281.30
## [218] 222433.56 223585.83 224738.09 225890.35 227042.62 228194.88 229347.14
## [225] 230499.41 231651.67 232803.93 233956.20 235108.46 236260.73 237412.99
## [232] 238565.25 239717.52 240869.78 242022.04 243174.31 244326.57 245478.83
## [239] 246631.10 247783.36 248935.62 250087.89 251240.15 252392.41 253544.68
## [246] 254696.94 255849.20 257001.47 258153.73 259306.00 260458.26 261610.52
## [253] 262762.79 263915.05 265067.31 266219.58 267371.84 268524.10 269676.37
## [260] 270828.63 271980.89 273133.16 274285.42 275437.68
samp_mean <- function(x, i){
mean(x[i])
}
BOOTSTRAP1<-boot(data$Profit,samp_mean, R = 1000)
plot(BOOTSTRAP1)
boot.ci(BOOTSTRAP1, type = "perc")
## BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
## Based on 1000 bootstrap replicates
##
## CALL :
## boot.ci(boot.out = BOOTSTRAP1, type = "perc")
##
## Intervals :
## Level Percentile
## 95% (115222, 135224 )
## Calculations and Intervals on Original Scale
min(3<=BOOTSTRAP1$t)
## [1] 1
library(caret)
## Loading required package: lattice
##
## Attaching package: 'lattice'
## The following object is masked from 'package:boot':
##
## melanoma
## Loading required package: ggplot2
library(lattice)
library(boot)
library(ggplot2)
data$Profit[is.na(data$Customer_Name)] <- 0
data$Customer_Name[is.na(data$Shipping_Cost)] <- 0
CV <- createDataPartition(data$Shipping_Cost, p=0.66,list = FALSE)
CV
## Resample1
## [1,] 2
## [2,] 3
## [3,] 4
## [4,] 5
## [5,] 6
## [6,] 8
## [7,] 9
## [8,] 10
## [9,] 11
## [10,] 12
## [11,] 14
## [12,] 15
## [13,] 17
## [14,] 18
## [15,] 19
## [16,] 20
## [17,] 21
## [18,] 23
## [19,] 24
## [20,] 25
## [21,] 26
## [22,] 27
## [23,] 28
## [24,] 32
## [25,] 35
## [26,] 36
## [27,] 38
## [28,] 39
## [29,] 42
## [30,] 43
## [31,] 45
## [32,] 46
## [33,] 47
## [34,] 51
## [35,] 52
## [36,] 53
## [37,] 54
## [38,] 55
## [39,] 56
## [40,] 58
## [41,] 59
## [42,] 60
## [43,] 61
## [44,] 62
## [45,] 65
## [46,] 66
## [47,] 68
## [48,] 69
## [49,] 71
## [50,] 72
## [51,] 75
## [52,] 77
## [53,] 82
## [54,] 83
## [55,] 84
## [56,] 86
## [57,] 87
## [58,] 88
## [59,] 89
## [60,] 91
## [61,] 92
## [62,] 94
## [63,] 95
## [64,] 98
## [65,] 99
## [66,] 102
## [67,] 104
## [68,] 107
## [69,] 108
## [70,] 109
## [71,] 110
## [72,] 111
## [73,] 112
## [74,] 113
## [75,] 116
## [76,] 118
## [77,] 120
## [78,] 121
## [79,] 122
## [80,] 123
## [81,] 124
## [82,] 125
## [83,] 129
## [84,] 130
## [85,] 131
## [86,] 132
## [87,] 134
## [88,] 137
## [89,] 138
## [90,] 139
## [91,] 141
## [92,] 142
## [93,] 143
## [94,] 145
## [95,] 147
## [96,] 148
## [97,] 149
## [98,] 151
## [99,] 152
## [100,] 153
## [101,] 154
## [102,] 156
## [103,] 157
## [104,] 163
## [105,] 164
## [106,] 165
## [107,] 167
## [108,] 168
## [109,] 172
## [110,] 173
## [111,] 174
## [112,] 175
## [113,] 176
## [114,] 178
## [115,] 179
## [116,] 180
## [117,] 181
## [118,] 184
## [119,] 185
## [120,] 186
## [121,] 188
## [122,] 190
## [123,] 194
## [124,] 195
## [125,] 196
## [126,] 197
## [127,] 198
## [128,] 199
## [129,] 200
## [130,] 201
## [131,] 202
## [132,] 203
## [133,] 204
## [134,] 205
## [135,] 206
## [136,] 209
## [137,] 210
## [138,] 213
## [139,] 214
## [140,] 215
## [141,] 216
## [142,] 217
## [143,] 219
## [144,] 220
## [145,] 221
## [146,] 222
## [147,] 223
## [148,] 224
## [149,] 225
## [150,] 228
## [151,] 231
## [152,] 232
## [153,] 233
## [154,] 238
## [155,] 239
## [156,] 241
## [157,] 242
## [158,] 244
## [159,] 245
## [160,] 247
## [161,] 248
## [162,] 249
## [163,] 251
## [164,] 252
## [165,] 253
## [166,] 254
## [167,] 255
## [168,] 256
## [169,] 257
## [170,] 258
## [171,] 259
## [172,] 260
## [173,] 261
## [174,] 262
## [175,] 263
hw <- data[CV,]
HW <- data[CV,]
HW
## Ship_Mode Profit Unit_Price Shipping_Cost Customer_Name
## 2 Delivery Truck 457.81 208.16 68.02 Barry French
## 3 Regular Air 46.71 8.69 2.99 Barry French
## 4 Regular Air 1198.97 195.99 3.99 Clay Rozendal
## 5 Regular Air -4.72 5.28 2.99 Claudia Miner
## 6 Regular Air 782.91 39.89 3.04 Neola Schneider
## 8 Delivery Truck 440.72 100.98 26.22 Sylvia Foulston
## 9 Regular Air -481.04 100.98 69.00 Sylvia Foulston
## 10 Regular Air -11.68 65.99 5.26 Jim Radford
## 11 Regular Air 313.58 155.99 8.99 Jim Radford
## 12 Express Air 26.92 3.69 0.50 Carlos Soltero
## 14 Regular Air -172.88 15.99 13.18 Carl Ludwig
## 15 Regular Air -144.55 4.89 4.93 Carl Ludwig
## 17 Regular Air 252.66 40.96 1.99 Jack Garza
## 18 Delivery Truck -1766.01 95.95 74.35 Julia West
## 19 Regular Air -236.27 3.89 74.35 Eugene Barchas
## 20 Delivery Truck 80.44 120.98 74.35 Eugene Barchas
## 21 Regular Air 118.94 500.98 74.35 Eugene Barchas
## 23 Regular Air -213.25 38.94 74.35 Muhammed MacIntyre
## 24 Delivery Truck 457.81 208.16 74.35 Barry French
## 25 Regular Air 46.71 8.69 74.35 Barry French
## 26 Regular Air 1198.97 195.99 74.35 Clay Rozendal
## 27 Regular Air 2351.23 5.28 74.35 Claudia Miner
## 28 Regular Air 3503.50 39.89 74.35 Neola Schneider
## 32 Regular Air 8112.55 65.99 74.35 Jim Radford
## 35 Regular Air 11569.34 4.71 74.35 Carlos Soltero
## 36 Regular Air 12721.61 15.99 74.35 Carl Ludwig
## 38 Regular Air 15026.13 2.88 74.35 Don Miller
## 39 Regular Air 16178.40 40.96 74.35 Jack Garza
## 42 Delivery Truck 19635.19 120.98 74.35 Eugene Barchas
## 43 Regular Air 20787.45 500.98 74.35 Eugene Barchas
## 45 Regular Air 23091.98 38.94 74.35 Muhammed MacIntyre
## 46 Delivery Truck 24244.24 208.16 74.35 Barry French
## 47 Regular Air 25396.50 8.69 74.35 Barry French
## 51 Regular Air 30005.56 15.74 74.35 Allen Rosenblatt
## 52 Delivery Truck 31157.82 100.98 74.35 Sylvia Foulston
## 53 Regular Air 32310.09 100.98 74.35 Sylvia Foulston
## 54 Regular Air 33462.35 65.99 74.35 Jim Radford
## 55 Regular Air 34614.61 155.99 74.35 Jim Radford
## 56 Express Air 35766.88 3.69 74.35 Carlos Soltero
## 58 Regular Air 38071.40 15.99 74.35 Carl Ludwig
## 59 Regular Air 39223.67 4.89 74.35 Carl Ludwig
## 60 Regular Air 40375.93 2.88 74.35 Don Miller
## 61 Regular Air 41528.19 40.96 74.35 Jack Garza
## 62 Delivery Truck 42680.46 95.95 74.35 Julia West
## 65 Regular Air 46137.25 500.98 74.35 Eugene Barchas
## 66 Delivery Truck 47289.51 500.98 74.35 Edward Hooks
## 68 Delivery Truck 49594.04 208.16 74.35 Barry French
## 69 Regular Air 50746.30 8.69 74.35 Barry French
## 71 Regular Air 53050.83 5.28 74.35 Claudia Miner
## 72 Regular Air 54203.09 39.89 74.35 Neola Schneider
## 75 Regular Air 57659.88 100.98 74.35 Sylvia Foulston
## 77 Regular Air 59964.41 155.99 74.35 Jim Radford
## 82 Regular Air 65725.73 2.88 74.35 Don Miller
## 83 Regular Air 66877.99 40.96 74.35 Jack Garza
## 84 Delivery Truck 68030.25 95.95 74.35 Julia West
## 86 Delivery Truck 70334.78 120.98 74.35 Eugene Barchas
## 87 Regular Air 71487.04 500.98 74.35 Eugene Barchas
## 88 Delivery Truck 72639.31 500.98 74.35 Edward Hooks
## 89 Regular Air 73791.57 38.94 74.35 Muhammed MacIntyre
## 91 Regular Air 76096.10 8.69 74.35 Barry French
## 92 Regular Air 77248.36 195.99 74.35 Clay Rozendal
## 94 Regular Air 79552.89 39.89 74.35 Neola Schneider
## 95 Regular Air 80705.15 15.74 74.35 Allen Rosenblatt
## 98 Regular Air 84161.94 65.99 74.35 Jim Radford
## 99 Regular Air 85314.21 155.99 74.35 Jim Radford
## 102 Regular Air 88771.00 15.99 74.35 Carl Ludwig
## 104 Regular Air 91075.52 2.88 74.35 Don Miller
## 107 Regular Air 94532.31 3.89 74.35 Eugene Barchas
## 108 Delivery Truck 95684.58 120.98 74.35 Eugene Barchas
## 109 Regular Air 96836.84 500.98 74.35 Eugene Barchas
## 110 Delivery Truck 97989.11 500.98 74.35 Edward Hooks
## 111 Regular Air 99141.37 38.94 74.35 Muhammed MacIntyre
## 112 Delivery Truck 100293.63 208.16 74.35 Barry French
## 113 Regular Air 101445.90 8.69 74.35 Barry French
## 116 Regular Air 104902.69 39.89 74.35 Neola Schneider
## 118 Delivery Truck 107207.21 100.98 74.35 Sylvia Foulston
## 120 Regular Air 109511.74 65.99 74.35 Jim Radford
## 121 Regular Air 110664.00 155.99 74.35 Jim Radford
## 122 Express Air 111816.27 3.69 74.35 Carlos Soltero
## 123 Regular Air 112968.53 4.71 74.35 Carlos Soltero
## 124 Regular Air 114120.79 15.99 74.35 Carl Ludwig
## 125 Regular Air 115273.06 4.89 74.35 Carl Ludwig
## 129 Regular Air 119882.11 3.89 74.35 Eugene Barchas
## 130 Delivery Truck 121034.38 120.98 74.35 Eugene Barchas
## 131 Regular Air 122186.64 500.98 74.35 Eugene Barchas
## 132 Delivery Truck 123338.90 500.98 74.35 Edward Hooks
## 134 Delivery Truck 125643.43 208.16 74.35 Barry French
## 137 Regular Air 129100.22 5.28 74.35 Claudia Miner
## 138 Regular Air 130252.48 39.89 74.35 Neola Schneider
## 139 Regular Air 131404.75 15.74 74.35 Allen Rosenblatt
## 141 Regular Air 133709.27 100.98 74.35 Sylvia Foulston
## 142 Regular Air 134861.54 65.99 74.35 Jim Radford
## 143 Regular Air 136013.80 155.99 74.35 Jim Radford
## 145 Regular Air 138318.33 4.71 74.35 Carlos Soltero
## 147 Regular Air 140622.85 4.89 74.35 Carl Ludwig
## 148 Regular Air 141775.12 2.88 74.35 Don Miller
## 149 Regular Air 142927.38 40.96 74.35 Jack Garza
## 151 Regular Air 145231.91 3.89 74.35 Eugene Barchas
## 152 Delivery Truck 146384.17 120.98 74.35 Eugene Barchas
## 153 Regular Air 147536.44 500.98 74.35 Eugene Barchas
## 154 Delivery Truck 148688.70 500.98 74.35 Edward Hooks
## 156 Delivery Truck 150993.23 208.16 74.35 Barry French
## 157 Regular Air 152145.49 8.69 74.35 Barry French
## 163 Regular Air 159059.07 100.98 74.35 Sylvia Foulston
## 164 Regular Air 160211.33 65.99 74.35 Jim Radford
## 165 Regular Air 161363.60 155.99 74.35 Jim Radford
## 167 Regular Air 163668.12 4.71 74.35 Carlos Soltero
## 168 Regular Air 164820.39 15.99 74.35 Carl Ludwig
## 172 Delivery Truck 169429.44 95.95 74.35 Julia West
## 173 Regular Air 170581.71 3.89 74.35 Eugene Barchas
## 174 Delivery Truck 171733.97 120.98 74.35 Eugene Barchas
## 175 Regular Air 172886.23 500.98 74.35 Eugene Barchas
## 176 Delivery Truck 174038.50 500.98 74.35 Edward Hooks
## 178 Delivery Truck 176343.02 208.16 74.35 Barry French
## 179 Regular Air 177495.29 8.69 74.35 Barry French
## 180 Regular Air 178647.55 195.99 74.35 Clay Rozendal
## 181 Regular Air 179799.81 5.28 74.35 Claudia Miner
## 184 Delivery Truck 183256.60 100.98 74.35 Sylvia Foulston
## 185 Regular Air 184408.87 100.98 74.35 Sylvia Foulston
## 186 Regular Air 185561.13 65.99 74.35 Jim Radford
## 188 Express Air 187865.66 3.69 74.35 Carlos Soltero
## 190 Regular Air 190170.19 15.99 74.35 Carl Ludwig
## 194 Delivery Truck 194779.24 95.95 74.35 Julia West
## 195 Regular Air 195931.50 3.89 74.35 Eugene Barchas
## 196 Delivery Truck 197083.77 120.98 74.35 Eugene Barchas
## 197 Regular Air 198236.03 500.98 74.35 Eugene Barchas
## 198 Delivery Truck 199388.29 500.98 74.35 Edward Hooks
## 199 Regular Air 200540.56 38.94 74.35 Muhammed MacIntyre
## 200 Delivery Truck 201692.82 208.16 74.35 Barry French
## 201 Regular Air 202845.08 8.69 74.35 Barry French
## 202 Regular Air 203997.35 195.99 74.35 Clay Rozendal
## 203 Regular Air 205149.61 5.28 74.35 Claudia Miner
## 204 Regular Air 206301.87 39.89 74.35 Neola Schneider
## 205 Regular Air 207454.14 15.74 74.35 Allen Rosenblatt
## 206 Delivery Truck 208606.40 100.98 74.35 Sylvia Foulston
## 209 Regular Air 212063.19 155.99 74.35 Jim Radford
## 210 Express Air 213215.46 3.69 74.35 Carlos Soltero
## 213 Regular Air 216672.25 4.89 74.35 Carl Ludwig
## 214 Regular Air 217824.51 2.88 74.35 Don Miller
## 215 Regular Air 218976.77 40.96 74.35 Jack Garza
## 216 Delivery Truck 220129.04 95.95 74.35 Julia West
## 217 Regular Air 221281.30 3.89 74.35 Eugene Barchas
## 219 Regular Air 223585.83 500.98 74.35 Eugene Barchas
## 220 Delivery Truck 224738.09 500.98 74.35 Edward Hooks
## 221 Regular Air 225890.35 38.94 74.35 Muhammed MacIntyre
## 222 Delivery Truck 227042.62 208.16 74.35 Barry French
## 223 Regular Air 228194.88 8.69 74.35 Barry French
## 224 Regular Air 229347.14 195.99 74.35 Clay Rozendal
## 225 Regular Air 230499.41 5.28 74.35 Claudia Miner
## 228 Delivery Truck 233956.20 100.98 74.35 Sylvia Foulston
## 231 Regular Air 237412.99 155.99 74.35 Jim Radford
## 232 Express Air 238565.25 3.69 74.35 Carlos Soltero
## 233 Regular Air 239717.52 4.71 74.35 Carlos Soltero
## 238 Delivery Truck 245478.83 95.95 74.35 Julia West
## 239 Regular Air 246631.10 3.89 74.35 Eugene Barchas
## 241 Regular Air 248935.62 500.98 74.35 Eugene Barchas
## 242 Delivery Truck 250087.89 500.98 74.35 Edward Hooks
## 244 Delivery Truck 252392.41 208.16 74.35 Barry French
## 245 Regular Air 253544.68 8.69 74.35 Barry French
## 247 Regular Air 255849.20 5.28 74.35 Claudia Miner
## 248 Regular Air 257001.47 39.89 74.35 Neola Schneider
## 249 Regular Air 258153.73 15.74 74.35 Allen Rosenblatt
## 251 Regular Air 260458.26 100.98 74.35 Sylvia Foulston
## 252 Regular Air 261610.52 65.99 74.35 Jim Radford
## 253 Regular Air 262762.79 155.99 74.35 Jim Radford
## 254 Express Air 263915.05 3.69 74.35 Carlos Soltero
## 255 Regular Air 265067.31 4.71 74.35 Carlos Soltero
## 256 Regular Air 266219.58 15.99 74.35 Carl Ludwig
## 257 Regular Air 267371.84 4.89 74.35 Carl Ludwig
## 258 Regular Air 268524.10 2.88 74.35 Don Miller
## 259 Regular Air 269676.37 40.96 74.35 Jack Garza
## 260 Delivery Truck 270828.63 95.95 74.35 Julia West
## 261 Regular Air 271980.89 3.89 74.35 Eugene Barchas
## 262 Delivery Truck 273133.16 120.98 74.35 Eugene Barchas
## 263 Regular Air 274285.42 500.98 74.35 Eugene Barchas
model <- lm(Profit ~ Customer_Name, data = HW)
summary(model)
##
## Call:
## lm(formula = Profit ~ Customer_Name, data = HW)
##
## Residuals:
## Min 1Q Median 3Q Max
## -152965 -79862 -2851 74612 161617
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 141545 40716 3.476 0.000654 ***
## Customer_NameBarry French -24401 45106 -0.541 0.589276
## Customer_NameCarl Ludwig -23420 47432 -0.494 0.622150
## Customer_NameCarlos Soltero 10954 47910 0.229 0.819445
## Customer_NameClaudia Miner -9570 51902 -0.184 0.853942
## Customer_NameClay Rozendal -26272 55129 -0.477 0.634335
## Customer_NameDon Miller -21498 53309 -0.403 0.687289
## Customer_NameEdward Hooks 7144 50781 0.141 0.888298
## Customer_NameEugene Barchas -2080 43978 -0.047 0.962336
## Customer_NameJack Garza -33485 53309 -0.628 0.530816
## Customer_NameJim Radford -21652 45760 -0.473 0.636750
## Customer_NameJulia West 9654 51902 0.186 0.852677
## Customer_NameMuhammed MacIntyre -37838 55129 -0.686 0.493489
## Customer_NameNeola Schneider -36982 51902 -0.713 0.477174
## Customer_NameSylvia Foulston -19102 47910 -0.399 0.690634
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 91040 on 160 degrees of freedom
## Multiple R-squared: 0.02832, Adjusted R-squared: -0.0567
## F-statistic: 0.3331 on 14 and 160 DF, p-value: 0.9888
col.rainbow <- rainbow(2)
palette(col.rainbow)
plot(data$Unit_Price ~ data$Shipping_Cost,pch=19,col = as.factor(data$Profit))
abline(model)
## Warning in abline(model): only using the first two of 15 regression coefficients
ggplot(data = data, mapping = aes(Profit,Unit_Price,color = "pink"))+
geom_jitter()+
geom_smooth(method = lm)
## `geom_smooth()` using formula 'y ~ x'
pre <- predict(model,data[-data$Shipping_Cost,])
pre
## 6 7 9 10 11 12 14 15
## 104562.6 141544.7 122442.3 119893.1 119893.1 152498.5 118124.4 118124.4
## 16 17 18 19 20 21 22 23
## 120046.7 108059.7 151198.7 139464.7 139464.7 139464.7 148688.7 103707.1
## 24 25 27 28 29 30 31 32
## 117143.6 117143.6 131974.4 104562.6 141544.7 122442.3 122442.3 119893.1
## 33 34 36 37 38 39 40 41
## 119893.1 152498.5 118124.4 118124.4 120046.7 108059.7 151198.7 139464.7
## 42 43 44 45 46 47 48 49
## 139464.7 139464.7 148688.7 103707.1 117143.6 117143.6 115273.1 131974.4
## 50 51 52 53 54 55 56 57
## 104562.6 141544.7 122442.3 122442.3 119893.1 119893.1 152498.5 152498.5
## 58 59 60 61 62 63 64 65
## 118124.4 118124.4 120046.7 108059.7 151198.7 139464.7 139464.7 139464.7
## 66 67 70 71 72 73 75 76
## 148688.7 103707.1 115273.1 131974.4 104562.6 141544.7 122442.3 119893.1
## 77 78 79 80 81 82 83 84
## 119893.1 152498.5 152498.5 118124.4 118124.4 120046.7 108059.7 151198.7
## 85 86 87 88 89 90 91 92
## 139464.7 139464.7 139464.7 148688.7 103707.1 117143.6 117143.6 115273.1
## 93 94 95 96 97 98 99 100
## 131974.4 104562.6 141544.7 122442.3 122442.3 119893.1 119893.1 152498.5
## 101 102 103 104 105 106 107 108
## 152498.5 118124.4 118124.4 120046.7 108059.7 151198.7 139464.7 139464.7
## 109 110 111 112 113 114 115 116
## 139464.7 148688.7 103707.1 117143.6 117143.6 115273.1 131974.4 104562.6
## 117 118 119 120 121 122 123 124
## 141544.7 122442.3 122442.3 119893.1 119893.1 152498.5 152498.5 118124.4
## 125 126 127 128 129 130 131 132
## 118124.4 120046.7 108059.7 151198.7 139464.7 139464.7 139464.7 148688.7
## 133 134 135 136 137 138 139 140
## 103707.1 117143.6 117143.6 115273.1 131974.4 104562.6 141544.7 122442.3
## 141 142 143 144 145 146 147 148
## 122442.3 119893.1 119893.1 152498.5 152498.5 118124.4 118124.4 120046.7
## 149 150 151 152 153 154 155 156
## 108059.7 151198.7 139464.7 139464.7 139464.7 148688.7 103707.1 117143.6
## 157 158 159 160 161 162 163 164
## 117143.6 115273.1 131974.4 104562.6 141544.7 122442.3 122442.3 119893.1
## 165 166 167 168 169 170 171 172
## 119893.1 152498.5 152498.5 118124.4 118124.4 120046.7 108059.7 151198.7
## 173 174 175 176 177 178 179 180
## 139464.7 139464.7 139464.7 148688.7 103707.1 117143.6 117143.6 115273.1
## 181 182 183 184 185 186 187 188
## 131974.4 104562.6 141544.7 122442.3 122442.3 119893.1 119893.1 152498.5
## 189 190 191 192 193 194 195 196
## 152498.5 118124.4 118124.4 120046.7 108059.7 151198.7 139464.7 139464.7
## 197 198 199 200 201 202 203 204
## 139464.7 148688.7 103707.1 117143.6 117143.6 115273.1 131974.4 104562.6
## 205 206 207 208 209 210 211 212
## 141544.7 122442.3 122442.3 119893.1 119893.1 152498.5 152498.5 118124.4
## 213 214 215 216 217 218 219 220
## 118124.4 120046.7 108059.7 151198.7 139464.7 139464.7 139464.7 148688.7
## 221 222 223 224 225 226 227 228
## 103707.1 117143.6 117143.6 115273.1 131974.4 104562.6 141544.7 122442.3
## 229 230 231 232 233 234 235 236
## 122442.3 119893.1 119893.1 152498.5 152498.5 118124.4 118124.4 120046.7
## 237 238 239 240 241 242 243 244
## 108059.7 151198.7 139464.7 139464.7 139464.7 148688.7 103707.1 117143.6
## 245 246 247 248 249 250 251 252
## 117143.6 115273.1 131974.4 104562.6 141544.7 122442.3 122442.3 119893.1
## 253 254 255 256 257 258 259 260
## 119893.1 152498.5 152498.5 118124.4 118124.4 120046.7 108059.7 151198.7
## 261 262 263 264
## 139464.7 139464.7 139464.7 148688.7
train.control <- trainControl(method = "cv", number = 10)
mode <- train(Profit ~ Shipping_Cost, data = data,
method="lm",
trControl=train.control)
## Warning in nominalTrainWorkflow(x = x, y = y, wts = weights, info = trainInfo, :
## There were missing values in resampled performance measures.
print(mode)
## Linear Regression
##
## 264 samples
## 1 predictor
##
## No pre-processing
## Resampling: Cross-Validated (10 fold)
## Summary of sample sizes: 237, 236, 240, 238, 237, 237, ...
## Resampling results:
##
## RMSE Rsquared MAE
## 80037.84 0.1537599 68256.43
##
## Tuning parameter 'intercept' was held constant at a value of TRUE
summary(mode)
##
## Call:
## lm(formula = .outcome ~ ., data = dat)
##
## Residuals:
## Min 1Q Median 3Q Max
## -134545 -67341 2980 66898 142659
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -13053 22824 -0.572 0.568
## Shipping_Cost 1961 316 6.207 2.11e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 80390 on 262 degrees of freedom
## Multiple R-squared: 0.1282, Adjusted R-squared: 0.1249
## F-statistic: 38.52 on 1 and 262 DF, p-value: 2.106e-09