简体   繁体   中英

How to calculate the t-statistics over many estimated coefficients (for the same variable, but across years) in r?

I am working on a paper replication project and i need some advice on the following issue. The baseline regression is in the form:

model <- feols(y_t2 ~ x1_t1 + x2, data = dat, fsplit = ~year)

This regression is ran across years. Assume there are in total 20 years, there are in total 20 annual cross-sectional regressions with 20 estimated coefficients for the key independent variable x1_t . How could I calculate the t-statistics of the 20 estimated coefficients in R, ie, how do i get the correct estimated standard errors of the 20 coefficients (for each regression there is an estimated coefficient and standard errors computed)?

Any help is highly appreciated!

Using CO2 (which comes with R) and also lmList from nlme (which comes from R so no installation required) we can calculate the t values of conc by Plant like this:

library(nlme)
coef(summary(lmList(uptake ~ conc | Plant, CO2)))[, , "conc"][, "t value"]

giving

      Qn1       Qn2       Qn3       Qc1       Qc3       Qc2       Mn3       Mn2 
2.3727920 3.2797927 2.9829021 2.7215324 3.1578555 3.2725825 1.7544113 1.9517375 
      Mn1       Mc2       Mc3       Mc1 
2.9368841 0.6942998 0.8113596 1.3932651 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM