R Under development (unstable) (2024-01-12 r85803 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(digits=3,warn=1,lfe.threads=2) > set.seed(42) > x <- rnorm(100) > x2 <- rnorm(length(x)) > x3 <- rnorm(length(x)) > id <- factor(sample(10, length(x), replace=TRUE)) > id.eff <- rnorm(nlevels(id)) > firm <- factor(sample(10,length(x),replace=TRUE)) > > y <- x + x2 + x3 + id.eff[id] + rnorm(length(x)) > z <- x/2 + x2/2 + x3/2 + id.eff[id]/2 + rnorm(length(x)) > v <- x/3 + x2/2 + x3/2 + id.eff[id]/2 + rnorm(length(x)) > w <- x/2 + x2/3 + x3/2 + id.eff[id]/3 + rnorm(length(x)) > > est <- felm(v|w|y|z ~ x+x2+x3|id,keepX=TRUE) > for(lh in est$lhs) { + print(summary(est, lhs=lh, robust=TRUE)) + } Summary for outcome v Call: felm(formula = v | w | y | z ~ x + x2 + x3 | id, keepX = TRUE) Residuals: Min 1Q Median 3Q Max -2.4995 -0.4254 -0.0321 0.4885 1.7591 Coefficients: Estimate Robust s.e t value Pr(>|t|) x 0.5637 0.0739 7.63 2.8e-11 *** x2 0.4178 0.0858 4.87 4.9e-06 *** x3 0.5643 0.0846 6.67 2.3e-09 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.843 on 87 degrees of freedom Multiple R-squared(full model): 0.638 Adjusted R-squared: 0.588 Multiple R-squared(proj model): 0.526 Adjusted R-squared: 0.461 F-statistic(full model, *iid*):12.8 on 12 and 87 DF, p-value: 1.34e-14 F-statistic(proj model): 50.7 on 3 and 87 DF, p-value: <2e-16 Summary for outcome w Call: felm(formula = v | w | y | z ~ x + x2 + x3 | id, keepX = TRUE) Residuals: Min 1Q Median 3Q Max -2.2058 -0.5929 -0.0948 0.6021 2.6465 Coefficients: Estimate Robust s.e t value Pr(>|t|) x 0.681 0.102 6.67 2.2e-09 *** x2 0.450 0.131 3.43 0.00092 *** x3 0.451 0.089 5.06 2.3e-06 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 0.924 on 87 degrees of freedom Multiple R-squared(full model): 0.587 Adjusted R-squared: 0.53 Multiple R-squared(proj model): 0.506 Adjusted R-squared: 0.437 F-statistic(full model, *iid*):10.3 on 12 and 87 DF, p-value: 2.75e-12 F-statistic(proj model): 22.5 on 3 and 87 DF, p-value: 6.99e-11 Summary for outcome y Call: felm(formula = v | w | y | z ~ x + x2 + x3 | id, keepX = TRUE) Residuals: Min 1Q Median 3Q Max -2.3645 -0.6425 0.0859 0.6470 2.9411 Coefficients: Estimate Robust s.e t value Pr(>|t|) x 1.151 0.088 13.09 < 2e-16 *** x2 1.000 0.120 8.32 1.1e-12 *** x3 1.173 0.108 10.89 < 2e-16 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.03 on 87 degrees of freedom Multiple R-squared(full model): 0.833 Adjusted R-squared: 0.81 Multiple R-squared(proj model): 0.772 Adjusted R-squared: 0.741 F-statistic(full model, *iid*):36.1 on 12 and 87 DF, p-value: <2e-16 F-statistic(proj model): 94.9 on 3 and 87 DF, p-value: <2e-16 Summary for outcome z Call: felm(formula = v | w | y | z ~ x + x2 + x3 | id, keepX = TRUE) Residuals: Min 1Q Median 3Q Max -2.6990 -0.6658 0.0189 0.6380 1.9743 Coefficients: Estimate Robust s.e t value Pr(>|t|) x 0.4902 0.0879 5.57 2.7e-07 *** x2 0.6401 0.1138 5.62 2.2e-07 *** x3 0.4422 0.1147 3.86 0.00022 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.02 on 87 degrees of freedom Multiple R-squared(full model): 0.599 Adjusted R-squared: 0.544 Multiple R-squared(proj model): 0.441 Adjusted R-squared: 0.364 F-statistic(full model, *iid*):10.8 on 12 and 87 DF, p-value: 8.33e-13 F-statistic(proj model): 28.6 on 3 and 87 DF, p-value: 5.6e-13 > summary(est, lhs='z', robust=TRUE) Summary for outcome z Call: felm(formula = v | w | y | z ~ x + x2 + x3 | id, keepX = TRUE) Residuals: Min 1Q Median 3Q Max -2.6990 -0.6658 0.0189 0.6380 1.9743 Coefficients: Estimate Robust s.e t value Pr(>|t|) x 0.4902 0.0879 5.57 2.7e-07 *** x2 0.6401 0.1138 5.62 2.2e-07 *** x3 0.4422 0.1147 3.86 0.00022 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.02 on 87 degrees of freedom Multiple R-squared(full model): 0.599 Adjusted R-squared: 0.544 Multiple R-squared(proj model): 0.441 Adjusted R-squared: 0.364 F-statistic(full model, *iid*):10.8 on 12 and 87 DF, p-value: 8.33e-13 F-statistic(proj model): 28.6 on 3 and 87 DF, p-value: 5.6e-13 > summary(zest <- felm(z ~x+x2+x3|id,keepX=TRUE), robust=TRUE) Call: felm(formula = z ~ x + x2 + x3 | id, keepX = TRUE) Residuals: Min 1Q Median 3Q Max -2.6990 -0.6658 0.0189 0.6380 1.9743 Coefficients: Estimate Robust s.e t value Pr(>|t|) x 0.4902 0.0879 5.57 2.7e-07 *** x2 0.6401 0.1138 5.62 2.2e-07 *** x3 0.4422 0.1147 3.86 0.00022 *** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.02 on 87 degrees of freedom Multiple R-squared(full model): 0.599 Adjusted R-squared: 0.544 Multiple R-squared(proj model): 0.441 Adjusted R-squared: 0.364 F-statistic(full model, *iid*):10.8 on 12 and 87 DF, p-value: 8.33e-13 F-statistic(proj model): 28.6 on 3 and 87 DF, p-value: 5.6e-13 > getfe(zest,se=TRUE) effect obs comp fe idx se id.1 0.0713 5 1 id 1 0.460 id.2 -0.3484 8 1 id 2 0.373 id.3 -0.7928 13 1 id 3 0.291 id.4 -0.5728 7 1 id 4 0.397 id.5 -1.6214 10 1 id 5 0.328 id.6 1.2285 7 1 id 6 0.387 id.7 0.7963 14 1 id 7 0.279 id.8 0.5192 15 1 id 8 0.265 id.9 -1.0537 5 1 id 9 0.460 id.10 -0.4860 16 1 id 10 0.260 > getfe(est,method='cg',se=TRUE,lhs=c('w','z')) effect.w effect.z obs comp fe idx se.w se.z id.1 0.277 0.0713 5 1 id 1 0.416 0.460 id.2 -0.193 -0.3484 8 1 id 2 0.337 0.373 id.3 -0.555 -0.7928 13 1 id 3 0.263 0.291 id.4 -0.407 -0.5728 7 1 id 4 0.359 0.397 id.5 -1.145 -1.6214 10 1 id 5 0.296 0.328 id.6 -0.475 1.2285 7 1 id 6 0.350 0.387 id.7 1.011 0.7963 14 1 id 7 0.252 0.279 id.8 0.326 0.5192 15 1 id 8 0.240 0.265 id.9 -0.993 -1.0537 5 1 id 9 0.416 0.460 id.10 -0.665 -0.4860 16 1 id 10 0.236 0.260 > lhs <- cbind(v,w,y,z) > rhs <- cbind(x,x2,x3) > est <- felm(lhs ~rhs|id+firm,keepX=TRUE) > summary(est,lhs='lhs.z', robust=TRUE) Summary for outcome lhs.z Call: felm(formula = lhs ~ rhs | id + firm, keepX = TRUE) Residuals: Min 1Q Median 3Q Max -2.2337 -0.6746 0.0996 0.6950 1.8839 Coefficients: Estimate Robust s.e t value Pr(>|t|) rhsx 0.521 0.101 5.16 1.8e-06 *** rhsx2 0.639 0.129 4.96 4.1e-06 *** rhsx3 0.429 0.126 3.40 0.0011 ** --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Residual standard error: 1.03 on 78 degrees of freedom Multiple R-squared(full model): 0.633 Adjusted R-squared: 0.534 Multiple R-squared(proj model): 0.449 Adjusted R-squared: 0.301 F-statistic(full model, *iid*): 6.4 on 21 and 78 DF, p-value: 6.04e-10 F-statistic(proj model): 20.5 on 3 and 78 DF, p-value: 6.98e-10 > getfe(est,se=TRUE) effect.lhs.v effect.lhs.w effect.lhs.y effect.lhs.z obs comp fe idx id.1 0.8749 0.9812 0.0489 0.7051 5 1 id 1 id.2 0.6719 0.4853 0.8638 0.0607 8 1 id 2 id.3 0.3024 0.1536 -0.4686 -0.4533 13 1 id 3 id.4 0.0844 0.2636 -0.0926 -0.0300 7 1 id 4 id.5 -0.3246 -0.2747 -0.7442 -1.2239 10 1 id 5 id.6 2.1050 0.1077 2.1595 1.5731 7 1 id 6 id.7 1.3908 1.8396 3.0891 1.2949 14 1 id 7 id.8 1.0757 0.9470 1.0288 1.0310 15 1 id 8 id.9 -0.0124 0.0539 -0.1982 -0.4388 5 1 id 9 id.10 0.0000 0.0000 0.0000 0.0000 16 1 id 10 firm.1 -0.8998 -0.4904 -0.7812 -0.7076 12 1 firm 1 firm.2 -1.0174 -1.0420 -1.4526 -0.1498 14 1 firm 2 firm.3 -1.2929 -0.5287 -1.0098 -0.4653 12 1 firm 3 firm.4 -0.8283 -0.7822 -0.4942 -0.3447 12 1 firm 4 firm.5 -1.2683 -1.3940 -1.0347 -0.8927 8 1 firm 5 firm.6 -2.0526 -0.2337 -0.6150 0.2459 3 1 firm 6 firm.7 -0.9234 -1.0914 -1.7224 -0.8636 6 1 firm 7 firm.8 -1.1723 -0.5550 -1.2184 -0.3741 13 1 firm 8 firm.9 -0.8319 -0.0858 -0.8495 -0.1335 9 1 firm 9 firm.10 -0.6497 -0.8919 -1.0865 -0.7919 11 1 firm 10 se.lhs.v se.lhs.w se.lhs.y se.lhs.z id.1 0.419 0.358 0.484 0.500 id.2 0.328 0.340 0.449 0.429 id.3 0.297 0.305 0.397 0.353 id.4 0.410 0.416 0.459 0.413 id.5 0.328 0.334 0.431 0.350 id.6 0.365 0.378 0.472 0.477 id.7 0.292 0.270 0.380 0.353 id.8 0.277 0.280 0.319 0.328 id.9 0.418 0.433 0.557 0.555 id.10 0.000 0.000 0.000 0.000 firm.1 0.233 0.252 0.316 0.336 firm.2 0.300 0.287 0.382 0.326 firm.3 0.284 0.281 0.327 0.361 firm.4 0.321 0.288 0.360 0.383 firm.5 0.384 0.315 0.496 0.436 firm.6 0.548 0.466 0.654 0.680 firm.7 0.394 0.457 0.495 0.478 firm.8 0.279 0.279 0.370 0.382 firm.9 0.340 0.333 0.388 0.420 firm.10 0.277 0.291 0.333 0.388 > > proc.time() user system elapsed 1.34 0.18 1.46