Lab1
Lab1
Learning R
Getting Started……
• 1. What is R? What is R good at?
• 2. How is R better than other packages?
• 3. How to learn R?
• 4. How to obtain R?
1. What is R?
What is R good at?
2. How is R better than other packages?
• R is much more flexible than most software used by econometricians because it
is a modern mathematical programming language, not just a program that does
regression and tests.
• Code written for R can be run on many computational platforms with or without
a graphical user interface, and R comes standard with some of the most flexible
and powerful graphics routines available anywhere.
2. How is R better than other packages?
• R is completely free for any use.
3. How to learn R?
• Homepage http://www.r-project.org
• Books & Manuals
• Websites:https://www.runoob.com/r/r-tutorial.html
• Learn R in R:swirl() https://swirlstats.com/
• Try typing help.start() in R
• We can download a copy of R from the comprehensive R Archive Network (CRAN). There
are binaries available for Linux, Mac and Windows.
• Once R is installed you can choose to either work with the basic R console, or with an
integrated development environment (IDE).
• RStudio is by far the most popular IDE for R and supports debugging, workspace
management, plotting and much more.
RStudio IDE
• Used by millions of people weekly, the RStudio integrated development
environment (IDE) is a set of tools built to help you be more productive
with R and Python.
• Examples include
• R commander,
• Deducer,
• RKWard,
Learning R
• The > sign is the prompt where you can type commands for R to
evaluate.
• Get familiar with the R syntax
• R is used by typing commands.
• The R commands are case sensitive and must be followed exactly.
• A few tricks for working in the Console of Rstudio.
• R script
• To install packages: an example
install.packages("swirl")
library(swirl)
• Objects in R
R functions for important arithmetic calculations
Exercises in Chapter 2
To run a simple linear regression
• Coefficients
• Naming and indexing vectors
• Fitted Values
• Residuals
To confirm the three properties of OLS statistics
using Example 2.7
To measure the goodness-of-fit
Incorporating Nonlinearities
Two special cases:
• 1. Regression through the origin
• 2. Regression on a constant