Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifications made during 2022 class of BSE658 #2

Open
wants to merge 63 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
71e534c
Added data files
juneeybug Aug 31, 2021
dc055f5
Added dice rolling pic
juneeybug Aug 31, 2021
dd82a57
Added mean vs median pic
juneeybug Aug 31, 2021
597ff1c
Included pics and datasets
Aug 31, 2021
6718529
Added a note on derivation of variance based estimates. Added Bessel'…
Sep 6, 2021
b31f80d
Added fig 4
juneeybug Sep 6, 2021
3e70c86
Added fig 5
juneeybug Sep 6, 2021
28c39aa
Set right figure paths
Sep 6, 2021
b03352e
Added scale() and associated histograms
Sep 7, 2021
ec119dc
Merge branch 'decisionlabiitk:main' into main
juneeybug Sep 9, 2021
fd29297
Merge branch 'decisionlabiitk:main' into main
juneeybug Sep 11, 2021
8c22e9d
Added load dataset command
Sep 11, 2021
34c5dec
Merge branch 'main' of github.com:juneeybug/BSE658 into main
Sep 11, 2021
b1124ce
Merge branch 'decisionlabiitk:main' into main
juneeybug Sep 20, 2021
7db764e
I added a few lines to illustrate committing to Git
Sep 20, 2021
5551f1a
Added normal and other distributions.
Sep 20, 2021
90280ef
Added line plots, Shapiro Wilk test, added definitions for dnorm, qno…
Sep 21, 2021
1340f80
Merge branch 'decisionlabiitk:main' into main
juneeybug Sep 27, 2021
ea11e82
Corrected some typos. Added assignment at the end for sample standard…
Sep 27, 2021
2e5a0e8
Merge branch 'decisionlabiitk:main' into main
juneeybug Oct 4, 2021
c2d800c
Sampling distribution and Power analysis
juneeybug Oct 25, 2021
d4784ea
ggplot related additions
juneeybug Aug 23, 2022
80e85fc
Via upload. Summary with different objects.
juneeybug Aug 30, 2022
64cc629
Included ggcorrplot, correlate functions
juneeybug Sep 6, 2022
d07b479
Binomial plots, ggplot histogram, density plots
juneeybug Sep 12, 2022
8bc3e9c
power calculation + null vs alternative comparison
juneeybug Oct 1, 2022
8c7eccc
Merge pull request #2 from decisionlabiitk/main
juneeybug Oct 17, 2022
f93b8e2
Added Normality Tests
juneeybug Oct 17, 2022
d91a361
Added Levene Test
juneeybug Oct 17, 2022
bdcbfeb
Added Chisq.test
juneeybug Oct 18, 2022
afe28c7
Added Salem.Rdata
juneeybug Oct 18, 2022
2f9a17e
Added Fischer Exact Test
juneeybug Oct 18, 2022
491ae81
Added agpp data
juneeybug Oct 18, 2022
601f6dc
Added McNemar Test
juneeybug Oct 18, 2022
f43a535
Added Post hoc testing
juneeybug Oct 25, 2022
307d090
Module 6 ANOVA
juneeybug Nov 1, 2022
ddd83f1
minor stuff chi sq html
juneeybug Nov 1, 2022
78e9616
Minor corrections.
juneeybug Nov 1, 2022
cdd32da
Update ANOVA.Rmd
juneeybug Nov 7, 2022
11b71ab
Regression Initial Commit
juneeybug Nov 7, 2022
17f9dcf
Added car package and InteractionPlot
juneeybug Nov 9, 2022
0509c92
Added tukeyHSD instead of pairwise t test
juneeybug Nov 9, 2022
309adcd
updated Cook's distance and plot of residuals
juneeybug Nov 9, 2022
b50de3a
Added diagnostics
juneeybug Nov 12, 2022
d84a5da
Added Bootstrapping from MKinfer
juneeybug Nov 12, 2022
90d05c0
Linear Mixed Models first update
juneeybug Nov 15, 2022
8e2e723
Shifted Module 1 & 2 in same folder
Chetank99 Aug 4, 2023
dfe0d54
Merge pull request #3 from Chetank99/main
juneeybug Aug 18, 2023
a1d15e6
Module 6 last set of changes
juneeybug Aug 18, 2023
461b084
Changes to distribution parameters
juneeybug Sep 1, 2023
53409ff
ggplot update
juneeybug Aug 15, 2024
99a2a5f
Update based on Moderndive
juneeybug Aug 15, 2024
d3e2df2
bar and boxplots
juneeybug Aug 15, 2024
fb432b8
Update Chi_sq.nb.html
juneeybug Oct 22, 2024
504d99d
module 4 updates
juneeybug Oct 22, 2024
68dcc05
easystats added
juneeybug Oct 30, 2024
5f7866c
Categorical Regression
juneeybug Nov 1, 2024
0d22dbb
predict()
juneeybug Nov 1, 2024
a58b627
Assumptions checks modified
juneeybug Nov 1, 2024
0214517
Dummy coding
juneeybug Nov 1, 2024
9d2132f
Normality test hypothesis
juneeybug Nov 1, 2024
35e6ea1
Added model assumptions check
juneeybug Nov 7, 2024
9a73b2e
Nonlinearity
juneeybug Nov 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
13 changes: 13 additions & 0 deletions BSE658.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX
109 changes: 109 additions & 0 deletions Module 1/Notebook for chapter 1.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
---
title: "R Notebook"
output: html_notebook
---

This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook. When you execute code within the notebook, the results appear beneath the code.

Try executing this chunk by clicking the *Run* button within the chunk or by placing your cursor inside it and pressing *Ctrl+Shift+Enter*.

```{r}
plot(cars)
```
Basic commands on R
Assigning variable
```{r}
x<- 2*8
x
```
Numeric Vector and operation on it
```{r}
y <- c(2.3, 1, 5)
y
```

```{r}
length(y)
mode(y)
class(y)
```
sequence of integers storing in vector
```{r}
mynums <- 10:1
mynums
```
operating on Numeric vector
```{r}
sum(mynums)
min(mynums)
max(mynums)
range(mynums)
```
standard deviation, mean and median
```{r}
mean(mynums)
sd(mynums)
median(mynums)
```
Indexing Numeric vector
```{r}
mynums[2]
mynums[1:4]
mynums[-4] # retrieve everything except fourth position
```
character vectors
```{r}
gender <- c('F', 'M', 'M', 'F', 'F')
gender
class(gender)
```
Finding repitition of a character
```{r}
gender[gender == 'F']
```
operating on Data frames
```{r}
participant <- c('louis', 'paula', 'vincenzo')
mydf <- data.frame(participant, score = c(67, 85, 32))
mydf
mydf$score
mean(mydf$score)
```
Indexing on Data frame
```{r}
mydf[1,] # first row
mydf[, 1][2]
```
Indexing
```{r}
mydf[2, ] # 2nd column
```
PLOTING
```{r}
mean(mydf$score)
str(mydf)
summary(mydf)
```
Loading files
```{r}
covid_19 <- read.csv('india_covid_19_statewise_status.csv')
covid_19
```
ASSIGNMENT
Assignment for chapter -1

1. Create a Numeric vector with 10 elements ranging between 20 to 30, name it Mynums. Find maximum and minimum element of the vector. Compute Sum operation on the vector put it in a variable z. Find out the 4,5,6 th element of the vector.

2. Create a 10 element numeric vector and compute mean, median and Standard deviation of the vector.

3. Create a dataframe with 5 participants and their math score. Calculate mean of their score.


Student name Math score
Louis 67
Paul 86
Vincenzo 80
Tim 56
Dorothy 91


457 changes: 457 additions & 0 deletions Module 1/Notebook for chapter 1.nb.html

Large diffs are not rendered by default.

45 changes: 45 additions & 0 deletions Module 1/R notebook tutorial-2.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
title: "R Notebook"
output: html_notebook
---

---
title: "Getting used to R notebooks"
output: html_document
---

### Hi all, Welcome to statistics with R
### This file is intended to make you familiar with R notebooks, if you are already an R user - thats good, but still you should have quick view of this tutorial, you may learn something new.

##### This is an R Markdown notebook file, you might have noticed that this file has the format of *.Rmd*
##### R Markdown or .Rmd is a file format for making dynamic documents with R. An R Markdown document is written in markdown (an easy-to-write plain text format) and contains chunks of embedded R code. Hence, this tutorial file can itself has plain text as well as embeded code. Currently, these instructions you are reading are in the markdown format, and if you wish to insert a chunck of code below it, you can do so by clicking the *Insert Chunk* button on the toolbar or by pressing *Ctrl+Alt+I*. So, why to wait, lets write a code chuck for printing "hello".
```{r}
print('Hello')
```

##### Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. There can be several different output formats for this markdown file and you can mention it at the start of this file under output:, for this notebook it is mentioned 'html document' which outputs a .html file with the same name as of the .Rmd file. You might be already reading this in a .html output file in your browser, if not then you can always preview that html file in you browser to have a look.

To know more about R Markdown you can visit this [link](http://rmarkdown.rstudio.com).

[R Markdown interface](https://rmarkdown.rstudio.com/lesson-2.html) notebook.

Try executing this chunk by clicking the *Run* button within the chunk or by placing your cursor inside it and pressing *Ctrl+Shift+Enter*.

### Knitting and converting
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

### Some basic markdown commands to make your text look good

```{r cars}
summary(cars)
```

## Including Plots

You can also embed plots, for example:

```{r pressure, echo=FALSE}
plot(pressure)
```

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
171 changes: 171 additions & 0 deletions Module 1/R notebook tutorial.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
---
title: "R Notebook"
output: html_notebook
---

---
title: "Introduction to R notebooks"
output: html_document
---

### Welcome to statistics with R!


This tutorial notebook is intended to introduce and make you familiar with **R notebooks**. Even if you have used R previously, you can take a quick glance at the tutorial and might learn something new.

This is an R Markdown notebook file, you might have noticed that this file has the format of *.Rmd*.
First things first,

##### What the heck is Markdown?
Markdown is a [markup language](https://en.wikipedia.org/wiki/Markup_language) for creating formatted text using a plain-text editor. The idea and terminology evolved from the "marking up" of paper manuscripts (i.e., the revision instructions by editors), which is traditionally written with a red or blue pen on authors' manuscripts. Markdown using any language including R is just a *digital* version of such blue and red pen annotations.

##### But what is an R Notebook then?
R Notebook is simply an R Markdown document (a document written in the *language* R Markdown) with chunks that can be executed independently and interactively, with output visible immediately beneath the input. It is an implementation of [Literate Programming](https://en.wikipedia.org/wiki/Literate_programming) that allows for direct interaction with R while producing a reproducible document with publication-quality output. A notebook can therefore be thought of as a special execution mode for R Markdown documents.

With the .Rmd file format, you can make such dynamic documents with R. In fact, this tutorial file itself is an R Notebook file with both plain text (that you're currently reading) and embeded code (which you'll insert below).

Before moving to code insertion, so far we've learnt that the R Notebook (R Markdown document) is written in R markdown (an easy-to-write markup language) and contains chunks of embedded R code.

Now if you wish to insert a code chunk, you can do so by clicking the *Insert Chunk* button on the toolbar or you can by press *Ctrl+Alt+I*. (*mac: Cmd + option + I*). Let's write our first code chunk for printing "hello". *Try it yourself:* Insert a new code chunk to print "My First Markdown File".
```{r}
print('Hello')
```

Try executing the inserted chunk(s) by clicking the *Run* button (green arrowhead) within the chunk or by placing your cursor inside it and pressing *Ctrl+Shift+Enter*.

##### Some more information on R Markdown
Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. There can be several different output formats for this markdown file and you can mention it at the start of this file under output:, for R notebooks, the output type is 'html document' which outputs a .html file with the same name as of the .Rmd file. You might be already reading this in a .html output file in your browser, if not then you can always *Preview* that html file in you browser to have a look.

To know more about R Markdown you can visit this [link](http://rmarkdown.rstudio.com).

[R Markdown interface](https://rmarkdown.rstudio.com/lesson-2.html) notebook.

**_Suggested reading:_** Section 3.2 (R Notebook) and Sections 2.5, 2.6 (Markdown syntax) from the book - [R Markdown: The definitive guide](https://bookdown.org/yihui/rmarkdown/)

#### R Markdown syntax
The text in an R Markdown document is written with the Markdown syntax. More precisely, it is [Pandoc’s Markdown](https://pandoc.org/MANUAL.html). The following information has been adapted form the above mentioned book.

_Note_ : It is suggested to view the file as HTML document for this section in order to see the effect of formatting. You can do so by clicking the Preview button in the toolbar.

##### Inline formatting

Inline text will be _italic_ if surrounded by underscores or asterisks, e.g., `_text_` or `*text*`. **Bold** text is produced using a pair of double asterisks (`**text**`). A pair of tildes (~) turn text to a subscript (e.g., `H~3~PO~4~` renders H~3~PO~4). A pair of carets (^) produce a superscript (e.g., `Cu^2+^` renders Cu^2+^).

To mark text as inline code, use a pair of backticks, e.g., `` `code` ``.

Hyperlinks are created using the syntax `[text](link)`, e.g., `[RStudio](https://www.rstudio.com)` will output [RStudio](https://www.rstudio.com). The syntax for images is similar: just add an exclamation mark, e.g., `![alt text or image title](path/to/image)`. Footnotes are put inside the square brackets after a caret `^[]`, e.g., `^[This is a footnote.]`

##### Block level elements
Section headers can be written after a number of hashtags, e.g.,

`# First-level header`

# First-level header

`## Second-level header`

## Second-level header

`### Third-level header`

### Third-level header

If you do not want a certain heading to be numbered, you can add {-} or {.unnumbered} after the heading, e.g.,

`# Preface {-}`

Unordered list items start with *, -, or +, and you can nest one list within another list by indenting the sub-list, e.g.,

```
- one item
- one item
- one item
- one more item
- one more item
- one more item
```

The output is:

- one item

- one item

- one item

- one more item

- one more item

- one more item

Ordered list items start with numbers (you can also nest lists within lists), e.g.,

```
1. the first item
2. the second item
3. the third item
- one unordered item
- one unordered item
```

The output does not look too much different with the Markdown source:

1. the first item

2. the second item

3. the third item

- one unordered item

- one unordered item

Plain code blocks can be written after three or more backticks.
````
```
Just like this
```
````

#### All about Code chunks
You inserted a code chunk in the beginning and therefore you now know that code chunks can be inserted by either using the RStudio toolbar (the `Insert` button) or the keyboard shortcut `Ctrl + Alt + I` (`Cmd + Option + I` on macOS). There are a lot of things you can do in a code chunk: you can produce text output, tables, or graphics. You have fine control over all these output via chunk options, which can be provided inside the curly braces (between ```` ```{r and }````). For example, you can choose hide text output via the chunk option `results = 'hide'`, or set the figure height to 4 inches via `fig.height = 4`. Chunk options are separated by commas, e.g.,

**```{r, chunk-label, results='hide', fig.height=4}**

A few of the options are:

`echo = FALSE` Whether to echo the source code in the output document (someone may not prefer reading your smart source code but only results)

`include = FALSE` prevents code and results from appearing in the finished file. R Markdown still runs the code in the chunk, and the results can be used by other chunks.

`message = FALSE` prevents messages that are generated by code from appearing in the finished file.

`warning = FALSE` prevents warnings that are generated by code from appearing in the finished.

`fig.cap = "..."` adds a caption to graphical results.

##### Plotting figures:
By default, figures produced by R code will be placed immediately after the code chunk they were generated from. For example:

```{r pressure, echo=FALSE}
plot(pressure)
```
Notice the `echo = 'FALSE'` option added in the code in the source file. That is why the code for the above plot is not visible in the HTML output file.

##### Creating tables

```{r tables-mtcars}
knitr::kable(iris[1:5, ], caption = 'A caption')
```

You might have noticed `knitr` in the above code chunk. So let's briefly know about Knitr here.

##### Knitr -
It is a package in the programming language R that enables integration of R code into LaTeX, LyX, HTML, Markdown, AsciiDoc, and reStructuredText documents. _Note_ - Packages will be introduced in a separate tutorial.

In the R Studio toolbar, where you can see the `Preview` button, if you click on the drop down arrow next to it, you will find the options `Knit to HTML`, `Knit to PDF`, `Knit to Word` etc. When you click the **Knit** button the specific output document will be generated that includes both content as well as the result of any embedded R code chunks within the notebook.

Before, we end this introductory tutorial, here's a [cheatsheet](https://rmarkdown.rstudio.com/lesson-15.html) for working with R Markdown and Notebooks for easy and quick reference.

Now that you've learnt about R Notebooks, you are ready to create your own and get started : Go to `File -> New File -> R Notebook`, or if you have opened an `R markdown` file, you can specify the output type as `html_notebook` in the document’s YAML metadata. Have fun working with R Notebooks!
423 changes: 423 additions & 0 deletions Module 1/R notebook tutorial.nb.html

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Module 1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# BSE658_chapter1
10 changes: 10 additions & 0 deletions Module 2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## BSE658: Chapter 2

### This repository covers two important things:

1. Tidyverse
2. ggplot2

`Tidyverse.rmd` file explains a few of the `tidyverse` packages in order to handle data frames. `ggplot.rmd` explains how to use `ggplot2` package to create beautiful plots.

The html files can be downloaded and opened to view in your browser.
Loading