mydta <- read.csv("C:/Users/Hp/OneDrive/Desktop/Ecommerce.Html/joza batool.csv")
attach(mydta)
summary(mydta)
## Observation Brand Price_. Megapixels
## Min. : 1.00 Length:28 Min. : 8.00 Min. :10.00
## 1st Qu.: 7.75 Class :character 1st Qu.:11.00 1st Qu.:12.00
## Median :14.50 Mode :character Median :16.00 Median :12.00
## Mean :14.50 Mean :17.54 Mean :12.86
## 3rd Qu.:21.25 3rd Qu.:20.00 3rd Qu.:14.00
## Max. :28.00 Max. :40.00 Max. :16.00
## Weight_oz Score Brand.1
## Min. :4.000 Min. :49.00 Min. :0.0000
## 1st Qu.:5.000 1st Qu.:59.00 1st Qu.:0.0000
## Median :6.000 Median :63.50 Median :0.0000
## Mean :5.821 Mean :63.36 Mean :0.4643
## 3rd Qu.:7.000 3rd Qu.:68.25 3rd Qu.:1.0000
## Max. :7.000 Max. :73.00 Max. :1.0000
str(mydta)
## '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 33 20 30 20 18 20 20 13 13 11 ...
## $ 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 73 73 72 69 69 68 67 67 66 62 ...
## $ Brand.1 : int 1 1 1 1 1 1 1 1 1 1 ...
boxplot(mydta $Price, horizontal = TRUE, xlab= "Price")
boxplot(mydta $Megapixels, horizontal = TRUE, xlab= "Megapixels")
boxplot(mydta $Weight_oz, horizontal = TRUE, xlab= "Weight")
boxplot(mydta$Score, horizontal = TRUE, xlab= "Score")
nikon_prices <- mydta $Price [mydta $Brand == "Nikon"]
canon_prices <- mydta $Price [mydta $Brand == "Canon"]
t_test_result <- t.test(nikon_prices, canon_prices)
print(t_test_result)
##
## Welch Two Sample t-test
##
## data: nikon_prices and canon_prices
## t = 0.08931, df = 25.993, p-value = 0.9295
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -6.209637 6.773739
## sample estimates:
## mean of x mean of y
## 17.66667 17.38462
mydta $Weight_Category <- cut(
mydta $Weight_oz,
breaks = c(-Inf, 4, 5, 6, 7, Inf),
labels = c("Other", "Light Weight", "Light Weight", "Medium Weight", "Heavy Weight"),
include.lowest = TRUE
)
head(mydta)
anova_result <- aov(mydta $Price ~ mydta $Weight_Category, data = mydta)
summary(anova_result)
## Df Sum Sq Mean Sq F value Pr(>F)
## mydta$Weight_Category 2 221.4 110.69 1.698 0.203
## Residuals 25 1629.6 65.18
hist(mydta $Price, col=3)
It appears to be Right Skewed.
hist(Megapixels, col=4)
It appears to be Right Skewed.
hist(Weight_oz, col=5)
It appears to be not normal.
hist(Score, col=6)
It appears to be left Skewed.
df <- data.frame(mydta$Price, Megapixels, Weight_oz, Score)
plot(df)
cor(df)
## mydta.Price Megapixels Weight_oz Score
## mydta.Price 1.0000000 0.138906307 0.3488151 0.683211844
## Megapixels 0.1389063 1.000000000 -0.1988338 -0.007729723
## Weight_oz 0.3488151 -0.198833809 1.0000000 0.285688204
## Score 0.6832118 -0.007729723 0.2856882 1.000000000
m1 <- lm(mydta $Price ~ Megapixels)
summary(m1)
##
## Call:
## lm(formula = mydta$Price ~ Megapixels)
##
## Residuals:
## Min 1Q Median 3Q Max
## -10.250 -6.062 -2.250 3.312 21.750
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 9.5000 11.3457 0.837 0.410
## Megapixels 0.6250 0.8739 0.715 0.481
##
## Residual standard error: 8.356 on 26 degrees of freedom
## Multiple R-squared: 0.01929, Adjusted R-squared: -0.01842
## F-statistic: 0.5115 on 1 and 26 DF, p-value: 0.4808
m2 <- lm(mydta $Price ~ Megapixels + Weight_oz)
summary(m2)
##
## Call:
## lm(formula = mydta$Price ~ Megapixels + Weight_oz)
##
## Residuals:
## Min 1Q Median 3Q Max
## -14.5401 -4.5509 -0.1143 4.2107 17.4599
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -14.2195 15.5185 -0.916 0.3683
## Megapixels 0.9756 0.8381 1.164 0.2554
## Weight_oz 3.3001 1.5685 2.104 0.0456 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.854 on 25 degrees of freedom
## Multiple R-squared: 0.1668, Adjusted R-squared: 0.1002
## F-statistic: 2.503 on 2 and 25 DF, p-value: 0.1021
m3 <- lm(mydta $Price ~ Megapixels + Weight_oz + Score)
summary(m3)
##
## Call:
## lm(formula = mydta$Price ~ Megapixels + Weight_oz + Score)
##
## Residuals:
## Min 1Q Median 3Q Max
## -7.622 -3.498 -1.431 3.688 17.416
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -52.3087 14.9344 -3.503 0.001831 **
## Megapixels 0.8318 0.6466 1.286 0.210573
## Weight_oz 1.7418 1.2627 1.379 0.180467
## Score 0.7735 0.1817 4.256 0.000275 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 6.051 on 24 degrees of freedom
## Multiple R-squared: 0.5252, Adjusted R-squared: 0.4659
## F-statistic: 8.85 on 3 and 24 DF, p-value: 0.0003961
anova(m1, m3)
anova(m2, m3)
mydta$Nikon <- ifelse(Brand == "Nikon", 1, 0)
str(mydta)
## 'data.frame': 28 obs. of 9 variables:
## $ Observation : int 1 2 3 4 5 6 7 8 9 10 ...
## $ Brand : chr "Canon" "Canon" "Canon" "Canon" ...
## $ Price_. : int 33 20 30 20 18 20 20 13 13 11 ...
## $ 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 73 73 72 69 69 68 67 67 66 62 ...
## $ Brand.1 : int 1 1 1 1 1 1 1 1 1 1 ...
## $ Weight_Category: Factor w/ 4 levels "Other","Light Weight",..: 3 2 3 2 2 3 2 3 2 2 ...
## $ Nikon : num 0 0 0 0 0 0 0 0 0 0 ...
m4 <- lm(mydta $Price ~ Megapixels + mydta$Nikon)
summary(m4)
##
## Call:
## lm(formula = mydta$Price ~ Megapixels + mydta$Nikon)
##
## Residuals:
## Min 1Q Median 3Q Max
## -9.960 -5.928 -1.960 2.982 22.040
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.5803 12.1361 0.707 0.486
## Megapixels 0.7337 0.9920 0.740 0.466
## mydta$Nikon -0.8919 3.5944 -0.248 0.806
##
## Residual standard error: 8.511 on 25 degrees of freedom
## Multiple R-squared: 0.0217, Adjusted R-squared: -0.05656
## F-statistic: 0.2773 on 2 and 25 DF, p-value: 0.7601
plot(m4)