data <- read.csv("C:/Users/Dell/Desktop/SI/camdata.csv")
attach(data)
summary(data)
## Observation Brand Price_. Megapixels
## Min. : 1.00 Length:28 Min. : 20.00 Min. :10.00
## 1st Qu.: 7.75 Class :character 1st Qu.: 28.00 1st Qu.:12.00
## Median :14.50 Mode :character Median : 40.50 Median :12.00
## Mean :14.50 Mean : 44.07 Mean :12.86
## 3rd Qu.:21.25 3rd Qu.: 50.00 3rd Qu.:14.00
## Max. :28.00 Max. :100.00 Max. :16.00
## Weight_oz Score Brand.1
## Min. :4.000 Min. :14.00 Min. :0.0000
## 1st Qu.:5.000 1st Qu.:15.00 1st Qu.:0.0000
## Median :6.000 Median :16.00 Median :0.0000
## Mean :5.821 Mean :15.82 Mean :0.4643
## 3rd Qu.:7.000 3rd Qu.:17.00 3rd Qu.:1.0000
## Max. :7.000 Max. :17.00 Max. :1.0000
str(data)
## '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 83 50 75 50 45 50 50 33 33 28 ...
## $ 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 17 15 17 16 15 17 15 17 15 15 ...
## $ Brand.1 : int 1 1 1 1 1 1 1 1 1 1 ...
qqnorm(Price_., main="QQ Plot",xlab="z score", ylab="prices", col="green")
qqline(Price_., col="red")
hist(Price_., main="Histogram", xlab="Price", ylab="Frequency",col="purple")
after we have done the transformation of data we find out that the normality of data has been affected but it is still aproximately normal.
Nikonvar <- var(Price_.[Brand=="Nikon"])
canonvar <- var(Price_.[Brand=="Canon"])
Nikonvar
## [1] 510.5429
# Hypothesis
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.088746, df = 26, p-value = 0.93
## alternative hypothesis: true difference in means between group Canon and group Nikon is not equal to 0
## 95 percent confidence interval:
## -17.09920 15.68381
## sample estimates:
## mean in group Canon mean in group Nikon
## 43.69231 44.40000
Coding Data on to a new Variable
WeightCategory <- ifelse(Weight_oz<6,"Light",ifelse(Weight_oz==6,"Medium","Heavy"))
camera<- WeightCategory
camera
## [1] "Heavy" "Light" "Heavy" "Medium" "Light" "Heavy" "Light" "Heavy"
## [9] "Light" "Light" "Light" "Medium" "Heavy" "Light" "Heavy" "Medium"
## [17] "Heavy" "Light" "Medium" "Light" "Medium" "Medium" "Medium" "Heavy"
## [25] "Heavy" "Light" "Light" "Light"
Testing Assumptions
boxplot(Price_.~WeightCategory,horizontal = T ,col=c(5,3,10))
The plot shows that data is not normal but the sample size is large we assume data is normal.
Lightvar <- var(Price_.[WeightCategory=="Light"])
Mediumvar <- var(Price_.[WeightCategory=="Medium"])
Heavyvar <- var(Price_.[WeightCategory=="Heavy"])
Lightvar
## [1] 176.6288
SDcheckweight <- Heavyvar/Mediumvar
SDcheckweight
## [1] 7.566438
Since we have already modified the data, it would not satisfy the Annova assumptions, but we anticipate that pre-transformed data will.
H0: AvgPriceLW = AvgPriceMW = AvgPriceHW H1: Average prices of three categories are not equal
ANOVA <- aov(Price_. ~ WeightCategory)
ANOVA
## Call:
## aov(formula = Price_. ~ WeightCategory)
##
## Terms:
## WeightCategory Residuals
## Sum of Squares 1261.671 10256.187
## Deg. of Freedom 2 25
##
## Residual standard error: 20.25457
## Estimated effects may be unbalanced
summary(ANOVA)
## Df Sum Sq Mean Sq F value Pr(>F)
## WeightCategory 2 1262 630.8 1.538 0.235
## Residuals 25 10256 410.2
"SSTR = 1262/2 = 532"
## [1] "SSTR = 1262/2 = 532"
"SSE = 10256/25 = 410.24 F Statistic = SSTR/SSE = 1.557"
## [1] "SSE = 10256/25 = 410.24 F Statistic = SSTR/SSE = 1.557"
"p value = 0.23"
## [1] "p value = 0.23"
"Alpha = 0.05"
## [1] "Alpha = 0.05"
"p value > Alpha"
## [1] "p value > Alpha"
"Accept H0"
## [1] "Accept H0"
"post hoc analysis if we reject h0"
## [1] "post hoc analysis if we reject h0"