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
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Regression Initial Commit
juneeybug committed Nov 7, 2022
commit 11b71ab321a4509aa9a48016818227e266ac1232
171 changes: 171 additions & 0 deletions Module 6/Regression.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
---
title: "Regression"
output: html_document
date: "2022-11-06"
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
setwd(dirname(rstudioapi::getActiveDocumentContext()$path)) # set curretn path as workpath
```



```{r}
load( file.path("parenthood.Rdata" ))
colnames(parenthood) <- c('dan.sleep','baby.sleep','dan.grump','day')
```

linear regression:
dan.grump ~ dan.sleep
```{r}
regression.1 <- lm( formula = dan.grump ~ dan.sleep,
data = parenthood )
print( regression.1 )
```
##Multiple linear regression
dan.grump ~ dan.sleep + baby.sleep

```{r}
regression.2 <- lm( formula = dan.grump ~ dan.sleep + baby.sleep,
data = parenthood )
print( regression.2 )
```


The R-squared value Calculation


#Calculating y-predicted
```{r}
X <- parenthood$dan.sleep # the predictor
Y <- parenthood$dan.grump # the outcome
Y.pred <- -8.95025 * X + 125.96557

```

#calculating residue
```{r}
SS.resid <- sum( (Y - Y.pred)^2 )
print( SS.resid )
```


```{r}
SS.tot <- sum( (Y - mean(Y))^2 )
print( SS.tot )
```


```{r}
R.squared <- 1 - (SS.resid / SS.tot)
print( R.squared )
```

```{r}
r <- cor(X, Y) # calculate the correlation
print( r^2 )
```

```{r}
print( regression.2 )
```

```{r}
summary( regression.2 )
```
```{r}
summary( regression.1 )
```

```{r}
cor.test( x = parenthood$dan.sleep, y = parenthood$dan.grump )
```

```{r}
library(lsr)
correlate(parenthood, test=TRUE)
```

```{r}
confint( object = regression.2,
level = .99)
```

```{r}
standardCoefs( regression.2 )

```

```{r}
residuals( object = regression.2 )
```

```{r}
rstandard( model = regression.2 )
```

```{r}
rstudent( model = regression.2 )
```

```{r}
hatvalues( model = regression.2 )
```

```{r}
ckd <- cooks.distance( model = regression.2 )
plot(regression.2,which=4)
```
```{r}
lm( formula = dan.grump ~ dan.sleep + baby.sleep, # same formula
data = parenthood, # same data frame...
subset = -64 # ...but observation 64 is deleted
)
```
```{r}
hist( x = residuals( regression.2 ), # data are the residuals
xlab = "Value of residual", # x-axis label
main = "", # no title
breaks = 20 # lots of breaks
)
```
```{r}
plot( x = regression.2, which = 2 )
```

Backward elimination

```{r}
full.model <- lm( formula = dan.grump ~ dan.sleep + baby.sleep + day,
data = parenthood
)
```

```{r}
step( object = full.model, # start at the full model
direction = "backward" # allow it remove predictors but not add them
)
```
Forward selection
```{r}
null.model <- lm( dan.grump ~ 1, parenthood ) # intercept only.
step( object = null.model, # start with null.model
direction = "forward", # only consider "addition" moves
scope = dan.grump ~ dan.sleep + baby.sleep + day # largest model allowed
)
```
Comparing two regression models
```{r}
M0 <- lm( dan.grump ~ dan.sleep + day, parenthood )
M1 <- lm( dan.grump ~ dan.sleep + day + baby.sleep, parenthood )
```

```{r}
AIC( M0, M1 )
```

```{r}
anova( M0, M1 )
```

Binary file added Module 6/parenthood.Rdata
Binary file not shown.