Handcoding a Panel Model

The most basic panel estimation is the Pooled OLS model, this model combines all data across indices and performs a regular Ordinary Least Squares Estimation. {% highlight r %} load the PLM library for panel estimation library(plm) load the Crime data set data(Crime) {% endhighlight %} {% highlight r %} define the model m1 <- formula(crmrte ~ prbarr + prbconv + polpc) create a panel data.frame (pdata.frame) object PanelCrime <- pdata.frame(Crime, index=c(“county”, “year”) )

Hand Coding Instumental Variables

In a previous post we discussed the linear model and how to write a function that performs a linear regression. In this post we will use that linear model function to perform a [Two-Stage Least Squares estimation]. This estimation allows us to […] Recall that we built the follow linear model function. {% highlight r %} ols <- function (y, X, intercept=TRUE) { if (intercept) X <- cbind(1, X) solve(t(X)%%X) %% t(X)%*%y # solve for beta } {% endhighlight %}

© Some rights reserved.

Using the Chirpy theme for Hugo.