Last updated: 2019-10-09

Checks: 6 1

Knit directory: myproject/

This reproducible R Markdown analysis was created with workflowr (version 1.4.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


The R Markdown file has unstaged changes. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20191009) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility. The version displayed above was the version of the Git repository at the time these results were generated.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Untracked files:
    Untracked:  analysis/Class-1.Rmd
    Untracked:  docs/Class-1.pdf

Unstaged changes:
    Modified:   analysis/Class 1.Rmd

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the R Markdown and HTML files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view them.

File Version Author Date Message
Rmd f7e5e11 Jorge Soler Lopez 2019-10-09 Start my new project

Frequentist Statistical Inference

We want to learn about a population. A population could be the inhabitants of a country, bacteria in an environment or a keyboard produced by a company. We want to know a specific characteristic of that population; for example, the average height in a country, the median size of the bacteria, or, average the number of key presses it takes for the keyboard to fail.

It would be unfeasible to calculate this measure directly from the population. For example, to pinpoit the exact average time for a product to fail, we would have repeatidly press every keyboard in production to find the number. This is why we want to take a sample from the population and use the data in the best way so we can learn about the specific characteristic.

For example, we want to know the average height of the population(\(\mu\)). We will use a sample to guess the value of \(\mu\) (i.e. the parameter of interest).

Caveat: We can never know if the guess we get from our sample is close to our true parameter. All we can do is to hope that our guess gives us a fair estimate.

But that hope is backed by a whole theory behind it. That’s why we use inference everyday. We can be wrong but we had made the best guess we could.

Population and Sampling Distributions

Our population has some distribution. This distribution tells us what can happen when I extract one subject from the population. For example, suppose that our population height (in dm = 10cm) is distributed \[ X \sim \mathcal{N} (17, \sigma ^ 2 = 9) \].

Then suppose that I want to know what is the probaility that one individual will be between 15dm and 19 dm $ P(15= lb & x <= ub lines(x, hx) polygon(c(lb,x[i],ub), c(0,hx[i],0), col=“red”)

area <- pnorm(ub, mean, sd) - pnorm(lb, mean, sd) result <- paste(“P(”,lb,“< X <”,ub,“) =”, signif(area, digits=3)) mtext(result,3) axis(1, at=seq(40, 160, 20), pos=0) ```

Warning! The custom fig.path you set was ignored by workflowr.

Statistics and their properties

Consider that we take a sample \((x_1,x_2,...,x_n)\) from the population \(X\).

Definition: A statistic \(T=T(x_1,x_2,...,x_n)\) is a function of the random sample \((x_1,x_2,...,x_n)\). As such, it is itself a random variable with a distribution PDF \(f_T(t)\) or CDF \(F_T(t)\).

This statistic will give be helpful to unconver an estimation of the parameter (\(\theta\), or in the case of the sample mean \(\mu\)) of the population that we are interested in.

We expect that the statistic has several properties:

1. Unbiasedness: Expected value of the statistic should be the parameter in question.

\[\mathbb{E}(T) = \theta\]

For example, in the case of \(T(\bar{x})=\sum_{i\in(1,..n)}x_i\), we get that \(E(T)=\mu\).

2, Consistency: As \(n\) becomes larger (we sample more subjects), the statistic will converge in probability to \(\theta\), i.e. If we consider a series of estimators indexed by n, we get \[\{T_n\}\overset{p}{\rightarrow}\theta\]

What is convergence in probability? Definition: \[\{T_n\}\overset{p}{\rightarrow}\theta\]

For example, if we go back to the avearage case, we can index the statistic by \(n\) and get:

\[T_j(\bar{x})=\sum_{i\in(1,..n_j)}x_i\] Definition: 3. Variance get smaller

\[\forall\epsilon>0,\forall\theta\in\Theta,lim_{n\rightarrow\infty}P(|T_{n}-\theta|\geq\epsilon)=0\iff lim_{n\rightarrow\infty}P(|T_{n}-\theta|\leq\epsilon)=1\]


sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS  10.15

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.4/Resources/lib/libRlapack.dylib

locale:
[1] C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] workflowr_1.4.0 Rcpp_0.12.16    digest_0.6.15   rprojroot_1.3-2
 [5] backports_1.1.4 git2r_0.21.0    magrittr_1.5    evaluate_0.14  
 [9] stringi_1.1.7   fs_1.3.1        whisker_0.3-2   rmarkdown_1.15 
[13] tools_3.4.4     stringr_1.3.0   glue_1.2.0      xfun_0.9       
[17] yaml_2.2.0      compiler_3.4.4  htmltools_0.3.6 knitr_1.25