*Bounty: 50*

I have estimated some repeated measures Fixed Effects models, with a nested error component, using plm. I am now interested to

- test if the full models are significantly different, i.e. $$H_o: beta_{Female} = beta_{Male}$$ where $beta_{Female}$ is the full model for
`Females`

and $beta_{Male}$ is the full model for `Males`

and
- subsequently test selected regression coefficients between two groups, i.e. $$H_o: beta_{Female == year1.5} = beta_{Male == year1.5}$$ where $beta_{Female == year1.5}$ is the regression coefficient for females at
`year1.5`

, and $beta_{Male == year1.5}$ is the regression coefficient for males at `year1.5`

.

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 %>% mutate(Female = recode(female,.default = 0L,`Female` = 1L))
```

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, cf. point1 above. I looked around SO and the internet and some suggest that I need to use `plm::pFtest()`

, also suggested here, 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]])
# >
# > F test for individual effects
# >
# >data: update(MoSpc, . ~ . - Female)
# >F = -0.30494, df1 = 113, df2 = 2693, p-value = 1
# >alternative hypothesis: significant effects
```

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? Cf. point 2 above.

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

I realize this question is a bit programming like, but I initially posted it in SO. However, DWin was kind enough to point out that the question belonged in CrossValidated and migrated it here.

fixed-effects-model r plm nested-data hypothesis-testing repeated-measures panel-data mixed-model regression

Get this bounty!!!