Wednesday, December 17, 2008

Helpful commands for R


  1. library(foreign) - Allows you to load Stata and Excel files, among others.

  2. foo <- read.dta("location") - Loads a Stata *.dta file.

  3. names(foo) - Lists the names of the variables in dataset foo.

  4. fit <- lm(y~x,data="foo") - Linear regression of Y on X using data in foo.

  5. fit <- glm(y~x,family=binomial(link="probit"),data="foo") - Probit regression of Y on X using data in foo.

  6. summary(fit) - The stuff you want in model fit.

No comments: