1 / 13

How to Use R and Its Packages

How to Use R and Its Packages. About R. Free software For statistical computing and graphics R homepage: www.r-project.org We use R 2.15.3 for windows Current version: R 3.0.1 for windows. First Things to Know. R regards things as objects

kellan
Download Presentation

How to Use R and Its Packages

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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

More Related