This is an R Markdown document that I'm throwing together super quick.
# load file for Mac
jh <- read.delim(file.choose(), header = TRUE)
## Error: file choice cancelled
head(jh)
## Error: object 'jh' not found
library(arm)
## Loading required package: MASS
## Loading required package: Matrix
## Loading required package: lattice
## Loading required package: lme4
## Attaching package: 'lme4'
## The following object(s) are masked from 'package:stats':
##
## AIC, BIC
## Loading required package: R2WinBUGS
## Loading required package: coda
## Attaching package: 'coda'
## The following object(s) are masked from 'package:lme4':
##
## HPDinterval
## Loading required package: abind
## Loading required package: foreign
## arm (Version 1.6-01.02, built: 2013-1-7)
## Working directory is /Users/arosati
## Attaching package: 'arm'
## The following object(s) are masked from 'package:coda':
##
## traceplot
jh_gard <- read.delim(file.choose(), colClass = c("factor", "factor", "factor",
"factor", "factor", "factor", "factor", "factor", "factor"))
## Error: file choice cancelled
summary(jh_gard)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'jh_gard' not found
names(jh_gard)
## Error: object 'jh_gard' not found
jh_gard$white <- ifelse(jh_gard$Race == 0, c(1), c(0))
## Error: object 'jh_gard' not found
summary(jh_gard$Race)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'jh_gard' not found
summary(jh_gard$Age)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'jh_gard' not found
summary(jh_gard$AgeGroup)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'jh_gard' not found
summary(jh_gard$InsuranceType)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'jh_gard' not found
summary(jh_gard$MedAssist)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'jh_gard' not found
summary(jh_gard$PracticeType)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'jh_gard' not found
modelblackmedassist = glm(Completed ~ relevel(MedAssist, "1") + relevel(Race,
"1"), family = binomial, data = jh_gard)
## Error: object 'jh_gard' not found
summary(modelblackmedassist)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'modelblackmedassist' not found
exp(cbind(OR = coef(modelblackmedassist), confint(modelblackmedassist)))
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'coef': Error: object 'modelblackmedassist' not found
whitetrash <- glm(Completed ~ white + relevel(MedAssist, "1"), family = binomial,
data = jh_gard)
## Error: object 'jh_gard' not found
summary(whitetrash)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'whitetrash' not found
exp(cbind(OR = coef(whitetrash), confint(whitetrash)))
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'coef': Error: object 'whitetrash' not found
richcolors <- glm(Completed ~ relevel(Race, "0") + relevel(MedAssist, "0") +
LocationType, family = binomial, data = jh_gard)
## Error: object 'jh_gard' not found
summary(richcolors)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'richcolors' not found
exp(cbind(OR = coef(richcolors), confint(richcolors)))
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'coef': Error: object 'richcolors' not found
poorblack <- glm(Completed ~ relevel(Race, "1") + relevel(MedAssist, "1"), family = binomial,
data = jh_gard)
## Error: object 'jh_gard' not found
summary(poorblack)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'poorblack' not found
exp(cbind(OR = coef(poorblack), confint(poorblack)))
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'coef': Error: object 'poorblack' not found
poorblackurban <- glm(Completed ~ black + relevel(MedAssist, "1") + relevel(LocationType,
"1"), family = binomial, data = jh_gard)
## Error: object 'jh_gard' not found
summary(poorblackurban)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'poorblackurban' not found
exp(cbind(OR = coef(poorblackurban), confint(poorblackurban)))
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'coef': Error: object 'poorblackurban' not found
jh_gard$black <- ifelse(jh_gard$Race == 1, c(1), c(0))
## Error: object 'jh_gard' not found
summary(jh_gard$black)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'jh_gard' not found
blackinsurancemilitary <- glm(Completed ~ black + relevel(InsuranceType, "3"),
family = binomial, data = jh_gard)
## Error: object 'jh_gard' not found
summary(blackinsurancemilitary)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'blackinsurancemilitary' not found
blackinsuranceassist <- glm(Completed ~ black + relevel(InsuranceType, "0"),
family = binomial, data = jh_gard)
## Error: object 'jh_gard' not found
summary(blackinsuranceassist)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'blackinsuranceassist' not found
blackinsuranceprivate <- glm(Completed ~ black + relevel(InsuranceType, "1"),
family = binomial, data = jh_gard)
## Error: object 'jh_gard' not found
summary(blackinsuranceprivate)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'blackinsuranceprivate' not found
blackinsurancehospital <- glm(Completed ~ black + relevel(InsuranceType, "2"),
family = binomial, data = jh_gard)
## Error: object 'jh_gard' not found
summary(blackinsurancehospital)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'blackinsurancehospital' not found
exp(cbind(OR = coef(blackinsurancemilitary), confint(blackinsurancemilitary)))
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'coef': Error: object 'blackinsurancemilitary' not found
exp(cbind(OR = coef(blackinsuranceprivate), confint(blackinsuranceprivate)))
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'coef': Error: object 'blackinsuranceprivate' not found
exp(cbind(OR = coef(blackinsurancehospital), confint(blackinsurancehospital)))
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'coef': Error: object 'blackinsurancehospital' not found
exp(cbind(OR = coef(blackinsuranceassist), confint(blackinsuranceassist)))
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'coef': Error: object 'blackinsuranceassist' not found
whiteinsuranceassist <- glm(Completed ~ white + relevel(InsuranceType, "0"),
family = binomial, data = jh_gard)
## Error: object 'jh_gard' not found
summary(whiteinsuranceassist)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'whiteinsuranceassist' not found
whiteinsuranceprivate <- glm(Completed ~ white + relevel(InsuranceType, "1"),
family = binomial, data = jh_gard)
## Error: object 'jh_gard' not found
summary(whiteinsuranceprivate)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'whiteinsuranceprivate' not found
whiteinsurancehospital <- glm(Completed ~ white + relevel(InsuranceType, "2"),
family = binomial, data = jh_gard)
## Error: object 'jh_gard' not found
summary(whiteinsurancehospital)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'whiteinsurancehospital' not found
whiteinsurancemilitary <- glm(Completed ~ white + relevel(InsuranceType, "3"),
family = binomial, data = jh_gard)
## Error: object 'jh_gard' not found
summary(whiteinsurancemilitary)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'whiteinsurancemilitary' not found
exp(cbind(OR = coef(whiteinsurancehospital), confint(whiteinsurancehospital)))
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'coef': Error: object 'whiteinsurancehospital' not found
exp(cbind(OR = coef(whiteinsurancemilitary), confint(whiteinsurancemilitary)))
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'coef': Error: object 'whiteinsurancemilitary' not found
exp(cbind(OR = coef(whiteinsuranceprivate), confint(whiteinsuranceprivate)))
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'coef': Error: object 'whiteinsuranceprivate' not found
exp(cbind(OR = coef(whiteinsuranceassist), confint(whiteinsuranceassist)))
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'coef': Error: object 'whiteinsuranceassist' not found
assistpractice <- glm(Completed ~ MedAssist + relevel(PracticeType, "0"), family = binomial,
data = jh_gard)
## Error: object 'jh_gard' not found
summary(assistpractice)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'assistpractice' not found
assistpractice1 <- glm(Completed ~ MedAssist + relevel(PracticeType, "1"), family = binomial,
data = jh_gard)
## Error: object 'jh_gard' not found
summary(assistpractice1)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'assistpractice1' not found
# so the problem is not between black and white races. it is because of
# medical assistance and also family practice. appearence of these factors
# nope...I need to put these coefficients into the
# exp(cbind(OR=coef(modelname), confint(model2name))) the output from that
# table tells me the multiplication factor of how different the two
# compared things are. In petra's example, white race compared to black
# race is OR 1.6924x higher liklihood. above 1 means increaseing.
# interpreting odds ratios...relative when comparing categories, then I do
# an ANOVA to compare the two models with one factor different to see
# which explains better code is: anova(model1, model2, test='Chisq') then
# plot it with plot(objectWITHcolumnsANDrows, main= 'Title')
model1 <- glm(Completed ~ relevel(InsuranceType, "0") + relevel(PracticeType,
"1"), family = binomial, data = jh_gard)
## Error: object 'jh_gard' not found
summary(model1)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'model1' not found
model15 <- glm(Completed ~ relevel(InsuranceType, "0") + relevel(PracticeType,
"1") + relevel(LocationType, "0"), family = binomial, data = jh_gard)
## Error: object 'jh_gard' not found
summary(model15)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'model15' not found
model2 <- glm(Completed ~ relevel(InsuranceType, "0") + relevel(PracticeType,
"1") + relevel(LocationType, "0") + relevel(AgeGroup, "1"), family = binomial,
data = jh_gard)
## Error: object 'jh_gard' not found
summary(model2)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'model2' not found
head(jh_gard)
## Error: error in evaluating the argument 'x' in selecting a method for
## function 'head': Error: object 'jh_gard' not found
model3 <- glm(Completed ~ relevel(InsuranceType, "0") + relevel(PracticeType,
"1") + relevel(LocationType, "0") + relevel(AgeGroup, "1") + white, family = binomial,
data = jh_gard)
## Error: object 'jh_gard' not found
summary(model3)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'model3' not found
model4 <- glm(Completed ~ relevel(InsuranceType, "0") + relevel(PracticeType,
"1") + relevel(LocationType, "0") + relevel(AgeGroup, "1") + black, family = binomial,
data = jh_gard)
## Error: object 'jh_gard' not found
summary(model4)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'model4' not found
plot(jh_gard$Completed, fitted(glm(Completed ~ PracticeType, binomial, data = jh_gard)),
xlab = "Completed", ylab = "P(Completed Shots)", pch = 15)
## Error: error in evaluating the argument 'x' in selecting a method for
## function 'plot': Error: object 'jh_gard' not found
exp(cbind(OR = coef(model1), confint(model1)))
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'coef': Error: object 'model1' not found
exp(cbind(OR = coef(model15), confint(model15)))
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'coef': Error: object 'model15' not found
exp(cbind(OR = coef(model2), confint(model2)))
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'coef': Error: object 'model2' not found
exp(cbind(OR = coef(model3), confint(model3)))
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'coef': Error: object 'model3' not found
exp(cbind(OR = coef(model4), confint(model4)))
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'coef': Error: object 'model4' not found
anova(model15, model1, test = "Chisq")
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'anova': Error: object 'model15' not found
anova(model1, model2, test = "Chisq")
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'anova': Error: object 'model1' not found
anova(model15, model2, test = "Chisq")
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'anova': Error: object 'model15' not found
anova(model1, model3, test = "Chisq")
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'anova': Error: object 'model1' not found
anova(model15, model3, test = "Chisq")
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'anova': Error: object 'model15' not found
anova(model1, model4, test = "Chisq")
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'anova': Error: object 'model1' not found
anova(model15, model4, test = "Chisq")
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'anova': Error: object 'model15' not found
anova(model2, model3, test = "Chisq")
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'anova': Error: object 'model2' not found
anova(model4, model2, test = "Chisq")
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'anova': Error: object 'model4' not found
anova(model3, model4, test = "Chisq")
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'anova': Error: object 'model3' not found
anova(model1, model2, model3, model4, test = "Chisq")
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'anova': Error: object 'model1' not found
anova(model1, model15, model2, model3, model4, test = "Chisq")
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'anova': Error: object 'model1' not found
model35 <- glm(Completed ~ relevel(InsuranceType, "1") + relevel(PracticeType,
"1") + relevel(LocationType, "0") + relevel(AgeGroup, "1") + white, family = binomial,
data = jh_gard)
## Error: object 'jh_gard' not found
summary(model35)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'summary': Error: object 'model35' not found
exp(cbind(OR = coef(model35), confint(model35)))
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'coef': Error: object 'model35' not found
anova(model3, model35, test = "Chisq")
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'anova': Error: object 'model3' not found
plot(model1)
## Error: error in evaluating the argument 'x' in selecting a method for
## function 'plot': Error: object 'model1' not found
plot(model2)
## Error: error in evaluating the argument 'x' in selecting a method for
## function 'plot': Error: object 'model2' not found
plot(model3)
## Error: error in evaluating the argument 'x' in selecting a method for
## function 'plot': Error: object 'model3' not found
plot(anova(model1, model2, test = "Chisq"))
## Error: error in evaluating the argument 'x' in selecting a method for
## function 'plot': Error in anova(model1, model2, test = "Chisq") : error in
## evaluating the argument 'object' in selecting a method for function
## 'anova': Error: object 'model1' not found
library(aod)
library(ggplot2)
wald.test(b = coef(model1), Sigma = vcov(model1), Terms = 4:6)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'coef': Error: object 'model1' not found
wald.test(b = coef(model2), Sigma = vcov(model2), Terms = 4:6)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'coef': Error: object 'model2' not found
wald.test(b = coef(model3), Sigma = vcov(model3), Terms = 4:6)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'coef': Error: object 'model3' not found
wald.test(b = coef(model4), Sigma = vcov(model4), Terms = 4:6)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'coef': Error: object 'model4' not found
plot(jh_gard$Completed ~ jh_gard$Race, main = "Racial Profile", sub = "Whites and Others appear to have highest completion rates",
xlab = "Race", ylab = "Completion - 1=Completed")
## Error: object 'jh_gard' not found
legend("bottom", title = "Races", c("0=White", "1=Black", "2=Hispanic", "3=Other"),
horiz = TRUE)
## Error: plot.new has not been called yet
plot(jh_gard$Completed ~ jh_gard$AgeGroup, main = "Age Profile", sub = "Adults appear to have higher completion rates",
xlab = "Age", ylab = "Completion - 1=Completed")
## Error: object 'jh_gard' not found
legend("bottom", title = "Age Groups", c("0=Child", "1=adult"), horiz = TRUE)
## Error: plot.new has not been called yet
plot(jh_gard$Completed ~ jh_gard$MedAssist, main = "Poorness Profile", sub = "Non-assisted people appear to have higher completion rates",
xlab = "Medical Assitance", ylab = "Completion - 1=Completed")
## Error: object 'jh_gard' not found
legend("bottom", title = "Medical Assistance Needed", c("0=No", "1=Yes"), horiz = TRUE)
## Error: plot.new has not been called yet
plot(jh_gard$Completed ~ jh_gard$LocationType, main = "Location Profile", sub = "Urban people appear to have higher completion rates",
xlab = "Location", ylab = "Completion - 1=Completed")
## Error: object 'jh_gard' not found
legend("bottom", title = "Location", c("0=Suburban", "1=Urban"), horiz = TRUE)
## Error: plot.new has not been called yet
plot(jh_gard$Completed ~ jh_gard$InsuranceType + jh_gard$PracticeType)
## Error: object 'jh_gard' not found
plot(model1)
## Error: error in evaluating the argument 'x' in selecting a method for
## function 'plot': Error: object 'model1' not found
plot(model2)
## Error: error in evaluating the argument 'x' in selecting a method for
## function 'plot': Error: object 'model2' not found
plot(model3)
## Error: error in evaluating the argument 'x' in selecting a method for
## function 'plot': Error: object 'model3' not found
plot(model4)
## Error: error in evaluating the argument 'x' in selecting a method for
## function 'plot': Error: object 'model4' not found
anova(model2, model3, test = "Chisq")
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'anova': Error: object 'model2' not found
plot(jh_gard$PracticeType ~ jh_gard$Race)
## Error: object 'jh_gard' not found
plot(jh_gard$AgeGroup ~ jh_gard$Race)
## Error: object 'jh_gard' not found
# fail <- subset(jh_gard, Completed==0) subsetmodel <-
# glm(fail+relevel(Race, '0'), family=binomial, data=jh_gard) plot(fail)
# doesn't exactly work...
plot(jh_gard$Shots)
## Error: error in evaluating the argument 'x' in selecting a method for
## function 'plot': Error: object 'jh_gard' not found
plot(jh_gard$Shots ~ jh_gard$Race)
## Error: object 'jh_gard' not found
plot(jh_gard$Shots ~ jh_gard$AgeGroup)
## Error: object 'jh_gard' not found
plot(jh_gard$Shots ~ jh_gard$InsuranceType)
## Error: object 'jh_gard' not found
plot(jh_gard$Shots ~ jh_gard$LocationType)
## Error: object 'jh_gard' not found
plot(jh_gard$Shots ~ jh_gard$PracticeType)
## Error: object 'jh_gard' not found
predict(model1)
## Error: error in evaluating the argument 'object' in selecting a method for
## function 'predict': Error: object 'model1' not found