Skip to content

Commit

Permalink
day8
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaczhang committed Apr 23, 2024
1 parent d32b91b commit 3ff6405
Show file tree
Hide file tree
Showing 16 changed files with 269 additions and 12 deletions.
26 changes: 17 additions & 9 deletions docs/schedule.html
Original file line number Diff line number Diff line change
Expand Up @@ -480,23 +480,30 @@ <h1>Week 2</h1>
<td style="text-align: center;">AM</td>
<td style="text-align: center;">Runde</td>
<td style="text-align: center;"><strong>Logistic regression</strong></td>
<td style="text-align: center;">Lecture</td>
<td style="text-align: center;"><a href="v24/Module7-Logistic-Regression.pdf">Lecture</a></td>
</tr>
<tr class="odd">
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;">Demo: ppn</td>
<td style="text-align: center;"><a href="v24/MF9130E - Introductory course in Statistics LR examples.pdf">Lecture</a>, <a href="https://github.com/ocbe-uio/teaching_mf9130e/blob/main/lab/code/height_demo.R">Code</a>, <a href="https://github.com/ocbe-uio/teaching_mf9130e/blob/main/lab/ppnLR.csv">ppnLR.csv</a>, <a href="https://github.com/ocbe-uio/teaching_mf9130e/blob/main/lab/classroom.csv">classroom.csv</a></td>
</tr>
<tr class="even">
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;">Lab 11</td>
<td style="text-align: center;"><a href="./lab/lab_logistic_reg.html">Lab notes</a></td>
</tr>
<tr class="even">
<tr class="odd">
<td style="text-align: center;"></td>
<td style="text-align: center;">PM</td>
<td style="text-align: center;"></td>
<td style="text-align: center;"><strong>Survival analysis</strong></td>
<td style="text-align: center;">Lecture</td>
<td style="text-align: center;"><a href="v24/Module8-Survival.pdf">Lecture</a></td>
</tr>
<tr class="odd">
<tr class="even">
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
Expand Down Expand Up @@ -1054,11 +1061,12 @@ <h1>Week 2</h1>
<span id="cb1-80"><a href="#cb1-80" aria-hidden="true" tabindex="-1"></a>| |PM | | **Linear regression III** | Lecture|</span>
<span id="cb1-81"><a href="#cb1-81" aria-hidden="true" tabindex="-1"></a>| | | |Lab 10 | <span class="co">[</span><span class="ot">Lab notes</span><span class="co">](lab/lab_linearreg-III.qmd)</span>|</span>
<span id="cb1-82"><a href="#cb1-82" aria-hidden="true" tabindex="-1"></a>| | | | Course summary | Lecture|</span>
<span id="cb1-83"><a href="#cb1-83" aria-hidden="true" tabindex="-1"></a>| Apr 25 |AM | Runde | **Logistic regression** | Lecture|</span>
<span id="cb1-84"><a href="#cb1-84" aria-hidden="true" tabindex="-1"></a>| | | | Lab 11| <span class="co">[</span><span class="ot">Lab notes</span><span class="co">](lab/lab_logistic_reg.qmd)</span>|</span>
<span id="cb1-85"><a href="#cb1-85" aria-hidden="true" tabindex="-1"></a>| |PM | | **Survival analysis** | Lecture|</span>
<span id="cb1-86"><a href="#cb1-86" aria-hidden="true" tabindex="-1"></a>| | | |Lab 12 | <span class="co">[</span><span class="ot">Lab notes</span><span class="co">](lab/lab_survival.qmd)</span>|</span>
<span id="cb1-87"><a href="#cb1-87" aria-hidden="true" tabindex="-1"></a></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
<span id="cb1-83"><a href="#cb1-83" aria-hidden="true" tabindex="-1"></a>| Apr 25 |AM | Runde | **Logistic regression** | <span class="co">[</span><span class="ot">Lecture</span><span class="co">](v24/Module7-Logistic-Regression.pdf)</span>|</span>
<span id="cb1-84"><a href="#cb1-84" aria-hidden="true" tabindex="-1"></a>| | | |Demo: ppn | <span class="co">[</span><span class="ot">Lecture</span><span class="co">](v24/MF9130E - Introductory course in Statistics LR examples.pdf)</span>, <span class="co">[</span><span class="ot">Code</span><span class="co">](https://github.com/ocbe-uio/teaching_mf9130e/blob/main/lab/code/height_demo.R)</span>, <span class="co">[</span><span class="ot">ppnLR.csv</span><span class="co">](https://github.com/ocbe-uio/teaching_mf9130e/blob/main/lab/ppnLR.csv)</span>, <span class="co">[</span><span class="ot">classroom.csv</span><span class="co">](https://github.com/ocbe-uio/teaching_mf9130e/blob/main/lab/classroom.csv)</span>|</span>
<span id="cb1-85"><a href="#cb1-85" aria-hidden="true" tabindex="-1"></a>| | | | Lab 11| <span class="co">[</span><span class="ot">Lab notes</span><span class="co">](lab/lab_logistic_reg.qmd)</span>|</span>
<span id="cb1-86"><a href="#cb1-86" aria-hidden="true" tabindex="-1"></a>| |PM | | **Survival analysis** | <span class="co">[</span><span class="ot">Lecture</span><span class="co">](v24/Module8-Survival.pdf)</span>|</span>
<span id="cb1-87"><a href="#cb1-87" aria-hidden="true" tabindex="-1"></a>| | | |Lab 12 | <span class="co">[</span><span class="ot">Lab notes</span><span class="co">](lab/lab_survival.qmd)</span>|</span>
<span id="cb1-88"><a href="#cb1-88" aria-hidden="true" tabindex="-1"></a></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div></div></div></div></div>
</div> <!-- /content -->

Expand Down
2 changes: 1 addition & 1 deletion docs/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@
"href": "schedule.html",
"title": "Schedule",
"section": "",
"text": "You can find the official course schedule provided by University of Oslo here. If there is an error in the time and place on this page, please refer to the official schedule.\n\n\n\n\n\n\nTime and place\n\n\n\nSessions are roughly divided by AM (morning) and PM (afternoon).\n\nAM: 8:30 - 11:45\nPM: 12:45 - 16:00\n\nLocations\n\nAud13: Auditorium 13 in Domus Medica (map)\nRunde: Runde auditorium R105 (map)\n\n\n\n\nWeek 1\n\n\n\nDay\nSession\nPlace\nTopic\nCourse material\n\n\n\n\nDay 1 - Apr 8\nPM\nAud 13\nCourse introduction\nLecture\n\n\n\n\n\nData and descriptive statistics\nLecture\n\n\nDay 2 - Apr 9\nAM\nAud 13\nLab 1\nLecture, Lab notes, Code\n\n\n\n\n\nLab 2\nLecture, Lab notes, Code\n\n\n\nPM\n\nIntro to probability\nLecture\n\n\n\n\n\nDiagnostic test\nLecture\n\n\n\n\n\nLab 3\nLab notes, Code\n\n\nDay 3 - Apr 10\nAM\nAud 13\nBinomial distribution\nLecture\n\n\n\n\n\nNormal distribution\nLecture\n\n\n\n\n\nLab 4\nLab notes, Code\n\n\n\nPM\n\nStatistical inference I\nLecture\n\n\n\n\n\nSample mean\nLecture\n\n\n\n\n\nConfidence interval\nLecture\n\n\n\n\n\nt-test\nLecture\n\n\nDay 4 - Apr 11\nAM\nAud 13\nLab 5\nLecture, Lab notes, Code\n\n\n\nPM\n\nStatistical inference II\nLecture\n\n\n\n\n\nOne proportion\nLecture\n\n\n\n\n\nTwo proportions\nLecture\n\n\n\n\n\nTable analysis\nLecture\n\n\nDay 5 - Apr 12\nAM\nAud 13\nLab 6\nLecture, Lab notes, Code\n\n\n\n\n\nWeek 2\n\n\n\nDay\nSession\nPlace\nTopic\nCourse material\n\n\n\n\nApr 22\nAM\nRunde\nExploratory analysis (Part II)\nLecture\n\n\n\n\n\nTransformation, non-parametric\nLecture\n\n\n\n\n\nRandomness and probability\nLecture\n\n\n\n\n\nLab 7\nLab notes\n\n\n\nPM\n\nSample size and statistical power\nLecture, Exercise, Code\n\n\nApr 23\nAM\nRunde\nStudy designs\nLecture\n\n\n\nPM\n\nLinear regression I\nLecture\n\n\n\n\n\nLab 8\nLab notes\n\n\nApr 24\nAM\nAud 13\nLinear regression II\nLecture\n\n\n\n\n\nLab 9\nLab notes\n\n\n\nPM\n\nLinear regression III\nLecture\n\n\n\n\n\nLab 10\nLab notes\n\n\n\n\n\nCourse summary\nLecture\n\n\nApr 25\nAM\nRunde\nLogistic regression\nLecture\n\n\n\n\n\nLab 11\nLab notes\n\n\n\nPM\n\nSurvival analysis\nLecture\n\n\n\n\n\nLab 12\nLab notes"
"text": "You can find the official course schedule provided by University of Oslo here. If there is an error in the time and place on this page, please refer to the official schedule.\n\n\n\n\n\n\nTime and place\n\n\n\nSessions are roughly divided by AM (morning) and PM (afternoon).\n\nAM: 8:30 - 11:45\nPM: 12:45 - 16:00\n\nLocations\n\nAud13: Auditorium 13 in Domus Medica (map)\nRunde: Runde auditorium R105 (map)\n\n\n\n\nWeek 1\n\n\n\nDay\nSession\nPlace\nTopic\nCourse material\n\n\n\n\nDay 1 - Apr 8\nPM\nAud 13\nCourse introduction\nLecture\n\n\n\n\n\nData and descriptive statistics\nLecture\n\n\nDay 2 - Apr 9\nAM\nAud 13\nLab 1\nLecture, Lab notes, Code\n\n\n\n\n\nLab 2\nLecture, Lab notes, Code\n\n\n\nPM\n\nIntro to probability\nLecture\n\n\n\n\n\nDiagnostic test\nLecture\n\n\n\n\n\nLab 3\nLab notes, Code\n\n\nDay 3 - Apr 10\nAM\nAud 13\nBinomial distribution\nLecture\n\n\n\n\n\nNormal distribution\nLecture\n\n\n\n\n\nLab 4\nLab notes, Code\n\n\n\nPM\n\nStatistical inference I\nLecture\n\n\n\n\n\nSample mean\nLecture\n\n\n\n\n\nConfidence interval\nLecture\n\n\n\n\n\nt-test\nLecture\n\n\nDay 4 - Apr 11\nAM\nAud 13\nLab 5\nLecture, Lab notes, Code\n\n\n\nPM\n\nStatistical inference II\nLecture\n\n\n\n\n\nOne proportion\nLecture\n\n\n\n\n\nTwo proportions\nLecture\n\n\n\n\n\nTable analysis\nLecture\n\n\nDay 5 - Apr 12\nAM\nAud 13\nLab 6\nLecture, Lab notes, Code\n\n\n\n\n\nWeek 2\n\n\n\nDay\nSession\nPlace\nTopic\nCourse material\n\n\n\n\nApr 22\nAM\nRunde\nExploratory analysis (Part II)\nLecture\n\n\n\n\n\nTransformation, non-parametric\nLecture\n\n\n\n\n\nRandomness and probability\nLecture\n\n\n\n\n\nLab 7\nLab notes\n\n\n\nPM\n\nSample size and statistical power\nLecture, Exercise, Code\n\n\nApr 23\nAM\nRunde\nStudy designs\nLecture\n\n\n\nPM\n\nLinear regression I\nLecture\n\n\n\n\n\nLab 8\nLab notes\n\n\nApr 24\nAM\nAud 13\nLinear regression II\nLecture\n\n\n\n\n\nLab 9\nLab notes\n\n\n\nPM\n\nLinear regression III\nLecture\n\n\n\n\n\nLab 10\nLab notes\n\n\n\n\n\nCourse summary\nLecture\n\n\nApr 25\nAM\nRunde\nLogistic regression\nLecture\n\n\n\n\n\nDemo: ppn\nLecture, Code, ppnLR.csv, classroom.csv\n\n\n\n\n\nLab 11\nLab notes\n\n\n\nPM\n\nSurvival analysis\nLecture\n\n\n\n\n\nLab 12\nLab notes"
},
{
"objectID": "lab_diagtest.html",
Expand Down
Binary file not shown.
Binary file added docs/v24/Module7-Logistic-Regression.pdf
Binary file not shown.
Binary file added docs/v24/Module8-Survival.pdf
Binary file not shown.
Binary file modified lab/.DS_Store
Binary file not shown.
46 changes: 46 additions & 0 deletions lab/code/height_demo.R
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)
39 changes: 39 additions & 0 deletions lab/data/classroom.csv
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
163 changes: 163 additions & 0 deletions lab/data/ppnLR.csv
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
5 changes: 3 additions & 2 deletions schedule.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ Locations
| |PM | | **Linear regression III** | Lecture|
| | | |Lab 10 | [Lab notes](lab/lab_linearreg-III.qmd)|
| | | | Course summary | Lecture|
| Apr 25 |AM | Runde | **Logistic regression** | Lecture|
| Apr 25 |AM | Runde | **Logistic regression** | [Lecture](v24/Module7-Logistic-Regression.pdf)|
| | | |Demo: ppn | [Lecture](v24/MF9130E - Introductory course in Statistics LR examples.pdf), [Code](https://github.com/ocbe-uio/teaching_mf9130e/blob/main/lab/code/height_demo.R), [ppnLR.csv](https://github.com/ocbe-uio/teaching_mf9130e/blob/main/lab/ppnLR.csv), [classroom.csv](https://github.com/ocbe-uio/teaching_mf9130e/blob/main/lab/classroom.csv)|
| | | | Lab 11| [Lab notes](lab/lab_logistic_reg.qmd)|
| |PM | | **Survival analysis** | Lecture|
| |PM | | **Survival analysis** | [Lecture](v24/Module8-Survival.pdf)|
| | | |Lab 12 | [Lab notes](lab/lab_survival.qmd)|


Binary file modified v23/.DS_Store
Binary file not shown.
Binary file modified v23/course_material/.DS_Store
Binary file not shown.
Binary file added v24/.DS_Store
Binary file not shown.
Binary file not shown.
Binary file added v24/Module7-Logistic-Regression.pdf
Binary file not shown.
Binary file added v24/Module8-Survival.pdf
Binary file not shown.

0 comments on commit 3ff6405

Please # to comment.