Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added Practicals/JudithNeve/BeamerExample.zip
Binary file not shown.
97 changes: 97 additions & 0 deletions Practicals/JudithNeve/BeamerExample/main.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
%\documentclass{beamer}
\documentclass[aspectratio=169]{beamer} % took this from the solution
\usetheme{default}
\usecolortheme{beaver}


\title{Example document to recreate with \texttt{beamer} in \LaTeX}
\author{Judith Neve}
%\institute{
% Markup Languages and Reproducible Programming in Statistics
%}
\date{\vspace{.5 in}\\ November 2022 \\ Markup Languages and Reproducible Programming in Statistics \vskip6mm} % this was taken from the solution

\beamertemplatenavigationsymbolsempty %suppress navigation bar
% this was taken from the solution

\begin{document}

%\begin{frame}[plain]
\titlepage
%\end{frame}
% commenting these out made it start lower on the slide

\begin{frame}{Outline}
%\tableofcontents
Working with equations\\
\hspace*{20pt} Aligning the same equation\\
\hspace*{20pt} Omit equation numbering\\
\hspace*{20pt} Ugly alignment\\
\vspace*{20pt}
Discussion

\end{frame}
% could have made subsections and not given names to the frames
\begin{frame}{Working with equations}

We define a set of equations as

\begin{equation}
a = b + c^2
\end{equation}
\begin{equation}
a - c^2 = b
\end{equation}
\begin{equation}
\text{left side} = \text{right side}
\end{equation}
\begin{equation}
\text{left side} + \text{something} \geq \text{right side}
\end{equation}
for all something $>$ 0.

\end{frame}

\begin{frame}{Aligning the same equations}

Aligning the equations by the equal sign gives a much better view into the placement of the separate equation components.

\begin{align}
a & = b + c^2\\
a - c^2 & = b\\
\text{left side} & = \text{right side}\\
\text{left side} + \text{something} & \geq \text{right side}
\end{align}

\end{frame}

\begin{frame}{Omit equation numbering}
Alternatively, the equation numbering can be omitted.
\begin{align*}
a & = b + c^2\\
a - c^2 & = b\\
\text{left side} & = \text{right side}\\
\text{left side} + \text{something} & \geq \text{right side}
\end{align*}
\end{frame}

\begin{frame}{Ugly alignment}
Some components do not look well, when aligned. Especially equations with different heights and spacing. For example,
\begin{align}
E = mc^2\\
m = \frac{E}{c^2}\\
c = \sqrt{\frac{E}{M}}
\end{align}
Take that into account.
\end{frame}

\begin{frame}{Discussion}
This is where you'd normally give your audience a recap of your talk, where you could discuss e.g. the following\begin{itemize}
\item Your main findings
\item The consequences of your main findings
\item Things to do
\item Any other business not currently investigated, but related to your talk
\end{itemize}
\end{frame}

\end{document}
13 changes: 13 additions & 0 deletions Practicals/JudithNeve/JudithNeve.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: ISO8859-1

RnwWeave: Sweave
LaTeX: pdfLaTeX
54 changes: 54 additions & 0 deletions Practicals/JudithNeve/Markup_A1.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
title: "Markup Assignment 1"
author: "Judith Neve"
date: '2022-09-19'
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

```{r}
# sample 100 samples from a normal distribution
set.seed(0070661)
n <- 5000
sim_dat <- matrix(NA, n, 100)
for (i in 1:100) {
sim_dat[,i] <- rnorm(n)
}
```

```{r}
sim_stats <- matrix(NA, 100, 4)
colnames(sim_stats) <- c("AbsoluteBias", "StandardError", "LowerBound", "UpperBound")

# for each sample, calculate:
for (i in 1:100) {
sim_stats[i,1:2] <- c(mean(sim_dat[,i]), # absolute bias (the mean was 0 so the mean of the sample works)
1/sqrt(n)) # standard error
sim_stats[i,3:4] <- c(sim_stats[i,1] - qt(.975, n-1)*sim_stats[i,2], # lower bound of the CI
sim_stats[i,1] + qt(.975, n-1)*sim_stats[i,2]) # upper bound of the CI
}
```

```{r}
# create a plot that demonstrates the following:
## “A replication of the procedure that generates a 95% confidence interval that is centered around the sample mean would cover the population value at least 95 out of 100 times” (Neyman, 1934)

library(tidyverse)

sim_stats <- sim_stats %>%
as.data.frame() %>%
mutate(MeanInInt = ifelse(0 > LowerBound & 0 < UpperBound, TRUE, FALSE))

sim_stats %>%
ggplot(aes(x = 1:100, y = AbsoluteBias)) +
geom_pointrange(aes(ymin = LowerBound, ymax = UpperBound, col = MeanInInt))
```

```{r}
# Present a table containing all simulated samples for which the resulting confidence interval does not contain the population value
othersamples <- sim_dat[,sim_stats$MeanInInt == FALSE]
```

91 changes: 91 additions & 0 deletions Practicals/JudithNeve/Markup_A2.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
title: "Practical 2"
author: "Judith Neve"
date: '2022-10-06'
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

# Introduction

## Aim

In this study, I aim to empirically show the proportion of observations within 1, 2, and 3 standard deviations of the mean in a normal distribution. These proportions are expected to be approximately 68, 95, and 99, respectively.

# Methods

## Data-generating mechanism

The `rnorm()` function is used to generate observations from a normal distribution. We generate three vectors with 1000 observations, each following a different distribution:
* A standard normal distribution,
* A normal distribution with mean 100 and standard deviation 50,
* A normal distribution with mean 10 and standard deviation 1.

```{r}
set.seed(9) # the number of books on my bedside table

StandardNormal <- rnorm(1000)
Mean100SD50 <- rnorm(1000, 100, 50)
Mean10SD1 <- rnorm(1000, 10, 1)
```

## Estimand

The estimator is the proportion of observations within 1, 2, or 3 standard deviations of the mean for each vector. We will have 9 estimates. The function in the chunk below will be used.

```{r}
propwithinSD <- function(vector, mean = 0, SD = 1, within = 1) {
vector <- abs(vector - mean) # we calculate the absolute difference between each observation and the mean
SD <- SD*within # we set how far we can stray from the mean
in_vector <- ifelse(vector > SD, 0, 1) # this will give a vector where 1 is an observation within the desired number of SDs
prop <- sum(in_vector) / length(in_vector)
return(prop)
}
```

## Method

I am trying to follow an ADEMP approach but I'm unsure this part is applicable to this study. Maybe if this was comparing different generator functions?

## Performance measures

I am trying to follow an ADEMP approach but I'm unsure this part is applicable to this study. Maybe if this was comparing different generator functions and trying to assess the one closest to the normal distribution?

# Results

We first look at the proportion of observations within 1 SD for each vector. This should be around 68.

```{r}
propwithinSD(StandardNormal, 0, 1, 1)
propwithinSD(Mean100SD50, 100, 50, 1)
propwithinSD(Mean10SD1, 10, 1, 1)
```

We are indeed around 68%.

Looking now at the proportion of observations within 2SD for each vector,

```{r}
propwithinSD(StandardNormal, 0, 1, 2)
propwithinSD(Mean100SD50, 100, 50, 2)
propwithinSD(Mean10SD1, 10, 1, 2)
```
we find they are all close to 95%, as expected.

Finally, looking at the proportion of observations within 3SD for each vector,

```{r}
propwithinSD(StandardNormal, 0, 1, 3)
propwithinSD(Mean100SD50, 100, 50, 3)
propwithinSD(Mean10SD1, 10, 1, 3)
```

we observe they are around 99%, as expected.

```{r}
sessionInfo()
```

521 changes: 521 additions & 0 deletions Practicals/JudithNeve/Markup_A2.html

Large diffs are not rendered by default.

Empty file.
13 changes: 13 additions & 0 deletions Practicals/JudithNeve/Practical 8/Practical 8.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: ISO8859-1

RnwWeave: Sweave
LaTeX: pdfLaTeX
Loading