Presentation is loading. Please wait.

Presentation is loading. Please wait.

How to Use R and Its Packages. About R Free software For statistical computing and graphics R homepage: www.r-project.orgwww.r-project.org We use R 2.15.3.

Similar presentations


Presentation on theme: "How to Use R and Its Packages. About R Free software For statistical computing and graphics R homepage: www.r-project.orgwww.r-project.org We use R 2.15.3."— Presentation transcript:

1 How to Use R and Its Packages

2 About R Free software For statistical computing and graphics R homepage: www.r-project.orgwww.r-project.org We use R 2.15.3 for windows – Current version: R 3.0.1 for windows

3 First Things to Know R regards things as objects – Datasets and the results of a regression are objects All commands are functions Text command and case sensitivity Interactive mode and batch mode

4 Reading Data mydata=read.table(“filename.txt”, header=T) – Text file with a header above each column mydata=read.csv(“filename.txt”, header=T) – Excel csv file with a header above each column attach(mydata)

5 Packages We Need AER quantreg plm rqpd

6 Installation install.packages("fBasics",repo="http://cran.cs.pu.edu.tw",dep=T) Or from the menu bar

7 Installation of rqpd First, install “quantreg”, “Formula” and “SparseM” install.packages(“rqpd",repos="http://R-forge.R-project.org”)

8 Descriptive Statistics Package: fBasics Function: basicStats(mydata)

9 Linear Model: OLS Output=lm(y~x1+x2+x3) summary(Output)

10 Testing a Linear Hypothesis Package: car (in AER) H0:Rβ=r Function: linearHypothesis(Output, hypothesis.matrix= R, rhs=r) Example: H0: β1=0 and β2=0 – R=rbind(c(0,1,0,0),c(0,0,1,0)) – r=c(0,0)

11 Testing a Restricted Model Function: anova(output of restricted, output of unrestricted)

12 Testing under Heteroskedasicity

13 Robust Standard Errors and Tests Packages: sandwich, lmtest (both in AER) Functions: – coeftest(output, vcov=vcovHC) – waldtest(outputr, outputur, vcov=vcovHC(outputur))


Download ppt "How to Use R and Its Packages. About R Free software For statistical computing and graphics R homepage: www.r-project.orgwww.r-project.org We use R 2.15.3."

Similar presentations


Ads by Google