Difference between revisions of "Regression Inference in R"

From ECLR
Jump to: navigation, search
(Created page with "here we will discuss how to perform standard inference in regression models. = Setup = We continue the example we started in R_Regression#A first example and which is rep...")
 
(Setup)
Line 2: Line 2:
  
 
= Setup =
 
= Setup =
We continue the example we started in [[R_Regression#A first example]] and which is replicated here, but note the first line which we include to gain access to the procedures in the AER toolbox:
+
We continue the example we started in [[R_Regression#A first example]] and which is replicated here:
 
      
 
      
    <span style="color:#0000ff">library(AER)</span>  # allow access to AER package
 
 
     # This is my first R regression!
 
     # This is my first R regression!
 
     setwd("T:/ECLR/R/FirstSteps")              # This sets the working directory
 
     setwd("T:/ECLR/R/FirstSteps")              # This sets the working directory
Line 23: Line 22:
 
     reg_ex1_sm <- summary(reg_ex1)
 
     reg_ex1_sm <- summary(reg_ex1)
  
 +
We will introduce inference in this model.
  
 
= t-tests =
 
= t-tests =

Revision as of 10:16, 14 April 2015

here we will discuss how to perform standard inference in regression models.

Setup

We continue the example we started in R_Regression#A first example and which is replicated here:

    # This is my first R regression!
    setwd("T:/ECLR/R/FirstSteps")              # This sets the working directory
    mydata <- read.csv("mroz.csv")  # Opens mroz.csv from working directory
     
    # Now convert variables with "." to num with NA
    mydata$wage <- as.numeric(as.character(mydata$wage))
    mydata$lwage <- as.numeric(as.character(mydata$lwage))

Before we run our initial regression model we shall restrict the dataframe mydata to those data that do not have missing wage information, using the following subset command:

   mydata <- subset(mydata, wage!="NA")  # select non NA data

Now we can run our initial regression:

    # Run a regression
    reg_ex1 <- lm(lwage~exper+log(huswage),data=mydata)
    reg_ex1_sm <- summary(reg_ex1)

We will introduce inference in this model.

t-tests

We use t-tests to test simple coefficient restrictions on regression coefficients.


F-tests

F-tests are used to test multiple coefficient restrictions on regression coefficients.