R Under development (unstable) (2024-02-25 r85988 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(lfe) Loading required package: Matrix > options(lfe.threads=2,digits=5,warn=1) > set.seed(6320) > x <- rnorm(1000,mean=200) > x2 <- rnorm(length(x)) > x3 <- rexp(length(x)) > ## create individual and firm > id <- factor(sample(200,length(x),replace=TRUE)) > firm <- factor(sample(200,length(x),replace=TRUE)) > shoe <- factor(sample(200,length(x),replace=TRUE)) > shirt <- factor(sample(200,length(x),replace=TRUE)) > ## effects > id.eff <- rnorm(nlevels(id)) > firm.eff <- rnorm(nlevels(firm)) > shoe.eff <- rnorm(nlevels(shoe)) > shirt.eff <- rnorm(nlevels(shirt)) > ## left hand side > y <- x + 0.25*x2 + 0.5*x3 + id.eff[id] + firm.eff[firm] + shoe.eff[shoe] + shirt.eff[shirt] + rnorm(length(x)) > > ## estimate > est <- felm(y ~ x+x2 + x3 | id + firm + shoe + shirt) > cat('Components:',nlevels(est$cfactor),'largest:',sum(est$cfactor == '1'),'\n') Components: 1 largest: 1000 > ## extract the group fixed effects > ## verify that id and firm coefficients are 1 > opt <- options(scipen=8,warn=1) > > for(ef in c('ln','ref','zm','zm2')) { + fe <- getfe(est,ef=ef) + ## merge back + + ideff <- fe[paste('id',id,sep='.'),'effect'] + firmeff <- fe[paste('firm',firm,sep='.'),'effect'] + shoeeff <- fe[paste('shoe',shoe,sep='.'),'effect'] + shirteff <- fe[paste('shirt',shirt,sep='.'),'effect'] + if(ef %in% c('zm','zm2')) { + icpt <- fe[paste('icpt',1:nlevels(est$cfactor),sep='.'),'effect'][est$cfactor] + print(summary(lm(y ~ x + x2 + x3 + ideff + firmeff + shoeeff +shirteff + icpt-1),digits=8)) + } else { + print(summary(lm(y ~ x + x2 + x3 + ideff + firmeff + shoeeff +shirteff-1),digits=8)) + } + } Warning in is.estimable(ef, obj$fe) : non-estimable function, largest error 0.02 in coordinate 35 ("id.35") Warning in getfe.kaczmarz(obj, se, ef = ef, bN = bN, robust = robust, cluster = cluster, : Supplied function seems non-estimable Call: lm(formula = y ~ x + x2 + x3 + ideff + firmeff + shoeeff + shirteff - 1) Residuals: Min 1Q Median 3Q Max -1.581 -0.270 0.000 0.278 1.752 Coefficients: Estimate Std. Error t value Pr(>|t|) x 1.036709 0.000257 4036.0 <2e-16 *** x2 0.244033 0.014252 17.1 <2e-16 *** x3 0.530698 0.014396 36.9 <2e-16 *** ideff 1.000000 0.010495 95.3 <2e-16 *** firmeff 1.000000 0.010924 91.5 <2e-16 *** shoeeff 1.000000 0.010992 91.0 <2e-16 *** shirteff 1.000000 0.011527 86.8 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.441 on 993 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 2.96e+07 on 7 and 993 DF, p-value: <2e-16 Call: lm(formula = y ~ x + x2 + x3 + ideff + firmeff + shoeeff + shirteff - 1) Residuals: Min 1Q Median 3Q Max -1.581 -0.270 0.000 0.278 1.752 Coefficients: Estimate Std. Error t value Pr(>|t|) x 1.036709 0.000381 2718.6 <2e-16 *** x2 0.244033 0.014252 17.1 <2e-16 *** x3 0.530698 0.014396 36.9 <2e-16 *** ideff 1.000000 0.010489 95.3 <2e-16 *** firmeff 1.000000 0.010925 91.5 <2e-16 *** shoeeff 1.000000 0.010992 91.0 <2e-16 *** shirteff 1.000000 0.011527 86.8 <2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.441 on 993 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 2.96e+07 on 7 and 993 DF, p-value: <2e-16 Call: lm(formula = y ~ x + x2 + x3 + ideff + firmeff + shoeeff + shirteff + icpt - 1) Residuals: Min 1Q Median 3Q Max -1.581 -0.270 0.000 0.278 1.752 Coefficients: Estimate Std. Error t value Pr(>|t|) x 1.0367 0.0145 71.58 <2e-16 *** x2 0.2440 0.0143 17.11 <2e-16 *** x3 0.5307 0.0144 36.85 <2e-16 *** ideff 1.0000 0.0105 95.21 <2e-16 *** firmeff 1.0000 0.0109 91.49 <2e-16 *** shoeeff 1.0000 0.0110 90.92 <2e-16 *** shirteff 1.0000 0.0115 86.71 <2e-16 *** icpt 1.0000 0.4240 2.36 0.019 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.441 on 992 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 2.59e+07 on 8 and 992 DF, p-value: <2e-16 Call: lm(formula = y ~ x + x2 + x3 + ideff + firmeff + shoeeff + shirteff + icpt - 1) Residuals: Min 1Q Median 3Q Max -1.581 -0.270 0.000 0.278 1.752 Coefficients: Estimate Std. Error t value Pr(>|t|) x 1.0367 0.0145 71.58 <2e-16 *** x2 0.2440 0.0143 17.11 <2e-16 *** x3 0.5307 0.0144 36.85 <2e-16 *** ideff 1.0000 0.0105 95.21 <2e-16 *** firmeff 1.0000 0.0109 91.49 <2e-16 *** shoeeff 1.0000 0.0110 90.92 <2e-16 *** shirteff 1.0000 0.0115 86.71 <2e-16 *** icpt 1.0000 0.4569 2.19 0.029 * --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.441 on 992 degrees of freedom Multiple R-squared: 1, Adjusted R-squared: 1 F-statistic: 2.59e+07 on 8 and 992 DF, p-value: <2e-16 > options(opt) > > proc.time() user system elapsed 1.43 0.21 1.64