samedi 16 juin 2018

compare two groups in models estimated using plm

I have estimated some repeated measures Fixed Effects models, with a nested error component, using . I am now interested to 1) test if the full models are significant different and 2) subsequently test selected regression coefficients between two groups.

I will illustrate the situation using the below working example,

First, some packages needed,

# install.packages(c("plm", "texreg", "tidyverse", "lmtest"), dependencies = TRUE)
library(plm); library(lmtest); require(tidyverse)

Second, some data preparation,

data(egsingle, package = "mlmRev")
dta <- egsingle
dta$Female <- with(dta, ifelse(female == 'Female', 1, 0))

Third, I estimate a set of models for each gender in data

MoSpc <- as.formula(math ~ Female + size + year)
dfMo = dta %>% group_by(female) %>%
    do(fitMo = plm(update(MoSpc, . ~ . -Female), 
       data = ., index = c("childid", "year", "schoolid"), model="within") )

Forth, lets look at the two estimated models,

texreg::screenreg(dfMo[[2]], custom.model.names = paste0('FE: ', dfMo[[1]]))
#> ===================================
#>            FE: Female   FE: Male   
#> -----------------------------------
#> year-1.5      0.79 ***     0.88 ***
#>              (0.07)       (0.10)   
#> year-0.5      1.80 ***     1.88 ***
#>              (0.07)       (0.10)   
#> year0.5       2.51 ***     2.56 ***
#>              (0.08)       (0.10)   
#> year1.5       3.04 ***     3.17 ***
#>              (0.08)       (0.10)   
#> year2.5       3.84 ***     3.98 ***
#>              (0.08)       (0.10)   
#> -----------------------------------
#> R^2           0.77         0.79    
#> Adj. R^2      0.70         0.72    
#> Num. obs.  3545         3685       
#> ===================================
#> *** p < 0.001, ** p < 0.01, * p < 0.05    #> 

Now, I want to test if these two (linear OLS) models are significantly different. I looked around SO and the internet and some suggest that I need to use plm::pFtest(), which I have tried, but I'm not convinced and wonder if someone here has experience and could possibly help me.

I tried,

plm::pFtest(dfMo[[1,2]], dfMo[[2,2]])
# [output omitted]

Second, I am interested to compare regression coefficients between two groups. Say, is the estimate for year1.5 of 3.04 significantly different from 3.17?

Please ask if any of the above is not clear and I will be happy to elaborate. Any help will be greatly appreciated!

Aucun commentaire:

Enregistrer un commentaire