. Confirm implications from econometric theory through numerical simulations. - Ex. Asymptotic theory considers the case when the sample size is large enough (i.e., \(N \rightarrow \infty\)) - Law of large numbers, central limit theorem - How well is the asymptotic approximation? - So called Monte Carlo simulations
R and R studioR and RStudio.R will summarize many of the concepts in this document..R fileRun command to run your entire code.Run in the source panel, your code is evaluated.To get started, we’ll use R like a simple calculator.
Addition, Subtraction, Multiplication and Division
| Math | R |
Result |
|---|---|---|
| \(3 + 2\) | 3 + 2 |
5 |
| \(3 - 2\) | 3 - 2 |
1 |
| \(3 \cdot2\) | 3 * 2 |
6 |
| \(3 / 2\) | 3 / 2 |
1.5 |
## [1] 4
Exponents
| Math | R |
Result |
|---|---|---|
| \(3^2\) | 3 ^ 2 |
9 |
| \(2^{(-3)}\) | 2 ^ (-3) |
0.125 |
| \(100^{1/2}\) | 100 ^ (1 / 2) |
10 |
| \(\sqrt{100}\) | sqrt(100) |
10 |
Mathematical Constants
| Math | R |
Result |
|---|---|---|
| \(\pi\) | pi |
3.1415927 |
| \(e\) | exp(1) |
2.7182818 |
Logarithms
ln() in R, instead it uses log() to mean the natural logarithm.| Math | R |
Result |
|---|---|---|
| \(\log(e)\) | log(exp(1)) |
1 |
| \(\log_{10}(1000)\) | log10(1000) |
3 |
| \(\log_{2}(8)\) | log2(8) |
3 |
| \(\log_{4}(16)\) | log(16, base = 4) |
2 |
Trigonometry
| Math | R |
Result |
|---|---|---|
| \(\sin(\pi / 2)\) | sin(pi / 2) |
1 |
| \(\cos(0)\) | cos(0) |
1 |
R as a calculator, we have seen a number of functions: sqrt(), exp(), log() and sin().R, simply put a question mark in front of the function name and RStudio will display the documentation, for example:One of the main strengths of R as an open-source project is its package system.
To install a package, use the install.packages() function.
R session before being used.
R, all the packages are closed and put back on the imaginary shelf.R, you do not have to install the package again, but you do have to load any packages you intend to use by invoking library().