Search code examples
rlinear-regressionhypothesis-test

R Help: F-Statistic regression test holding one variable constant


I am trying to run a number of F tests on a regression to test whether or not elasticity coefficients are statistically different from 0. The regression I am using is shown below, and I am trying to test dem-elasticity of gdp.

reg7=lm(log(gdp)~log.dem+educ+log.dem_educ+age+popscaled+d1970+d1975+
        d1980+d1985+d1990+d1995+d2000)

Where:

  • log.dem represents a log of a variable "dem"
  • log.dem_educ represents an interaction regressor, a product of log(dem) and a continuous variable "educ"
  • educ represents the average years of education completed by residents

The elasticity of dem is given by the sum of the coefficient of log.dem, and the coefficient log.dem_educ multiplied by educ.

  • Elasticity = coeff(log.dem) + coeff(log.dem_educ)*educ

I want to test the statistical significance of the elasticity of dem for different values of educ (educ=1, educ=2, ..., educ=10), but am unsure how to accomplish this with R. For the case of educ=1, I can just run an F-test using the code shown below since elasticity is just the sum of coeff(log.dem) + coeff(log.dem_educ)*1. However, I am unsure of how to adapt this to test elasticity coefficients for values of educ greater than 1.

linearHypothesis(reg7,c("log.dem + log.dem_educ = 0"),vcov = vcovHC(reg7, "HC1"))

Any suggestions would be greatly appreciated!


Solution

  • I wonder if c("log.dem = 0","log.dem_educ = 0") are really the hypotheses you want to test for the significance of the marginal effect of log.dem when educ is 1. Do you mean instead "log.dem + log.dem_educ = 0"?

    In a similar manner, for different levels of educ you would run

    linearHypothesis(reg7, "log.dem + 2 * log.dem_educ = 0", vcov = vcovHC(reg7, "HC1"))
    linearHypothesis(reg7, "log.dem + 3 * log.dem_educ = 0", vcov = vcovHC(reg7, "HC1"))
    linearHypothesis(reg7, "log.dem + 4 * log.dem_educ = 0", vcov = vcovHC(reg7, "HC1"))
    

    and so on.