Skip to main content

Basic Econometrics - Chapter 1


Chapter1

Chapter 1 - Page 27


#### U.S. Egg production

egg_prod <- read.table(file = "https://raw.githubusercontent.com/cablegui/Econometrics/master/OriginalData/Table%201.1.txt", 
    skip = 7, header = TRUE)

colnames(egg_prod)
## [1] "STATE" "Y1"    "Y2"    "X1"    "X2"
head(egg_prod)
##   STATE     Y1     Y2    X1    X2
## 1    AL 2206.0 2186.0  92.7  91.4
## 2    AK    0.7    0.7 151.0 149.0
## 3    AZ   73.0   74.0  61.0  56.0
## 4    AR 3620.0 3737.0  86.3  91.8
## 5    CA 7472.0 7444.0  63.4  58.4
## 6    CO  788.0  873.0  77.8  73.0


Desription of data set

======================

Data set shows U.S. egg production and egg prices for 50 U.S. states for 1990 and 1991. This is an example of cross-sectional data. Cross-sectional data is data collected on one or more variables at the same point in time. This data set has two cross-sectional data, for 1990 and 1991. The variables are the amount of eggs (in millions) and the price per dozen (in cents).

STATE – The short code for the state within the U.S. union
Y1 – Eggs produced in 1990 (millions)
Y2 – Eggs produced in 1991 (millions)
X1 – Price per dozen (cents) in 1990
X2 – Price per dozen (cents) in 1991

library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.2.3
ggplot(egg_prod, aes(x=Y1, y=X1)) + geom_point() + 
  ylab("Price per dozen (cents) in 1990") +
  xlab("Eggs produced in 1990 (millions)")

ggplot(egg_prod, aes(x=Y2, y=X2)) + geom_point() +
ylab("Price per dozen (cents) in 1991") +
  xlab("Eggs produced in 1991 (millions)")
Fig 1. U.S. egg production plotsFig 1. U.S. egg production plots

Fig 1. U.S. egg production plots

Comments

Popular posts from this blog

Installing and using ROracle in R

Hi, Hope this post keeps you in the best of health. I am an oracle user and wanted to know how to fetch database information in R. There is a package out there called ROracle but there are no binaries for it and it thus needs to be built and then installed. Here are the steps to install it on Windows 7 machines. 1. Download the package from http://cran.r-project.org/web/packages/ROracle/index.html. Since I wrote this post the latest that was available was  ROracle_1.1-12.tar.gz . 2. Place the package in the directory where R is installed. I placed mine in E:\R\R-3.0.2\bin folder. 3. Install RTools from http://cran.r-project.org/bin/windows/Rtools/. Since my R version is R-3.0.2 the toolkit I needed was RTools31.exe. 4. Install the Rtools software in the R home directory. I placed mine in E:\R\Rtools. Place all the extras in there too. For example I placed my 32 bit extras in E:\R\RExtras32 and the 64 bit in E:\R\RExtras64 folder. These extras are not necessary for ...

Step by step guide to installing and using miktex with RStudio (Windows)

Using miktex with Rstudio is very easy with the miktex portable app available from http://miktex.org/portable. Steps 1. Follow the instructions from http://miktex.org/portable to download and unzip the miktex portable application in a loccation of your choice. 2. In R write the following code in a script and save it. Note that the E:\\Software-Silo\\Miktex\\miktex\\bin location is the location where I unzipped the miktex portable application. # Install miktex y <- Sys.getenv("PATH") x <- paste0(y,";","E:\\Software-Silo\\Miktex\\miktex\\bin") Sys.setenv(PATH=x) 3. Run Miktex by double clicking the following application "miktex-portable.cmd" in the Miktex main directory. 4. Run step 2 in RStudio to install the path into R environment. 5. Open a new RNW in RStudio to test whether Miktex works . 6. Run Compile PDF in RStudio. It should be just at the top of the RNW file created in step 5. 7. You will now see a PDF file whic...

Using R to publish to google blogger

I got frustrated with trying to get R html to show properly on my Wordpress.com blog as images dont show up at all in the blog. So I checked out Google Blogger and found no hassles there. A step by step guide to create the following webpage http://nevilleandrade.blogspot.de/2014/10/testing-r-using-google-blogger.html The steps I followed were (Windows) 1. Open RStudio and create a new Rmd file. 2. Knit to html using either the button "Knit HTML" or run knit2html("yourRMD.Rmd") on command line. 3. Open the html file created using notepad, copy the contents. 4. Create a new post on Google blogger. 5. Switch to html composition mode. 6. You will find the following content in the beginning <div dir="ltr" style="text-align: left;" trbidi="on"> </div> Do not remove this stuff other wise the link to the blog gets funny rather than the actual name of the blog. 7. Put a title for the blog. 8. Paste the conte...