-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d32b91b
commit 3ff6405
Showing
16 changed files
with
269 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
|
||
#read in data after downloading the csv file | ||
#NB edit directory to match file location on your computer | ||
ppnLR <- read.csv("~/tempi/BT2012/ppnLR.csv", sep=";") | ||
|
||
#define variables and put into a data frame | ||
sex<-as.factor(ppnLR$sex) | ||
height<-ppnLR$height | ||
ppn<-as.factor(ppnLR$ppn) | ||
|
||
ppnData = data.frame(ppn,height,sex) | ||
|
||
#call graphics library (install first if not already present) | ||
library(ggplot2) | ||
#investigate distribution of height using histogram with 20 bins | ||
ggplot(ppnData,aes(x=height))+geom_histogram(bins=20) | ||
#split the histogram by sex | ||
ggplot(ppnData,aes(x=height))+geom_histogram(aes(color = sex, fill = sex), position = "identity",bins=15, alpha = 0.4) | ||
#investigate frequency of ppn for females and males | ||
#create first a frequency table by combining the two variables sex and ppn | ||
sex_ppn <- table(ppnData$sex,ppnData$ppn) | ||
sex_ppn | ||
prop.table(sex_ppn,1) | ||
prop.table(sex_ppn,2) | ||
|
||
#fit logistic regression model to explain ppn risk as a function of height | ||
ppnLR <- glm(ppn ~ height, family = "binomial") | ||
#examine model fitting results | ||
summary(ppnLR) | ||
|
||
#fit another logistic regression model to compare ppn risk between females and males | ||
ppnLR2 <- glm(ppn ~ sex, family = "binomial") | ||
#examine model fitting results (no significant difference associated with sex) | ||
summary(ppnLR2) | ||
|
||
#include now both height and sex as an explanatory variables in an additive model | ||
ppnLR3 <- glm(ppn ~ height+sex, family = "binomial") | ||
summary(ppnLR3) | ||
|
||
#examine last what happens if an interaction effect between sex and height is included in the model | ||
ppnLR4 <- glm(ppn ~ height+sex+height:sex, family = "binomial") | ||
summary(ppnLR4) | ||
#note how inclusion of the additional term changes the estimate of height effect and the baseline (Intercept) | ||
|
||
#use boxplots to compare height distributions between diagnosed vs non-diagnosed and females/males | ||
ggplot(ppnData,aes(x=ppn,y=height,group=ppn))+geom_boxplot(aes(fill=sex))+facet_grid(. ~ sex) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
ppn;height;sex | ||
0;162;F | ||
0;170;F | ||
0;160;F | ||
0;178;F | ||
1;197;M | ||
0;171;F | ||
0;185;M | ||
0;191;M | ||
0;170;F | ||
0;182;M | ||
0;172;F | ||
0;180;M | ||
0;168;F | ||
0;170;F | ||
0;169;F | ||
0;158;F | ||
0;166;M | ||
0;169;F | ||
0;164;F | ||
1;180;M | ||
0;179;M | ||
0;182;M | ||
0;186;M | ||
1;162;F | ||
1;175;M | ||
1;165;F | ||
0;189;M | ||
1;165;F | ||
0;162;F | ||
0;170;F | ||
0;169;F | ||
0;169;F | ||
0;164;F | ||
0;163;F | ||
1;174;M | ||
0;168;F | ||
1;178;M | ||
0;198;M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
ppn;height;sex | ||
1;175;F | ||
0;172;M | ||
1;185;M | ||
1;190;M | ||
0;169;M | ||
1;178;F | ||
1;182;M | ||
0;165;F | ||
0;162;F | ||
0;174;M | ||
0;180;M | ||
0;177;F | ||
1;173;M | ||
1;181;F | ||
0;170;M | ||
0;159;F | ||
1;171;F | ||
1;176;F | ||
1;168;F | ||
1;166;F | ||
0;154;F | ||
0;159;F | ||
0;161;F | ||
0;149;F | ||
0;170;F | ||
1;183;M | ||
1;189;M | ||
1;170;M | ||
1;192;M | ||
0;168;M | ||
0;166;M | ||
0;183;M | ||
1;179;F | ||
1;175;F | ||
1;171;F | ||
1;165;F | ||
0;166;F | ||
0;160;F | ||
0;159;F | ||
0;156;F | ||
0;155;F | ||
1;185;M | ||
1;178;M | ||
1;177;M | ||
1;172;M | ||
0;169;M | ||
0;173;M | ||
0;161;M | ||
0;160;F | ||
1;169;F | ||
1;175;F | ||
1;166;F | ||
1;165;F | ||
0;152;F | ||
0;158;F | ||
0;163;F | ||
0;148;F | ||
0;175;F | ||
1;181;M | ||
1;188;M | ||
1;169;M | ||
1;195;M | ||
0;170;M | ||
0;165;M | ||
0;187;M | ||
1;178;F | ||
1;174;F | ||
1;172;F | ||
1;164;F | ||
0;166;F | ||
0;159;F | ||
0;160;F | ||
0;155;F | ||
0;154;F | ||
1;189;M | ||
1;177;M | ||
1;179;M | ||
1;170;M | ||
0;168;M | ||
0;176;M | ||
0;166;M | ||
1;175;F | ||
0;172;M | ||
0;185;M | ||
1;190;M | ||
1;169;M | ||
1;178;F | ||
1;182;M | ||
0;165;F | ||
1;162;F | ||
0;174;M | ||
0;180;M | ||
0;177;F | ||
1;173;M | ||
1;181;F | ||
0;170;M | ||
1;159;F | ||
1;171;F | ||
1;176;F | ||
1;168;F | ||
1;166;F | ||
0;154;F | ||
0;159;F | ||
0;161;F | ||
0;149;F | ||
0;170;F | ||
1;183;M | ||
1;189;M | ||
1;170;M | ||
1;192;M | ||
0;168;M | ||
0;166;M | ||
0;183;M | ||
1;179;F | ||
1;175;F | ||
1;171;F | ||
0;165;F | ||
0;166;F | ||
0;160;F | ||
0;159;F | ||
0;156;F | ||
0;155;F | ||
1;185;M | ||
1;178;M | ||
0;177;M | ||
1;172;M | ||
0;169;M | ||
0;173;M | ||
0;161;M | ||
0;160;F | ||
1;169;F | ||
1;175;F | ||
0;166;F | ||
1;165;F | ||
0;152;F | ||
0;158;F | ||
0;163;F | ||
0;148;F | ||
0;175;F | ||
1;181;M | ||
0;188;M | ||
1;169;M | ||
1;195;M | ||
0;170;M | ||
0;165;M | ||
0;187;M | ||
1;178;F | ||
1;174;F | ||
1;172;F | ||
1;164;F | ||
0;166;F | ||
1;159;F | ||
0;160;F | ||
0;155;F | ||
0;154;F | ||
1;189;M | ||
1;177;M | ||
0;179;M | ||
1;170;M | ||
0;168;M | ||
0;176;M | ||
0;166;M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.