You are on page 1of 2

One Way ANOVA

tyre.dat=read.csv("C:\\Users\\Dell\\Desktop\\BMQT2\\tyre.csv")

attach(tyre.dat)
View(tyre.dat)

is.factor(Brands) -----> SHould be true. Change data type if false

summary(tyre.dat)

require(psych)
describe(tyre.dat)
describeBy(Mileage,group = Brands, mat = TRUE, digits = 2)

tyres.aov<- aov(Mileage~Brands, tyre.dat) ----> (DV in the left and IV in the


right)
class(tyres.aov)

typeof(tyres.aov)
names(tyres.aov)
summary(tyres.aov)

If null hypo rejected, do the foll tests

pairwise.t.test(Mileage, Brands,p.adjust.method = "none")

or

require(lsr)
posthocPairwiseT(tyres.aov,p.adjust.method = "none")

TukeyHSD(tyres.aov, conf.level = 0.99)

par()$oma #current margin


par(oma=c(0,5,0,0)) # adjust the margins because the factor names are long
plot(TukeyHSD(tyres.aov, conf.level = 0.99),las=1, col = "red")
par(oma=c(0,0,0,0)) # put the margins back

2 - Way ANOVA

Take care of the variable names


Look at the respective file
Create a csv and import

CORRELATION

sales=read.csv("F:\\XLRI\\Term 2\\QT2\\Adv_Sales_cor.csv")
> View(sales)
> attach(sales)
> cor(Advertising, Sales)
plot(Advertising, Sales)

cor(Advertising, Sales, method = "spearman")

cor(Advertising, Sales, method = "kendall")

cor.test(Advertising, Sales, method = "pearson") # 2 sided test


cor.test(Advertising, Sales, alternative = "greater", method = "pearson") # 1 sided
test

/*data: Advertising and Sales


t = 4.7481, df = 34, p-value = 1.818e-05
alternative hypothesis: true correlation is greater than 0
95 percent confidence interval:
0.4280073 1.0000000
sample estimates:
cor
0.6314276*/

cor.test(Advertising, Sales, alternative = "greater", method = "pearson",


conf.level = 0.99) #one sided test with confidence interval as 99

REGRESSION

You might also like