Difference between revisions of "Regression Exercise"

From Statistical Genetics Courses

Jump to: navigation, search
(Created page with "__NOTITLE__ ==Regression exercise== In R: load("dbp.R")<br data-attributes="%20/" />ls()<br data-attributes="%20/" />dbp[1:5,]<br data-attributes="%20/" />#<br data-attribut...")
(No difference)

Revision as of 18:51, 23 February 2017

Regression exercise

In R:

load("dbp.R")
ls()
dbp[1:5,]
#
result.snp12 = glm (affection ~ rs1112, family=binomial("logit"), data=dbp)
print (result.snp12)
print ( class (result.snp12) )
print ( summary(result.snp12) )
#
dev.geno = anova (result.snp12, test="Chi")
lrt.pvalue = pchisq(dev.geno[dim(dev.geno)[1],"Deviance"],
df=2, ncp=0, FALSE)
print ( lrt.pvalue )
#
print ( summary(result.snp12)$coefficients )
snp.beta = summary(result.snp12)$coefficients[2:3,1]
print ( snp.beta )
print ( exp(snp.beta) )
ci = confint (result.snp12)
print (ci)
print ( exp(ci) )
#
snp.data = dbp[,c("affection", "rs1112")]
summary(snp.data)
snp.data[,"rs1112"]
summary(snp.data)
#
result.all = glm (affection ~ rs1112, family=binomial("logit"),
data=snp.data)
dev.all = anova (result.all, test="Chi")
summary(result.all)
print(dev.all)
#
snp.data = dbp[,c("affection", "trait","sex", "age", "rs1112", "rs1117")]
summary(snp.data)
snp.data[,"rs1112"]
snp.data[,"rs1117"] #
result.adj = glm (affection ~ sex + rs1112 , family=binomial("logit"),
data=snp.data)
summary(result.adj)
#
result.adj = glm (affection ~ age + rs1112 , family=binomial("logit"),
data=snp.data)
summary(result.adj)
#
result.adj = glm (affection ~ sex + age + rs1112, family=binomial("logit"),
data=snp.data)
summary(result.adj)
#
result.adj = glm (affection ~ rs1117 + rs1112, family=binomial("logit"),
data=snp.data)
summary(result.adj)
anova (result.adj, test="Chi")
result.adj = glm (affection ~ rs1112 + rs1117, family=binomial("logit"),
data=snp.data)
summary(result.adj)
anova (result.adj, test="Chi")
#
result.adj = lm (trait ~ rs1112, data=snp.data)
summary(result.adj)
result.adj = lm (trait ~ sex + rs1112, data=snp.data)
summary(result.adj)
#
result.inter = glm (affection ~ sex * rs1112, family=binomial("logit"),
data=snp.data)
summary(result.inter)
result.inter = glm (affection ~ age * rs1112, family=binomial("logit"),
data=snp.data)
summary(result.inter)
#
result.inter = glm (affection ~ rs1112 * rs1117, family=binomial("logit"),
data=snp.data)
summary(result.inter)
#
q()