Module 8

 #Module 8 Assignment

##Question 1

##Data input for stress level vectors


HighStress <- c(10,9,8,9,10,8)


ModerateStress <- c(8,10,6,7,8,8)


LowStress <- c(4,6,6,4,2,2)


#generate data frame to help incorpirate all three variables


stress <- data.frame(cbind(HighStress, ModerateStress, LowStress))


stressStack <- stack(stress)


#Next, I will run an ANOVA test on the dataframe created from the inital data for each stress level


oneway.test(values~ind,data = stressStack)



## Remember this assumes a non-equal variance (note to self: See personal notepad as to why)


#Next WE will perform an ANOVA test o the data derived from the initial Stress level vectors


aovResult <- aov(values~ind,data = stressStack)


summary(aovResult)


##Key for results in Console

#df = degrees of freedom

#SumSq = Sum of the Squares from the variable

#Mean sq = sum sq / df

#F-Value = mean sq var / mean sq residual

#p-value associated with the f-value denoted by Pr(>F)


# Because the p-value is less than a 0.05 

##The results are signifigant and the null hypothesis is rejected







#Question 2

##First I need to set up to zelazo dataset


library(ISwR)

data("zelazo")

##First line of buisiness involves creating a dataframe and employing cbind for the columns

##We will then conduct an independant t-test with the dataframe and then an ANOVA test


##The data set zelazo is a list of 4 vectors 

##We need to convert the list into dataframecolumns


zdf <- as.data.frame(do.call(cbind, zelazo))


#stack zdf


zdfstsack <- stack(zdf)


#Independant T-Test on active and passive


t.test(zelazo$active, zelazo$passive)


#Defining the test results to a variable to examine the summary results


A.S.Stat <- t.test(zelazo$active, zelazo$passive)


summary(A.S.Stat)


##Next, an ANOVA test with the datafram zdf


aov(values~ind,data = zdfstack)


##This dataset ran warnings and would not compile or give any entries

##For some reason my computer is having issues internally with this package 


Comments

Popular posts from this blog

R Package: pfStat

Module 7 Assignment

The Tampa Feasibility Report featuring R based Visualizations