data(MktDATA, package = "UBStats")
# Independent samples (default type), UNKNOWN variances
# CI for the difference between means of males and females
# - Using x,y: build vectors with data on the two groups
AOV_M <- MktDATA$AOV[MktDATA$Gender == "M"]
AOV_F <- MktDATA$AOV[MktDATA$Gender == "F"]
CI.diffmean(x = AOV_M, y = AOV_F)
# - Change confidence level
CI.diffmean(x = AOV_M, y = AOV_F, conf.level = 0.99)
# - Using x,by: groups identified by ordered levels of by
CI.diffmean(x = AOV, by = Gender, conf.level = 0.99, data = MktDATA)
# Since order is F, M, CI is for mean(F) - mean(M)
# To get the interval for mean(M) - mean(F)
Gender.R <- factor(MktDATA$Gender, levels = c("M", "F"))
CI.diffmean(x = AOV, by = Gender.R, conf.level = 0.99,
data = MktDATA)
# - Testing hypotheses on equality of unknown variances
CI.diffmean(x = AOV_M, y = AOV_F, conf.level = 0.99,
var.test = TRUE)
# - Output results: only information on the CI
out.ci_diffM<-CI.diffmean(x = AOV_M, y = AOV_F)
# - Output results: list with information on CI and test on var
out.ci_diffM.V<-CI.diffmean(x = AOV_M, y = AOV_F, var.test = TRUE)
# Independent samples (default type), KNOWN variances
# CI for the difference between means of males and females
# - Using x,y: build vectors with data on the two groups
AOV_M <- MktDATA$AOV[MktDATA$Gender == "M"]
AOV_F <- MktDATA$AOV[MktDATA$Gender == "F"]
CI.diffmean(x = AOV_M, y = AOV_F,
sigma.x = 10, sigma.y = 20)
# - Using x,by: groups identified by ordered levels of by
CI.diffmean(x = AOV, by = Gender,
sigma.by = c("M" = 10, "F"=20), data = MktDATA)
# To change the sign, order levels as desired
Gender.R <- factor(MktDATA$Gender, levels = c("M", "F"))
CI.diffmean(x = AOV, by = Gender.R,
sigma.by = c("M" = 10, "F"=20), data = MktDATA)
# - Output results
out.ci_diffM<-CI.diffmean(x = AOV_M, y = AOV_F,
sigma.x = 10, sigma.y = 20)
# Paired samples: UNKNOWN variances
# - Default settings
CI.diffmean(x = NStore_Purch, y = NWeb_Purch,
type = "paired", data=MktDATA)
# - Change confidence level
CI.diffmean(x = NStore_Purch, y = NWeb_Purch,
type = "paired", conf.level = 0.9, data = MktDATA)
# Paired: KNOWN variances
CI.diffmean(x = NStore_Purch, y = NWeb_Purch,
type = "paired", conf.level = 0.9,
sigma.d = 2, data = MktDATA)
# - Output results
out.ci_diffM<-CI.diffmean(x = NStore_Purch, y = NWeb_Purch,
type = "paired", conf.level = 0.9,
sigma.d = 2, data = MktDATA)
# Arguments force.digits and use.scientific
# An input variable taking very low values
SmallX<-MktDATA$AOV/5000
SmallX_M <- SmallX[MktDATA$Gender == "M"]
SmallX_F <- SmallX[MktDATA$Gender == "F"]
# - Default: manages possible excess of rounding
CI.diffmean(x = SmallX_M, y = SmallX_F)
# - Force to the requested nr of digits (default, 2)
CI.diffmean(x = SmallX_M, y = SmallX_F,
force.digits = TRUE)
# - Allow scientific notation
CI.diffmean(x = SmallX_M, y = SmallX_F,
use.scientific = TRUE)
Run the code above in your browser using DataLab