**R-exercises**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

R has great potential in Economic data analysis, as well as econometrics. In this set of exercises, we will go through a wide variety of topics in econometrics, including wage equations, growth regressions, dynamic regressions and time series models, hedonic regressions, the demand for health care, and labor force participation. In the first set of exercises, we will start with using basic functions to calculate statistical measures and visualizations.

For some of the exercises, we will use the `AER`

package from `CRAN`

, which is a educational package for the book “Applied Econometrics by Christian Kleiber and Achim Zeileis (2008).”

`install.packages("AER")`

`library(AER)`

For this set of exercises, we will load and use a data-set available in the `AER`

package called `CPS1985`

. CPS1985’s data-frame has 534 observations and 11 variables, including wage, education, experience, age, ethnicity, region, gender, occupation, sector, union, and marriage. The first variables are numerical and others are factors.

`data("CPS1985")`

`str(CPS1985)`

Answers to these exercises are available here.

For other parts of this exercise set, follow the tag econometrics.

**Exercise 1**

In the first exercise, we will calculate simple statistics of wage in the CPS1985 data-frame. First, use the summary function to see the summary statistics of wage; then, calculate mean, median, variance, and standard deviation of the wage.

**Exercise 2**

Graphical illustration of statistics would be also helpful. Since wage is numerical, histograms (density plot) and box-plots would be helpful. In this exercise, create a histogram for a wage parameter in the CPS1985 data-frame.

**Exercise 3**

As for categorical variables, it is not possible to calculate mean and variance. Instead, we can produce frequency tables, bar-plots, and pie charts. In this exercise, use a table function to produce a frequency table for sector and occupation variables. Along with these, produce bar-plots and pie charts for these variables.

**Exercise 4**

It would also be useful to see the relationship between two categorical variables. In this exercise, consider the gender and occupation variables. Use the xtabs function to show the contingency table, then use the plot function to plot a bar-plot showing gender proportion for each occupation type.

**Exercise 5**

In this exercise, first calculate the correlation between wage and education to investigate how wage changes by education, then calculate the mean wage for each gender. Finally, compare the wage between males and females using box-plots and qq plots.

**leave a comment**for the author, please follow the link and comment on their blog:

**R-exercises**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.