TRAVEL

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

file:///C:/Users/Astrid/Documents/RcmdrMarkdown.

html

TRAVEL <-

readXL("C:/Users/Astrid/Downloads/2_Caso_de_estudio_7B10E023B.xlsx",

rownames=FALSE, header=TRUE, na="", sheet="Sheet1", stringsAsFactors=TRUE)

summary(TRAVEL)

TRAVEL <- within(TRAVEL, {

brand <- as.factor(brand)

})

TRAVEL <- within(TRAVEL, {

region <- factor(region, labels=c('Maritimes','Quebec','Ontario','West'))

})

TRAVEL <- within(TRAVEL, {

gender <- factor(gender, labels=c('Female','Male'))

})

TRAVEL <- within(TRAVEL, {

children <- factor(children, labels=c('Yes','No'))

})

TRAVEL <- within(TRAVEL, {

income <- factor(income, labels=c('<$30k','$30-$49.9k','$50-$74.9',

'$75k+'))

})

TRAVEL <- within(TRAVEL, {

loyalbin <- factor(loyalbin, labels=c('not loyal','loyal'))

})

local({

.Table <- with(TRAVEL, table(brand))

cat("\ncounts:\n")

print(.Table)

cat("\npercentages:\n")
print(round(100*.Table/sum(.Table), 2))

})

library(abind, pos=17)

local({

.Table <- xtabs(~brand+loyalbin, data=TRAVEL)

cat("\nFrequency table:\n")

print(.Table)

.Test <- chisq.test(.Table, correct=FALSE)

print(.Test)

})

FAST <- readXL("C:/Users/Astrid/Downloads/2_Caso_de_estudio_7B10E023A.xlsx",

rownames=FALSE, header=TRUE, na="", sheet="Sheet1", stringsAsFactors=TRUE)

FAST <- within(FAST, {

brand <- as.factor(brand)

})

library(mvtnorm, pos=18)

library(survival, pos=18)

library(MASS, pos=18)

library(TH.data, pos=18)

library(multcomp, pos=18)

AnovaModel.1 <- aov(brand_equity ~ brand, data=FAST)

summary(AnovaModel.1)

with(FAST, numSummary(brand_equity, groups=brand, statistics=c("mean",

"sd")))

LinearModel.2 <- lm(brand_equity ~ loyal + relev + famil + uniqu + popul,

data=FAST)

summary(LinearModel.2)

FAST <- within(FAST, {

loyal <- as.factor(loyal)


})

FAST <- within(FAST, {

region <- as.factor(region)

})

local({

.Table <- xtabs(~loyal+region, data=FAST)

cat("\nFrequency table:\n")

print(.Table)

.Test <- chisq.test(.Table, correct=FALSE)

print(.Test)

})

FAST <- within(FAST, {

familbin <- as.factor(familbin)

loyalbin <- as.factor(loyalbin)

populbin <- as.factor(populbin)

relevbin <- as.factor(relevbin)

uniqubin <- as.factor(uniqubin)

})

GLM.4 <- glm(brand_equity ~ familbin + loyalbin + populbin + relevbin +

uniqubin, family=binomial(logit), data=FAST)

summary(GLM.4)

exp(coef(GLM.4)) # Exponentiated coefficients ("odds ratios")

LinearModel.5 <- lm(brand_equity ~ familbin + loyalbin + populbin +

relevbin + uniqubin, data=FAST)

summary(LinearModel.5)

You might also like