0% found this document useful (0 votes)
6 views

Lab1

The document provides an introduction to R, highlighting its flexibility, extensive libraries, and powerful graphics capabilities compared to other software. It outlines resources for learning R, including the official homepage and various tutorials, and explains how to obtain R and use the RStudio IDE. Additionally, it covers basic R commands, functions for arithmetic calculations, and exercises related to linear regression and OLS statistics.

Uploaded by

percywangwghz
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Lab1

The document provides an introduction to R, highlighting its flexibility, extensive libraries, and powerful graphics capabilities compared to other software. It outlines resources for learning R, including the official homepage and various tutorials, and explains how to obtain R and use the RStudio IDE. Additionally, it covers basic R commands, functions for arithmetic calculations, and exercises related to linear regression and OLS statistics.

Uploaded by

percywangwghz
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

Lab 1

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.

• There is an extensive and constantly expanding collection of libraries online for


use in many disciplines. So, R is always at the forefront of statistical knowledge.

• 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

The best way to learn R


is
by doing.
4. How to obtain R?
• Homepage http://www.r-project.org

• A wealth of information is available as well as the software itself.

• 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.

• It includes a console, syntax-highlighting editor that supports direct code


execution. It also features tools for plotting, viewing history, debugging and
managing your workspace.

• To download Rstudio, go to http://www.rstudio.com/


• There are some other user interfaces added on top of plain R.

• 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

• Using the example of CEO salary and ROE


Expected Values, Variances and Standard Errors

You might also like