Practical 4 DS
Practical 4 DS
> X <- c(11.1, 10.3, 12.0, 15.1, 13.7, 18.5, 17.3, 14.2, 14.8, 15.3)
> Y <- c(10.9, 14.2, 13.8, 21.5, 13.2, 21.1, 16.4, 19.3, 17.4, 19.0)
> print(spearman_corr)
[1] 0.6969697
> print(pearson_corr)
[1] 0.7317151
>
> #Q2
> X <- c(34, 37, 36, 32, 32, 36, 35, 34, 29, 35)
> Y <- c(37, 37, 34, 34, 33, 40, 39, 37, 36, 35)
> model
Call:
lm(formula = X ~ Y)
Coefficients:
(Intercept)
18.9167 0.4167
>
> #Q3
> Sales <- c(50, 50, 55, 60, 65, 65, 65, 60, 60, 50)
> Expenses <- c(11, 13, 14, 16, 16, 15, 15, 14, 13, 13)
> Advertising <- c(24, 42, 43, 54, 54, 27, 35, 34, 39, 42)
> model
Call:
Coefficients:
>
> #Q4
> n <- 15
> print(P_X_3)
[1] 0.1285054
> print(P_X_7)
[1]
0.0002770056
[1] 0.9999664
> print(P_X_geq_8)
[1] 3.362489e-05
> print(x_value)
[1] 1
>
> #Q5
> sd <- 5
> print(P_X_leq_40)
[1] 0.9772499
> print(P_X_leq_56)
[1] 0.9999999
> print(P_X_gt_50)
[1] 3.167124e-05
> print(P_25_leq_X_leq_35)
[1] 0.6826895
>
> #Q6
>
> Sales_A <- c(100, 120, 140, 160, 150, 170, 180, 200, 210, 230, 240, 260)
> Sales_B <- c(190, 210, 130, 250, 240, 180, 170, 180, 200, 220, 230, 250)
> plot(months, Sales_A, type = "o", col = "blue", xlab = "Month", ylab = "Sales", main
= "Monthly Sales of Products A and B")
> install.packages("forecast")
> library(forecast)
> plot(forecast_A, main = "Sales Forecast for Product A", xlab = "Month", ylab =
"Sales")
> plot(forecast_B, main = "Sales Forecast for Product B", xlab = "Month", ylab =
"Sales")