Econometric Models
Univariate Characterizations
- In a regression setting, it's important to start with a univariate characterization of the data.
- This involves examining the statistical summaries, features, and distributions of all variables.
- Popular univariate graphical tools include histograms, density plots, QQ plots, and boxplots.
Statistical Summary
Statistical summaries help identify potential issues when building a regression model, such as NAs or values outside the expected range.
The
pastecsandpsychlibraries in R can be used to generate summary statistics.Example using
pastecs:library(pastecs) stat.desc(rnorm(100), norm=TRUE)Example using
psych:library(psych) describe(Prestige)The
normflag includes normal distribution statistics like skewness and kurtosis.
Histograms
Histograms are essential for understanding each variable's properties.
Key aspects to look for:
- Outliers: Can influence the regression fit.
- Shape: Symmetric, skewed, etc.
- Range: Very large ranges (several orders of magnitude).
- Density/Clustering: Clustering in certain regions can lead to unstable fits in less dense ones.
The near-optimal number of bins can be calculated as:
Freedman-Diaconis (FD) formula for bin width:
Example in R:
n = 1000; k = 1 + log2(n) hist(rnorm(n), breaks = k, col="skyblue4", main = "Normal Distr. Using k ") hist(rnorm(n), breaks = "FD", col="skyblue4", main = "Normal Distr. Using FD") hist(rexp(n,0.5), breaks = k, col="skyblue2", main ="Exp Distr. Using k") hist(rexp(n,0.5), breaks = "FD", col="skyblue2", main ="Exp Distr. Using FD")
Density Estimation
Visualizing the density plot along with the histogram and rug plot can be more informative.
A common kernel-density estimate is:
- is the kernel function (e.g., Normal distribution).
- is the bandwidth (smoothness).
- is the number of observations.
Example in R:
n=1000 hist(rexp(n,0.5), breaks ="FD", col="skyblue2", freq = FALSE, ylab = "Density") lines(density(rexp(n,0.5)), lwd = 2, col ="red") lines(density(rexp(n,0.5), adjust =0.5), lwd = 2, col = "blue", type ='l', lty=2) rug(rexp(n,0.5))Density plots can also be created with color using
ggplot2.
Quantile Plots
Quantile plots are useful for comparing the distribution of a variable to a theoretical reference distribution (default: Normal).
Example in R using the
carpackage:library(car) attach(Prestige) qqPlot(~ income, data=Prestige, id=list(n=3)) qqPlot(income ~ type, data=Prestige, layout=c(1, 3)) qqPlot(lm(prestige ~ income + education + type, data=Duncan), envelope=.99)These plots display quantiles of the data against quantiles of the reference distribution.
Boxplots
Boxplots show quantitative aspects of a variable's distribution: min, max, Q1, Q3, IQR, and Median.
They are convenient for comparing many distributions simultaneously or conditioning on other variables.
Example in R:
Boxplot(~income, data=Prestige) Boxplot(Ornsteinnation)Parallel boxplots allow comparison across groups.
Error bar plots can be created using
plotCIfrom theplotrixlibrary.
Bivariate Characterizations
- After univariate descriptions, examine pairwise associations.
Scatterplots
Scatterplots are used to examine the relationship between two variables.
Example using the
carpackage:library(car) attach(Prestige) scatterplot(prestige ~income, lwd=3, id=TRUE) scatterplot(prestige ~income|type, lwd=3,col=c("blue", "green", "red"),id=TRUE)Lowess smoother provides a locally weighted smoother.
Conditioning on other variables allows for examining relationships within subgroups.
Scatterplot matrices are useful for visualizing relationships between multiple variables.
Jittering Scatterplots
Jittering (adding noise) helps separate over-plotted observations.
Example:
plot(Vocabeducation) plot(jitter(Vocabeducation))The
factorargument injitter()controls the amount of noise added.abline()andlowess()can be used to add regression lines.
The Method of Least Squares for the Simple Linear Regression
- Regression models help quantify relationships between economic variables.
- The model is based on assumptions about the conditional PDF of given .
- is a continuous random variable with a probability density function (PDF).
- The PDF is conditional upon a specific value of .
- The conditional mean of is = , and the conditional variance is = .
- Building an econometric model is necessary for quantitative economic analysis.
An Econometric Model
- The econometric model is derived from economic theory (e.g., a supply equation).
- Parameters of the model are known as population parameters.
- For example, a household spends $80 plus 10 cents of each dollar of income on food.
- Algebraically, this is , where is weekly food expenditure and is weekly income.
- The error term $$"e