child.life <- read.csv('C:/your.directory/child.life.csv') child.life attach(child.life) str(child.life) # Posthole 2 my.vars <- data.frame(MYPAS, Intervention, as.factor(Intervention)) summary(my.vars) hist(MYPAS, col='darkgrey') hist(MYPAS[Intervention==0], col='darkgrey', xlim=c(20, 90), ylim=c(0, 25)) hist(MYPAS[Intervention==1], col='darkgrey', xlim=c(20, 90), ylim=c(0, 25)) # Posthole 4 & 1 cor(MYPAS, Intervention) round(cor(MYPAS, Intervention), digits=2) my.wicked.awesome.model <- lm(MYPAS ~ Intervention) plot(MYPAS ~ jitter(Intervention), col='darkgrey') points(MYPAS ~ Intervention, pch=16, col='black') abline(my.wicked.awesome.model) # Posthole 5, 6, 7 & 8 my.wicked.awesome.model <- lm(MYPAS ~ Intervention) summary(my.wicked.awesome.model) confint(my.wicked.awesome.model) plot(MYPAS ~ jitter(Intervention), col='darkgrey') points(MYPAS ~ Intervention, pch=16, col='black') abline(my.wicked.awesome.model) # Posthole A Anxious <- MYPAS >= 30 observed.count.table <- table(Intervention, Anxious) expected.count.table <- (as.array(margin.table(observed.count.table, 1)) %*% t(as.array(margin.table(observed.count.table, 2))) / margin.table(observed.count.table)) st.res <- function(o, e) {(o-e)/sqrt(e)} standardized.residual.table <- st.res(observed.count.table, expected.count.table) observed.count.table round(expected.count.table, digits=0) round(standardized.residual.table, digits=1) summary(observed.count.table)