<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/applied-economic-analysis-with-r-part-1-exercises/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://www.r-exercises.com/2018/04/15/applied-economic-analysis-with-r-part-1/"> R-exercises</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p><a rel="nofollow" href="https://i2.wp.com/www.r-exercises.com/wp-content/uploads/2018/04/econometrics-03-00317-g004.png?ssl=1" target="_blank"><img sizes="(max-width: 150px) 100vw, 150px" src="https://i0.wp.com/www.r-exercises.com/wp-content/uploads/2018/04/econometrics-03-00317-g004-150x150.png?resize=150%2C150&ssl=1" alt="" width="150" class="wp-image-11294" data-recalc-dims="1" height="150"></a>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.</p>
<p>For some of the exercises, we will use the <code>AER</code> package from <code>CRAN</code>, which is a educational package for the book “Applied Econometrics by Christian Kleiber and Achim Zeileis (2008).”</p>
<p><code>install.packages(&quot;AER&quot;)</code><br>
<code>library(AER)</code></p>
<p>For this set of exercises, we will load and use a data-set available in the <code>AER</code> package called <code>CPS1985</code>. 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.</p>
<p><code>data(&quot;CPS1985&quot;)</code><br>
<code>str(CPS1985)</code></p>
<p>Answers to these exercises are available <a rel="nofollow" href="https://www.r-exercises.com/2018/04/15/applied-economic-analysis-with-r-part-1-solutions/" target="_blank">here</a>.</p>
<p>For other parts of this exercise set, follow the tag <a rel="nofollow" href="http://r-exercises.com/tag/econometrics" target="_blank">econometrics</a>.</p>
<p><strong>Exercise 1</strong><br>
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.</p>
<p><strong>Exercise 2</strong><br>
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.</p>
<p><strong>Exercise 3</strong><br>
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.</p>
<p><strong>Exercise 4</strong><br>
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.</p>
<p><strong>Exercise 5</strong><br>
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.</p>
<div>
<h3>Related exercise sets:</h3>
<ol>
<li><a rel="nofollow" href="https://www.r-exercises.com/2017/11/29/spatial-data-analysis-introduction-to-raster-processing-part-1/" title="Spatial Data Analysis: Introduction to Raster Processing (Part 1)" target="_blank">Spatial Data Analysis: Introduction to Raster Processing (Part 1) </a></li>
<li><a rel="nofollow" href="https://www.r-exercises.com/2017/06/10/density-based-clustering-exercises/" title="Density-Based Clustering Exercises" target="_blank">Density-Based Clustering Exercises </a></li>
<li><a rel="nofollow" href="https://www.r-exercises.com/2017/08/03/parallel-computing-exercises-snow-and-rmpi-part-3/" title="Parallel Computing Exercises: Snow and Rmpi (Part-3)" target="_blank">Parallel Computing Exercises: Snow and Rmpi (Part-3) </a></li>
<li><a rel="nofollow" href="http://www.r-exercises.com/start-here-to-learn-r/" target="_blank">Explore all our (>1000) R exercises</a></li>
<li><a rel="nofollow" href="http://www.r-exercises.com/r-courses/" target="_blank">Find an R course using our R Course Finder</a> directory</li>
</ol>
</div>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="https://www.r-exercises.com/2018/04/15/applied-economic-analysis-with-r-part-1/"> R-exercises</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/7ODEuwIMdhU" height="1"></a></div>