cdata <- read.csv("C:/Users/hm840/OneDrive/Desktop/cameradata.csv")
attach(cdata)
summary(cdata)
## Observation Brand Price_. Megapixels
## Min. : 1.00 Length:28 Min. : 72.0 Min. :10.00
## 1st Qu.: 7.75 Class :character 1st Qu.: 99.0 1st Qu.:12.00
## Median :14.50 Mode :character Median :144.0 Median :12.00
## Mean :14.50 Mean :157.8 Mean :12.86
## 3rd Qu.:21.25 3rd Qu.:180.0 3rd Qu.:14.00
## Max. :28.00 Max. :360.0 Max. :16.00
## Weight_oz Score Brand.1
## Min. :4.000 Min. :51.00 Min. :0.0000
## 1st Qu.:5.000 1st Qu.:61.00 1st Qu.:0.0000
## Median :6.000 Median :65.50 Median :0.0000
## Mean :5.821 Mean :65.36 Mean :0.4643
## 3rd Qu.:7.000 3rd Qu.:70.25 3rd Qu.:1.0000
## Max. :7.000 Max. :75.00 Max. :1.0000
str(cdata)
## 'data.frame': 28 obs. of 7 variables:
## $ Observation: int 1 2 3 4 5 6 7 8 9 10 ...
## $ Brand : chr "Canon" "Canon" "Canon" "Canon" ...
## $ Price_. : int 297 180 270 180 162 180 180 117 117 99 ...
## $ Megapixels : int 10 12 12 10 12 12 14 10 12 16 ...
## $ Weight_oz : int 7 5 7 6 5 7 5 7 5 5 ...
## $ Score : int 75 75 74 71 71 70 69 69 68 64 ...
## $ Brand.1 : int 1 1 1 1 1 1 1 1 1 1 ...
Brand-String Price-Integer Megapixel-Integer Weight-Integer Score-Integer Brand-Boolean
Brand-Nominal Price-Scaled Megapixel-Scaled Weight-Scaled Score-Scaled Brand-Scaled
hist( Price_., col=2 )
boxplot( Price_., horizontal = T, col = 3, main="Box-plot")
qqnorm( Price_., main = "Normality test")
qqline( Price_.)
The number of observations is 28 which is a large enough population size
to assume it is normally distributed
var( Price_.[Brand=="Nikon"])
## [1] 6626.571
var( Price_.[Brand== "Canon"])
## [1] 4759.269
var( Price_.[Brand=="Nikon"])/var( Price_.[Brand== "Canon"])
## [1] 1.392351
The value concluded by dividing these ratios is less than 2 hence we can proceed with Pooled T test as we assume them to be equal
t.test( Price_. ~ Brand, mu = 0, alt = "two.sided",conf=0.95, var.eq = T, Paired = F )
##
## Two Sample t-test
##
## data: Price_. by Brand
## t = -0.088231, df = 26, p-value = 0.9304
## alternative hypothesis: true difference in means between group Canon and group Nikon is not equal to 0
## 95 percent confidence interval:
## -61.67764 56.60071
## sample estimates:
## mean in group Canon mean in group Nikon
## 156.4615 159.0000
The T value from the test is 0.088231.
while the p value was 0.9304.
The average price of Nikon is 159.0000.
The average price of canon is 156.4615.
Hence we accept H0.
Light weight= 4oz, 5oz.
Medium weight= 6oz.
Heavy weight= 7oz.
cdata$Weightcat <- ifelse(Weight_oz<6, "Light weight",ifelse(Weight_oz==6, "Medium weight", "Heavy weight"))
attach(cdata)
## The following objects are masked from cdata (pos = 3):
##
## Brand, Brand.1, Megapixels, Observation, Price_., Score, Weight_oz
str(cdata)
## 'data.frame': 28 obs. of 8 variables:
## $ Observation: int 1 2 3 4 5 6 7 8 9 10 ...
## $ Brand : chr "Canon" "Canon" "Canon" "Canon" ...
## $ Price_. : int 297 180 270 180 162 180 180 117 117 99 ...
## $ Megapixels : int 10 12 12 10 12 12 14 10 12 16 ...
## $ Weight_oz : int 7 5 7 6 5 7 5 7 5 5 ...
## $ Score : int 75 75 74 71 71 70 69 69 68 64 ...
## $ Brand.1 : int 1 1 1 1 1 1 1 1 1 1 ...
## $ Weightcat : chr "Heavy weight" "Light weight" "Heavy weight" "Medium weight" ...
print(cdata)
## Observation Brand Price_. Megapixels Weight_oz Score Brand.1 Weightcat
## 1 1 Canon 297 10 7 75 1 Heavy weight
## 2 2 Canon 180 12 5 75 1 Light weight
## 3 3 Canon 270 12 7 74 1 Heavy weight
## 4 4 Canon 180 10 6 71 1 Medium weight
## 5 5 Canon 162 12 5 71 1 Light weight
## 6 6 Canon 180 12 7 70 1 Heavy weight
## 7 7 Canon 180 14 5 69 1 Light weight
## 8 8 Canon 117 10 7 69 1 Heavy weight
## 9 9 Canon 117 12 5 68 1 Light weight
## 10 10 Canon 99 16 5 64 1 Light weight
## 11 11 Canon 81 14 5 61 1 Light weight
## 12 12 Canon 90 10 6 60 1 Medium weight
## 13 13 Canon 81 12 7 55 1 Heavy weight
## 14 14 Nikon 243 16 5 74 0 Light weight
## 15 15 Nikon 270 16 7 72 0 Heavy weight
## 16 16 Nikon 180 14 6 70 0 Medium weight
## 17 17 Nikon 360 14 7 68 0 Heavy weight
## 18 18 Nikon 108 14 5 66 0 Light weight
## 19 19 Nikon 153 16 6 65 0 Medium weight
## 20 20 Nikon 135 12 5 65 0 Light weight
## 21 21 Nikon 207 14 6 64 0 Medium weight
## 22 22 Nikon 162 12 6 62 0 Medium weight
## 23 23 Nikon 117 12 6 62 0 Medium weight
## 24 24 Nikon 72 12 7 61 0 Heavy weight
## 25 25 Nikon 72 14 7 59 0 Heavy weight
## 26 26 Nikon 90 12 4 55 0 Light weight
## 27 27 Nikon 99 12 5 54 0 Light weight
## 28 28 Nikon 117 14 4 51 0 Light weight
Simple random samples
Independent samples
Normal Populations
Equal populations
boxplot(Price_.~ Weightcat, horizontal = T, col = c(2,3,4))
var(Price_.[Weightcat=="Light weight"])
## [1] 2304.205
var(Price_.[Weightcat=="Medium weight"])
## [1] 1612.286
var(Price_.[Weightcat=="Heavy weight"])
## [1] 12287.25
var(Price_.[Weightcat=="Heavy weight"])/var(Price_.[Weightcat=="Medium weight"])
## [1] 7.621013
ANOVA1 <- aov(Price_. ~ Weightcat)
summary(ANOVA1)
## Df Sum Sq Mean Sq F value Pr(>F)
## Weightcat 2 16610 8305 1.557 0.23
## Residuals 25 133318 5333
SSTR= 16610/2 = 8305
SSE= 133318/25 = 5332.7
The F statistic is 1.557
degree of freedom is 27
p value of the test is 0.23
The sum of square of known and error is 149928
Assuming 5% CONFIDENCE interval we conlcude that H0 will be accepted as there is not enough evidence to reject H0 as the p value 0.23 is greator than 0.05