R Under development (unstable) (2025-10-03 r88899 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 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( micEcon ) If you have questions, suggestions, or comments regarding one of the 'micEcon' packages, please use a forum or 'tracker' at micEcon's R-Forge site: https://r-forge.r-project.org/projects/micecon/ > library( plm ) > options( digits = 3 ) > printQuadFuncEst <- function( x ) { + for( n in names( x ) ) { + cat( "$", n, "\n", sep ="" ) + if( n == "model.matrix" && is.numeric( x[[ n ]] ) ) { + for( i in 1:ncol( x[[ n ]] ) ) { + size <- floor( log( x[[ n ]][ , i ], base = 10 ) ) + 1 + size[ size < -5 ] <- -5 + fac <- 10^( size - 5 ) + x[[ n ]][ , i ] <- fac * round( x[[ n ]][ , i ] / fac ) + } + } + print( x[[ n ]] ) + cat( "\n" ) + } + cat( "attr(,\"class\")\n" ) + print( class( x ) ) + } > > ## preparing data > data( germanFarms ) > # output quantity: > germanFarms$qOutput <- germanFarms$vOutput / germanFarms$pOutput > # quantity of variable inputs > germanFarms$qVarInput <- germanFarms$vVarInput / germanFarms$pVarInput > # a time trend to account for technical progress: > germanFarms$time <- c(1:20) > # mean values of all variables > germanFarmsMeans <- colMeans( germanFarms[ , -1 ] ) > > ## estimate a quadratic production function > estResult <- quadFuncEst( "qOutput", + c( "qLabor", "land", "qVarInput", "time" ), germanFarms ) > coef( estResult ) a_0 a_1 a_2 a_3 a_4 b_1_1 b_1_2 b_1_3 -1.89e+04 1.64e+04 2.89e+01 1.92e+01 -1.50e+02 -1.14e+04 2.45e+02 -5.29e+00 b_1_4 b_2_2 b_2_3 b_2_4 b_3_3 b_3_4 b_4_4 -1.45e+02 -4.79e+00 -3.67e-01 5.18e+00 -7.90e-03 5.06e-01 -1.30e+01 > print( estResult ) $call quadFuncEst(yName = "qOutput", xNames = c("qLabor", "land", "qVarInput", "time"), data = germanFarms) $nExog [1] 4 $nShifter [1] 0 $est Call: lm(formula = as.formula(estFormula), data = estData) Coefficients: (Intercept) a_1 a_2 a_3 a_4 b_1_1 -1.89e+04 1.64e+04 2.89e+01 1.92e+01 -1.50e+02 -1.14e+04 b_1_2 b_1_3 b_1_4 b_2_2 b_2_3 b_2_4 2.45e+02 -5.29e+00 -1.45e+02 -4.79e+00 -3.67e-01 5.18e+00 b_3_3 b_3_4 b_4_4 -7.90e-03 5.06e-01 -1.30e+01 $residuals 1 2 3 4 5 6 7 8 9 10 7.432 -39.365 21.652 32.467 -0.816 -21.651 -0.640 -4.241 12.971 -7.827 11 12 13 14 15 16 17 18 19 20 -2.867 2.988 -6.250 0.863 7.942 7.057 -20.630 13.722 -3.067 0.260 $fitted 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 939 1002 1048 1139 1179 1207 1240 1293 1195 1286 1363 1538 1581 1695 1637 1619 17 18 19 20 1676 1742 1890 1992 $coef a_0 a_1 a_2 a_3 a_4 b_1_1 b_1_2 b_1_3 -1.89e+04 1.64e+04 2.89e+01 1.92e+01 -1.50e+02 -1.14e+04 2.45e+02 -5.29e+00 b_1_4 b_2_2 b_2_3 b_2_4 b_3_3 b_3_4 b_4_4 -1.45e+02 -4.79e+00 -3.67e-01 5.18e+00 -7.90e-03 5.06e-01 -1.30e+01 $coefCov a_0 a_1 a_2 a_3 a_4 b_1_1 b_1_2 a_0 1.94e+08 -2.20e+08 -6.68e+06 1.05e+05 6.70e+06 1.13e+08 4.31e+06 a_1 -2.20e+08 2.81e+08 6.63e+06 -1.51e+05 -7.66e+06 -1.69e+08 -4.62e+06 a_2 -6.68e+06 6.63e+06 5.13e+05 -1.06e+04 -3.64e+05 -2.55e+06 -3.15e+05 a_3 1.05e+05 -1.51e+05 -1.06e+04 3.56e+02 6.68e+03 9.83e+04 6.98e+03 a_4 6.70e+06 -7.66e+06 -3.64e+05 6.68e+03 3.83e+05 3.87e+06 2.36e+05 b_1_1 1.13e+08 -1.69e+08 -2.55e+06 9.83e+04 3.87e+06 1.54e+08 1.38e+06 b_1_2 4.31e+06 -4.62e+06 -3.15e+05 6.98e+03 2.36e+05 1.38e+06 2.19e+05 b_1_3 -5.15e+04 8.65e+04 5.88e+03 -2.18e+02 -3.90e+03 -1.23e+05 -3.00e+03 b_1_4 -4.18e+06 5.22e+06 1.98e+05 -4.24e+03 -2.25e+05 -2.28e+06 -1.55e+05 b_2_2 -3.05e+04 5.44e+04 -4.26e+03 1.12e+02 1.34e+03 -2.62e+04 1.32e+03 b_2_3 2.27e+03 -2.43e+03 1.66e+01 -2.32e+00 4.27e+01 2.20e+03 -2.74e+01 b_2_4 -4.87e+04 4.09e+04 6.71e+03 -1.44e+02 -4.86e+03 -2.31e+04 -3.26e+03 b_3_3 -1.41e+02 1.45e+02 3.27e+00 3.76e-03 -3.92e+00 4.58e+01 -3.77e+00 b_3_4 3.10e+02 -8.51e+02 -9.78e+01 4.01e+00 5.87e+01 -3.90e+02 8.93e+01 b_4_4 8.31e+04 -8.74e+04 -5.40e+03 9.41e+01 5.21e+03 5.26e+04 2.81e+03 b_1_3 b_1_4 b_2_2 b_2_3 b_2_4 b_3_3 b_3_4 a_0 -5.15e+04 -4.18e+06 -3.05e+04 2.27e+03 -4.87e+04 -1.41e+02 310.0540 a_1 8.65e+04 5.22e+06 5.44e+04 -2.43e+03 4.09e+04 1.45e+02 -851.3935 a_2 5.88e+03 1.98e+05 -4.26e+03 1.66e+01 6.71e+03 3.27e+00 -97.8391 a_3 -2.18e+02 -4.24e+03 1.12e+02 -2.32e+00 -1.44e+02 3.76e-03 4.0064 a_4 -3.90e+03 -2.25e+05 1.34e+03 4.27e+01 -4.86e+03 -3.92e+00 58.7104 b_1_1 -1.23e+05 -2.28e+06 -2.62e+04 2.20e+03 -2.31e+04 4.58e+01 -390.2702 b_1_2 -3.00e+03 -1.55e+05 1.32e+03 -2.74e+01 -3.26e+03 -3.77e+00 89.3295 b_1_3 2.47e+02 1.53e+03 -8.48e+01 -8.32e-02 1.01e+02 -2.22e-01 -0.6176 b_1_4 1.53e+03 1.63e+05 9.87e+02 -1.76e+01 1.55e+03 4.53e+00 -60.5660 b_2_2 -8.48e+01 9.87e+02 2.33e+02 -3.65e+00 -1.69e+02 1.56e-01 1.4021 b_2_3 -8.32e-02 -1.76e+01 -3.65e+00 1.66e-01 1.60e+00 -2.07e-03 -0.0899 b_2_4 1.01e+02 1.55e+03 -1.69e+02 1.60e+00 1.67e+02 -5.80e-02 -1.3807 b_3_3 -2.22e-01 4.53e+00 1.56e-01 -2.07e-03 -5.80e-02 6.19e-04 -0.0022 b_3_4 -6.18e-01 -6.06e+01 1.40e+00 -8.99e-02 -1.38e+00 -2.20e-03 0.0971 b_4_4 -7.19e+01 -2.31e+03 8.05e+01 1.74e-01 -1.10e+02 8.29e-03 0.4406 b_4_4 a_0 8.31e+04 a_1 -8.74e+04 a_2 -5.40e+03 a_3 9.41e+01 a_4 5.21e+03 b_1_1 5.26e+04 b_1_2 2.81e+03 b_1_3 -7.19e+01 b_1_4 -2.31e+03 b_2_2 8.05e+01 b_2_3 1.74e-01 b_2_4 -1.10e+02 b_3_3 8.29e-03 b_3_4 4.41e-01 b_4_4 1.01e+02 $r2 [1] 0.997 $r2bar [1] 0.99 $nObs [1] 20 $yName [1] "qOutput" $xNames [1] "qLabor" "land" "qVarInput" "time" $regScale [1] 1 $model.matrix (Intercept) a_1 a_2 a_3 a_4 b_1_1 b_1_2 b_1_3 b_1_4 b_2_2 b_2_3 b_2_4 1 1 1.44 23.4 557 1 1.04 33.7 801 1.44 274 13023 23.4 2 1 1.45 24.2 607 2 1.05 35.1 880 2.90 293 14681 48.4 3 1 1.44 24.7 608 3 1.04 35.6 875 4.32 305 15009 74.1 4 1 1.48 24.9 654 4 1.10 36.9 968 5.92 310 16290 99.6 5 1 1.48 24.9 648 5 1.10 36.9 958 7.40 310 16132 124.5 6 1 1.47 25.2 657 6 1.08 37.1 966 8.82 318 16576 151.4 7 1 1.45 25.9 673 7 1.05 37.6 977 10.15 336 17449 181.4 8 1 1.49 26.0 648 8 1.11 38.7 965 11.92 337 16826 207.8 9 1 1.48 25.2 640 9 1.10 37.3 947 13.32 317 16115 226.6 10 1 1.53 26.1 648 10 1.17 39.9 992 15.30 340 16906 260.7 11 1 1.53 26.8 682 11 1.17 41.0 1044 16.83 358 18267 294.5 12 1 1.69 29.9 761 12 1.43 50.5 1286 20.28 446 22730 358.4 13 1 1.70 31.1 801 13 1.44 52.9 1362 22.10 484 24927 404.4 14 1 1.67 32.2 798 14 1.39 53.8 1332 23.38 518 25681 450.7 15 1 1.65 31.5 737 15 1.36 52.0 1216 24.75 497 23230 472.8 16 1 1.61 31.9 719 16 1.30 51.3 1157 25.76 508 22914 510.1 17 1 1.62 33.5 701 17 1.31 54.3 1135 27.54 562 23501 570.2 18 1 1.62 35.1 702 18 1.31 56.8 1137 29.16 615 24605 631.1 19 1 1.62 37.3 731 19 1.31 60.4 1185 30.78 696 27283 708.9 20 1 1.62 39.4 770 20 1.31 63.8 1248 32.40 776 30337 787.8 b_3_3 b_3_4 b_4_4 1 154872 557 0.5 2 184006 1213 2.0 3 184781 1824 4.5 4 213832 2616 8.0 5 209710 3238 12.5 6 215817 3942 18.0 7 226774 4714 24.5 8 209890 5183 32.0 9 204785 5760 40.5 10 210262 6485 50.0 11 232820 7506 60.5 12 289533 9132 72.0 13 321010 10416 84.5 14 318247 11169 98.0 15 271572 11055 112.5 16 258318 11500 128.0 17 245488 11912 144.5 18 246256 12632 162.0 19 267367 13894 180.5 20 296583 15403 200.0 attr(,"assign") [1] 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 attr(,"class") [1] "quadFuncEst" > > ## compute fitted values > fitted <- quadFuncCalc( c( "qLabor", "land", "qVarInput", "time" ), + germanFarms, coef( estResult ) ) > all.equal( fitted, estResult$fitted ) [1] TRUE > all.equal( fitted, predict( estResult ) ) [1] TRUE > all.equal( fitted, predict( estResult, newdata = germanFarms ) ) [1] TRUE > > # only at mean values > fittedMean <- quadFuncCalc( + xNames = c( "qLabor", "land", "qVarInput", "time" ), + data = germanFarmsMeans, coef = coef( estResult ) ) > print( fittedMean ) 1 1556 > all.equal( fittedMean, + predict( estResult, newdata = germanFarmsMeans ) ) [1] TRUE > > ## compute the marginal products of the inputs > margProducts <- quadFuncDeriv( + c( "qLabor", "land", "qVarInput", "time" ), + germanFarms, coef( estResult ), vcov( estResult ) ) > print( margProducts ) qLabor land qVarInput time 1 2547 70.4 -0.877 31.42 2 2219 55.8 -1.113 46.48 3 2302 55.7 -0.744 38.12 4 1509 52.7 -0.894 43.80 5 1398 60.2 -0.338 27.60 6 1397 58.0 0.030 22.46 7 1561 49.0 0.262 24.22 8 1108 73.1 0.737 -7.18 9 927 82.5 1.648 -26.83 10 383 92.5 1.496 -38.13 11 230 81.9 1.477 -30.33 12 -1403 82.6 -0.622 -10.60 13 -1571 69.5 -0.942 1.79 14 -1089 63.4 -0.647 -3.02 15 -847 89.2 0.692 -47.38 16 -349 89.6 1.421 -61.94 17 -106 95.9 1.408 -76.92 18 116 93.4 1.347 -81.48 19 366 77.0 0.795 -67.89 20 525 57.9 0.230 -50.40 > print( attributes( margProducts )$variance ) qLabor land qVarInput time 1 3.03e+08 544271 364 401579 2 2.97e+08 542045 363 399238 3 2.92e+08 533248 358 393740 4 2.89e+08 538663 363 395792 5 2.84e+08 531000 359 390564 6 2.78e+08 521654 354 383957 7 2.71e+08 511097 348 376823 8 2.75e+08 517159 351 382143 9 2.66e+08 504238 344 371779 10 2.72e+08 516764 353 381507 11 2.67e+08 512576 350 377697 12 2.97e+08 573963 391 422271 13 2.96e+08 575409 393 423171 14 2.90e+08 561121 383 415690 15 2.84e+08 543736 371 405186 16 2.76e+08 524678 359 393181 17 2.83e+08 528807 362 400594 18 2.86e+08 528980 362 403758 19 2.90e+08 532351 364 409489 20 2.93e+08 534965 365 414060 > print( attributes( margProducts )$stdDev ) qLabor land qVarInput time 1 17415 738 19.1 634 2 17244 736 19.1 632 3 17085 730 18.9 627 4 17014 734 19.1 629 5 16859 729 18.9 625 6 16667 722 18.8 620 7 16470 715 18.6 614 8 16579 719 18.7 618 9 16305 710 18.6 610 10 16498 719 18.8 618 11 16354 716 18.7 615 12 17227 758 19.8 650 13 17190 759 19.8 651 14 17040 749 19.6 645 15 16851 737 19.3 637 16 16610 724 18.9 627 17 16815 727 19.0 633 18 16901 727 19.0 635 19 17023 730 19.1 640 20 17109 731 19.1 643 > # only at mean values > margProductsMean <- quadFuncDeriv( + xNames = c( "qLabor", "land", "qVarInput", "time" ), + data = germanFarmsMeans, coef = coef( estResult ), + coefCov = vcov( estResult ) ) > print( margProductsMean ) qLabor land qVarInput time 1 561 72.5 0.268 -13.3 > print( attributes( margProductsMean )$variance ) qLabor land qVarInput time 1 2.83e+08 532305 361 395950 > print( attributes( margProductsMean )$stdDev ) qLabor land qVarInput time 1 16814 730 19 629 > > ## estimate a quadratic production function with a shifter > estResultShifter <- quadFuncEst( yName = "qOutput", + xNames = c( "qLabor", "land", "qVarInput" ), + shifterNames = "time", data = germanFarms ) > coef( estResultShifter ) a_0 a_1 a_2 a_3 b_1_1 b_1_2 b_1_3 b_2_2 -1.15e+04 1.03e+04 1.41e+02 5.35e+00 -2.03e+03 -7.46e+01 -7.16e+00 -3.06e-01 b_2_3 b_3_3 d_1 3.27e-02 8.63e-03 9.66e+00 > print( estResultShifter ) $call quadFuncEst(yName = "qOutput", xNames = c("qLabor", "land", "qVarInput"), data = germanFarms, shifterNames = "time") $nExog [1] 3 $nShifter [1] 1 $est Call: lm(formula = as.formula(estFormula), data = estData) Coefficients: (Intercept) a_1 a_2 a_3 b_1_1 b_1_2 -1.15e+04 1.03e+04 1.41e+02 5.35e+00 -2.03e+03 -7.46e+01 b_1_3 b_2_2 b_2_3 b_3_3 d_1 -7.16e+00 -3.06e-01 3.27e-02 8.63e-03 9.66e+00 $residuals 1 2 3 4 5 6 7 8 9 10 11 17.93 -65.87 19.35 10.28 14.47 -5.97 -4.82 41.68 2.13 -18.24 -8.45 12 13 14 15 16 17 18 19 20 14.30 -28.06 16.30 27.35 -18.70 -32.87 7.02 22.26 -10.10 $fitted 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 928 1029 1050 1162 1164 1192 1244 1247 1206 1297 1369 1526 1603 1680 1617 1645 17 18 19 20 1688 1749 1865 2002 $coef a_0 a_1 a_2 a_3 b_1_1 b_1_2 b_1_3 b_2_2 -1.15e+04 1.03e+04 1.41e+02 5.35e+00 -2.03e+03 -7.46e+01 -7.16e+00 -3.06e-01 b_2_3 b_3_3 d_1 3.27e-02 8.63e-03 9.66e+00 $coefCov a_0 a_1 a_2 a_3 b_1_1 b_1_2 b_1_3 a_0 8.58e+07 -9.12e+07 -1.90e+06 3.56e+04 4.25e+07 9.52e+05 -1.89e+03 a_1 -9.12e+07 1.31e+08 9.73e+05 -7.13e+04 -1.04e+08 -2.64e+05 5.58e+04 a_2 -1.90e+06 9.73e+05 1.57e+05 -2.98e+03 2.53e+05 -9.17e+04 1.60e+03 a_3 3.56e+04 -7.13e+04 -2.98e+03 1.73e+02 1.01e+05 1.52e+03 -1.80e+02 b_1_1 4.25e+07 -1.04e+08 2.53e+05 1.01e+05 1.36e+08 -4.72e+05 -1.34e+05 b_1_2 9.52e+05 -2.64e+05 -9.17e+04 1.52e+03 -4.72e+05 5.71e+04 -8.00e+02 b_1_3 -1.89e+03 5.58e+04 1.60e+03 -1.80e+02 -1.34e+05 -8.00e+02 2.49e+02 b_2_2 -1.76e+03 2.62e+03 1.37e+02 -6.47e+00 -7.26e+02 -6.47e+01 8.92e-01 b_2_3 5.18e+02 -8.23e+02 -1.61e+01 9.90e-01 7.12e+02 1.29e+00 -4.41e-01 b_3_3 -6.97e+01 1.40e+01 1.32e+00 1.13e-01 1.24e+02 -4.00e-01 -2.82e-01 d_1 7.51e+04 -5.93e+04 -2.33e+03 1.30e+01 1.03e+04 1.26e+03 1.15e+01 b_2_2 b_2_3 b_3_3 d_1 a_0 -1.76e+03 5.18e+02 -6.97e+01 7.51e+04 a_1 2.62e+03 -8.23e+02 1.40e+01 -5.93e+04 a_2 1.37e+02 -1.61e+01 1.32e+00 -2.33e+03 a_3 -6.47e+00 9.90e-01 1.13e-01 1.30e+01 b_1_1 -7.26e+02 7.12e+02 1.24e+02 1.03e+04 b_1_2 -6.47e+01 1.29e+00 -4.00e-01 1.26e+03 b_1_3 8.92e-01 -4.41e-01 -2.82e-01 1.15e+01 b_2_2 1.15e+01 -5.69e-01 3.13e-02 5.30e+00 b_2_3 -5.69e-01 4.46e-02 -2.33e-03 6.41e-02 b_3_3 3.13e-02 -2.33e-03 5.72e-04 -4.71e-02 d_1 5.30e+00 6.41e-02 -4.71e-02 1.10e+02 $r2 [1] 0.993 $r2bar [1] 0.986 $nObs [1] 20 $yName [1] "qOutput" $xNames [1] "qLabor" "land" "qVarInput" $shifterNames [1] "time" $regScale [1] 1 $model.matrix (Intercept) a_1 a_2 a_3 b_1_1 b_1_2 b_1_3 b_2_2 b_2_3 b_3_3 d_1 1 1 1.44 23.4 557 1.04 33.7 801 274 13023 154872 1 2 1 1.45 24.2 607 1.05 35.1 880 293 14681 184006 2 3 1 1.44 24.7 608 1.04 35.6 875 305 15009 184781 3 4 1 1.48 24.9 654 1.10 36.9 968 310 16290 213832 4 5 1 1.48 24.9 648 1.10 36.9 958 310 16132 209710 5 6 1 1.47 25.2 657 1.08 37.1 966 318 16576 215817 6 7 1 1.45 25.9 673 1.05 37.6 977 336 17449 226774 7 8 1 1.49 26.0 648 1.11 38.7 965 337 16826 209890 8 9 1 1.48 25.2 640 1.10 37.3 947 317 16115 204785 9 10 1 1.53 26.1 648 1.17 39.9 992 340 16906 210262 10 11 1 1.53 26.8 682 1.17 41.0 1044 358 18267 232820 11 12 1 1.69 29.9 761 1.43 50.5 1286 446 22730 289533 12 13 1 1.70 31.1 801 1.44 52.9 1362 484 24927 321010 13 14 1 1.67 32.2 798 1.39 53.8 1332 518 25681 318247 14 15 1 1.65 31.5 737 1.36 52.0 1216 497 23230 271572 15 16 1 1.61 31.9 719 1.30 51.3 1157 508 22914 258318 16 17 1 1.62 33.5 701 1.31 54.3 1135 562 23501 245488 17 18 1 1.62 35.1 702 1.31 56.8 1137 615 24605 246256 18 19 1 1.62 37.3 731 1.31 60.4 1185 696 27283 267367 19 20 1 1.62 39.4 770 1.31 63.8 1248 776 30337 296583 20 attr(,"assign") [1] 0 1 2 3 4 5 6 7 8 9 10 attr(,"class") [1] "quadFuncEst" > # compute fitted values > fitted <- quadFuncCalc( c( "qLabor", "land", "qVarInput" ), + shifterNames = "time", data = germanFarms, coef( estResultShifter ) ) > all.equal( fitted, estResultShifter$fitted ) [1] TRUE > all.equal( fitted, predict( estResultShifter ) ) [1] TRUE > all.equal( fitted, predict( estResultShifter, newdata = germanFarms ) ) [1] TRUE > # compute marginal products = partial derivatives > margProdShifter <- quadFuncDeriv( + c( "qLabor", "land", "qVarInput" ), + germanFarms, coef( estResultShifter ), vcov( estResultShifter ) ) > print( margProdShifter ) qLabor land qVarInput 1 1636 44.9 0.613 2 1197 45.6 1.000 3 1172 46.2 1.098 4 745 44.6 1.217 5 790 44.4 1.162 6 719 45.4 1.325 7 591 47.2 1.633 8 689 43.4 1.128 9 825 44.1 1.105 10 596 40.4 0.849 11 301 41.3 1.165 12 -818 31.0 0.800 13 -1220 31.2 1.117 14 -1214 33.0 1.337 15 -688 32.7 0.933 16 -504 34.9 1.074 17 -518 33.1 0.901 18 -639 32.7 0.960 19 -1018 32.9 1.288 20 -1452 33.6 1.692 > print( attributes( margProdShifter )$variance ) qLabor land qVarInput 1 1.28e+08 140313 175 2 1.25e+08 141525 169 3 1.24e+08 140739 167 4 1.25e+08 144357 168 5 1.26e+08 144246 169 6 1.24e+08 143588 166 7 1.22e+08 142268 161 8 1.27e+08 144793 169 9 1.26e+08 144061 169 10 1.31e+08 147940 176 11 1.29e+08 148376 172 12 1.43e+08 163662 190 13 1.42e+08 165266 187 14 1.40e+08 161944 180 15 1.41e+08 158933 183 16 1.38e+08 154877 177 17 1.42e+08 155312 180 18 1.43e+08 155201 179 19 1.43e+08 155398 173 20 1.44e+08 155753 167 > print( attributes( margProdShifter )$stdDev ) qLabor land qVarInput 1 11306 375 13.2 2 11181 376 13.0 3 11135 375 12.9 4 11189 380 13.0 5 11205 380 13.0 6 11140 379 12.9 7 11032 377 12.7 8 11259 381 13.0 9 11228 380 13.0 10 11448 385 13.3 11 11357 385 13.1 12 11960 405 13.8 13 11929 407 13.7 14 11820 402 13.4 15 11861 399 13.5 16 11732 394 13.3 17 11896 394 13.4 18 11955 394 13.4 19 11968 394 13.2 20 11980 395 12.9 > > ## estimate a quadratic production function with 2 shifters > germanFarms$timeSq <- germanFarms$time^2 > estResultShifter2 <- quadFuncEst( yName = "qOutput", + xNames = c( "qLabor", "land", "qVarInput" ), + shifterNames = c( "time", "timeSq" ), data = germanFarms ) > coef( estResultShifter2 ) a_0 a_1 a_2 a_3 b_1_1 b_1_2 b_1_3 b_2_2 -1.33e+04 1.42e+04 -1.28e+01 6.89e+00 -4.78e+03 3.04e+01 -1.05e+01 -1.97e+00 b_2_3 b_3_3 d_1 d_2 1.45e-01 7.72e-03 3.97e+01 -2.58e+00 > print( estResultShifter2 ) $call quadFuncEst(yName = "qOutput", xNames = c("qLabor", "land", "qVarInput"), data = germanFarms, shifterNames = c("time", "timeSq")) $nExog [1] 3 $nShifter [1] 2 $est Call: lm(formula = as.formula(estFormula), data = estData) Coefficients: (Intercept) a_1 a_2 a_3 b_1_1 b_1_2 -1.33e+04 1.42e+04 -1.28e+01 6.89e+00 -4.78e+03 3.04e+01 b_1_3 b_2_2 b_2_3 b_3_3 d_1 d_2 -1.05e+01 -1.97e+00 1.45e-01 7.72e-03 3.97e+01 -2.58e+00 $residuals 1 2 3 4 5 6 7 8 9 10 11 23.04 -50.56 11.51 19.01 8.98 -9.62 -1.67 9.91 3.60 -32.99 15.03 12 13 14 15 16 17 18 19 20 9.97 -15.83 -2.24 25.01 7.80 -37.88 6.40 19.28 -8.76 $fitted 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 923 1013 1058 1153 1169 1195 1241 1279 1204 1311 1346 1531 1591 1698 1620 1618 17 18 19 20 1693 1749 1868 2001 $coef a_0 a_1 a_2 a_3 b_1_1 b_1_2 b_1_3 b_2_2 -1.33e+04 1.42e+04 -1.28e+01 6.89e+00 -4.78e+03 3.04e+01 -1.05e+01 -1.97e+00 b_2_3 b_3_3 d_1 d_2 1.45e-01 7.72e-03 3.97e+01 -2.58e+00 $coefCov a_0 a_1 a_2 a_3 b_1_1 b_1_2 b_1_3 a_0 6.85e+07 -7.39e+07 -1.41e+06 2.72e+04 3.49e+07 6.95e+05 2.24e+02 a_1 -7.39e+07 1.08e+08 5.92e+05 -5.44e+04 -8.54e+07 -8.91e+04 4.02e+04 a_2 -1.41e+06 5.92e+05 1.30e+05 -2.42e+03 3.23e+05 -7.70e+04 1.41e+03 a_3 2.72e+04 -5.44e+04 -2.42e+03 1.37e+02 7.83e+04 1.24e+03 -1.43e+02 b_1_1 3.49e+07 -8.54e+07 3.23e+05 7.83e+04 1.09e+08 -4.56e+05 -1.03e+05 b_1_2 6.95e+05 -8.91e+04 -7.70e+04 1.24e+03 -4.56e+05 4.82e+04 -7.32e+02 b_1_3 2.24e+02 4.02e+04 1.41e+03 -1.43e+02 -1.03e+05 -7.32e+02 1.99e+02 b_2_2 -5.24e+02 1.76e+02 1.83e+02 -5.84e+00 7.65e+02 -1.02e+02 2.31e+00 b_2_3 3.50e+02 -5.22e+02 -1.77e+01 8.30e-01 4.71e+02 4.45e+00 -4.55e-01 b_3_3 -5.44e+01 9.99e+00 1.08e+00 8.87e-02 9.86e+01 -3.43e-01 -2.21e-01 d_1 4.36e+04 -1.27e+04 -3.18e+03 2.38e+01 -1.59e+04 1.91e+03 -1.99e+01 d_2 1.33e+03 -2.92e+03 1.16e+02 -1.16e+00 2.06e+03 -7.90e+01 2.49e+00 b_2_2 b_2_3 b_3_3 d_1 d_2 a_0 -524.2018 3.50e+02 -5.44e+01 4.36e+04 1.33e+03 a_1 175.9629 -5.22e+02 9.99e+00 -1.27e+04 -2.92e+03 a_2 183.2068 -1.77e+01 1.08e+00 -3.18e+03 1.16e+02 a_3 -5.8447 8.30e-01 8.87e-02 2.38e+01 -1.16e+00 b_1_1 764.5635 4.71e+02 9.86e+01 -1.59e+04 2.06e+03 b_1_2 -102.0921 4.45e+00 -3.43e-01 1.91e+03 -7.90e+01 b_1_3 2.3134 -4.55e-01 -2.21e-01 -1.99e+01 2.49e+00 b_2_2 9.8807 -5.03e-01 2.51e-02 -1.04e+01 1.25e+00 b_2_3 -0.5029 3.88e-02 -1.87e-03 1.03e+00 -8.41e-02 b_3_3 0.0251 -1.87e-03 4.51e-04 -4.52e-02 6.91e-04 d_1 -10.4405 1.03e+00 -4.52e-02 3.50e+02 -2.26e+01 d_2 1.2548 -8.41e-02 6.91e-04 -2.26e+01 1.94e+00 $r2 [1] 0.995 $r2bar [1] 0.989 $nObs [1] 20 $yName [1] "qOutput" $xNames [1] "qLabor" "land" "qVarInput" $shifterNames [1] "time" "timeSq" $regScale [1] 1 $model.matrix (Intercept) a_1 a_2 a_3 b_1_1 b_1_2 b_1_3 b_2_2 b_2_3 b_3_3 d_1 d_2 1 1 1.44 23.4 557 1.04 33.7 801 274 13023 154872 1 1 2 1 1.45 24.2 607 1.05 35.1 880 293 14681 184006 2 4 3 1 1.44 24.7 608 1.04 35.6 875 305 15009 184781 3 9 4 1 1.48 24.9 654 1.10 36.9 968 310 16290 213832 4 16 5 1 1.48 24.9 648 1.10 36.9 958 310 16132 209710 5 25 6 1 1.47 25.2 657 1.08 37.1 966 318 16576 215817 6 36 7 1 1.45 25.9 673 1.05 37.6 977 336 17449 226774 7 49 8 1 1.49 26.0 648 1.11 38.7 965 337 16826 209890 8 64 9 1 1.48 25.2 640 1.10 37.3 947 317 16115 204785 9 81 10 1 1.53 26.1 648 1.17 39.9 992 340 16906 210262 10 100 11 1 1.53 26.8 682 1.17 41.0 1044 358 18267 232820 11 121 12 1 1.69 29.9 761 1.43 50.5 1286 446 22730 289533 12 144 13 1 1.70 31.1 801 1.44 52.9 1362 484 24927 321010 13 169 14 1 1.67 32.2 798 1.39 53.8 1332 518 25681 318247 14 196 15 1 1.65 31.5 737 1.36 52.0 1216 497 23230 271572 15 225 16 1 1.61 31.9 719 1.30 51.3 1157 508 22914 258318 16 256 17 1 1.62 33.5 701 1.31 54.3 1135 562 23501 245488 17 289 18 1 1.62 35.1 702 1.31 56.8 1137 615 24605 246256 18 324 19 1 1.62 37.3 731 1.31 60.4 1185 696 27283 267367 19 361 20 1 1.62 39.4 770 1.31 63.8 1248 776 30337 296583 20 400 attr(,"assign") [1] 0 1 2 3 4 5 6 7 8 9 10 11 attr(,"class") [1] "quadFuncEst" > # compute fitted values > fitted <- quadFuncCalc( c( "qLabor", "land", "qVarInput" ), + shifterNames = c( "time", "timeSq" ), data = germanFarms, + coef( estResultShifter2 ) ) > all.equal( fitted, estResultShifter2$fitted ) [1] TRUE > all.equal( fitted, predict( estResultShifter2 ) ) [1] TRUE > all.equal( fitted, predict( estResultShifter2, newdata = germanFarms ) ) [1] TRUE > > ## estimate a linear functions with quadFuncEst > estResultLinear <- quadFuncEst( yName = "qOutput", xNames = NULL, + shifterNames = c( "time", "qLabor", "land", "qVarInput" ), + data = germanFarms ) > coef( estResultLinear ) a_0 d_1 d_2 d_3 d_4 -97.67 21.03 -185.95 29.34 1.06 > print( estResultLinear ) $call quadFuncEst(yName = "qOutput", xNames = NULL, data = germanFarms, shifterNames = c("time", "qLabor", "land", "qVarInput")) $nExog [1] 0 $nShifter [1] 4 $est Call: lm(formula = as.formula(estFormula), data = estData) Coefficients: (Intercept) d_1 d_2 d_3 d_4 -97.67 21.03 -185.95 29.34 1.06 $residuals 1 2 3 4 5 6 7 8 9 10 11 13.50 -65.69 2.54 35.86 27.87 -6.64 -15.27 45.70 -26.45 -2.61 2.04 12 13 14 15 16 17 18 19 20 16.62 -47.43 18.87 27.04 -11.33 -31.02 2.75 16.27 -2.61 $fitted 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 933 1028 1067 1136 1150 1192 1255 1243 1234 1281 1359 1524 1622 1677 1618 1637 17 18 19 20 1686 1753 1871 1994 $coef a_0 d_1 d_2 d_3 d_4 -97.67 21.03 -185.95 29.34 1.06 $coefCov a_0 d_1 d_2 d_3 d_4 a_0 52830.9 6.23e+02 -40094.9 -411.851 21.57957 d_1 623.2 1.61e+01 -221.6 -15.403 -0.00291 d_2 -40094.9 -2.22e+02 47108.1 25.245 -45.73182 d_3 -411.9 -1.54e+01 25.2 21.110 -0.11185 d_4 21.6 -2.91e-03 -45.7 -0.112 0.07665 $r2 [1] 0.992 $r2bar [1] 0.99 $nObs [1] 20 $yName [1] "qOutput" $shifterNames [1] "time" "qLabor" "land" "qVarInput" $regScale [1] 1 $model.matrix (Intercept) d_1 d_2 d_3 d_4 1 1 1 1.44 23.4 557 2 1 2 1.45 24.2 607 3 1 3 1.44 24.7 608 4 1 4 1.48 24.9 654 5 1 5 1.48 24.9 648 6 1 6 1.47 25.2 657 7 1 7 1.45 25.9 673 8 1 8 1.49 26.0 648 9 1 9 1.48 25.2 640 10 1 10 1.53 26.1 648 11 1 11 1.53 26.8 682 12 1 12 1.69 29.9 761 13 1 13 1.70 31.1 801 14 1 14 1.67 32.2 798 15 1 15 1.65 31.5 737 16 1 16 1.61 31.9 719 17 1 17 1.62 33.5 701 18 1 18 1.62 35.1 702 19 1 19 1.62 37.3 731 20 1 20 1.62 39.4 770 attr(,"assign") [1] 0 1 2 3 4 attr(,"class") [1] "quadFuncEst" > estResultLin <- quadFuncEst( yName = "qOutput", + xNames = c( "time", "qLabor", "land", "qVarInput" ), + data = germanFarms, linear = TRUE ) > all.equal( coef( estResultLinear ), coef( estResultLin )[1:5], + check.attributes = FALSE ) [1] TRUE > all.equal( vcov( estResultLinear ), vcov( estResultLin )[1:5,1:5], + check.attributes = FALSE ) [1] TRUE > coef( estResultLin ) a_0 a_1 a_2 a_3 a_4 b_1_1 b_1_2 b_1_3 b_1_4 b_2_2 -97.67 21.03 -185.95 29.34 1.06 0.00 0.00 0.00 0.00 0.00 b_2_3 b_2_4 b_3_3 b_3_4 b_4_4 0.00 0.00 0.00 0.00 0.00 > vcov( estResultLin ) a_0 a_1 a_2 a_3 a_4 b_1_1 b_1_2 b_1_3 b_1_4 a_0 52830.9 6.23e+02 -40094.9 -411.851 21.57957 0 0 0 0 a_1 623.2 1.61e+01 -221.6 -15.403 -0.00291 0 0 0 0 a_2 -40094.9 -2.22e+02 47108.1 25.245 -45.73182 0 0 0 0 a_3 -411.9 -1.54e+01 25.2 21.110 -0.11185 0 0 0 0 a_4 21.6 -2.91e-03 -45.7 -0.112 0.07665 0 0 0 0 b_1_1 0.0 0.00e+00 0.0 0.000 0.00000 0 0 0 0 b_1_2 0.0 0.00e+00 0.0 0.000 0.00000 0 0 0 0 b_1_3 0.0 0.00e+00 0.0 0.000 0.00000 0 0 0 0 b_1_4 0.0 0.00e+00 0.0 0.000 0.00000 0 0 0 0 b_2_2 0.0 0.00e+00 0.0 0.000 0.00000 0 0 0 0 b_2_3 0.0 0.00e+00 0.0 0.000 0.00000 0 0 0 0 b_2_4 0.0 0.00e+00 0.0 0.000 0.00000 0 0 0 0 b_3_3 0.0 0.00e+00 0.0 0.000 0.00000 0 0 0 0 b_3_4 0.0 0.00e+00 0.0 0.000 0.00000 0 0 0 0 b_4_4 0.0 0.00e+00 0.0 0.000 0.00000 0 0 0 0 b_2_2 b_2_3 b_2_4 b_3_3 b_3_4 b_4_4 a_0 0 0 0 0 0 0 a_1 0 0 0 0 0 0 a_2 0 0 0 0 0 0 a_3 0 0 0 0 0 0 a_4 0 0 0 0 0 0 b_1_1 0 0 0 0 0 0 b_1_2 0 0 0 0 0 0 b_1_3 0 0 0 0 0 0 b_1_4 0 0 0 0 0 0 b_2_2 0 0 0 0 0 0 b_2_3 0 0 0 0 0 0 b_2_4 0 0 0 0 0 0 b_3_3 0 0 0 0 0 0 b_3_4 0 0 0 0 0 0 b_4_4 0 0 0 0 0 0 > print( estResultLin ) $call quadFuncEst(yName = "qOutput", xNames = c("time", "qLabor", "land", "qVarInput"), data = germanFarms, linear = TRUE) $nExog [1] 4 $nShifter [1] 0 $est Call: lm(formula = as.formula(estFormula), data = estData) Coefficients: (Intercept) a_1 a_2 a_3 a_4 -97.67 21.03 -185.95 29.34 1.06 $residuals 1 2 3 4 5 6 7 8 9 10 11 13.50 -65.69 2.54 35.86 27.87 -6.64 -15.27 45.70 -26.45 -2.61 2.04 12 13 14 15 16 17 18 19 20 16.62 -47.43 18.87 27.04 -11.33 -31.02 2.75 16.27 -2.61 $fitted 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 933 1028 1067 1136 1150 1192 1255 1243 1234 1281 1359 1524 1622 1677 1618 1637 17 18 19 20 1686 1753 1871 1994 $coef a_0 a_1 a_2 a_3 a_4 b_1_1 b_1_2 b_1_3 b_1_4 b_2_2 -97.67 21.03 -185.95 29.34 1.06 0.00 0.00 0.00 0.00 0.00 b_2_3 b_2_4 b_3_3 b_3_4 b_4_4 0.00 0.00 0.00 0.00 0.00 $coefCov a_0 a_1 a_2 a_3 a_4 b_1_1 b_1_2 b_1_3 b_1_4 a_0 52830.9 6.23e+02 -40094.9 -411.851 21.57957 0 0 0 0 a_1 623.2 1.61e+01 -221.6 -15.403 -0.00291 0 0 0 0 a_2 -40094.9 -2.22e+02 47108.1 25.245 -45.73182 0 0 0 0 a_3 -411.9 -1.54e+01 25.2 21.110 -0.11185 0 0 0 0 a_4 21.6 -2.91e-03 -45.7 -0.112 0.07665 0 0 0 0 b_1_1 0.0 0.00e+00 0.0 0.000 0.00000 0 0 0 0 b_1_2 0.0 0.00e+00 0.0 0.000 0.00000 0 0 0 0 b_1_3 0.0 0.00e+00 0.0 0.000 0.00000 0 0 0 0 b_1_4 0.0 0.00e+00 0.0 0.000 0.00000 0 0 0 0 b_2_2 0.0 0.00e+00 0.0 0.000 0.00000 0 0 0 0 b_2_3 0.0 0.00e+00 0.0 0.000 0.00000 0 0 0 0 b_2_4 0.0 0.00e+00 0.0 0.000 0.00000 0 0 0 0 b_3_3 0.0 0.00e+00 0.0 0.000 0.00000 0 0 0 0 b_3_4 0.0 0.00e+00 0.0 0.000 0.00000 0 0 0 0 b_4_4 0.0 0.00e+00 0.0 0.000 0.00000 0 0 0 0 b_2_2 b_2_3 b_2_4 b_3_3 b_3_4 b_4_4 a_0 0 0 0 0 0 0 a_1 0 0 0 0 0 0 a_2 0 0 0 0 0 0 a_3 0 0 0 0 0 0 a_4 0 0 0 0 0 0 b_1_1 0 0 0 0 0 0 b_1_2 0 0 0 0 0 0 b_1_3 0 0 0 0 0 0 b_1_4 0 0 0 0 0 0 b_2_2 0 0 0 0 0 0 b_2_3 0 0 0 0 0 0 b_2_4 0 0 0 0 0 0 b_3_3 0 0 0 0 0 0 b_3_4 0 0 0 0 0 0 b_4_4 0 0 0 0 0 0 $r2 [1] 0.992 $r2bar [1] 0.99 $nObs [1] 20 $yName [1] "qOutput" $xNames [1] "time" "qLabor" "land" "qVarInput" $regScale [1] 1 $model.matrix (Intercept) a_1 a_2 a_3 a_4 1 1 1 1.44 23.4 557 2 1 2 1.45 24.2 607 3 1 3 1.44 24.7 608 4 1 4 1.48 24.9 654 5 1 5 1.48 24.9 648 6 1 6 1.47 25.2 657 7 1 7 1.45 25.9 673 8 1 8 1.49 26.0 648 9 1 9 1.48 25.2 640 10 1 10 1.53 26.1 648 11 1 11 1.53 26.8 682 12 1 12 1.69 29.9 761 13 1 13 1.70 31.1 801 14 1 14 1.67 32.2 798 15 1 15 1.65 31.5 737 16 1 16 1.61 31.9 719 17 1 17 1.62 33.5 701 18 1 18 1.62 35.1 702 19 1 19 1.62 37.3 731 20 1 20 1.62 39.4 770 attr(,"assign") [1] 0 1 2 3 4 attr(,"class") [1] "quadFuncEst" > # compute fitted values > fitted <- quadFuncCalc( xNames = NULL, + shifterNames = c( "time", "qLabor", "land", "qVarInput" ), + data = germanFarms, coef( estResultLinear ) ) > all.equal( fitted, estResultLinear$fitted ) [1] TRUE > all.equal( fitted, predict( estResultLinear ) ) [1] TRUE > all.equal( fitted, predict( estResultLinear, newdata = germanFarms ) ) [1] TRUE > > fitted <- quadFuncCalc( xNames = c( "time", "qLabor", "land", "qVarInput" ), + data = germanFarms, coef( estResultLin ) ) > all.equal( fitted, estResultLin$fitted ) [1] TRUE > all.equal( fitted, predict( estResultLin ) ) [1] TRUE > all.equal( fitted, predict( estResultLin, newdata = germanFarms ) ) [1] TRUE > all.equal( estResultLinear$fitted, estResultLin$fitted ) [1] TRUE > # compute partial derivatives > margProducts <- quadFuncDeriv( + c( "qLabor", "land", "qVarInput", "time" ), + data = germanFarms, coef = coef( estResultLin ), + coefCov = vcov( estResultLin ) ) > sapply( margProducts, sd ) qLabor land qVarInput time 0 0 0 0 > all.equal( margProducts[1,], coef( estResultLin )[2:5], + check.attributes = FALSE ) [1] TRUE > all.equal( attributes( margProducts )$variance[1,], diag( vcov( estResultLin ) )[2:5], + check.attributes = FALSE ) [1] TRUE > > ## estimate a quadratic production function with a logical variable as shifter > germanFarms$reUnif <- germanFarms$time >= 16 > estResultShifterLogi <- quadFuncEst( yName = "qOutput", + xNames = c( "qLabor", "land", "qVarInput" ), + shifterNames = c( "reUnif" ), data = germanFarms ) > coef( estResultShifterLogi ) a_0 a_1 a_2 a_3 b_1_1 b_1_2 b_1_3 b_2_2 -1.99e+04 1.69e+04 4.87e+02 8.21e-01 -4.35e+03 -2.33e+02 -5.45e+00 -1.18e+00 b_2_3 b_3_3 d_1_TRUE -2.71e-02 1.31e-02 -9.48e+01 > print( estResultShifterLogi ) $call quadFuncEst(yName = "qOutput", xNames = c("qLabor", "land", "qVarInput"), data = germanFarms, shifterNames = c("reUnif")) $nExog [1] 3 $nShifter [1] 1 $est Call: lm(formula = as.formula(estFormula), data = estData) Coefficients: (Intercept) a_1 a_2 a_3 b_1_1 b_1_2 -1.99e+04 1.69e+04 4.87e+02 8.21e-01 -4.35e+03 -2.33e+02 b_1_3 b_2_2 b_2_3 b_3_3 d_1_TRUE -5.45e+00 -1.18e+00 -2.71e-02 1.31e-02 -9.48e+01 $residuals 1 2 3 4 5 6 7 8 9 10 11 20.60 -64.61 6.52 10.39 20.72 2.26 -6.92 21.64 28.64 -27.53 -19.88 12 13 14 15 16 17 18 19 20 15.47 -17.18 5.18 4.68 13.37 -21.80 1.71 13.22 -6.50 $fitted 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 926 1027 1063 1161 1157 1184 1246 1267 1179 1306 1380 1525 1592 1691 1640 1613 17 18 19 20 1677 1754 1874 1998 $coef a_0 a_1 a_2 a_3 b_1_1 b_1_2 b_1_3 b_2_2 -1.99e+04 1.69e+04 4.87e+02 8.21e-01 -4.35e+03 -2.33e+02 -5.45e+00 -1.18e+00 b_2_3 b_3_3 d_1_TRUE -2.71e-02 1.31e-02 -9.48e+01 $coefCov a_0 a_1 a_2 a_3 b_1_1 b_1_2 b_1_3 a_0 2.79e+07 -4.04e+07 -3.08e+05 2.26e+04 28500046 9.36e+04 -9.04e+03 a_1 -4.04e+07 7.81e+07 -1.68e+05 -5.18e+04 -78103687 3.08e+05 4.97e+04 a_2 -3.08e+05 -1.68e+05 8.98e+04 -2.25e+03 315003 -5.28e+04 1.55e+03 a_3 2.26e+04 -5.18e+04 -2.25e+03 1.38e+02 79606 1.12e+03 -1.45e+02 b_1_1 2.85e+07 -7.81e+07 3.15e+05 7.96e+04 106386622 -4.45e+05 -1.07e+05 b_1_2 9.36e+04 3.08e+05 -5.28e+04 1.12e+03 -444670 3.40e+04 -7.68e+02 b_1_3 -9.04e+03 4.97e+04 1.55e+03 -1.45e+02 -107096 -7.68e+02 1.96e+02 b_2_2 -4.03e+03 4.15e+03 1.80e+02 -5.18e+00 -800 -9.32e+01 -4.73e-02 b_2_3 3.99e+02 -6.40e+02 -1.37e+01 8.23e-01 575 1.16e+00 -3.93e-01 b_3_3 -2.96e+01 -8.84e+00 2.67e-01 9.28e-02 101 1.06e-01 -2.17e-01 d_1_TRUE 4.77e+04 -3.72e+04 -3.75e+03 9.03e+01 37570 1.26e+03 -7.27e+01 b_2_2 b_2_3 b_3_3 d_1_TRUE a_0 -4.03e+03 3.99e+02 -2.96e+01 4.77e+04 a_1 4.15e+03 -6.40e+02 -8.84e+00 -3.72e+04 a_2 1.80e+02 -1.37e+01 2.67e-01 -3.75e+03 a_3 -5.18e+00 8.23e-01 9.28e-02 9.03e+01 b_1_1 -8.00e+02 5.75e+02 1.01e+02 3.76e+04 b_1_2 -9.32e+01 1.16e+00 1.06e-01 1.26e+03 b_1_3 -4.73e-02 -3.93e-01 -2.17e-01 -7.27e+01 b_2_2 8.88e+00 -4.43e-01 2.63e-02 1.08e+01 b_2_3 -4.43e-01 3.58e-02 -1.81e-03 1.45e+00 b_3_3 2.63e-02 -1.81e-03 4.33e-04 -9.53e-03 d_1_TRUE 1.08e+01 1.45e+00 -9.53e-03 2.53e+03 $r2 [1] 0.995 $r2bar [1] 0.989 $nObs [1] 20 $yName [1] "qOutput" $xNames [1] "qLabor" "land" "qVarInput" $shifterNames [1] "reUnif" $regScale [1] 1 $model.matrix (Intercept) a_1 a_2 a_3 b_1_1 b_1_2 b_1_3 b_2_2 b_2_3 b_3_3 d_1_TRUE 1 1 1.44 23.4 557 1.04 33.7 801 274 13023 154872 0 2 1 1.45 24.2 607 1.05 35.1 880 293 14681 184006 0 3 1 1.44 24.7 608 1.04 35.6 875 305 15009 184781 0 4 1 1.48 24.9 654 1.10 36.9 968 310 16290 213832 0 5 1 1.48 24.9 648 1.10 36.9 958 310 16132 209710 0 6 1 1.47 25.2 657 1.08 37.1 966 318 16576 215817 0 7 1 1.45 25.9 673 1.05 37.6 977 336 17449 226774 0 8 1 1.49 26.0 648 1.11 38.7 965 337 16826 209890 0 9 1 1.48 25.2 640 1.10 37.3 947 317 16115 204785 0 10 1 1.53 26.1 648 1.17 39.9 992 340 16906 210262 0 11 1 1.53 26.8 682 1.17 41.0 1044 358 18267 232820 0 12 1 1.69 29.9 761 1.43 50.5 1286 446 22730 289533 0 13 1 1.70 31.1 801 1.44 52.9 1362 484 24927 321010 0 14 1 1.67 32.2 798 1.39 53.8 1332 518 25681 318247 0 15 1 1.65 31.5 737 1.36 52.0 1216 497 23230 271572 0 16 1 1.61 31.9 719 1.30 51.3 1157 508 22914 258318 1 17 1 1.62 33.5 701 1.31 54.3 1135 562 23501 245488 1 18 1 1.62 35.1 702 1.31 56.8 1137 615 24605 246256 1 19 1 1.62 37.3 731 1.31 60.4 1185 696 27283 267367 1 20 1 1.62 39.4 770 1.31 63.8 1248 776 30337 296583 1 attr(,"assign") [1] 0 1 2 3 4 5 6 7 8 9 10 attr(,"contrasts") attr(,"contrasts")$d_1_ [1] "contr.treatment" attr(,"class") [1] "quadFuncEst" > # compute fitted values > fitted <- quadFuncCalc( c( "qLabor", "land", "qVarInput" ), + shifterNames = c( "reUnif" ), data = germanFarms, + coef( estResultShifterLogi ) ) > all.equal( fitted, estResultShifterLogi$fitted ) [1] TRUE > all.equal( fitted, predict( estResultShifterLogi ) ) [1] TRUE > all.equal( fitted, predict( estResultShifterLogi, newdata = germanFarms ) ) [1] TRUE > > ## estimate a quadratic production function with a factor as shifter > germanFarms$decade <- as.factor( c( rep( "70s", 5 ), rep( "80s", 10 ), + rep( "90s", 5 ) ) ) > estResultShifterFac <- quadFuncEst( yName = "qOutput", + xNames = c( "qLabor", "land", "qVarInput" ), + shifterNames = c( "decade" ), data = germanFarms ) > coef( estResultShifterFac ) a_0 a_1 a_2 a_3 b_1_1 b_1_2 b_1_3 b_2_2 -1.93e+04 1.69e+04 4.38e+02 9.90e-01 -5.07e+03 -2.05e+02 -4.85e+00 -1.18e+00 b_2_3 b_3_3 d_1_80s d_1_90s -2.07e-02 1.13e-02 7.61e+00 -8.29e+01 > print( estResultShifterFac ) $call quadFuncEst(yName = "qOutput", xNames = c("qLabor", "land", "qVarInput"), data = germanFarms, shifterNames = c("decade")) $nExog [1] 3 $nShifter [1] 1 $est Call: lm(formula = as.formula(estFormula), data = estData) Coefficients: (Intercept) a_1 a_2 a_3 b_1_1 b_1_2 -1.93e+04 1.69e+04 4.38e+02 9.90e-01 -5.07e+03 -2.05e+02 b_1_3 b_2_2 b_2_3 b_3_3 d_1_80s d_1_90s -4.85e+00 -1.18e+00 -2.07e-02 1.13e-02 7.61e+00 -8.29e+01 $residuals 1 2 3 4 5 6 7 8 9 10 11 20.42 -64.92 8.65 12.73 23.11 -1.57 -6.41 21.06 24.80 -27.53 -18.46 12 13 14 15 16 17 18 19 20 15.59 -17.66 5.49 4.69 13.40 -21.93 2.04 12.90 -6.41 $fitted 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 926 1028 1061 1159 1155 1187 1246 1268 1183 1306 1379 1525 1593 1690 1640 1613 17 18 19 20 1677 1754 1875 1998 $coef a_0 a_1 a_2 a_3 b_1_1 b_1_2 b_1_3 b_2_2 -1.93e+04 1.69e+04 4.38e+02 9.90e-01 -5.07e+03 -2.05e+02 -4.85e+00 -1.18e+00 b_2_3 b_3_3 d_1_80s d_1_90s -2.07e-02 1.13e-02 7.61e+00 -8.29e+01 $coefCov a_0 a_1 a_2 a_3 b_1_1 b_1_2 b_1_3 a_0 4.05e+07 -4.55e+07 -1.07e+06 2.78e+04 21264944 5.08e+05 -1.30e+03 a_1 -4.55e+07 8.74e+07 -1.67e+05 -5.80e+04 -87097217 3.34e+05 5.54e+04 a_2 -1.07e+06 -1.67e+05 1.57e+05 -2.72e+03 1180373 -9.06e+04 1.05e+03 a_3 2.78e+04 -5.80e+04 -2.72e+03 1.55e+02 86227 1.36e+03 -1.60e+02 b_1_1 2.13e+07 -8.71e+07 1.18e+06 8.62e+04 131222698 -9.60e+05 -1.30e+05 b_1_2 5.08e+05 3.34e+05 -9.06e+04 1.36e+03 -960052 5.57e+04 -4.76e+02 b_1_3 -1.30e+03 5.54e+04 1.05e+03 -1.60e+02 -129947 -4.76e+02 2.28e+02 b_2_2 -4.57e+03 4.64e+03 2.07e+02 -5.82e+00 -815 -1.07e+02 -1.20e-01 b_2_3 5.41e+02 -7.19e+02 -2.26e+01 9.46e-01 536 5.39e+00 -3.50e-01 b_3_3 -6.04e+01 -9.12e+00 2.43e+00 9.65e-02 144 -1.07e+00 -2.69e-01 d_1_80s 1.12e+05 -3.20e+03 -8.74e+03 3.02e+01 -128559 4.88e+03 1.07e+02 d_1_90s 2.30e+05 -4.66e+04 -1.79e+04 1.48e+02 -159729 9.07e+03 8.61e+01 b_2_2 b_2_3 b_3_3 d_1_80s d_1_90s a_0 -4.57e+03 5.41e+02 -6.04e+01 1.12e+05 2.30e+05 a_1 4.64e+03 -7.19e+02 -9.12e+00 -3.20e+03 -4.66e+04 a_2 2.07e+02 -2.26e+01 2.43e+00 -8.74e+03 -1.79e+04 a_3 -5.82e+00 9.46e-01 9.65e-02 3.02e+01 1.48e+02 b_1_1 -8.15e+02 5.36e+02 1.44e+02 -1.29e+05 -1.60e+05 b_1_2 -1.07e+02 5.39e+00 -1.07e+00 4.88e+03 9.07e+03 b_1_3 -1.20e-01 -3.50e-01 -2.69e-01 1.07e+02 8.61e+01 b_2_2 9.93e+00 -4.96e-01 2.97e-02 -8.48e-01 1.07e+01 b_2_3 -4.96e-01 4.10e-02 -2.31e-03 1.14e+00 3.41e+00 b_3_3 2.97e-02 -2.31e-03 5.65e-04 -3.30e-01 -5.29e-01 d_1_80s -8.48e-01 1.14e+00 -3.30e-01 1.36e+03 2.13e+03 d_1_90s 1.07e+01 3.41e+00 -5.29e-01 2.13e+03 6.18e+03 $r2 [1] 0.995 $r2bar [1] 0.988 $nObs [1] 20 $yName [1] "qOutput" $xNames [1] "qLabor" "land" "qVarInput" $shifterNames [1] "decade" $regScale [1] 1 $model.matrix (Intercept) a_1 a_2 a_3 b_1_1 b_1_2 b_1_3 b_2_2 b_2_3 b_3_3 d_1_80s 1 1 1.44 23.4 557 1.04 33.7 801 274 13023 154872 0 2 1 1.45 24.2 607 1.05 35.1 880 293 14681 184006 0 3 1 1.44 24.7 608 1.04 35.6 875 305 15009 184781 0 4 1 1.48 24.9 654 1.10 36.9 968 310 16290 213832 0 5 1 1.48 24.9 648 1.10 36.9 958 310 16132 209710 0 6 1 1.47 25.2 657 1.08 37.1 966 318 16576 215817 1 7 1 1.45 25.9 673 1.05 37.6 977 336 17449 226774 1 8 1 1.49 26.0 648 1.11 38.7 965 337 16826 209890 1 9 1 1.48 25.2 640 1.10 37.3 947 317 16115 204785 1 10 1 1.53 26.1 648 1.17 39.9 992 340 16906 210262 1 11 1 1.53 26.8 682 1.17 41.0 1044 358 18267 232820 1 12 1 1.69 29.9 761 1.43 50.5 1286 446 22730 289533 1 13 1 1.70 31.1 801 1.44 52.9 1362 484 24927 321010 1 14 1 1.67 32.2 798 1.39 53.8 1332 518 25681 318247 1 15 1 1.65 31.5 737 1.36 52.0 1216 497 23230 271572 1 16 1 1.61 31.9 719 1.30 51.3 1157 508 22914 258318 0 17 1 1.62 33.5 701 1.31 54.3 1135 562 23501 245488 0 18 1 1.62 35.1 702 1.31 56.8 1137 615 24605 246256 0 19 1 1.62 37.3 731 1.31 60.4 1185 696 27283 267367 0 20 1 1.62 39.4 770 1.31 63.8 1248 776 30337 296583 0 d_1_90s 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 0 12 0 13 0 14 0 15 0 16 1 17 1 18 1 19 1 20 1 attr(,"assign") [1] 0 1 2 3 4 5 6 7 8 9 10 10 attr(,"contrasts") attr(,"contrasts")$d_1_ [1] "contr.treatment" attr(,"class") [1] "quadFuncEst" > # compute fitted values > fitted <- quadFuncCalc( c( "qLabor", "land", "qVarInput" ), + shifterNames = c( "decade" ), data = germanFarms, + coef( estResultShifterFac ) ) > all.equal( fitted, estResultShifterFac$fitted ) [1] TRUE > all.equal( fitted, predict( estResultShifterFac ) ) [1] TRUE > all.equal( fitted, predict( estResultShifterFac, newdata = germanFarms ) ) [1] TRUE > > ## estimate a quadratic production function with some shifters are logical > estResultShifterLogi2 <- quadFuncEst( yName = "qOutput", + xNames = c( "qLabor", "land", "qVarInput" ), + shifterNames = c( "time", "reUnif" ), data = germanFarms ) > coef( estResultShifterLogi2 ) a_0 a_1 a_2 a_3 b_1_1 b_1_2 b_1_3 b_2_2 -1.61e+04 1.39e+04 3.62e+02 1.73e+00 -3.73e+03 -1.67e+02 -5.11e+00 -8.85e-01 b_2_3 b_3_3 d_1 d_2_TRUE -1.95e-02 1.08e-02 5.35e+00 -8.70e+01 > print( estResultShifterLogi2 ) $call quadFuncEst(yName = "qOutput", xNames = c("qLabor", "land", "qVarInput"), data = germanFarms, shifterNames = c("time", "reUnif")) $nExog [1] 3 $nShifter [1] 2 $est Call: lm(formula = as.formula(estFormula), data = estData) Coefficients: (Intercept) a_1 a_2 a_3 b_1_1 b_1_2 -1.61e+04 1.39e+04 3.62e+02 1.73e+00 -3.73e+03 -1.67e+02 b_1_3 b_2_2 b_2_3 b_3_3 d_1 d_2_TRUE -5.11e+00 -8.85e-01 -1.95e-02 1.08e-02 5.35e+00 -8.70e+01 $residuals 1 2 3 4 5 6 7 8 9 10 20.280 -62.629 9.130 16.474 22.003 0.344 -7.456 25.574 13.685 -26.917 11 12 13 14 15 16 17 18 19 20 -18.702 17.405 -20.083 7.416 3.476 13.421 -22.091 1.947 13.494 -6.772 $fitted 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 926 1025 1060 1155 1156 1185 1247 1263 1194 1305 1379 1523 1595 1689 1641 1613 17 18 19 20 1677 1754 1874 1999 $coef a_0 a_1 a_2 a_3 b_1_1 b_1_2 b_1_3 b_2_2 -1.61e+04 1.39e+04 3.62e+02 1.73e+00 -3.73e+03 -1.67e+02 -5.11e+00 -8.85e-01 b_2_3 b_3_3 d_1 d_2_TRUE -1.95e-02 1.08e-02 5.35e+00 -8.70e+01 $coefCov a_0 a_1 a_2 a_3 b_1_1 b_1_2 b_1_3 a_0 8.13e+07 -84219919 -2.01e+06 3.68e+04 39262698 9.77e+05 -5.29e+03 a_1 -8.42e+07 116647378 1.14e+06 -6.59e+04 -91400577 -3.56e+05 5.04e+04 a_2 -2.01e+06 1140366 1.53e+05 -2.85e+03 69726 -8.61e+04 1.54e+03 a_3 3.68e+04 -65896 -2.85e+03 1.53e+02 88472 1.42e+03 -1.56e+02 b_1_1 3.93e+07 -91400577 6.97e+04 8.85e+04 116928660 -3.41e+05 -1.16e+05 b_1_2 9.77e+05 -355785 -8.61e+04 1.42e+03 -340778 5.20e+04 -7.57e+02 b_1_3 -5.29e+03 50423 1.54e+03 -1.56e+02 -115613 -7.57e+02 2.14e+02 b_2_2 -4.62e+02 1420 6.72e+01 -4.69e+00 -234 -3.42e+01 2.96e-01 b_2_3 5.35e+02 -775 -1.82e+01 9.18e-01 641 3.00e+00 -4.18e-01 b_3_3 -6.33e+01 15 1.31e+00 9.33e-02 104 -4.20e-01 -2.39e-01 d_1 7.18e+04 -56612 -2.36e+03 1.72e+01 11662 1.23e+03 6.37e+00 d_2_TRUE 1.56e+05 -122693 -7.50e+03 1.23e+02 57774 3.15e+03 -6.97e+01 b_2_2 b_2_3 b_3_3 d_1 d_2_TRUE a_0 -462.1618 5.35e+02 -6.33e+01 7.18e+04 1.56e+05 a_1 1419.5359 -7.75e+02 1.50e+01 -5.66e+04 -1.23e+05 a_2 67.1620 -1.82e+01 1.31e+00 -2.36e+03 -7.50e+03 a_3 -4.6929 9.18e-01 9.33e-02 1.72e+01 1.23e+02 b_1_1 -234.0715 6.41e+02 1.04e+02 1.17e+04 5.78e+04 b_1_2 -34.1784 3.00e+00 -4.20e-01 1.23e+03 3.15e+03 b_1_3 0.2961 -4.18e-01 -2.39e-01 6.37e+00 -6.97e+01 b_2_2 9.9432 -4.73e-01 2.62e-02 5.49e+00 1.97e+01 b_2_3 -0.4734 3.91e-02 -2.03e-03 1.43e-01 1.78e+00 b_3_3 0.0262 -2.03e-03 4.89e-04 -4.38e-02 -7.41e-02 d_1 5.4950 1.43e-01 -4.38e-02 1.01e+02 1.47e+02 d_2_TRUE 19.7059 1.78e+00 -7.41e-02 1.47e+02 2.96e+03 $r2 [1] 0.995 $r2bar [1] 0.988 $nObs [1] 20 $yName [1] "qOutput" $xNames [1] "qLabor" "land" "qVarInput" $shifterNames [1] "time" "reUnif" $regScale [1] 1 $model.matrix (Intercept) a_1 a_2 a_3 b_1_1 b_1_2 b_1_3 b_2_2 b_2_3 b_3_3 d_1 d_2_TRUE 1 1 1.44 23.4 557 1.04 33.7 801 274 13023 154872 1 0 2 1 1.45 24.2 607 1.05 35.1 880 293 14681 184006 2 0 3 1 1.44 24.7 608 1.04 35.6 875 305 15009 184781 3 0 4 1 1.48 24.9 654 1.10 36.9 968 310 16290 213832 4 0 5 1 1.48 24.9 648 1.10 36.9 958 310 16132 209710 5 0 6 1 1.47 25.2 657 1.08 37.1 966 318 16576 215817 6 0 7 1 1.45 25.9 673 1.05 37.6 977 336 17449 226774 7 0 8 1 1.49 26.0 648 1.11 38.7 965 337 16826 209890 8 0 9 1 1.48 25.2 640 1.10 37.3 947 317 16115 204785 9 0 10 1 1.53 26.1 648 1.17 39.9 992 340 16906 210262 10 0 11 1 1.53 26.8 682 1.17 41.0 1044 358 18267 232820 11 0 12 1 1.69 29.9 761 1.43 50.5 1286 446 22730 289533 12 0 13 1 1.70 31.1 801 1.44 52.9 1362 484 24927 321010 13 0 14 1 1.67 32.2 798 1.39 53.8 1332 518 25681 318247 14 0 15 1 1.65 31.5 737 1.36 52.0 1216 497 23230 271572 15 0 16 1 1.61 31.9 719 1.30 51.3 1157 508 22914 258318 16 1 17 1 1.62 33.5 701 1.31 54.3 1135 562 23501 245488 17 1 18 1 1.62 35.1 702 1.31 56.8 1137 615 24605 246256 18 1 19 1 1.62 37.3 731 1.31 60.4 1185 696 27283 267367 19 1 20 1 1.62 39.4 770 1.31 63.8 1248 776 30337 296583 20 1 attr(,"assign") [1] 0 1 2 3 4 5 6 7 8 9 10 11 attr(,"contrasts") attr(,"contrasts")$d_2_ [1] "contr.treatment" attr(,"class") [1] "quadFuncEst" > # compute fitted values > fitted <- quadFuncCalc( c( "qLabor", "land", "qVarInput" ), + shifterNames = c( "time", "reUnif" ), data = germanFarms, + coef( estResultShifterLogi2 ) ) > all.equal( fitted, estResultShifterLogi2$fitted ) [1] TRUE > all.equal( fitted, predict( estResultShifterLogi2 ) ) [1] TRUE > all.equal( fitted, predict( estResultShifterLogi2, newdata = germanFarms ) ) [1] TRUE > > ## estimate a quadratic production function with some shifters are factors > estResultShifterFac2 <- quadFuncEst( yName = "qOutput", + xNames = c( "qLabor", "land", "qVarInput" ), + shifterNames = c( "time", "decade" ), data = germanFarms ) > coef( estResultShifterFac2 ) a_0 a_1 a_2 a_3 b_1_1 b_1_2 b_1_3 b_2_2 -1.53e+04 1.25e+04 3.85e+02 1.88e+00 -2.20e+03 -1.83e+02 -5.97e+00 -7.36e-01 b_2_3 b_3_3 d_1 d_2_80s d_2_90s -2.68e-02 1.29e-02 7.93e+00 -1.30e+01 -1.04e+02 > print( estResultShifterFac2 ) $call quadFuncEst(yName = "qOutput", xNames = c("qLabor", "land", "qVarInput"), data = germanFarms, shifterNames = c("time", "decade")) $nExog [1] 3 $nShifter [1] 2 $est Call: lm(formula = as.formula(estFormula), data = estData) Coefficients: (Intercept) a_1 a_2 a_3 b_1_1 b_1_2 -1.53e+04 1.25e+04 3.85e+02 1.88e+00 -2.20e+03 -1.83e+02 b_1_3 b_2_2 b_2_3 b_3_3 d_1 d_2_80s -5.97e+00 -7.36e-01 -2.68e-02 1.29e-02 7.93e+00 -1.30e+01 d_2_90s -1.04e+02 $residuals 1 2 3 4 5 6 7 8 9 10 11 20.44 -61.15 6.75 15.41 18.54 5.95 -8.59 28.47 13.03 -26.62 -20.55 12 13 14 15 16 17 18 19 20 18.13 -20.67 7.97 2.87 13.40 -22.01 1.49 14.17 -7.05 $fitted 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 926 1024 1063 1156 1160 1180 1248 1260 1195 1305 1381 1523 1596 1688 1642 1613 17 18 19 20 1677 1754 1873 1999 $coef a_0 a_1 a_2 a_3 b_1_1 b_1_2 b_1_3 b_2_2 -1.53e+04 1.25e+04 3.85e+02 1.88e+00 -2.20e+03 -1.83e+02 -5.97e+00 -7.36e-01 b_2_3 b_3_3 d_1 d_2_80s d_2_90s -2.68e-02 1.29e-02 7.93e+00 -1.30e+01 -1.04e+02 $coefCov a_0 a_1 a_2 a_3 b_1_1 b_1_2 b_1_3 a_0 1.03e+08 -1.15e+08 -1.96e+06 4.39e+04 6.59e+07 8.96e+05 -1.80e+04 a_1 -1.15e+08 1.69e+08 6.87e+05 -7.87e+04 -1.43e+08 -8.06e+03 7.94e+04 a_2 -1.96e+06 6.87e+05 1.83e+05 -3.17e+03 7.32e+05 -1.04e+05 1.38e+03 a_3 4.39e+04 -7.87e+04 -3.17e+03 1.74e+02 1.05e+05 1.57e+03 -1.80e+02 b_1_1 6.59e+07 -1.43e+08 7.32e+05 1.05e+05 1.75e+08 -8.13e+05 -1.55e+05 b_1_2 8.96e+05 -8.06e+03 -1.04e+05 1.57e+03 -8.13e+05 6.32e+04 -6.19e+02 b_1_3 -1.80e+04 7.94e+04 1.38e+03 -1.80e+02 -1.55e+05 -6.19e+02 2.56e+02 b_2_2 1.55e+03 -2.25e+03 1.40e+02 -4.91e+00 3.89e+03 -8.02e+01 -2.00e+00 b_2_3 5.06e+02 -6.91e+02 -2.37e+01 1.02e+00 5.24e+02 5.42e+00 -3.60e-01 b_3_3 -4.33e+01 -3.59e+01 2.36e+00 1.11e-01 1.76e+02 -1.04e+00 -3.03e-01 d_1 1.17e+05 -1.31e+05 -1.57e+03 2.66e+01 8.54e+04 6.76e+02 -3.33e+01 d_2_80s -1.81e+05 3.37e+05 -5.55e+03 -3.59e+01 -3.63e+05 3.62e+03 2.04e+02 d_2_90s -5.51e+04 2.93e+05 -1.56e+04 9.35e+01 -4.00e+05 8.21e+03 1.82e+02 b_2_2 b_2_3 b_3_3 d_1 d_2_80s d_2_90s a_0 1.55e+03 5.06e+02 -4.33e+01 1.17e+05 -1.81e+05 -5.51e+04 a_1 -2.25e+03 -6.91e+02 -3.59e+01 -1.31e+05 3.37e+05 2.93e+05 a_2 1.40e+02 -2.37e+01 2.36e+00 -1.57e+03 -5.55e+03 -1.56e+04 a_3 -4.91e+00 1.02e+00 1.11e-01 2.66e+01 -3.59e+01 9.35e+01 b_1_1 3.89e+03 5.24e+02 1.76e+02 8.54e+04 -3.63e+05 -4.00e+05 b_1_2 -8.02e+01 5.42e+00 -1.04e+00 6.76e+02 3.62e+03 8.21e+03 b_1_3 -2.00e+00 -3.60e-01 -3.03e-01 -3.33e+01 2.04e+02 1.82e+02 b_2_2 1.17e+01 -5.57e-01 3.53e-02 1.33e+01 -3.54e+01 -2.29e+01 b_2_3 -5.57e-01 4.53e-02 -2.58e-03 -1.80e-01 1.72e+00 4.22e+00 b_3_3 3.53e-02 -2.58e-03 6.31e-04 4.66e-02 -4.85e-01 -7.05e-01 d_1 1.33e+01 -1.80e-01 4.66e-02 2.36e+02 -6.13e+02 -6.19e+02 d_2_80s -3.54e+01 1.72e+00 -4.85e-01 -6.13e+02 3.09e+03 3.95e+03 d_2_90s -2.29e+01 4.22e+00 -7.05e-01 -6.19e+02 3.95e+03 8.42e+03 $r2 [1] 0.995 $r2bar [1] 0.987 $nObs [1] 20 $yName [1] "qOutput" $xNames [1] "qLabor" "land" "qVarInput" $shifterNames [1] "time" "decade" $regScale [1] 1 $model.matrix (Intercept) a_1 a_2 a_3 b_1_1 b_1_2 b_1_3 b_2_2 b_2_3 b_3_3 d_1 d_2_80s 1 1 1.44 23.4 557 1.04 33.7 801 274 13023 154872 1 0 2 1 1.45 24.2 607 1.05 35.1 880 293 14681 184006 2 0 3 1 1.44 24.7 608 1.04 35.6 875 305 15009 184781 3 0 4 1 1.48 24.9 654 1.10 36.9 968 310 16290 213832 4 0 5 1 1.48 24.9 648 1.10 36.9 958 310 16132 209710 5 0 6 1 1.47 25.2 657 1.08 37.1 966 318 16576 215817 6 1 7 1 1.45 25.9 673 1.05 37.6 977 336 17449 226774 7 1 8 1 1.49 26.0 648 1.11 38.7 965 337 16826 209890 8 1 9 1 1.48 25.2 640 1.10 37.3 947 317 16115 204785 9 1 10 1 1.53 26.1 648 1.17 39.9 992 340 16906 210262 10 1 11 1 1.53 26.8 682 1.17 41.0 1044 358 18267 232820 11 1 12 1 1.69 29.9 761 1.43 50.5 1286 446 22730 289533 12 1 13 1 1.70 31.1 801 1.44 52.9 1362 484 24927 321010 13 1 14 1 1.67 32.2 798 1.39 53.8 1332 518 25681 318247 14 1 15 1 1.65 31.5 737 1.36 52.0 1216 497 23230 271572 15 1 16 1 1.61 31.9 719 1.30 51.3 1157 508 22914 258318 16 0 17 1 1.62 33.5 701 1.31 54.3 1135 562 23501 245488 17 0 18 1 1.62 35.1 702 1.31 56.8 1137 615 24605 246256 18 0 19 1 1.62 37.3 731 1.31 60.4 1185 696 27283 267367 19 0 20 1 1.62 39.4 770 1.31 63.8 1248 776 30337 296583 20 0 d_2_90s 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0 11 0 12 0 13 0 14 0 15 0 16 1 17 1 18 1 19 1 20 1 attr(,"assign") [1] 0 1 2 3 4 5 6 7 8 9 10 11 11 attr(,"contrasts") attr(,"contrasts")$d_2_ [1] "contr.treatment" attr(,"class") [1] "quadFuncEst" > # compute fitted values > fitted <- quadFuncCalc( c( "qLabor", "land", "qVarInput" ), + shifterNames = c( "time", "decade" ), data = germanFarms, + coef( estResultShifterFac2 ) ) > all.equal( fitted, estResultShifterFac2$fitted ) [1] TRUE > all.equal( fitted, predict( estResultShifterFac2 ) ) [1] TRUE > all.equal( fitted, predict( estResultShifterFac2, newdata = germanFarms ) ) [1] TRUE > > ## estimate with further argument passed to lm() > estResult2 <- quadFuncEst( yName = "qOutput", + xNames = c( "qLabor", "land", "qVarInput", "time" ), + germanFarms, x = TRUE, y = TRUE ) > coef( estResult2 ) a_0 a_1 a_2 a_3 a_4 b_1_1 b_1_2 b_1_3 -1.89e+04 1.64e+04 2.89e+01 1.92e+01 -1.50e+02 -1.14e+04 2.45e+02 -5.29e+00 b_1_4 b_2_2 b_2_3 b_2_4 b_3_3 b_3_4 b_4_4 -1.45e+02 -4.79e+00 -3.67e-01 5.18e+00 -7.90e-03 5.06e-01 -1.30e+01 > print( estResult2 ) $call quadFuncEst(yName = "qOutput", xNames = c("qLabor", "land", "qVarInput", "time"), data = germanFarms, x = TRUE, y = TRUE) $nExog [1] 4 $nShifter [1] 0 $est Call: lm(formula = as.formula(estFormula), data = estData, x = TRUE, y = TRUE) Coefficients: (Intercept) a_1 a_2 a_3 a_4 b_1_1 -1.89e+04 1.64e+04 2.89e+01 1.92e+01 -1.50e+02 -1.14e+04 b_1_2 b_1_3 b_1_4 b_2_2 b_2_3 b_2_4 2.45e+02 -5.29e+00 -1.45e+02 -4.79e+00 -3.67e-01 5.18e+00 b_3_3 b_3_4 b_4_4 -7.90e-03 5.06e-01 -1.30e+01 $residuals 1 2 3 4 5 6 7 8 9 10 7.432 -39.365 21.652 32.467 -0.816 -21.651 -0.640 -4.241 12.971 -7.827 11 12 13 14 15 16 17 18 19 20 -2.867 2.988 -6.250 0.863 7.942 7.057 -20.630 13.722 -3.067 0.260 $fitted 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 939 1002 1048 1139 1179 1207 1240 1293 1195 1286 1363 1538 1581 1695 1637 1619 17 18 19 20 1676 1742 1890 1992 $coef a_0 a_1 a_2 a_3 a_4 b_1_1 b_1_2 b_1_3 -1.89e+04 1.64e+04 2.89e+01 1.92e+01 -1.50e+02 -1.14e+04 2.45e+02 -5.29e+00 b_1_4 b_2_2 b_2_3 b_2_4 b_3_3 b_3_4 b_4_4 -1.45e+02 -4.79e+00 -3.67e-01 5.18e+00 -7.90e-03 5.06e-01 -1.30e+01 $coefCov a_0 a_1 a_2 a_3 a_4 b_1_1 b_1_2 a_0 1.94e+08 -2.20e+08 -6.68e+06 1.05e+05 6.70e+06 1.13e+08 4.31e+06 a_1 -2.20e+08 2.81e+08 6.63e+06 -1.51e+05 -7.66e+06 -1.69e+08 -4.62e+06 a_2 -6.68e+06 6.63e+06 5.13e+05 -1.06e+04 -3.64e+05 -2.55e+06 -3.15e+05 a_3 1.05e+05 -1.51e+05 -1.06e+04 3.56e+02 6.68e+03 9.83e+04 6.98e+03 a_4 6.70e+06 -7.66e+06 -3.64e+05 6.68e+03 3.83e+05 3.87e+06 2.36e+05 b_1_1 1.13e+08 -1.69e+08 -2.55e+06 9.83e+04 3.87e+06 1.54e+08 1.38e+06 b_1_2 4.31e+06 -4.62e+06 -3.15e+05 6.98e+03 2.36e+05 1.38e+06 2.19e+05 b_1_3 -5.15e+04 8.65e+04 5.88e+03 -2.18e+02 -3.90e+03 -1.23e+05 -3.00e+03 b_1_4 -4.18e+06 5.22e+06 1.98e+05 -4.24e+03 -2.25e+05 -2.28e+06 -1.55e+05 b_2_2 -3.05e+04 5.44e+04 -4.26e+03 1.12e+02 1.34e+03 -2.62e+04 1.32e+03 b_2_3 2.27e+03 -2.43e+03 1.66e+01 -2.32e+00 4.27e+01 2.20e+03 -2.74e+01 b_2_4 -4.87e+04 4.09e+04 6.71e+03 -1.44e+02 -4.86e+03 -2.31e+04 -3.26e+03 b_3_3 -1.41e+02 1.45e+02 3.27e+00 3.76e-03 -3.92e+00 4.58e+01 -3.77e+00 b_3_4 3.10e+02 -8.51e+02 -9.78e+01 4.01e+00 5.87e+01 -3.90e+02 8.93e+01 b_4_4 8.31e+04 -8.74e+04 -5.40e+03 9.41e+01 5.21e+03 5.26e+04 2.81e+03 b_1_3 b_1_4 b_2_2 b_2_3 b_2_4 b_3_3 b_3_4 a_0 -5.15e+04 -4.18e+06 -3.05e+04 2.27e+03 -4.87e+04 -1.41e+02 310.0540 a_1 8.65e+04 5.22e+06 5.44e+04 -2.43e+03 4.09e+04 1.45e+02 -851.3935 a_2 5.88e+03 1.98e+05 -4.26e+03 1.66e+01 6.71e+03 3.27e+00 -97.8391 a_3 -2.18e+02 -4.24e+03 1.12e+02 -2.32e+00 -1.44e+02 3.76e-03 4.0064 a_4 -3.90e+03 -2.25e+05 1.34e+03 4.27e+01 -4.86e+03 -3.92e+00 58.7104 b_1_1 -1.23e+05 -2.28e+06 -2.62e+04 2.20e+03 -2.31e+04 4.58e+01 -390.2702 b_1_2 -3.00e+03 -1.55e+05 1.32e+03 -2.74e+01 -3.26e+03 -3.77e+00 89.3295 b_1_3 2.47e+02 1.53e+03 -8.48e+01 -8.32e-02 1.01e+02 -2.22e-01 -0.6176 b_1_4 1.53e+03 1.63e+05 9.87e+02 -1.76e+01 1.55e+03 4.53e+00 -60.5660 b_2_2 -8.48e+01 9.87e+02 2.33e+02 -3.65e+00 -1.69e+02 1.56e-01 1.4021 b_2_3 -8.32e-02 -1.76e+01 -3.65e+00 1.66e-01 1.60e+00 -2.07e-03 -0.0899 b_2_4 1.01e+02 1.55e+03 -1.69e+02 1.60e+00 1.67e+02 -5.80e-02 -1.3807 b_3_3 -2.22e-01 4.53e+00 1.56e-01 -2.07e-03 -5.80e-02 6.19e-04 -0.0022 b_3_4 -6.18e-01 -6.06e+01 1.40e+00 -8.99e-02 -1.38e+00 -2.20e-03 0.0971 b_4_4 -7.19e+01 -2.31e+03 8.05e+01 1.74e-01 -1.10e+02 8.29e-03 0.4406 b_4_4 a_0 8.31e+04 a_1 -8.74e+04 a_2 -5.40e+03 a_3 9.41e+01 a_4 5.21e+03 b_1_1 5.26e+04 b_1_2 2.81e+03 b_1_3 -7.19e+01 b_1_4 -2.31e+03 b_2_2 8.05e+01 b_2_3 1.74e-01 b_2_4 -1.10e+02 b_3_3 8.29e-03 b_3_4 4.41e-01 b_4_4 1.01e+02 $r2 [1] 0.997 $r2bar [1] 0.99 $nObs [1] 20 $yName [1] "qOutput" $xNames [1] "qLabor" "land" "qVarInput" "time" $regScale [1] 1 $model.matrix (Intercept) a_1 a_2 a_3 a_4 b_1_1 b_1_2 b_1_3 b_1_4 b_2_2 b_2_3 b_2_4 1 1 1.44 23.4 557 1 1.04 33.7 801 1.44 274 13023 23.4 2 1 1.45 24.2 607 2 1.05 35.1 880 2.90 293 14681 48.4 3 1 1.44 24.7 608 3 1.04 35.6 875 4.32 305 15009 74.1 4 1 1.48 24.9 654 4 1.10 36.9 968 5.92 310 16290 99.6 5 1 1.48 24.9 648 5 1.10 36.9 958 7.40 310 16132 124.5 6 1 1.47 25.2 657 6 1.08 37.1 966 8.82 318 16576 151.4 7 1 1.45 25.9 673 7 1.05 37.6 977 10.15 336 17449 181.4 8 1 1.49 26.0 648 8 1.11 38.7 965 11.92 337 16826 207.8 9 1 1.48 25.2 640 9 1.10 37.3 947 13.32 317 16115 226.6 10 1 1.53 26.1 648 10 1.17 39.9 992 15.30 340 16906 260.7 11 1 1.53 26.8 682 11 1.17 41.0 1044 16.83 358 18267 294.5 12 1 1.69 29.9 761 12 1.43 50.5 1286 20.28 446 22730 358.4 13 1 1.70 31.1 801 13 1.44 52.9 1362 22.10 484 24927 404.4 14 1 1.67 32.2 798 14 1.39 53.8 1332 23.38 518 25681 450.7 15 1 1.65 31.5 737 15 1.36 52.0 1216 24.75 497 23230 472.8 16 1 1.61 31.9 719 16 1.30 51.3 1157 25.76 508 22914 510.1 17 1 1.62 33.5 701 17 1.31 54.3 1135 27.54 562 23501 570.2 18 1 1.62 35.1 702 18 1.31 56.8 1137 29.16 615 24605 631.1 19 1 1.62 37.3 731 19 1.31 60.4 1185 30.78 696 27283 708.9 20 1 1.62 39.4 770 20 1.31 63.8 1248 32.40 776 30337 787.8 b_3_3 b_3_4 b_4_4 1 154872 557 0.5 2 184006 1213 2.0 3 184781 1824 4.5 4 213832 2616 8.0 5 209710 3238 12.5 6 215817 3942 18.0 7 226774 4714 24.5 8 209890 5183 32.0 9 204785 5760 40.5 10 210262 6485 50.0 11 232820 7506 60.5 12 289533 9132 72.0 13 321010 10416 84.5 14 318247 11169 98.0 15 271572 11055 112.5 16 258318 11500 128.0 17 245488 11912 144.5 18 246256 12632 162.0 19 267367 13894 180.5 20 296583 15403 200.0 attr(,"assign") [1] 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 attr(,"class") [1] "quadFuncEst" > > ## calculating elasticities > estElaFit <- quadFuncEla( + xNames = c( "qLabor", "land", "qVarInput", "time" ), + data = germanFarms, coef = coef( estResult ) ) > all.equal( estElaFit, elas( estResult ) ) [1] TRUE > print( estElaFit ) qLabor land qVarInput time 1 3.907 1.75 -0.5199 0.0335 2 3.210 1.35 -0.6738 0.0928 3 3.163 1.31 -0.4316 0.1091 4 1.961 1.15 -0.5131 0.1538 5 1.755 1.27 -0.1855 0.1171 6 1.701 1.21 0.0163 0.1116 7 1.825 1.02 0.1424 0.1367 8 1.277 1.47 0.3692 -0.0444 9 1.148 1.74 0.8830 -0.2021 10 0.455 1.88 0.7543 -0.2965 11 0.258 1.61 0.7394 -0.2447 12 -1.541 1.60 -0.3078 -0.0827 13 -1.689 1.37 -0.4775 0.0147 14 -1.073 1.20 -0.3044 -0.0249 15 -0.854 1.72 0.3115 -0.4342 16 -0.347 1.76 0.6310 -0.6121 17 -0.103 1.92 0.5887 -0.7804 18 0.108 1.88 0.5428 -0.8420 19 0.314 1.52 0.3074 -0.6823 20 0.427 1.15 0.0889 -0.5061 > estElaObs <- quadFuncEla( + xNames = c( "qLabor", "land", "qVarInput", "time" ), + data = germanFarms, coef = coef( estResult ), + yName = "qOutput" ) > all.equal( estElaObs, elas( estResult, yObs = TRUE ) ) [1] TRUE > print( estElaObs ) qLabor land qVarInput time 1 3.876 1.74 -0.5159 0.0332 2 3.341 1.40 -0.7014 0.0966 3 3.099 1.29 -0.4228 0.1069 4 1.906 1.12 -0.4989 0.1495 5 1.757 1.27 -0.1856 0.1172 6 1.732 1.23 0.0166 0.1136 7 1.826 1.02 0.1425 0.1368 8 1.282 1.47 0.3704 -0.0446 9 1.136 1.72 0.8735 -0.1999 10 0.458 1.89 0.7589 -0.2983 11 0.259 1.61 0.7410 -0.2452 12 -1.538 1.60 -0.3072 -0.0826 13 -1.696 1.37 -0.4794 0.0147 14 -1.073 1.20 -0.3042 -0.0249 15 -0.850 1.71 0.3100 -0.4321 16 -0.346 1.76 0.6283 -0.6095 17 -0.104 1.94 0.5961 -0.7901 18 0.107 1.87 0.5386 -0.8354 19 0.315 1.52 0.3079 -0.6834 20 0.427 1.15 0.0888 -0.5060 > max( abs( estElaFit - estElaObs ) ) [1] 0.131 > # only at mean values > estElaMeanFit <- elas( estResult, data = germanFarmsMeans ) > print( estElaMeanFit ) qLabor land qVarInput time 1 0.56 1.35 0.118 -0.0898 > estElaMeanObs <- elas( estResult, data = germanFarmsMeans, yObs = TRUE ) > print( estElaMeanObs ) qLabor land qVarInput time 1 0.616 1.49 0.13 -0.0989 > print( estElaMeanFit - estElaMeanObs ) qLabor land qVarInput time 1 -0.0566 -0.136 -0.012 0.00908 > # with a shifter > estElaShifterFit <- quadFuncEla( + xNames = c( "qLabor", "land", "qVarInput" ), + data = germanFarms, coef = coef( estResultShifter ), + shifterNames = "time" ) > all.equal( estElaShifterFit, elas( estResultShifter ) ) [1] TRUE > print( estElaShifterFit ) qLabor land qVarInput 1 2.538 1.132 0.367 2 1.688 1.072 0.590 3 1.607 1.086 0.636 4 0.949 0.957 0.685 5 1.005 0.951 0.647 6 0.887 0.961 0.730 7 0.689 0.983 0.884 8 0.823 0.903 0.586 9 1.012 0.921 0.587 10 0.703 0.812 0.425 11 0.336 0.807 0.581 12 -0.906 0.606 0.399 13 -1.293 0.605 0.558 14 -1.208 0.632 0.635 15 -0.702 0.637 0.425 16 -0.493 0.677 0.469 17 -0.497 0.658 0.374 18 -0.592 0.655 0.385 19 -0.884 0.659 0.505 20 -1.175 0.661 0.651 > estElaShifterObs <- quadFuncEla( + xNames = c( "qLabor", "land", "qVarInput" ), + data = germanFarms, coef = coef( estResultShifter ), + yName = "qOutput" ) > all.equal( estElaShifterObs, elas( estResultShifter, yObs = TRUE ) ) [1] TRUE > print( estElaShifterObs ) qLabor land qVarInput 1 2.490 1.111 0.360 2 1.803 1.145 0.630 3 1.578 1.066 0.624 4 0.940 0.949 0.679 5 0.992 0.940 0.639 6 0.892 0.966 0.734 7 0.692 0.987 0.887 8 0.796 0.874 0.567 9 1.011 0.920 0.586 10 0.713 0.824 0.431 11 0.338 0.812 0.584 12 -0.898 0.600 0.395 13 -1.317 0.616 0.568 14 -1.196 0.626 0.629 15 -0.691 0.626 0.418 16 -0.499 0.685 0.475 17 -0.507 0.671 0.381 18 -0.590 0.652 0.384 19 -0.874 0.651 0.499 20 -1.181 0.664 0.654 > max( abs( estElaShifterFit - estElaShifterObs ) ) [1] 0.115 > estElaShifterObs2 <- quadFuncEla( + xNames = c( "qLabor", "land", "qVarInput" ), + data = germanFarms, coef = coef( estResultShifter ), + yName = "qOutput", shifterNames = "time" ) > all.equal( estElaShifterObs, estElaShifterObs2 ) [1] TRUE > # only at mean values > estElaShifterMeanFit <- elas( estResultShifter, data = germanFarmsMeans ) > print( estElaShifterMeanFit ) qLabor land qVarInput 1 0.0631 0.775 0.526 > estElaShifterMeanObs <- elas( estResultShifter, data = germanFarmsMeans, + yObs = TRUE ) > print( estElaShifterMeanObs ) qLabor land qVarInput 1 0.0653 0.802 0.544 > print( estElaShifterMeanFit - estElaShifterMeanObs ) qLabor land qVarInput 1 -0.00216 -0.0265 -0.018 > > > ################ imposing homogeneity ##################### > ## linear functions with homogeneity imposed > estResultLinHom <- quadFuncEst( yName = "qOutput", + xNames = c( "time", "qLabor", "land", "qVarInput" ), + data = germanFarms, linear = TRUE, + homWeights = c( qLabor = 0.2, land = 0.5, qVarInput = 0.3 ) ) > coef( estResultLinHom ) a_0 a_1 a_2 a_3 a_4 b_1_1 b_1_2 b_1_3 b_1_4 b_2_2 -204866 35 -169744 107691 62053 0 0 0 0 0 b_2_3 b_2_4 b_3_3 b_3_4 b_4_4 0 0 0 0 0 > all.equal( sum( coef( estResultLinHom )[3:4] ), - coef( estResultLinHom )[5], + check.attributes = FALSE ) [1] TRUE > vcov( estResultLinHom ) a_0 a_1 a_2 a_3 a_4 b_1_1 b_1_2 b_1_3 b_1_4 a_0 2.85e+09 197398.2 2.34e+09 -1.48e+09 -8.60e+08 0 0 0 0 a_1 1.97e+05 23.5 1.65e+05 -1.06e+05 -5.95e+04 0 0 0 0 a_2 2.34e+09 165444.1 1.93e+09 -1.22e+09 -7.07e+08 0 0 0 0 a_3 -1.48e+09 -105986.7 -1.22e+09 7.74e+08 4.47e+08 0 0 0 0 a_4 -8.60e+08 -59457.3 -7.07e+08 4.47e+08 2.59e+08 0 0 0 0 b_1_1 0.00e+00 0.0 0.00e+00 0.00e+00 0.00e+00 0 0 0 0 b_1_2 0.00e+00 0.0 0.00e+00 0.00e+00 0.00e+00 0 0 0 0 b_1_3 0.00e+00 0.0 0.00e+00 0.00e+00 0.00e+00 0 0 0 0 b_1_4 0.00e+00 0.0 0.00e+00 0.00e+00 0.00e+00 0 0 0 0 b_2_2 0.00e+00 0.0 0.00e+00 0.00e+00 0.00e+00 0 0 0 0 b_2_3 0.00e+00 0.0 0.00e+00 0.00e+00 0.00e+00 0 0 0 0 b_2_4 0.00e+00 0.0 0.00e+00 0.00e+00 0.00e+00 0 0 0 0 b_3_3 0.00e+00 0.0 0.00e+00 0.00e+00 0.00e+00 0 0 0 0 b_3_4 0.00e+00 0.0 0.00e+00 0.00e+00 0.00e+00 0 0 0 0 b_4_4 0.00e+00 0.0 0.00e+00 0.00e+00 0.00e+00 0 0 0 0 b_2_2 b_2_3 b_2_4 b_3_3 b_3_4 b_4_4 a_0 0 0 0 0 0 0 a_1 0 0 0 0 0 0 a_2 0 0 0 0 0 0 a_3 0 0 0 0 0 0 a_4 0 0 0 0 0 0 b_1_1 0 0 0 0 0 0 b_1_2 0 0 0 0 0 0 b_1_3 0 0 0 0 0 0 b_1_4 0 0 0 0 0 0 b_2_2 0 0 0 0 0 0 b_2_3 0 0 0 0 0 0 b_2_4 0 0 0 0 0 0 b_3_3 0 0 0 0 0 0 b_3_4 0 0 0 0 0 0 b_4_4 0 0 0 0 0 0 > all.equal( rowSums( vcov( estResultLinHom )[ , 3:4 ] ), + - vcov( estResultLinHom )[ , 5 ] ) [1] TRUE > all.equal( colSums( vcov( estResultLinHom )[ 3:4, ] ), + - vcov( estResultLinHom )[ 5, ] ) [1] TRUE > # different order of weights > estResultLinHom2 <- quadFuncEst( yName = "qOutput", + xNames = c( "time", "qLabor", "land", "qVarInput" ), + data = germanFarms, linear = TRUE, + homWeights = c( qVarInput = 0.3, land = 0.5, qLabor = 0.2 ) ) > all.equal( coef( estResultLinHom ), coef( estResultLinHom2 ) ) [1] TRUE > all.equal( vcov( estResultLinHom ), vcov( estResultLinHom2 ) ) [1] TRUE > # different order of xNames > estResultLinHom3 <- quadFuncEst( yName = "qOutput", + xNames = c( "qLabor", "land", "qVarInput", "time" ), + data = germanFarms, linear = TRUE, + homWeights = c( qLabor = 0.2, land = 0.5, qVarInput = 0.3 ) ) > all.equal( coef( estResultLinHom ), + coef( estResultLinHom3 )[ c( 1, 5, 2:4, 6:15 ) ], + check.attributes = FALSE ) [1] TRUE > all.equal( vcov( estResultLinHom ), + vcov( estResultLinHom3 )[ c( 1, 5, 2:4, 6:15 ), c( 1, 5, 2:4, 6:15 ) ], + check.attributes = FALSE ) [1] TRUE > # homogenous in all variables > estResultLinHom4 <- quadFuncEst( yName = "qOutput", + xNames = c( "time", "qLabor", "land", "qVarInput" ), + data = germanFarms, linear = TRUE, + homWeights = c( qLabor = 0.2, land = 0.5, qVarInput = 0.3, time = 0 ) ) > coef( estResultLinHom4 ) a_0 a_1 a_2 a_3 a_4 b_1_1 b_1_2 b_1_3 b_1_4 b_2_2 -281898 6871 -240607 148456 85281 0 0 0 0 0 b_2_3 b_2_4 b_3_3 b_3_4 b_4_4 0 0 0 0 0 > all.equal( sum( coef( estResultLinHom4 )[2:4] ), + - coef( estResultLinHom4 )[5], check.attributes = FALSE ) [1] TRUE > vcov( estResultLinHom4 ) a_0 a_1 a_2 a_3 a_4 b_1_1 b_1_2 b_1_3 b_1_4 a_0 4.02e+09 62725525 3.24e+09 -2.08e+09 -1.21e+09 0 0 0 0 a_1 6.27e+07 1980508 5.08e+07 -3.38e+07 -1.89e+07 0 0 0 0 a_2 3.24e+09 50755181 2.60e+09 -1.68e+09 -9.76e+08 0 0 0 0 a_3 -2.08e+09 -33849741 -1.68e+09 1.08e+09 6.29e+08 0 0 0 0 a_4 -1.21e+09 -18885947 -9.76e+08 6.29e+08 3.66e+08 0 0 0 0 b_1_1 0.00e+00 0 0.00e+00 0.00e+00 0.00e+00 0 0 0 0 b_1_2 0.00e+00 0 0.00e+00 0.00e+00 0.00e+00 0 0 0 0 b_1_3 0.00e+00 0 0.00e+00 0.00e+00 0.00e+00 0 0 0 0 b_1_4 0.00e+00 0 0.00e+00 0.00e+00 0.00e+00 0 0 0 0 b_2_2 0.00e+00 0 0.00e+00 0.00e+00 0.00e+00 0 0 0 0 b_2_3 0.00e+00 0 0.00e+00 0.00e+00 0.00e+00 0 0 0 0 b_2_4 0.00e+00 0 0.00e+00 0.00e+00 0.00e+00 0 0 0 0 b_3_3 0.00e+00 0 0.00e+00 0.00e+00 0.00e+00 0 0 0 0 b_3_4 0.00e+00 0 0.00e+00 0.00e+00 0.00e+00 0 0 0 0 b_4_4 0.00e+00 0 0.00e+00 0.00e+00 0.00e+00 0 0 0 0 b_2_2 b_2_3 b_2_4 b_3_3 b_3_4 b_4_4 a_0 0 0 0 0 0 0 a_1 0 0 0 0 0 0 a_2 0 0 0 0 0 0 a_3 0 0 0 0 0 0 a_4 0 0 0 0 0 0 b_1_1 0 0 0 0 0 0 b_1_2 0 0 0 0 0 0 b_1_3 0 0 0 0 0 0 b_1_4 0 0 0 0 0 0 b_2_2 0 0 0 0 0 0 b_2_3 0 0 0 0 0 0 b_2_4 0 0 0 0 0 0 b_3_3 0 0 0 0 0 0 b_3_4 0 0 0 0 0 0 b_4_4 0 0 0 0 0 0 > all.equal( rowSums( vcov( estResultLinHom4 )[ , 2:4 ] ), + - vcov( estResultLinHom4 )[ , 5 ] ) [1] TRUE > all.equal( colSums( vcov( estResultLinHom4 )[ 2:4, ] ), + - vcov( estResultLinHom4 )[ 5, ] ) [1] TRUE > > ## computing fitted values of linear functions with homogeneity imposed > fitted <- quadFuncCalc( + xNames = c( "time", "qLabor", "land", "qVarInput" ), + coef = coef( estResultLinHom ), data = germanFarms, + homWeights = c( qLabor = 0.2, land = 0.5, qVarInput = 0.3 ) ) > all.equal( estResultLinHom$fitted, fitted ) [1] TRUE > all.equal( fitted, predict( estResultLinHom ) ) [1] TRUE > all.equal( fitted, predict( estResultLinHom, newdata = germanFarms ) ) [1] TRUE > fitted <- quadFuncCalc( + xNames = c( "time", "qLabor", "land", "qVarInput" ), + coef = coef( estResultLinHom ), data = germanFarms, + homWeights = c( qVarInput = 0.3, land = 0.5, qLabor = 0.2 ) ) > all.equal( estResultLinHom$fitted, fitted ) [1] TRUE > fitted <- quadFuncCalc( + xNames = c( "time", "qLabor", "land", "qVarInput" ), + coef = coef( estResultLinHom2 ), data = germanFarms, + homWeights = c( qVarInput = 0.3, land = 0.5, qLabor = 0.2 ) ) > all.equal( estResultLinHom2$fitted, fitted ) [1] TRUE > all.equal( fitted, predict( estResultLinHom2 ) ) [1] TRUE > all.equal( fitted, predict( estResultLinHom2, newdata = germanFarms ) ) [1] TRUE > fitted <- quadFuncCalc( + xNames = c( "qLabor", "land", "qVarInput", "time" ), + coef = coef( estResultLinHom3 ), data = germanFarms, + homWeights = c( qLabor = 0.2, land = 0.5, qVarInput = 0.3 ) ) > all.equal( estResultLinHom3$fitted, fitted ) [1] TRUE > all.equal( fitted, predict( estResultLinHom3 ) ) [1] TRUE > all.equal( fitted, predict( estResultLinHom3, newdata = germanFarms ) ) [1] TRUE > fitted <- quadFuncCalc( + xNames = c( "time", "qLabor", "land", "qVarInput" ), + coef = coef( estResultLinHom4 ), data = germanFarms, + homWeights = c( qLabor = 0.2, land = 0.5, qVarInput = 0.3, time = 0 ) ) > all.equal( estResultLinHom4$fitted, fitted ) [1] TRUE > all.equal( fitted, predict( estResultLinHom4 ) ) [1] TRUE > all.equal( fitted, predict( estResultLinHom4, newdata = germanFarms ) ) [1] TRUE > > ## derivatives of linear functions with homogeneity imposed > estResultLinHomDeriv <- quadFuncDeriv( + xNames = c( "time", "qLabor", "land", "qVarInput" ), + coef = coef( estResultLinHom ), data = germanFarms, + homWeights = c( qLabor = 0.2, land = 0.5, qVarInput = 0.3 ) ) > print( estResultLinHomDeriv ) time qLabor land qVarInput 1 35 -1178 27.0 1.912 2 35 -1085 24.6 1.610 3 35 -1082 24.5 1.567 4 35 -1009 22.8 1.416 5 35 -1019 23.0 1.443 6 35 -1004 22.6 1.378 7 35 -980 21.9 1.266 8 35 -1016 22.9 1.417 9 35 -1029 23.3 1.465 10 35 -1015 23.0 1.470 11 35 -966 21.7 1.313 12 35 -866 19.5 1.159 13 35 -823 18.4 1.033 14 35 -825 18.3 0.987 15 35 -889 19.9 1.140 16 35 -910 20.3 1.137 17 35 -928 20.7 1.154 18 35 -924 20.5 1.106 19 35 -885 19.5 0.965 20 35 -840 18.4 0.827 > all.equal( estResultLinHomDeriv$qLabor * germanFarms$qLabor + + estResultLinHomDeriv$land * germanFarms$land, + - estResultLinHomDeriv$qVarInput * germanFarms$qVarInput ) [1] TRUE > # different order of weights (different from order used for estimation) > estResultLinHom1Deriv <- quadFuncDeriv( + xNames = c( "time", "qLabor", "land", "qVarInput" ), + coef = coef( estResultLinHom ), data = germanFarms, + homWeights = c( qVarInput = 0.3, land = 0.5, qLabor = 0.2 ) ) > all.equal( estResultLinHomDeriv, estResultLinHom1Deriv ) [1] TRUE > # different order of weights (same order as used for estimation) > estResultLinHom2Deriv <- quadFuncDeriv( + xNames = c( "time", "qLabor", "land", "qVarInput" ), + coef = coef( estResultLinHom2 ), data = germanFarms, + homWeights = c( qVarInput = 0.3, land = 0.5, qLabor = 0.2 ) ) > all.equal( estResultLinHomDeriv, estResultLinHom2Deriv ) [1] TRUE > # different order of independent variables > estResultLinHom3Deriv <- quadFuncDeriv( + xNames = c( "qLabor", "land", "qVarInput", "time" ), + coef = coef( estResultLinHom3 ), data = germanFarms, + homWeights = c( qLabor = 0.2, land = 0.5, qVarInput = 0.3 ) ) > all.equal( estResultLinHomDeriv, + estResultLinHom3Deriv[ , c( 4, 1, 2, 3 ) ] ) [1] TRUE > # homogenous in all independent variables > estResultLinHom4Deriv <- quadFuncDeriv( + xNames = c( "time", "qLabor", "land", "qVarInput" ), + coef = coef( estResultLinHom4 ), data = germanFarms, + homWeights = c( qLabor = 0.2, land = 0.5, qVarInput = 0.3, time = 0 ) ) > print( estResultLinHom4Deriv ) time qLabor land qVarInput 1 38.4 -1661 39.6 2.563 2 35.3 -1529 36.0 2.101 3 35.2 -1524 35.7 1.985 4 32.9 -1423 33.2 1.754 5 33.2 -1436 33.4 1.739 6 32.7 -1415 32.8 1.609 7 31.9 -1381 31.7 1.420 8 33.1 -1431 33.0 1.559 9 33.5 -1451 33.5 1.567 10 33.1 -1430 33.0 1.538 11 31.5 -1361 31.1 1.323 12 28.2 -1221 27.9 1.170 13 26.8 -1160 26.3 1.004 14 26.9 -1162 26.2 0.904 15 29.0 -1253 28.3 1.005 16 29.6 -1282 28.8 0.934 17 30.2 -1308 29.3 0.889 18 30.1 -1302 29.0 0.785 19 28.8 -1248 27.5 0.610 20 27.4 -1184 25.9 0.454 > all.equal( estResultLinHom4Deriv$qLabor * germanFarms$qLabor + + estResultLinHom4Deriv$land * germanFarms$land + + estResultLinHom4Deriv$qVarInput * germanFarms$qVarInput, + - estResultLinHom4Deriv$time * germanFarms$time ) [1] TRUE > > ## quadratic functions with homogeneity imposed > estResultHom <- quadFuncEst( yName = "qOutput", + xNames = c( "time", "qLabor", "land", "qVarInput" ), + data = germanFarms, + homWeights = c( qLabor = 0.7, land = 0.1, qVarInput = 0.2 ) ) > coef( estResultHom ) a_0 a_1 a_2 a_3 a_4 b_1_1 b_1_2 b_1_3 -1.01e+08 -3.36e+04 -6.65e+07 2.60e+07 4.06e+07 -1.53e+00 -1.08e+04 4.02e+03 b_1_4 b_2_2 b_2_3 b_2_4 b_3_3 b_3_4 b_4_4 6.78e+03 -2.19e+07 8.51e+06 1.34e+07 -3.28e+06 -5.23e+06 -8.17e+06 > all.equal( sum( coef( estResultHom )[3:4] ), - coef( estResultHom )[5], + check.attributes = FALSE ) # a_2:4 [1] TRUE > all.equal( sum( coef( estResultHom )[7:8] ), - coef( estResultHom )[9], + check.attributes = FALSE ) # b_1_2:4 [1] TRUE > all.equal( sum( coef( estResultHom )[10:11] ), - coef( estResultHom )[12], + check.attributes = FALSE ) # b_2_2:4 [1] TRUE > all.equal( sum( coef( estResultHom )[13:14] ), - coef( estResultHom )[11], + check.attributes = FALSE ) # b_3_2:4 [1] TRUE > all.equal( sum( coef( estResultHom )[14:15] ), - coef( estResultHom )[12], + check.attributes = FALSE ) # b_4_2:4 [1] TRUE > vcov( estResultHom ) a_0 a_1 a_2 a_3 a_4 b_1_1 b_1_2 a_0 1.34e+16 3.83e+12 8.72e+15 -3.32e+15 -5.40e+15 6.19e+08 1.27e+12 a_1 3.83e+12 1.30e+09 2.54e+12 -9.90e+11 -1.55e+12 2.36e+05 4.41e+08 a_2 8.72e+15 2.54e+12 5.68e+15 -2.17e+15 -3.52e+15 4.13e+08 8.42e+11 a_3 -3.32e+15 -9.90e+11 -2.17e+15 8.32e+14 1.34e+15 -1.64e+08 -3.30e+11 a_4 -5.40e+15 -1.55e+12 -3.52e+15 1.34e+15 2.18e+15 -2.49e+08 -5.12e+11 b_1_1 6.19e+08 2.36e+05 4.13e+08 -1.64e+08 -2.49e+08 5.17e+01 8.06e+04 b_1_2 1.27e+12 4.41e+08 8.42e+11 -3.30e+11 -5.12e+11 8.06e+04 1.50e+08 b_1_3 -4.99e+11 -1.79e+08 -3.32e+11 1.31e+11 2.01e+11 -3.31e+04 -6.12e+07 b_1_4 -7.72e+11 -2.62e+08 -5.11e+11 1.99e+11 3.11e+11 -4.75e+04 -8.88e+07 b_2_2 2.85e+15 8.42e+11 1.86e+15 -7.11e+14 -1.15e+15 1.39e+08 2.80e+11 b_2_3 -1.09e+15 -3.31e+11 -7.13e+14 2.74e+14 4.38e+14 -5.54e+07 -1.11e+11 b_2_4 -1.76e+15 -5.11e+11 -1.15e+15 4.37e+14 7.09e+14 -8.32e+07 -1.70e+11 b_3_3 4.19e+14 1.32e+11 2.76e+14 -1.07e+14 -1.69e+14 2.25e+07 4.43e+10 b_3_4 6.68e+14 1.99e+11 4.37e+14 -1.68e+14 -2.69e+14 3.29e+07 6.65e+10 b_4_4 1.09e+15 3.11e+11 7.09e+14 -2.70e+14 -4.39e+14 5.02e+07 1.03e+11 b_1_3 b_1_4 b_2_2 b_2_3 b_2_4 b_3_3 b_3_4 a_0 -4.99e+11 -7.72e+11 2.85e+15 -1.09e+15 -1.76e+15 4.19e+14 6.68e+14 a_1 -1.79e+08 -2.62e+08 8.42e+11 -3.31e+11 -5.11e+11 1.32e+11 1.99e+11 a_2 -3.32e+11 -5.11e+11 1.86e+15 -7.13e+14 -1.15e+15 2.76e+14 4.37e+14 a_3 1.31e+11 1.99e+11 -7.11e+14 2.74e+14 4.37e+14 -1.07e+14 -1.68e+14 a_4 2.01e+11 3.11e+11 -1.15e+15 4.38e+14 7.09e+14 -1.69e+14 -2.69e+14 b_1_1 -3.31e+04 -4.75e+04 1.39e+08 -5.54e+07 -8.32e+07 2.25e+07 3.29e+07 b_1_2 -6.12e+07 -8.88e+07 2.80e+11 -1.11e+11 -1.70e+11 4.43e+10 6.65e+10 b_1_3 2.52e+07 3.60e+07 -1.11e+11 4.41e+10 6.68e+10 -1.78e+10 -2.63e+10 b_1_4 3.60e+07 5.28e+07 -1.69e+11 6.67e+10 1.03e+11 -2.65e+10 -4.01e+10 b_2_2 -1.11e+11 -1.69e+11 6.09e+14 -2.34e+14 -3.75e+14 9.09e+13 1.43e+14 b_2_3 4.41e+10 6.67e+10 -2.34e+14 9.07e+13 1.44e+14 -3.54e+13 -5.52e+13 b_2_4 6.68e+10 1.03e+11 -3.75e+14 1.44e+14 2.31e+14 -5.55e+13 -8.81e+13 b_3_3 -1.78e+10 -2.65e+10 9.09e+13 -3.54e+13 -5.55e+13 1.39e+13 2.15e+13 b_3_4 -2.63e+10 -4.01e+10 1.43e+14 -5.52e+13 -8.81e+13 2.15e+13 3.38e+13 b_4_4 -4.05e+10 -6.27e+10 2.31e+14 -8.84e+13 -1.43e+14 3.40e+13 5.43e+13 b_4_4 a_0 1.09e+15 a_1 3.11e+11 a_2 7.09e+14 a_3 -2.70e+14 a_4 -4.39e+14 b_1_1 5.02e+07 b_1_2 1.03e+11 b_1_3 -4.05e+10 b_1_4 -6.27e+10 b_2_2 2.31e+14 b_2_3 -8.84e+13 b_2_4 -1.43e+14 b_3_3 3.40e+13 b_3_4 5.43e+13 b_4_4 8.86e+13 > all.equal( rowSums( vcov( estResultHom )[ , 3:4 ] ), + - vcov( estResultHom )[ , 5 ] ) # a_2:4 [1] TRUE > all.equal( rowSums( vcov( estResultHom )[ , 7:8 ] ), + - vcov( estResultHom )[ , 9 ] ) # b_1_2:4 [1] TRUE > all.equal( rowSums( vcov( estResultHom )[ , 10:11 ] ), + - vcov( estResultHom )[ , 12 ] ) # b_2_2:4 [1] TRUE > all.equal( rowSums( vcov( estResultHom )[ , 13:14 ] ), + - vcov( estResultHom )[ , 11 ] ) # b_3_2:4 [1] TRUE > all.equal( rowSums( vcov( estResultHom )[ , 14:15 ] ), + - vcov( estResultHom )[ , 12 ] ) # b_4_2:4 [1] TRUE > all.equal( colSums( vcov( estResultHom )[ 3:4, ] ), + - vcov( estResultHom )[ 5, ] ) # a_2:4 [1] TRUE > all.equal( colSums( vcov( estResultHom )[ 7:8, ] ), + - vcov( estResultHom )[ 9, ] ) # b_1_2:4 [1] TRUE > all.equal( colSums( vcov( estResultHom )[ 10:11, ] ), + - vcov( estResultHom )[ 12, ] ) # b_2_2:4 [1] TRUE > all.equal( colSums( vcov( estResultHom )[ 13:14, ] ), + - vcov( estResultHom )[ 11, ] ) # b_3_2:4 [1] TRUE > all.equal( colSums( vcov( estResultHom )[ 14:15, ] ), + - vcov( estResultHom )[ 12, ] ) # b_4_2:4 [1] TRUE > # different order of weights > estResultHom2 <- quadFuncEst( yName = "qOutput", + xNames = c( "time", "qLabor", "land", "qVarInput" ), + data = germanFarms, + homWeights = c( qVarInput = 0.2, land = 0.1, qLabor = 0.7 ) ) > all.equal( coef( estResultHom ), coef( estResultHom2 ) ) [1] TRUE > all.equal( vcov( estResultHom ), vcov( estResultHom2 ) ) [1] TRUE > # different order of xNames > estResultHom3 <- quadFuncEst( yName = "qOutput", + xNames = c( "qLabor", "land", "qVarInput", "time" ), + data = germanFarms, + homWeights = c( qLabor = 0.7, land = 0.1, qVarInput = 0.2 ) ) > coefOrderHom3 <- c( 1, 5, 2:4, 15, 9, 12, 14, 6:8, 10, 11, 13 ) > all.equal( coef( estResultHom ), coef( estResultHom3 )[ coefOrderHom3 ], + check.attributes = FALSE ) [1] TRUE > all.equal( vcov( estResultHom ), + vcov( estResultHom3 )[ coefOrderHom3, coefOrderHom3 ], + check.attributes = FALSE ) [1] TRUE > # homogenous in all variables > estResultHom4 <- quadFuncEst( yName = "qOutput", + xNames = c( "time", "qLabor", "land", "qVarInput" ), + data = germanFarms, + homWeights = c( qLabor = 0.7, land = 0.1, qVarInput = 0.2, time = 0 ) ) > coef( estResultHom4 ) a_0 a_1 a_2 a_3 a_4 b_1_1 b_1_2 b_1_3 -1.33e+08 -8.59e+06 -7.99e+07 3.48e+07 5.37e+07 -1.33e+05 -2.67e+06 1.07e+06 b_1_4 b_2_2 b_2_3 b_2_4 b_3_3 b_3_4 b_4_4 1.73e+06 -2.39e+07 1.05e+07 1.61e+07 -4.58e+06 -7.00e+06 -1.08e+07 > all.equal( sum( coef( estResultHom4 )[2:4] ), - coef( estResultHom4 )[5], + check.attributes = FALSE ) # a_1:4 [1] TRUE > all.equal( sum( coef( estResultHom4 )[6:8] ), - coef( estResultHom4 )[9], + check.attributes = FALSE ) # b_1_1:4 [1] TRUE > all.equal( sum( coef( estResultHom4 )[10:12] ), - coef( estResultHom4 )[7], + check.attributes = FALSE ) # b_2_1:4 [1] TRUE > all.equal( sum( coef( estResultHom4 )[c(11,13,14)] ), - coef( estResultHom4 )[8], + check.attributes = FALSE ) # b_3_1:4 [1] TRUE > all.equal( sum( coef( estResultHom4 )[c(12,14,15)] ), - coef( estResultHom4 )[9], + check.attributes = FALSE ) # b_4_1:4 [1] TRUE > vcov( estResultHom4 ) a_0 a_1 a_2 a_3 a_4 b_1_1 b_1_2 a_0 1.23e+16 4.91e+14 7.41e+15 -2.94e+15 -4.97e+15 1.15e+13 1.48e+14 a_1 4.91e+14 2.88e+13 2.94e+14 -1.25e+14 -1.98e+14 8.54e+11 9.00e+12 a_2 7.41e+15 2.94e+14 4.47e+15 -1.77e+15 -2.99e+15 6.90e+12 8.88e+13 a_3 -2.94e+15 -1.25e+14 -1.77e+15 7.13e+14 1.19e+15 -3.12e+12 -3.80e+13 a_4 -4.97e+15 -1.98e+14 -2.99e+15 1.19e+15 2.00e+15 -4.63e+12 -5.98e+13 b_1_1 1.15e+13 8.54e+11 6.90e+12 -3.12e+12 -4.63e+12 3.58e+10 2.64e+11 b_1_2 1.48e+14 9.00e+12 8.88e+13 -3.80e+13 -5.98e+13 2.64e+11 2.83e+12 b_1_3 -6.08e+13 -4.07e+12 -3.64e+13 1.59e+13 2.45e+13 -1.28e+11 -1.29e+12 b_1_4 -9.89e+13 -5.78e+12 -5.93e+13 2.52e+13 3.99e+13 -1.72e+11 -1.81e+12 b_2_2 2.23e+15 8.83e+13 1.35e+15 -5.35e+14 -9.02e+14 2.08e+12 2.66e+13 b_2_3 -8.87e+14 -3.80e+13 -5.35e+14 2.16e+14 3.58e+14 -9.58e+11 -1.16e+13 b_2_4 -1.50e+15 -5.93e+13 -9.02e+14 3.58e+14 6.03e+14 -1.39e+12 -1.79e+13 b_3_3 3.55e+14 1.69e+13 2.14e+14 -8.78e+13 -1.43e+14 4.58e+11 5.18e+12 b_3_4 5.93e+14 2.52e+13 3.58e+14 -1.44e+14 -2.39e+14 6.28e+11 7.66e+12 b_4_4 1.00e+15 3.99e+13 6.03e+14 -2.39e+14 -4.04e+14 9.31e+11 1.20e+13 b_1_3 b_1_4 b_2_2 b_2_3 b_2_4 b_3_3 b_3_4 a_0 -6.08e+13 -9.89e+13 2.23e+15 -8.87e+14 -1.50e+15 3.55e+14 5.93e+14 a_1 -4.07e+12 -5.78e+12 8.83e+13 -3.80e+13 -5.93e+13 1.69e+13 2.52e+13 a_2 -3.64e+13 -5.93e+13 1.35e+15 -5.35e+14 -9.02e+14 2.14e+14 3.58e+14 a_3 1.59e+13 2.52e+13 -5.35e+14 2.16e+14 3.58e+14 -8.78e+13 -1.44e+14 a_4 2.45e+13 3.99e+13 -9.02e+14 3.58e+14 6.03e+14 -1.43e+14 -2.39e+14 b_1_1 -1.28e+11 -1.72e+11 2.08e+12 -9.58e+11 -1.39e+12 4.58e+11 6.28e+11 b_1_2 -1.29e+12 -1.81e+12 2.66e+13 -1.16e+13 -1.79e+13 5.18e+12 7.66e+12 b_1_3 5.99e+11 8.16e+11 -1.09e+13 4.85e+12 7.33e+12 -2.25e+12 -3.21e+12 b_1_4 8.16e+11 1.16e+12 -1.78e+13 7.66e+12 1.20e+13 -3.39e+12 -5.08e+12 b_2_2 -1.09e+13 -1.78e+13 4.07e+14 -1.62e+14 -2.72e+14 6.47e+13 1.08e+14 b_2_3 4.85e+12 7.66e+12 -1.62e+14 6.53e+13 1.08e+14 -2.67e+13 -4.35e+13 b_2_4 7.33e+12 1.20e+13 -2.72e+14 1.08e+14 1.82e+14 -4.32e+13 -7.21e+13 b_3_3 -2.25e+12 -3.39e+12 6.47e+13 -2.67e+13 -4.32e+13 1.12e+13 1.77e+13 b_3_4 -3.21e+12 -5.08e+12 1.08e+14 -4.35e+13 -7.21e+13 1.77e+13 2.90e+13 b_4_4 -4.94e+12 -8.04e+12 1.82e+14 -7.22e+13 -1.22e+14 2.89e+13 4.82e+13 b_4_4 a_0 1.00e+15 a_1 3.99e+13 a_2 6.03e+14 a_3 -2.39e+14 a_4 -4.04e+14 b_1_1 9.31e+11 b_1_2 1.20e+13 b_1_3 -4.94e+12 b_1_4 -8.04e+12 b_2_2 1.82e+14 b_2_3 -7.22e+13 b_2_4 -1.22e+14 b_3_3 2.89e+13 b_3_4 4.82e+13 b_4_4 8.16e+13 > all.equal( rowSums( vcov( estResultHom4 )[ , 2:4 ] ), + - vcov( estResultHom4 )[ , 5 ] ) # a_1:4 [1] TRUE > all.equal( rowSums( vcov( estResultHom4 )[ , 6:8 ] ), + - vcov( estResultHom4 )[ , 9 ] ) # b_1_1:4 [1] TRUE > all.equal( rowSums( vcov( estResultHom4 )[ , 10:12 ] ), + - vcov( estResultHom4 )[ , 7 ] ) # b_2_1:4 [1] TRUE > all.equal( rowSums( vcov( estResultHom4 )[ , c(11,13,14) ] ), + - vcov( estResultHom4 )[ , 8 ] ) # b_3_1:4 [1] TRUE > all.equal( rowSums( vcov( estResultHom4 )[ , c(12,14,15) ] ), + - vcov( estResultHom4 )[ , 9 ] ) # b_4_1:4 [1] TRUE > all.equal( colSums( vcov( estResultHom4 )[ 2:4, ] ), + - vcov( estResultHom4 )[ 5, ] ) # a_1:4 [1] TRUE > all.equal( colSums( vcov( estResultHom4 )[ 6:8, ] ), + - vcov( estResultHom4 )[ 9, ] ) # b_1_1:4 [1] TRUE > all.equal( colSums( vcov( estResultHom4 )[ 10:12, ] ), + - vcov( estResultHom4 )[ 7, ] ) # b_2_1:4 [1] TRUE > all.equal( colSums( vcov( estResultHom4 )[ c(11,13,14), ] ), + - vcov( estResultHom4 )[ 8, ] ) # b_3_1:4 [1] TRUE > all.equal( colSums( vcov( estResultHom4 )[ c(12,14,15), ] ), + - vcov( estResultHom4 )[ 9, ] ) # b_4_1:4 [1] TRUE > > ## computing fitted values of quadratic functions with homogeneity imposed > fitted <- quadFuncCalc( + xNames = c( "time", "qLabor", "land", "qVarInput" ), + coef = coef( estResultHom ), data = germanFarms, + homWeights = c( qLabor = 0.7, land = 0.1, qVarInput = 0.2 ) ) > all.equal( estResultHom$fitted, fitted ) [1] TRUE > all.equal( fitted, predict( estResultHom ) ) [1] TRUE > all.equal( fitted, predict( estResultHom, newdata = germanFarms ) ) [1] TRUE > fitted <- quadFuncCalc( + xNames = c( "time", "qLabor", "land", "qVarInput" ), + coef = coef( estResultHom ), data = germanFarms, + homWeights = c( qVarInput = 0.2, land = 0.1, qLabor = 0.7 ) ) > all.equal( estResultHom$fitted, fitted ) [1] TRUE > fitted <- quadFuncCalc( + xNames = c( "time", "qLabor", "land", "qVarInput" ), + coef = coef( estResultHom2 ), data = germanFarms, + homWeights = c( qVarInput = 0.2, land = 0.1, qLabor = 0.7 ) ) > all.equal( estResultHom2$fitted, fitted ) [1] TRUE > all.equal( fitted, predict( estResultHom2 ) ) [1] TRUE > all.equal( fitted, predict( estResultHom2, newdata = germanFarms ) ) [1] TRUE > fitted <- quadFuncCalc( + xNames = c( "qLabor", "land", "qVarInput", "time" ), + coef = coef( estResultHom3 ), data = germanFarms, + homWeights = c( qLabor = 0.7, land = 0.1, qVarInput = 0.2 ) ) > all.equal( estResultHom3$fitted, fitted ) [1] TRUE > all.equal( fitted, predict( estResultHom3 ) ) [1] TRUE > all.equal( fitted, predict( estResultHom3, newdata = germanFarms ) ) [1] TRUE > fitted <- quadFuncCalc( + xNames = c( "time", "qLabor", "land", "qVarInput" ), + coef = coef( estResultHom4 ), data = germanFarms, + homWeights = c( qLabor = 0.7, land = 0.1, qVarInput = 0.2, time = 0 ) ) > all.equal( estResultHom4$fitted, fitted ) [1] TRUE > all.equal( fitted, predict( estResultHom4 ) ) [1] TRUE > all.equal( fitted, predict( estResultHom4, newdata = germanFarms ) ) [1] TRUE > > ## derivatives of quadratic functions with homogeneity imposed > estResultHomDeriv <- quadFuncDeriv( + xNames = c( "time", "qLabor", "land", "qVarInput" ), + coef = coef( estResultHom ), data = germanFarms, + homWeights = c( qLabor = 0.7, land = 0.1, qVarInput = 0.2 ) ) > print( estResultHomDeriv ) time qLabor land qVarInput 1 5.57 -1158.7 26.07 1.902 2 30.04 -196.1 -7.96 0.786 3 34.40 -125.6 -10.41 0.720 4 42.46 -94.9 -18.44 0.917 5 38.42 -446.5 -10.24 1.414 6 44.69 -339.0 -15.22 1.343 7 57.50 71.6 -27.92 0.920 8 36.58 -982.6 1.84 2.186 9 30.55 -1519.1 12.35 3.027 10 23.94 -1935.7 24.14 3.597 11 38.90 -1416.0 6.83 2.907 12 41.00 -1343.6 6.32 2.736 13 54.71 -932.0 -6.17 2.217 14 62.76 -698.0 -11.59 1.929 15 44.58 -1522.6 11.80 2.904 16 47.90 -1493.2 11.61 2.830 17 45.49 -1589.5 19.15 2.758 18 51.17 -1385.5 16.05 2.396 19 68.46 -718.1 -1.17 1.651 20 85.95 -145.6 -17.41 1.196 > all.equal( estResultHomDeriv$qLabor * germanFarms$qLabor + + estResultHomDeriv$land * germanFarms$land, + - estResultHomDeriv$qVarInput * germanFarms$qVarInput ) [1] TRUE > # different order of weights (different from order used for estimation) > estResultHom1Deriv <- quadFuncDeriv( + xNames = c( "time", "qLabor", "land", "qVarInput" ), + coef = coef( estResultHom ), data = germanFarms, + homWeights = c( qVarInput = 0.2, land = 0.1, qLabor = 0.7 ) ) > all.equal( estResultHomDeriv, estResultHom1Deriv ) [1] TRUE > # different order of weights (same order as used for estimation) > estResultHom2Deriv <- quadFuncDeriv( + xNames = c( "time", "qLabor", "land", "qVarInput" ), + coef = coef( estResultHom2 ), data = germanFarms, + homWeights = c( qVarInput = 0.2, land = 0.1, qLabor = 0.7 ) ) > all.equal( estResultHomDeriv, estResultHom2Deriv ) [1] TRUE > # different order of independent variables > estResultHom3Deriv <- quadFuncDeriv( + xNames = c( "qLabor", "land", "qVarInput", "time" ), + coef = coef( estResultHom3 ), data = germanFarms, + homWeights = c( qLabor = 0.7, land = 0.1, qVarInput = 0.2 ) ) > all.equal( estResultHomDeriv, + estResultHom3Deriv[ , c( 4, 1, 2, 3 ) ] ) [1] TRUE > # homogenous in all independent variables > estResultHom4Deriv <- quadFuncDeriv( + xNames = c( "time", "qLabor", "land", "qVarInput" ), + coef = coef( estResultHom4 ), data = germanFarms, + homWeights = c( qLabor = 0.7, land = 0.1, qVarInput = 0.2, time = 0 ) ) > print( estResultHom4Deriv ) time qLabor land qVarInput 1 11.35 -606.9 7.66 1.2280 2 51.77 293.2 -19.61 -0.0891 3 56.28 192.5 -21.27 0.1301 4 60.85 77.0 -15.94 0.0607 5 49.44 -535.9 -1.18 0.8883 6 56.47 -529.6 -4.11 0.8270 7 75.52 -90.2 -19.94 0.1763 8 34.66 -1657.0 21.23 2.5316 9 16.83 -2579.7 46.59 3.8959 10 1.75 -3170.2 61.33 4.9871 11 26.67 -2422.8 39.55 3.4508 12 31.27 -1896.0 27.51 2.6378 13 50.76 -1241.4 8.37 1.4855 14 62.46 -991.2 -3.48 1.1191 15 31.21 -2455.0 31.00 3.5355 16 34.21 -2639.4 29.98 3.8210 17 29.73 -2955.8 30.48 4.6538 18 39.12 -2742.6 18.78 4.3895 19 69.07 -1651.7 -14.26 2.5918 20 96.01 -627.6 -42.79 1.0153 > all.equal( estResultHom4Deriv$qLabor * germanFarms$qLabor + + estResultHom4Deriv$land * germanFarms$land + + estResultHom4Deriv$qVarInput * germanFarms$qVarInput, + - estResultHom4Deriv$time * germanFarms$time ) [1] TRUE > > ## elasticities of quadratic functions with homogeneity imposed > estResultHomEla <- quadFuncEla( + xNames = c( "time", "qLabor", "land", "qVarInput" ), + coef = coef( estResultHom ), data = germanFarms, + homWeights = c( qLabor = 0.7, land = 0.1, qVarInput = 0.2 ) ) > all.equal( estResultHomEla, elas( estResultHom ) ) [1] TRUE > print( estResultHomEla ) time qLabor land qVarInput 1 0.00594 -1.7801 0.6507 1.129 2 0.05889 -0.2788 -0.1889 0.468 3 0.09824 -0.1722 -0.2447 0.417 4 0.15175 -0.1255 -0.4103 0.536 5 0.16670 -0.5735 -0.2213 0.795 6 0.22220 -0.4130 -0.3182 0.731 7 0.31842 0.0821 -0.5723 0.490 8 0.23342 -1.1677 0.0381 1.130 9 0.21589 -1.7652 0.2442 1.521 10 0.19018 -2.3527 0.4999 1.853 11 0.30331 -1.5358 0.1297 1.406 12 0.33426 -1.5428 0.1282 1.415 13 0.44241 -0.9856 -0.1194 1.105 14 0.52490 -0.6963 -0.2230 0.919 15 0.41674 -1.5656 0.2317 1.334 16 0.46079 -1.4454 0.2226 1.223 17 0.46322 -1.5425 0.3848 1.158 18 0.52712 -1.2846 0.3220 0.963 19 0.69109 -0.6180 -0.0232 0.641 20 0.86196 -0.1183 -0.3438 0.462 > all.equal( estResultHomEla$qLabor + estResultHomEla$land, + - estResultHomEla$qVarInput ) [1] TRUE > estResultHomElaObs <- quadFuncEla( + xNames = c( "time", "qLabor", "land", "qVarInput" ), + coef = coef( estResultHom ), data = germanFarms, yName = "qOutput", + homWeights = c( qLabor = 0.7, land = 0.1, qVarInput = 0.2 ) ) > all.equal( estResultHomElaObs, elas( estResultHom, yObs = TRUE ) ) [1] TRUE > print( estResultHomElaObs ) time qLabor land qVarInput 1 0.00589 -1.7635 0.6447 1.119 2 0.06240 -0.2954 -0.2001 0.496 3 0.09647 -0.1691 -0.2403 0.409 4 0.14494 -0.1199 -0.3919 0.512 5 0.16306 -0.5610 -0.2164 0.777 6 0.22610 -0.4203 -0.3238 0.744 7 0.32477 0.0838 -0.5838 0.500 8 0.22712 -1.1362 0.0370 1.099 9 0.22768 -1.8616 0.2576 1.604 10 0.18727 -2.3167 0.4923 1.824 11 0.31447 -1.5923 0.1344 1.458 12 0.31930 -1.4738 0.1225 1.351 13 0.45152 -1.0059 -0.1219 1.128 14 0.51808 -0.6873 -0.2201 0.907 15 0.40660 -1.5275 0.2261 1.301 16 0.47133 -1.4785 0.2277 1.251 17 0.46723 -1.5559 0.3881 1.168 18 0.52461 -1.2785 0.3205 0.958 19 0.68919 -0.6163 -0.0232 0.640 20 0.86298 -0.1184 -0.3442 0.463 > all.equal( estResultHomElaObs$qLabor + estResultHomElaObs$land, + - estResultHomElaObs$qVarInput ) [1] TRUE > max( abs( estResultHomEla - estResultHomElaObs ) ) [1] 0.0964 > # only at mean values > estResultHomElaMeanFit <- elas( estResultHom, data = germanFarmsMeans ) > print( estResultHomElaMeanFit ) time qLabor land qVarInput 1 0.351 -0.915 -0.0414 0.956 > estResultHomElaMeanObs <- elas( estResultHom, data = germanFarmsMeans, + yObs = TRUE ) > print( estResultHomElaMeanObs ) time qLabor land qVarInput 1 0.343 -0.894 -0.0405 0.935 > print( estResultHomElaMeanFit - estResultHomElaMeanObs ) time qLabor land qVarInput 1 0.00785 -0.0205 -0.000926 0.0214 > # different order of weights (different from order used for estimation) > estResultHom1Ela <- quadFuncEla( + xNames = c( "time", "qLabor", "land", "qVarInput" ), + coef = coef( estResultHom ), data = germanFarms, + homWeights = c( qVarInput = 0.2, land = 0.1, qLabor = 0.7 ) ) > all.equal( estResultHomEla, estResultHom1Ela ) [1] TRUE > estResultHom1ElaObs <- quadFuncEla( + xNames = c( "time", "qLabor", "land", "qVarInput" ), + coef = coef( estResultHom ), data = germanFarms, yName = "qOutput", + homWeights = c( qVarInput = 0.2, land = 0.1, qLabor = 0.7 ) ) > all.equal( estResultHomElaObs, estResultHom1ElaObs ) [1] TRUE > # different order of weights (same order as used for estimation) > estResultHom2Ela <- quadFuncEla( + xNames = c( "time", "qLabor", "land", "qVarInput" ), + coef = coef( estResultHom2 ), data = germanFarms, + homWeights = c( qVarInput = 0.2, land = 0.1, qLabor = 0.7 ) ) > all.equal( estResultHom2Ela, elas( estResultHom2 ) ) [1] TRUE > all.equal( estResultHomEla, estResultHom2Ela ) [1] TRUE > estResultHom2ElaObs <- quadFuncEla( + xNames = c( "time", "qLabor", "land", "qVarInput" ), + coef = coef( estResultHom2 ), data = germanFarms, yName = "qOutput", + homWeights = c( qVarInput = 0.2, land = 0.1, qLabor = 0.7 ) ) > all.equal( estResultHom2ElaObs, elas( estResultHom2, yObs = TRUE ) ) [1] TRUE > all.equal( estResultHomElaObs, estResultHom2ElaObs ) [1] TRUE > # different order of independent variables > estResultHom3Ela <- quadFuncEla( + xNames = c( "qLabor", "land", "qVarInput", "time" ), + coef = coef( estResultHom3 ), data = germanFarms, + homWeights = c( qLabor = 0.7, land = 0.1, qVarInput = 0.2 ) ) > all.equal( estResultHom3Ela, elas( estResultHom3 ) ) [1] TRUE > all.equal( estResultHomEla, estResultHom3Ela[ , c( 4, 1, 2, 3 ) ] ) [1] TRUE > estResultHom3ElaObs <- quadFuncEla( + xNames = c( "qLabor", "land", "qVarInput", "time" ), + coef = coef( estResultHom3 ), data = germanFarms, yName = "qOutput", + homWeights = c( qLabor = 0.7, land = 0.1, qVarInput = 0.2 ) ) > all.equal( estResultHom3ElaObs, elas( estResultHom3, yObs = TRUE ) ) [1] TRUE > all.equal( estResultHomElaObs, estResultHom3ElaObs[ , c( 4, 1, 2, 3 ) ] ) [1] TRUE > # homogenous in all independent variables > estResultHom4Ela <- quadFuncEla( + xNames = c( "time", "qLabor", "land", "qVarInput" ), + coef = coef( estResultHom4 ), data = germanFarms, + homWeights = c( qLabor = 0.7, land = 0.1, qVarInput = 0.2, time = 0 ) ) > all.equal( estResultHom4Ela, elas( estResultHom4 ) ) [1] TRUE > print( estResultHom4Ela ) time qLabor land qVarInput 1 0.0120 -0.922 0.1889 0.7207 2 0.1035 0.425 -0.4743 -0.0540 3 0.1620 0.266 -0.5038 0.0759 4 0.2200 0.103 -0.3588 0.0359 5 0.2133 -0.684 -0.0253 0.4964 6 0.2767 -0.636 -0.0847 0.4438 7 0.4077 -0.101 -0.3984 0.0916 8 0.2158 -1.921 0.4290 1.2764 9 0.1184 -2.983 0.9165 1.9479 10 0.0142 -3.940 1.2987 2.6268 11 0.2062 -2.605 0.7441 1.6549 12 0.2589 -2.211 0.5671 1.3853 13 0.4180 -1.337 0.1649 0.7539 14 0.5246 -0.993 -0.0672 0.5356 15 0.2919 -2.525 0.6091 1.6245 16 0.3253 -2.526 0.5680 1.6323 17 0.3043 -2.884 0.6157 1.9640 18 0.4053 -2.558 0.3790 1.7733 19 0.6917 -1.410 -0.2804 0.9989 20 0.9657 -0.511 -0.8477 0.3933 > all.equal( estResultHom4Ela$qLabor + estResultHom4Ela$land + + estResultHom4Ela$qVarInput, - estResultHom4Ela$time ) [1] TRUE > estResultHom4ElaObs <- quadFuncEla( + xNames = c( "time", "qLabor", "land", "qVarInput" ), + coef = coef( estResultHom4 ), data = germanFarms, yName = "qOutput", + homWeights = c( qLabor = 0.7, land = 0.1, qVarInput = 0.2, time = 0 ) ) > all.equal( estResultHom4ElaObs, elas( estResultHom4, yObs = TRUE ) ) [1] TRUE > print( estResultHom4ElaObs ) time qLabor land qVarInput 1 0.0120 -0.9237 0.1894 0.7224 2 0.1076 0.4416 -0.4930 -0.0562 3 0.1579 0.2591 -0.4909 0.0739 4 0.2077 0.0973 -0.3388 0.0339 5 0.2098 -0.6732 -0.0249 0.4883 6 0.2857 -0.6565 -0.0874 0.4582 7 0.4265 -0.1055 -0.4168 0.0958 8 0.2152 -1.9160 0.4279 1.2729 9 0.1254 -3.1613 0.9714 2.0645 10 0.0137 -3.7941 1.2507 2.5298 11 0.2156 -2.7244 0.7782 1.7307 12 0.2435 -2.0796 0.5333 1.3028 13 0.4190 -1.3399 0.1652 0.7557 14 0.5156 -0.9760 -0.0660 0.5264 15 0.2847 -2.4629 0.5940 1.5843 16 0.3366 -2.6134 0.5878 1.6890 17 0.3053 -2.8932 0.6176 1.9703 18 0.4011 -2.5308 0.3750 1.7547 19 0.6954 -1.4176 -0.2819 1.0042 20 0.9640 -0.5104 -0.8462 0.3926 > all.equal( estResultHom4ElaObs$qLabor + estResultHom4ElaObs$land + + estResultHom4ElaObs$qVarInput, - estResultHom4ElaObs$time ) [1] TRUE > max( abs( estResultHom4Ela - estResultHom4ElaObs ) ) [1] 0.179 > > > ################ panel data ##################### > data( "GrunfeldGreene", package = "systemfit" ) > ggData <- pdata.frame( GrunfeldGreene, c( "firm", "year" ), + row.names = FALSE ) > # fixed effects > ggResult <- quadFuncEst( "invest", c( "value", "capital" ), ggData ) > coef( ggResult ) a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 5.31e+01 5.09e-02 1.11e-01 7.57e-06 3.01e-05 1.23e-04 > print( ggResult ) $call quadFuncEst(yName = "invest", xNames = c("value", "capital"), data = ggData) $nExog [1] 2 $nShifter [1] 0 $est Model Formula: y ~ 1 + a_1 + a_2 + b_1_1 + b_1_2 + b_2_2 Coefficients: a_1 a_2 b_1_1 b_1_2 b_2_2 5.09e-02 1.11e-01 7.57e-06 3.01e-05 1.23e-04 $residuals 1 2 3 4 5 6 7 8 23.635 -41.940 -118.614 -58.222 -111.475 -12.191 33.871 73.225 9 10 11 12 13 14 15 16 64.460 99.762 52.975 133.058 40.606 -22.317 -76.567 -22.798 17 18 19 20 21 22 23 24 -78.565 -48.548 13.295 56.349 -14.090 -5.102 -17.699 -9.173 25 26 27 28 29 30 31 32 -23.801 -9.993 -7.286 -15.034 -23.932 -17.196 4.192 -17.690 33 34 35 36 37 38 39 40 -12.223 5.743 -3.850 9.235 55.734 31.056 32.819 38.289 41 42 43 44 45 46 47 48 46.468 1.453 -26.109 -10.358 -25.678 6.877 60.243 43.786 49 50 51 52 53 54 55 56 -4.914 -5.122 8.142 53.340 59.335 43.264 -8.029 -34.209 57 58 59 60 61 62 63 64 -15.819 -30.282 -54.723 -107.665 8.168 3.861 0.281 -3.820 65 66 67 68 69 70 71 72 -6.318 -3.064 20.735 10.922 -1.866 -2.584 -7.795 5.938 73 74 75 76 77 78 79 80 15.001 1.391 -13.081 -15.203 2.650 9.088 1.737 -26.043 81 82 83 84 85 86 87 88 -106.735 10.542 51.190 -120.742 -174.742 -149.817 46.361 27.408 89 90 91 92 93 94 95 96 -43.362 -99.465 -118.766 23.369 36.927 114.994 13.696 25.252 97 98 99 100 151.215 195.475 158.900 -41.700 $fitted 1 2 3 4 5 6 7 8 9 10 293.96 433.74 529.21 315.92 442.28 473.39 478.13 374.77 435.14 447.74 11 12 13 14 15 16 17 18 19 20 508.22 555.04 528.29 551.52 631.67 665.70 834.47 939.75 1291.11 1430.35 21 22 23 24 25 26 27 28 29 30 54.38 77.86 83.96 60.77 76.21 79.40 75.64 61.83 71.33 76.77 31 32 33 34 35 36 37 38 39 40 84.59 91.81 74.90 83.62 82.83 91.43 104.89 113.94 142.11 134.20 41 42 43 44 45 46 47 48 49 50 -13.37 43.55 103.31 54.96 73.78 67.52 52.76 48.11 66.21 61.92 51 52 53 54 55 56 57 58 59 60 85.46 106.56 87.87 103.04 106.33 127.71 151.02 187.58 234.22 297.26 61 62 63 64 65 66 67 68 69 70 4.76 22.04 34.77 26.71 25.16 31.63 27.77 32.42 38.89 40.39 71 72 73 74 75 76 77 78 79 80 47.07 47.52 40.56 48.17 45.12 47.44 51.73 62.69 88.34 94.64 81 82 83 84 85 86 87 88 89 90 316.64 344.76 418.71 383.04 405.14 411.42 426.44 418.19 404.96 387.66 91 92 93 94 95 96 97 98 99 100 377.47 396.93 383.57 379.51 391.40 393.55 436.98 449.73 482.10 501.00 $coef a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 5.31e+01 5.09e-02 1.11e-01 7.57e-06 3.01e-05 1.23e-04 $coefCov a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 a_0 NA NA NA NA NA NA a_1 NA 1.78e-03 -9.30e-04 -4.93e-07 2.11e-07 1.61e-07 a_2 NA -9.30e-04 4.60e-03 4.19e-07 -1.05e-06 3.04e-07 b_1_1 NA -4.93e-07 4.19e-07 1.64e-10 -1.40e-10 1.35e-10 b_1_2 NA 2.11e-07 -1.05e-06 -1.40e-10 7.16e-10 -2.47e-09 b_2_2 NA 1.61e-07 3.04e-07 1.35e-10 -2.47e-09 1.28e-08 $r2 [1] 0.841 $r2bar [1] 0.825 $nObs [1] 100 $yName [1] "invest" $xNames [1] "value" "capital" $regScale [1] 1 attr(,"class") [1] "quadFuncEst" > round( fitted( ggResult ), 2 ) 1 2 3 4 5 6 7 8 9 10 293.96 433.74 529.21 315.92 442.28 473.39 478.13 374.77 435.14 447.74 11 12 13 14 15 16 17 18 19 20 508.22 555.04 528.29 551.52 631.67 665.70 834.47 939.75 1291.11 1430.35 21 22 23 24 25 26 27 28 29 30 54.38 77.86 83.96 60.77 76.21 79.40 75.64 61.83 71.33 76.77 31 32 33 34 35 36 37 38 39 40 84.59 91.81 74.90 83.62 82.83 91.43 104.89 113.94 142.11 134.20 41 42 43 44 45 46 47 48 49 50 -13.37 43.55 103.31 54.96 73.78 67.52 52.76 48.11 66.21 61.92 51 52 53 54 55 56 57 58 59 60 85.46 106.56 87.87 103.04 106.33 127.71 151.02 187.58 234.22 297.26 61 62 63 64 65 66 67 68 69 70 4.76 22.04 34.77 26.71 25.16 31.63 27.77 32.42 38.89 40.39 71 72 73 74 75 76 77 78 79 80 47.07 47.52 40.56 48.17 45.12 47.44 51.73 62.69 88.34 94.64 81 82 83 84 85 86 87 88 89 90 316.64 344.76 418.71 383.04 405.14 411.42 426.44 418.19 404.96 387.66 91 92 93 94 95 96 97 98 99 100 377.47 396.93 383.57 379.51 391.40 393.55 436.98 449.73 482.10 501.00 > all.equal( predict( ggResult ), + fitted( ggResult ), check.attributes = FALSE ) [1] TRUE Warning message: In predict.quadFuncEst(ggResult) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > round( predict( ggResult, newdata = ggData ), 2 ) 1 2 3 4 5 6 7 8 9 10 11 246.2 386.0 481.5 268.2 394.6 425.7 430.4 327.1 387.4 400.0 460.5 12 13 14 15 16 17 18 19 20 21 22 507.3 480.6 503.8 584.0 618.0 786.8 892.0 1243.4 1382.6 76.3 99.8 23 24 25 26 27 28 29 30 31 32 33 105.9 82.7 98.2 101.3 97.6 83.8 93.3 98.7 106.5 113.8 96.8 34 35 36 37 38 39 40 41 42 43 44 105.6 104.8 113.4 126.8 135.9 164.1 156.2 132.8 189.7 249.4 201.1 45 46 47 48 49 50 51 52 53 54 55 219.9 213.7 198.9 194.2 212.3 208.1 231.6 252.7 234.0 249.2 252.5 56 57 58 59 60 61 62 63 64 65 66 273.8 297.1 333.7 380.4 443.4 63.2 80.5 93.2 85.2 83.6 90.1 67 68 69 70 71 72 73 74 75 76 77 86.2 90.9 97.3 98.8 105.5 106.0 99.0 106.6 103.6 105.9 110.2 78 79 80 81 82 83 84 85 86 87 88 121.1 146.8 153.1 137.8 166.0 239.9 204.2 226.3 232.6 247.6 239.4 89 90 91 92 93 94 95 96 97 98 99 226.2 208.9 198.7 218.1 204.8 200.7 212.6 214.7 258.2 270.9 303.3 100 322.2 Warning message: In predict.quadFuncEst(ggResult, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > all.equal( predict( ggResult, newdata = ggData ), + fitted( ggResult ), check.attributes = FALSE ) [1] "Mean relative difference: 0.364" Warning message: In predict.quadFuncEst(ggResult, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > all.equal( predict( ggResult, newdata = ggData ), + predict( ggResult ), check.attributes = FALSE ) [1] "Mean relative difference: 0.364" Warning messages: 1: In predict.quadFuncEst(ggResult, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects 2: In predict.quadFuncEst(ggResult) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > > # random effects > ggResultRan <- quadFuncEst( "invest", c( "value", "capital" ), ggData, + model = "random", random.method = "amemiya" ) > coef( ggResultRan ) a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 4.01e+01 6.11e-02 1.08e-01 5.29e-06 3.16e-05 1.19e-04 > print( ggResultRan ) $call quadFuncEst(yName = "invest", xNames = c("value", "capital"), data = ggData, model = "random", random.method = "amemiya") $nExog [1] 2 $nShifter [1] 0 $est Model Formula: y ~ 1 + a_1 + a_2 + b_1_1 + b_1_2 + b_2_2 Coefficients: (Intercept) a_1 a_2 b_1_1 b_1_2 b_2_2 4.01e+01 6.11e-02 1.08e-01 5.29e-06 3.16e-05 1.19e-04 $residuals 1 2 3 4 5 6 7 8 30.489 -37.455 -113.723 -50.463 -107.372 -8.195 37.747 79.291 9 10 11 12 13 14 15 16 68.702 103.831 56.861 136.608 45.925 -15.724 -71.424 -17.675 17 18 19 20 21 22 23 24 -75.541 -45.302 17.302 61.340 -13.827 -8.538 -21.467 -8.988 25 26 27 28 29 30 31 32 -25.766 -12.370 -8.906 -14.541 -25.080 -19.334 0.777 -21.434 33 34 35 36 37 38 39 40 -13.207 3.763 -4.794 7.409 53.009 29.323 28.872 37.217 41 42 43 44 45 46 47 48 32.492 -18.202 -49.605 -30.113 -46.625 -13.382 41.808 27.110 49 50 51 52 53 54 55 56 -22.633 -22.418 -11.230 32.823 42.565 27.120 -22.610 -50.059 57 58 59 60 61 62 63 64 -33.108 -49.166 -75.208 -130.070 5.897 -1.467 -6.907 -9.507 65 66 67 68 69 70 71 72 -11.626 -9.335 15.304 5.337 -7.893 -8.678 -14.858 -1.342 73 74 75 76 77 78 79 80 9.368 -4.914 -18.648 -21.249 -4.200 1.071 -8.882 -36.540 81 82 83 84 85 86 87 88 -81.050 33.255 69.379 -97.751 -152.654 -129.250 65.982 48.217 89 90 91 92 93 94 95 96 -21.462 -76.521 -96.152 44.684 59.959 139.253 37.763 49.261 97 98 99 100 171.400 216.559 181.193 -19.821 $fitted 1 2 3 4 5 6 7 8 287.111 429.255 524.323 308.163 438.172 469.395 474.253 368.709 9 10 11 12 13 14 15 16 430.898 443.669 504.339 551.492 522.975 544.924 626.524 660.575 17 18 19 20 21 22 23 24 831.441 936.502 1287.098 1425.360 54.117 81.298 87.727 60.588 25 26 27 28 29 30 31 32 78.176 81.780 77.256 61.341 72.480 78.904 88.003 95.554 33 34 35 36 37 38 39 40 75.887 85.597 83.774 93.251 107.611 115.677 146.058 135.273 41 42 43 44 45 46 47 48 0.608 63.202 126.805 74.713 94.725 87.782 71.192 64.790 49 50 51 52 53 54 55 56 83.933 79.218 104.830 127.077 104.635 119.180 120.910 143.559 57 58 59 60 61 62 63 64 168.308 206.466 254.708 319.670 7.033 27.367 41.957 32.397 65 66 67 68 69 70 71 72 30.466 37.905 33.206 38.003 44.913 46.488 54.128 54.802 73 74 75 76 77 78 79 80 46.192 54.474 50.688 53.489 58.580 70.709 98.962 105.140 81 82 83 84 85 86 87 88 290.950 322.045 400.521 360.051 383.054 390.850 406.818 397.383 89 90 91 92 93 94 95 96 383.062 364.721 354.852 375.616 360.541 355.247 367.337 369.539 97 98 99 100 416.800 428.641 459.807 479.121 $coef a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 4.01e+01 6.11e-02 1.08e-01 5.29e-06 3.16e-05 1.19e-04 $coefCov a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 a_0 4.60e+03 -1.67e+00 1.03e-01 4.08e-04 -4.74e-05 -4.82e-05 a_1 -1.67e+00 1.58e-03 -9.47e-04 -4.53e-07 2.08e-07 1.88e-07 a_2 1.03e-01 -9.47e-04 4.63e-03 4.24e-07 -1.05e-06 3.05e-07 b_1_1 4.08e-04 -4.53e-07 4.24e-07 1.56e-10 -1.40e-10 1.31e-10 b_1_2 -4.74e-05 2.08e-07 -1.05e-06 -1.40e-10 7.21e-10 -2.48e-09 b_2_2 -4.82e-05 1.88e-07 3.05e-07 1.31e-10 -2.48e-09 1.28e-08 $r2 [1] 0.838 $r2bar [1] 0.829 $nObs [1] 100 $yName [1] "invest" $xNames [1] "value" "capital" $regScale [1] 1 attr(,"class") [1] "quadFuncEst" > round( fitted( ggResultRan ), 2 ) 1 2 3 4 5 6 7 8 9 10 287.11 429.25 524.32 308.16 438.17 469.39 474.25 368.71 430.90 443.67 11 12 13 14 15 16 17 18 19 20 504.34 551.49 522.97 544.92 626.52 660.57 831.44 936.50 1287.10 1425.36 21 22 23 24 25 26 27 28 29 30 54.12 81.30 87.73 60.59 78.18 81.78 77.26 61.34 72.48 78.90 31 32 33 34 35 36 37 38 39 40 88.00 95.55 75.89 85.60 83.77 93.25 107.61 115.68 146.06 135.27 41 42 43 44 45 46 47 48 49 50 0.61 63.20 126.81 74.71 94.73 87.78 71.19 64.79 83.93 79.22 51 52 53 54 55 56 57 58 59 60 104.83 127.08 104.63 119.18 120.91 143.56 168.31 206.47 254.71 319.67 61 62 63 64 65 66 67 68 69 70 7.03 27.37 41.96 32.40 30.47 37.91 33.21 38.00 44.91 46.49 71 72 73 74 75 76 77 78 79 80 54.13 54.80 46.19 54.47 50.69 53.49 58.58 70.71 98.96 105.14 81 82 83 84 85 86 87 88 89 90 290.95 322.05 400.52 360.05 383.05 390.85 406.82 397.38 383.06 364.72 91 92 93 94 95 96 97 98 99 100 354.85 375.62 360.54 355.25 367.34 369.54 416.80 428.64 459.81 479.12 > unname( round( predict( ggResultRan ), 2 ) ) [1] 253.9 396.0 491.1 274.9 404.9 436.1 441.0 335.5 397.6 410.4 [11] 471.1 518.2 489.7 511.7 593.3 627.3 798.2 903.3 1253.8 1392.1 [21] 67.3 94.5 101.0 73.8 91.4 95.0 90.5 74.6 85.7 92.1 [31] 101.2 108.8 89.1 98.8 97.0 106.5 120.8 128.9 159.3 148.5 [41] 130.0 192.6 256.2 204.1 224.1 217.1 200.6 194.2 213.3 208.6 [51] 234.2 256.4 234.0 248.5 250.3 272.9 297.7 335.8 384.1 449.0 [61] 52.1 72.4 87.0 77.5 75.5 83.0 78.3 83.1 90.0 91.5 [71] 99.2 99.9 91.3 99.5 95.8 98.5 103.6 115.8 144.0 150.2 [81] 136.5 167.6 246.1 205.6 228.7 236.4 252.4 243.0 228.7 210.3 [91] 200.4 221.2 206.1 200.8 212.9 215.1 262.4 274.2 305.4 324.7 Warning message: In predict.quadFuncEst(ggResultRan) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > all.equal( predict( ggResultRan ), + fitted( ggResultRan ), check.attributes = FALSE ) [1] "Mean relative difference: 0.302" Warning message: In predict.quadFuncEst(ggResultRan) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > round( predict( ggResultRan, newdata = ggData ), 2 ) 1 2 3 4 5 6 7 8 9 10 11 253.9 396.0 491.1 274.9 404.9 436.1 441.0 335.5 397.6 410.4 471.1 12 13 14 15 16 17 18 19 20 21 22 518.2 489.7 511.7 593.3 627.3 798.2 903.3 1253.8 1392.1 67.3 94.5 23 24 25 26 27 28 29 30 31 32 33 101.0 73.8 91.4 95.0 90.5 74.6 85.7 92.1 101.2 108.8 89.1 34 35 36 37 38 39 40 41 42 43 44 98.8 97.0 106.5 120.8 128.9 159.3 148.5 130.0 192.6 256.2 204.1 45 46 47 48 49 50 51 52 53 54 55 224.1 217.1 200.6 194.2 213.3 208.6 234.2 256.4 234.0 248.5 250.3 56 57 58 59 60 61 62 63 64 65 66 272.9 297.7 335.8 384.1 449.0 52.1 72.4 87.0 77.5 75.5 83.0 67 68 69 70 71 72 73 74 75 76 77 78.3 83.1 90.0 91.5 99.2 99.9 91.3 99.5 95.8 98.5 103.6 78 79 80 81 82 83 84 85 86 87 88 115.8 144.0 150.2 136.5 167.6 246.1 205.6 228.7 236.4 252.4 243.0 89 90 91 92 93 94 95 96 97 98 99 228.7 210.3 200.4 221.2 206.1 200.8 212.9 215.1 262.4 274.2 305.4 100 324.7 Warning message: In predict.quadFuncEst(ggResultRan, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > all.equal( predict( ggResultRan, newdata = ggData ), + fitted( ggResultRan ), check.attributes = FALSE ) [1] "Mean relative difference: 0.302" Warning message: In predict.quadFuncEst(ggResultRan, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > all.equal( predict( ggResultRan, newdata = ggData ), + predict( ggResultRan ), check.attributes = FALSE ) [1] TRUE Warning messages: 1: In predict.quadFuncEst(ggResultRan, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects 2: In predict.quadFuncEst(ggResultRan) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > > ## panel data with a shifter > ggData$yearInt <- as.numeric( as.character( ggData$year ) ) > ggData$tech <- exp( ggData$yearInt - min( ggData$yearInt ) ) > # fixed effects > ggResShifter <- quadFuncEst( "invest", c( "value", "capital" ), ggData, + shifterNames = "tech" ) > coef( ggResShifter ) a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 d_1 5.34e+01 5.07e-02 1.10e-01 7.59e-06 3.02e-05 1.22e-04 3.02e-09 > printQuadFuncEst( ggResShifter ) $call quadFuncEst(yName = "invest", xNames = c("value", "capital"), data = ggData, shifterNames = "tech") $nExog [1] 2 $nShifter [1] 1 $est Model Formula: y ~ 1 + a_1 + a_2 + b_1_1 + b_1_2 + b_2_2 + d_1 Coefficients: a_1 a_2 b_1_1 b_1_2 b_2_2 d_1 5.07e-02 1.10e-01 7.59e-06 3.02e-05 1.22e-04 3.02e-09 $residuals 1 2 3 4 5 6 7 8 23.535 -41.895 -118.560 -58.353 -111.490 -12.188 33.861 73.137 9 10 11 12 13 14 15 16 64.423 99.752 52.976 133.036 40.612 -22.246 -76.474 -22.680 17 18 19 20 21 22 23 24 -78.517 -48.462 13.172 56.363 -14.135 -5.075 -17.657 -9.199 25 26 27 28 29 30 31 32 -23.783 -9.966 -7.270 -15.058 -23.928 -17.177 4.234 -17.632 33 34 35 36 37 38 39 40 -12.210 5.778 -3.819 9.281 55.795 31.099 32.794 37.927 41 42 43 44 45 46 47 48 46.316 1.417 -26.052 -10.383 -25.676 6.868 60.208 43.743 49 50 51 52 53 54 55 56 -4.930 -5.144 8.151 53.373 59.361 43.325 -7.942 -34.103 57 58 59 60 61 62 63 64 -15.708 -30.181 -54.703 -107.942 8.100 3.850 0.309 -3.818 65 66 67 68 69 70 71 72 -6.321 -3.047 20.740 10.939 -1.832 -2.546 -7.739 5.996 73 74 75 76 77 78 79 80 15.039 1.449 -13.033 -15.156 2.691 9.110 1.688 -26.419 81 82 83 84 85 86 87 88 -106.833 10.508 51.271 -120.732 -174.702 -149.768 46.429 27.463 89 90 91 92 93 94 95 96 -43.322 -99.448 -118.763 23.400 36.937 114.998 13.717 25.270 97 98 99 100 151.265 195.499 158.863 -42.052 $fitted 1 2 3 4 5 6 7 8 9 10 294.07 433.69 529.16 316.05 442.29 473.39 478.14 374.86 435.18 447.75 11 12 13 14 15 16 17 18 19 20 508.22 555.06 528.29 551.45 631.57 665.58 834.42 939.66 1291.23 1430.34 21 22 23 24 25 26 27 28 29 30 54.43 77.83 83.92 60.80 76.19 79.38 75.62 61.86 71.33 76.75 31 32 33 34 35 36 37 38 39 40 84.55 91.75 74.89 83.58 82.80 91.38 104.82 113.90 142.14 134.56 41 42 43 44 45 46 47 48 49 50 -13.22 43.58 103.25 54.98 73.78 67.53 52.79 48.16 66.23 61.94 51 52 53 54 55 56 57 58 59 60 85.45 106.53 87.84 102.98 106.24 127.60 150.91 187.48 234.20 297.54 61 62 63 64 65 66 67 68 69 70 4.83 22.05 34.74 26.71 25.16 31.62 27.77 32.40 38.85 40.36 71 72 73 74 75 76 77 78 79 80 47.01 47.46 40.52 48.11 45.07 47.40 51.69 62.67 88.39 95.02 81 82 83 84 85 86 87 88 89 90 316.73 344.79 418.63 383.03 405.10 411.37 426.37 418.14 404.92 387.65 91 92 93 94 95 96 97 98 99 100 377.46 396.90 383.56 379.50 391.38 393.53 436.93 449.70 482.14 501.35 $coef a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 d_1 5.34e+01 5.07e-02 1.10e-01 7.59e-06 3.02e-05 1.22e-04 3.02e-09 $coefCov a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 d_1 a_0 NA NA NA NA NA NA NA a_1 NA 1.99e-03 -5.30e-04 -5.21e-07 5.10e-08 7.83e-07 -3.05e-09 a_2 NA -5.30e-04 5.55e-03 3.76e-07 -1.41e-06 1.66e-06 -6.62e-09 b_1_1 NA -5.21e-07 3.76e-07 1.68e-10 -1.22e-10 6.41e-11 3.54e-13 b_1_2 NA 5.10e-08 -1.41e-06 -1.22e-10 8.65e-10 -3.03e-09 2.63e-12 b_2_2 NA 7.83e-07 1.66e-06 6.41e-11 -3.03e-09 1.49e-08 -1.00e-11 d_1 NA -3.05e-09 -6.62e-09 3.54e-13 2.63e-12 -1.00e-11 4.91e-14 $r2 [1] 0.841 $r2bar [1] 0.823 $nObs [1] 100 $yName [1] "invest" $xNames [1] "value" "capital" $shifterNames [1] "tech" $regScale [1] 1 attr(,"class") [1] "quadFuncEst" > round( fitted( ggResShifter ), 2 ) 1 2 3 4 5 6 7 8 9 10 294.07 433.69 529.16 316.05 442.29 473.39 478.14 374.86 435.18 447.75 11 12 13 14 15 16 17 18 19 20 508.22 555.06 528.29 551.45 631.57 665.58 834.42 939.66 1291.23 1430.34 21 22 23 24 25 26 27 28 29 30 54.43 77.83 83.92 60.80 76.19 79.38 75.62 61.86 71.33 76.75 31 32 33 34 35 36 37 38 39 40 84.55 91.75 74.89 83.58 82.80 91.38 104.82 113.90 142.14 134.56 41 42 43 44 45 46 47 48 49 50 -13.22 43.58 103.25 54.98 73.78 67.53 52.79 48.16 66.23 61.94 51 52 53 54 55 56 57 58 59 60 85.45 106.53 87.84 102.98 106.24 127.60 150.91 187.48 234.20 297.54 61 62 63 64 65 66 67 68 69 70 4.83 22.05 34.74 26.71 25.16 31.62 27.77 32.40 38.85 40.36 71 72 73 74 75 76 77 78 79 80 47.01 47.46 40.52 48.11 45.07 47.40 51.69 62.67 88.39 95.02 81 82 83 84 85 86 87 88 89 90 316.73 344.79 418.63 383.03 405.10 411.37 426.37 418.14 404.92 387.65 91 92 93 94 95 96 97 98 99 100 377.46 396.90 383.56 379.50 391.38 393.53 436.93 449.70 482.14 501.35 > all.equal( predict( ggResShifter ), + fitted( ggResShifter ), check.attributes = FALSE ) [1] TRUE Warning message: In predict.quadFuncEst(ggResShifter) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > round( predict( ggResShifter, newdata = ggData ), 2 ) 1 2 3 4 5 6 7 8 9 10 11 246.1 385.7 481.2 268.1 394.3 425.4 430.1 326.9 387.2 399.8 460.2 12 13 14 15 16 17 18 19 20 21 22 507.1 480.3 503.5 583.6 617.6 786.4 891.7 1243.2 1382.3 76.5 100.0 23 24 25 26 27 28 29 30 31 32 33 106.0 82.9 98.3 101.5 97.8 84.0 93.5 98.9 106.7 113.9 97.0 34 35 36 37 38 39 40 41 42 43 44 105.7 104.9 113.5 127.0 136.0 164.3 156.7 132.8 189.6 249.3 201.0 45 46 47 48 49 50 51 52 53 54 55 219.8 213.6 198.8 194.2 212.3 208.0 231.5 252.6 233.9 249.0 252.3 56 57 58 59 60 61 62 63 64 65 66 273.6 297.0 333.5 380.2 443.6 63.5 80.7 93.4 85.4 83.8 90.3 67 68 69 70 71 72 73 74 75 76 77 86.4 91.0 97.5 99.0 105.7 106.1 99.2 106.8 103.7 106.0 110.3 78 79 80 81 82 83 84 85 86 87 88 121.3 147.0 153.7 137.9 165.9 239.8 204.2 226.3 232.5 247.5 239.3 89 90 91 92 93 94 95 96 97 98 99 226.1 208.8 198.6 218.1 204.7 200.7 212.5 214.7 258.1 270.9 303.3 100 322.5 Warning message: In predict.quadFuncEst(ggResShifter, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > all.equal( predict( ggResShifter, newdata = ggData ), + fitted( ggResShifter ), check.attributes = FALSE ) [1] "Mean relative difference: 0.364" Warning message: In predict.quadFuncEst(ggResShifter, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > all.equal( predict( ggResShifter, newdata = ggData ), + predict( ggResShifter ), check.attributes = FALSE ) [1] "Mean relative difference: 0.364" Warning messages: 1: In predict.quadFuncEst(ggResShifter, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects 2: In predict.quadFuncEst(ggResShifter) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > > # random effects > ggResShifterRan <- quadFuncEst( "invest", c( "value", "capital" ), ggData, + shifterNames = "tech", model = "random", random.method = "amemiya" ) > coef( ggResShifterRan ) a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 d_1 3.85e+01 6.21e-02 1.10e-01 5.20e-06 3.05e-05 1.23e-04 -1.99e-08 > printQuadFuncEst( ggResShifterRan ) $call quadFuncEst(yName = "invest", xNames = c("value", "capital"), data = ggData, shifterNames = "tech", model = "random", random.method = "amemiya") $nExog [1] 2 $nShifter [1] 1 $est Model Formula: y ~ 1 + a_1 + a_2 + b_1_1 + b_1_2 + b_2_2 + d_1 Coefficients: (Intercept) a_1 a_2 b_1_1 b_1_2 b_2_2 3.85e+01 6.21e-02 1.10e-01 5.20e-06 3.05e-05 1.23e-04 d_1 -1.99e-08 $residuals 1 2 3 4 5 6 7 8 30.880 -37.913 -114.234 -49.899 -107.441 -8.371 37.661 79.625 9 10 11 12 13 14 15 16 68.771 103.737 56.713 136.613 45.679 -16.433 -72.226 -18.645 17 18 19 20 21 22 23 24 -75.992 -46.002 17.944 61.090 -13.484 -8.559 -21.572 -8.759 25 26 27 28 29 30 31 32 -25.765 -12.414 -8.901 -14.338 -25.012 -19.340 0.664 -21.644 33 34 35 36 37 38 39 40 -13.199 3.656 -4.902 7.228 52.756 29.175 29.239 39.738 41 42 43 44 45 46 47 48 33.290 -17.997 -49.889 -29.976 -46.630 -13.332 41.973 27.277 49 50 51 52 53 54 55 56 -22.610 -22.369 -11.318 32.610 42.295 26.610 -23.329 -50.865 57 58 59 60 61 62 63 64 -33.904 -49.852 -75.300 -128.144 6.358 -1.296 -6.936 -9.412 65 66 67 68 69 70 71 72 -11.508 -9.316 15.379 5.336 -7.994 -8.802 -15.071 -1.557 73 74 75 76 77 78 79 80 9.234 -5.152 -18.842 -21.426 -4.313 1.124 -8.291 -33.784 81 82 83 84 85 86 87 88 -80.565 33.413 68.926 -97.878 -152.949 -129.564 65.577 47.854 89 90 91 92 93 94 95 96 -21.750 -76.688 -96.225 44.469 59.830 139.128 37.535 49.055 97 98 99 100 171.097 216.409 181.424 -17.491 $fitted 1 2 3 4 5 6 7 8 9 10 286.72 429.71 524.83 307.60 438.24 469.57 474.34 368.37 430.83 443.76 11 12 13 14 15 16 17 18 19 20 504.49 551.49 523.22 545.63 627.33 661.55 831.89 937.20 1286.46 1425.61 21 22 23 24 25 26 27 28 29 30 53.77 81.32 87.83 60.36 78.18 81.82 77.25 61.14 72.41 78.91 31 32 33 34 35 36 37 38 39 40 88.12 95.76 75.88 85.70 83.88 93.43 107.86 115.83 145.69 132.75 41 42 43 44 45 46 47 48 49 50 -0.19 63.00 127.09 74.58 94.73 87.73 71.03 64.62 83.91 79.17 51 52 53 54 55 56 57 58 59 60 104.92 127.29 104.91 119.69 121.63 144.36 169.10 207.15 254.80 317.74 61 62 63 64 65 66 67 68 69 70 6.57 27.20 41.99 32.30 30.35 37.89 33.13 38.00 45.01 46.61 71 72 73 74 75 76 77 78 79 80 54.34 55.02 46.33 54.71 50.88 53.67 58.69 70.66 98.37 102.38 81 82 83 84 85 86 87 88 89 90 290.46 321.89 400.97 360.18 383.35 391.16 407.22 397.75 383.35 364.89 91 92 93 94 95 96 97 98 99 100 354.93 375.83 360.67 355.37 367.56 369.75 417.10 428.79 459.58 476.79 $coef a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 d_1 3.85e+01 6.21e-02 1.10e-01 5.20e-06 3.05e-05 1.23e-04 -1.99e-08 $coefCov a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 d_1 a_0 4.95e+03 -1.87e+00 -4.02e-01 4.29e-04 1.55e-04 -8.27e-04 3.79e-06 a_1 -1.87e+00 1.70e-03 -6.61e-04 -4.67e-07 9.19e-08 6.45e-07 -2.21e-09 a_2 -4.02e-01 -6.61e-04 5.52e-03 4.02e-07 -1.40e-06 1.60e-06 -6.28e-09 b_1_1 4.29e-04 -4.67e-07 4.02e-07 1.58e-10 -1.30e-10 9.10e-11 2.01e-13 b_1_2 1.55e-04 9.19e-08 -1.40e-06 -1.30e-10 8.63e-10 -3.03e-09 2.52e-12 b_2_2 -8.27e-04 6.45e-07 1.60e-06 9.10e-11 -3.03e-09 1.49e-08 -9.64e-12 d_1 3.79e-06 -2.21e-09 -6.28e-09 2.01e-13 2.52e-12 -9.64e-12 4.69e-14 $r2 [1] 0.838 $r2bar [1] 0.827 $nObs [1] 100 $yName [1] "invest" $xNames [1] "value" "capital" $shifterNames [1] "tech" $regScale [1] 1 attr(,"class") [1] "quadFuncEst" > round( fitted( ggResShifterRan ), 2 ) 1 2 3 4 5 6 7 8 9 10 286.72 429.71 524.83 307.60 438.24 469.57 474.34 368.37 430.83 443.76 11 12 13 14 15 16 17 18 19 20 504.49 551.49 523.22 545.63 627.33 661.55 831.89 937.20 1286.46 1425.61 21 22 23 24 25 26 27 28 29 30 53.77 81.32 87.83 60.36 78.18 81.82 77.25 61.14 72.41 78.91 31 32 33 34 35 36 37 38 39 40 88.12 95.76 75.88 85.70 83.88 93.43 107.86 115.83 145.69 132.75 41 42 43 44 45 46 47 48 49 50 -0.19 63.00 127.09 74.58 94.73 87.73 71.03 64.62 83.91 79.17 51 52 53 54 55 56 57 58 59 60 104.92 127.29 104.91 119.69 121.63 144.36 169.10 207.15 254.80 317.74 61 62 63 64 65 66 67 68 69 70 6.57 27.20 41.99 32.30 30.35 37.89 33.13 38.00 45.01 46.61 71 72 73 74 75 76 77 78 79 80 54.34 55.02 46.33 54.71 50.88 53.67 58.69 70.66 98.37 102.38 81 82 83 84 85 86 87 88 89 90 290.46 321.89 400.97 360.18 383.35 391.16 407.22 397.75 383.35 364.89 91 92 93 94 95 96 97 98 99 100 354.93 375.83 360.67 355.37 367.56 369.75 417.10 428.79 459.58 476.79 > unname( round( predict( ggResShifterRan ), 2 ) ) [1] 254.7 397.7 492.9 275.6 406.3 437.6 442.4 336.4 398.9 411.8 [11] 472.5 519.5 491.2 513.6 595.3 629.6 799.9 905.2 1254.5 1393.6 [21] 66.2 93.7 100.2 72.7 90.5 94.2 89.6 73.5 84.8 91.3 [31] 100.5 108.1 88.3 98.1 96.3 105.8 120.2 128.2 158.1 145.1 [41] 129.6 192.8 256.8 204.3 224.5 217.5 200.8 194.4 213.7 208.9 [51] 234.7 257.1 234.7 249.4 251.4 274.1 298.9 336.9 384.6 447.5 [61] 50.7 71.3 86.1 76.4 74.5 82.0 77.2 82.1 89.1 90.7 [71] 98.5 99.1 90.4 98.8 95.0 97.8 102.8 114.8 142.5 146.5 [81] 136.2 167.6 246.7 205.9 229.1 236.9 253.0 243.5 229.1 210.6 [91] 200.7 221.6 206.4 201.1 213.3 215.5 262.9 274.5 305.3 322.5 Warning message: In predict.quadFuncEst(ggResShifterRan) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > all.equal( predict( ggResShifterRan ), + fitted( ggResShifterRan ), check.attributes = FALSE ) [1] "Mean relative difference: 0.299" Warning message: In predict.quadFuncEst(ggResShifterRan) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > round( predict( ggResShifterRan, newdata = ggData ), 2 ) 1 2 3 4 5 6 7 8 9 10 11 254.7 397.7 492.9 275.6 406.3 437.6 442.4 336.4 398.9 411.8 472.5 12 13 14 15 16 17 18 19 20 21 22 519.5 491.2 513.6 595.3 629.6 799.9 905.2 1254.5 1393.6 66.2 93.7 23 24 25 26 27 28 29 30 31 32 33 100.2 72.7 90.5 94.2 89.6 73.5 84.8 91.3 100.5 108.1 88.3 34 35 36 37 38 39 40 41 42 43 44 98.1 96.3 105.8 120.2 128.2 158.1 145.1 129.6 192.8 256.8 204.3 45 46 47 48 49 50 51 52 53 54 55 224.5 217.5 200.8 194.4 213.7 208.9 234.7 257.1 234.7 249.4 251.4 56 57 58 59 60 61 62 63 64 65 66 274.1 298.9 336.9 384.6 447.5 50.7 71.3 86.1 76.4 74.5 82.0 67 68 69 70 71 72 73 74 75 76 77 77.2 82.1 89.1 90.7 98.5 99.1 90.4 98.8 95.0 97.8 102.8 78 79 80 81 82 83 84 85 86 87 88 114.8 142.5 146.5 136.2 167.6 246.7 205.9 229.1 236.9 253.0 243.5 89 90 91 92 93 94 95 96 97 98 99 229.1 210.6 200.7 221.6 206.4 201.1 213.3 215.5 262.9 274.5 305.3 100 322.5 Warning message: In predict.quadFuncEst(ggResShifterRan, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > all.equal( predict( ggResShifterRan, newdata = ggData ), + fitted( ggResShifterRan ), check.attributes = FALSE ) [1] "Mean relative difference: 0.299" Warning message: In predict.quadFuncEst(ggResShifterRan, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > all.equal( predict( ggResShifterRan, newdata = ggData ), + predict( ggResShifterRan ), check.attributes = FALSE ) [1] TRUE Warning messages: 1: In predict.quadFuncEst(ggResShifterRan, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects 2: In predict.quadFuncEst(ggResShifterRan) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > > ## panel data with a logical variable as shifter > ggData$war <- ggData$yearInt >= 1939 & ggData$yearInt <= 1945 > # fixed effects > ggResShifterLogi <- quadFuncEst( "invest", c( "value", "capital" ), ggData, + shifterNames = "war" ) > coef( ggResShifterLogi ) a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 d_1_TRUE 5.98e+01 5.34e-02 9.03e-02 6.62e-06 3.48e-05 1.13e-04 -1.58e+01 > printQuadFuncEst( ggResShifterLogi ) $call quadFuncEst(yName = "invest", xNames = c("value", "capital"), data = ggData, shifterNames = "war") $nExog [1] 2 $nShifter [1] 1 $est Model Formula: y ~ 1 + a_1 + a_2 + b_1_1 + b_1_2 + b_2_2 + d_1_ Coefficients: a_1 a_2 b_1_1 b_1_2 b_2_2 d_1_TRUE 5.34e-02 9.03e-02 6.62e-06 3.48e-05 1.13e-04 -1.58e+01 $residuals 1 2 3 4 5 6 7 8 13.5972 -50.1708 -125.7798 -66.6254 -104.2421 -4.6884 41.3493 81.0733 9 10 11 12 13 14 15 16 71.7758 107.0378 60.6778 125.0953 36.6305 -23.3366 -77.9311 -23.3212 17 18 19 20 21 22 23 24 -81.9972 -49.9994 9.0300 61.8251 -21.0952 -12.9256 -25.1957 -15.4461 25 26 27 28 29 30 31 32 -14.5826 -0.8269 2.2084 -5.0685 -14.4622 -8.0855 12.9007 -24.3589 33 34 35 36 37 38 39 40 -17.9789 -0.0386 -8.6741 4.4420 51.3937 28.6429 30.6232 38.5278 41 42 43 44 45 46 47 48 37.5743 -8.5727 -36.5632 -19.7796 -19.3690 13.5081 67.7923 52.8431 49 50 51 52 53 54 55 56 4.2677 4.2293 16.7475 46.0982 55.1982 40.8494 -8.3535 -34.6840 57 58 59 60 61 62 63 64 -16.6731 -31.1626 -55.4615 -108.4889 2.1511 -2.8733 -6.7444 -10.3321 65 66 67 68 69 70 71 72 3.1513 6.2371 30.4010 20.9882 8.5086 7.8942 2.4538 0.2223 73 74 75 76 77 78 79 80 10.1596 -3.2831 -17.3436 -19.6949 -2.1908 4.1996 -3.3930 -30.5114 81 82 83 84 85 86 87 88 -114.8660 1.8219 42.5414 -126.6192 -164.3796 -140.6991 55.2961 37.1596 89 90 91 92 93 94 95 96 -33.2123 -89.2904 -109.5944 16.6284 31.1275 110.2151 9.5231 21.1604 97 98 99 100 145.5106 191.4813 158.1530 -41.9573 $fitted 1 2 3 4 5 6 7 8 9 10 304.00 441.97 536.38 324.33 435.04 465.89 470.65 366.93 427.82 440.46 11 12 13 14 15 16 17 18 19 20 500.52 563.00 532.27 552.54 633.03 666.22 837.90 941.20 1295.37 1424.87 21 22 23 24 25 26 27 28 29 30 61.39 85.69 91.46 67.05 66.99 70.24 66.14 51.87 61.86 67.66 31 32 33 34 35 36 37 38 39 40 75.88 98.48 80.66 89.40 87.65 96.22 109.23 116.36 144.31 133.96 41 42 43 44 45 46 47 48 49 50 -4.47 53.57 113.76 64.38 67.47 60.89 45.21 39.06 57.03 52.57 51 52 53 54 55 56 57 58 59 60 76.85 113.80 92.00 105.45 106.65 128.18 151.87 188.46 234.96 298.09 61 62 63 64 65 66 67 68 69 70 10.78 28.77 41.79 33.22 15.69 22.33 18.11 22.35 28.51 29.92 71 72 73 74 75 76 77 78 79 80 36.82 53.24 45.40 52.84 49.38 51.93 56.57 67.58 93.47 99.11 81 82 83 84 85 86 87 88 89 90 324.77 353.48 427.36 388.92 394.78 402.30 417.50 408.44 394.81 377.49 91 92 93 94 95 96 97 98 99 100 368.29 403.67 389.37 384.28 395.58 397.64 442.69 453.72 482.85 501.26 $coef a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 d_1_TRUE 5.98e+01 5.34e-02 9.03e-02 6.62e-06 3.48e-05 1.13e-04 -1.58e+01 $coefCov a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 d_1_TRUE a_0 NA NA NA NA NA NA NA a_1 NA 1.78e-03 -9.68e-04 -4.94e-07 2.20e-07 1.40e-07 -3.13e-02 a_2 NA -9.68e-04 4.93e-03 4.34e-07 -1.12e-06 4.68e-07 2.59e-01 b_1_1 NA -4.94e-07 4.34e-07 1.64e-10 -1.43e-10 1.42e-10 1.20e-05 b_1_2 NA 2.20e-07 -1.12e-06 -1.43e-10 7.32e-10 -2.50e-09 -6.00e-05 b_2_2 NA 1.40e-07 4.68e-07 1.42e-10 -2.50e-09 1.28e-08 1.27e-04 d_1_TRUE NA -3.13e-02 2.59e-01 1.20e-05 -6.00e-05 1.27e-04 1.99e+02 $r2 [1] 0.843 $r2bar [1] 0.825 $nObs [1] 100 $yName [1] "invest" $xNames [1] "value" "capital" $shifterNames [1] "war" $regScale [1] 1 attr(,"class") [1] "quadFuncEst" > round( fitted( ggResShifterLogi ), 2 ) 1 2 3 4 5 6 7 8 9 10 304.00 441.97 536.38 324.33 435.04 465.89 470.65 366.93 427.82 440.46 11 12 13 14 15 16 17 18 19 20 500.52 563.00 532.27 552.54 633.03 666.22 837.90 941.20 1295.37 1424.87 21 22 23 24 25 26 27 28 29 30 61.39 85.69 91.46 67.05 66.99 70.24 66.14 51.87 61.86 67.66 31 32 33 34 35 36 37 38 39 40 75.88 98.48 80.66 89.40 87.65 96.22 109.23 116.36 144.31 133.96 41 42 43 44 45 46 47 48 49 50 -4.47 53.57 113.76 64.38 67.47 60.89 45.21 39.06 57.03 52.57 51 52 53 54 55 56 57 58 59 60 76.85 113.80 92.00 105.45 106.65 128.18 151.87 188.46 234.96 298.09 61 62 63 64 65 66 67 68 69 70 10.78 28.77 41.79 33.22 15.69 22.33 18.11 22.35 28.51 29.92 71 72 73 74 75 76 77 78 79 80 36.82 53.24 45.40 52.84 49.38 51.93 56.57 67.58 93.47 99.11 81 82 83 84 85 86 87 88 89 90 324.77 353.48 427.36 388.92 394.78 402.30 417.50 408.44 394.81 377.49 91 92 93 94 95 96 97 98 99 100 368.29 403.67 389.37 384.28 395.58 397.64 442.69 453.72 482.85 501.26 > all.equal( predict( ggResShifterLogi ), + fitted( ggResShifterLogi ), check.attributes = FALSE ) [1] TRUE Warning message: In predict.quadFuncEst(ggResShifterLogi) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > round( predict( ggResShifterLogi, newdata = ggData ), 2 ) 1 2 3 4 5 6 7 8 9 10 11 256.0 394.0 488.4 276.4 387.1 417.9 422.7 319.0 379.9 392.5 452.6 12 13 14 15 16 17 18 19 20 21 22 515.0 484.3 504.6 585.1 618.2 789.9 893.2 1247.4 1376.9 83.8 108.0 23 24 25 26 27 28 29 30 31 32 33 113.8 89.4 89.3 92.6 88.5 74.2 84.2 90.0 98.2 120.8 103.0 34 35 36 37 38 39 40 41 42 43 44 111.8 110.0 118.6 131.6 138.7 166.7 156.3 140.2 198.2 258.4 209.0 45 46 47 48 49 50 51 52 53 54 55 212.1 205.5 189.8 183.7 201.7 197.2 221.5 258.4 236.6 250.1 251.3 56 57 58 59 60 61 62 63 64 65 66 272.8 296.5 333.1 379.6 442.7 70.3 88.3 101.3 92.7 75.2 81.8 67 68 69 70 71 72 73 74 75 76 77 77.6 81.9 88.0 89.4 96.3 112.8 104.9 112.4 108.9 111.5 116.1 78 79 80 81 82 83 84 85 86 87 88 127.1 153.0 158.6 146.2 174.9 248.8 210.4 216.2 223.8 239.0 229.9 89 90 91 92 93 94 95 96 97 98 99 216.3 198.9 189.8 225.1 210.8 205.7 217.0 219.1 264.1 275.2 304.3 100 322.7 Warning message: In predict.quadFuncEst(ggResShifterLogi, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > all.equal( predict( ggResShifterLogi, newdata = ggData ), + fitted( ggResShifterLogi ), check.attributes = FALSE ) [1] "Mean relative difference: 0.364" Warning message: In predict.quadFuncEst(ggResShifterLogi, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > all.equal( predict( ggResShifterLogi, newdata = ggData ), + predict( ggResShifterLogi ), check.attributes = FALSE ) [1] "Mean relative difference: 0.364" Warning messages: 1: In predict.quadFuncEst(ggResShifterLogi, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects 2: In predict.quadFuncEst(ggResShifterLogi) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > > # random effects > ggResShifterLogiRan <- quadFuncEst( "invest", c( "value", "capital" ), ggData, + shifterNames = "war", model = "random", random.method = "amemiya" ) > coef( ggResShifterLogiRan ) a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 d_1_TRUE 4.67e+01 6.37e-02 8.70e-02 4.31e-06 3.64e-05 1.09e-04 -1.60e+01 > printQuadFuncEst( ggResShifterLogiRan ) $call quadFuncEst(yName = "invest", xNames = c("value", "capital"), data = ggData, shifterNames = "war", model = "random", random.method = "amemiya") $nExog [1] 2 $nShifter [1] 1 $est Model Formula: y ~ 1 + a_1 + a_2 + b_1_1 + b_1_2 + b_2_2 + d_1_ Coefficients: (Intercept) a_1 a_2 b_1_1 b_1_2 b_2_2 4.67e+01 6.37e-02 8.70e-02 4.31e-06 3.64e-05 1.09e-04 d_1_TRUE -1.60e+01 $residuals 1 2 3 4 5 6 7 8 20.3476 -45.7828 -120.9655 -58.9453 -100.0474 -0.5961 45.3201 87.2469 9 10 11 12 13 14 15 16 76.1115 111.1983 64.6630 128.5579 41.9011 -16.7591 -72.8129 -18.2148 17 18 19 20 21 22 23 24 -79.0134 -46.7731 13.0297 66.8754 -20.9330 -16.4986 -29.1011 -15.3570 25 26 27 28 29 30 31 32 -16.4716 -3.1315 0.6697 -4.4744 -15.5261 -10.1493 9.5463 -28.2327 33 34 35 36 37 38 39 40 -19.0647 -2.1272 -9.7112 2.5169 48.5664 26.8302 26.5825 37.4033 41 42 43 44 45 46 47 48 23.7933 -28.0843 -59.9464 -39.3863 -39.9842 -6.4112 49.7172 36.5534 49 50 51 52 53 54 55 56 -13.0712 -12.6816 -2.2614 25.7454 38.6451 24.9399 -22.6722 -50.2815 57 58 59 60 61 62 63 64 -33.7224 -49.8170 -75.7264 -130.6865 -0.2618 -8.3732 -14.1211 -16.1906 65 66 67 68 69 70 71 72 -2.1326 -0.0197 24.9942 15.4292 2.5076 1.8266 -4.5920 -7.2352 73 74 75 76 77 78 79 80 4.3691 -9.7496 -23.0633 -25.8989 -9.2083 -3.9940 -14.2098 -41.1995 81 82 83 84 85 86 87 88 -89.3678 24.3204 60.4847 -103.8156 -142.2895 -120.1512 74.8895 57.9572 89 90 91 92 93 94 95 96 -11.3137 -66.3403 -86.9857 37.7374 53.9733 134.3063 33.4254 45.0056 97 98 99 100 165.4914 212.3825 180.2978 -20.2244 $fitted 1 2 3 4 5 6 7 8 9 10 297.25 437.58 531.57 316.65 430.85 461.80 466.68 360.75 423.49 436.30 11 12 13 14 15 16 17 18 19 20 496.54 559.54 527.00 545.96 627.91 661.11 834.91 937.97 1291.37 1419.82 21 22 23 24 25 26 27 28 29 30 61.22 89.26 95.36 66.96 68.88 72.54 67.68 51.27 62.93 69.72 31 32 33 34 35 36 37 38 39 40 79.23 102.35 81.74 91.49 88.69 98.14 112.05 118.17 148.35 135.09 41 42 43 44 45 46 47 48 49 50 9.31 73.08 137.15 83.99 88.08 80.81 63.28 55.35 74.37 69.48 51 52 53 54 55 56 57 58 59 60 95.86 134.15 108.55 121.36 120.97 143.78 168.92 207.12 255.23 320.29 61 62 63 64 65 66 67 68 69 70 13.19 34.27 49.17 39.08 20.97 28.59 23.52 27.91 34.51 35.98 71 72 73 74 75 76 77 78 79 80 43.86 60.70 51.19 59.31 55.10 58.14 63.59 75.77 104.29 109.80 81 82 83 84 85 86 87 88 89 90 299.27 330.98 409.42 366.12 372.69 381.75 397.91 387.64 372.91 354.54 91 92 93 94 95 96 97 98 99 100 345.69 382.56 366.53 360.19 371.67 373.79 422.71 432.82 460.70 479.52 $coef a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 d_1_TRUE 4.67e+01 6.37e-02 8.70e-02 4.31e-06 3.64e-05 1.09e-04 -1.60e+01 $coefCov a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 d_1_TRUE a_0 4.64e+03 -1.65e+00 -4.07e-03 4.02e-04 -2.25e-05 -1.00e-04 -8.23e+01 a_1 -1.65e+00 1.58e-03 -9.87e-04 -4.54e-07 2.18e-07 1.66e-07 -3.33e-02 a_2 -4.07e-03 -9.87e-04 4.95e-03 4.39e-07 -1.13e-06 4.69e-07 2.60e-01 b_1_1 4.02e-04 -4.54e-07 4.39e-07 1.56e-10 -1.43e-10 1.38e-10 1.25e-05 b_1_2 -2.25e-05 2.18e-07 -1.13e-06 -1.43e-10 7.36e-10 -2.51e-09 -6.03e-05 b_2_2 -1.00e-04 1.66e-07 4.69e-07 1.38e-10 -2.51e-09 1.29e-08 1.27e-04 d_1_TRUE -8.23e+01 -3.33e-02 2.60e-01 1.25e-05 -6.03e-05 1.27e-04 2.01e+02 $r2 [1] 0.84 $r2bar [1] 0.83 $nObs [1] 100 $yName [1] "invest" $xNames [1] "value" "capital" $shifterNames [1] "war" $regScale [1] 1 attr(,"class") [1] "quadFuncEst" > round( fitted( ggResShifterLogiRan ), 2 ) 1 2 3 4 5 6 7 8 9 10 297.25 437.58 531.57 316.65 430.85 461.80 466.68 360.75 423.49 436.30 11 12 13 14 15 16 17 18 19 20 496.54 559.54 527.00 545.96 627.91 661.11 834.91 937.97 1291.37 1419.82 21 22 23 24 25 26 27 28 29 30 61.22 89.26 95.36 66.96 68.88 72.54 67.68 51.27 62.93 69.72 31 32 33 34 35 36 37 38 39 40 79.23 102.35 81.74 91.49 88.69 98.14 112.05 118.17 148.35 135.09 41 42 43 44 45 46 47 48 49 50 9.31 73.08 137.15 83.99 88.08 80.81 63.28 55.35 74.37 69.48 51 52 53 54 55 56 57 58 59 60 95.86 134.15 108.55 121.36 120.97 143.78 168.92 207.12 255.23 320.29 61 62 63 64 65 66 67 68 69 70 13.19 34.27 49.17 39.08 20.97 28.59 23.52 27.91 34.51 35.98 71 72 73 74 75 76 77 78 79 80 43.86 60.70 51.19 59.31 55.10 58.14 63.59 75.77 104.29 109.80 81 82 83 84 85 86 87 88 89 90 299.27 330.98 409.42 366.12 372.69 381.75 397.91 387.64 372.91 354.54 91 92 93 94 95 96 97 98 99 100 345.69 382.56 366.53 360.19 371.67 373.79 422.71 432.82 460.70 479.52 > unname( round( predict( ggResShifterLogiRan ), 2 ) ) [1] 263.8 404.1 498.1 283.2 397.4 428.4 433.2 327.3 390.1 402.9 [11] 463.1 526.1 493.6 512.5 594.5 627.7 801.5 904.5 1257.9 1386.4 [21] 74.8 102.8 108.9 80.5 82.4 86.1 81.2 64.8 76.5 83.3 [31] 92.8 115.9 95.3 105.0 102.2 111.7 125.6 131.7 161.9 148.7 [41] 137.4 201.2 265.3 212.1 216.2 208.9 191.4 183.5 202.5 197.6 [51] 224.0 262.3 236.7 249.5 249.1 271.9 297.1 335.2 383.4 448.4 [61] 59.2 80.3 95.2 85.1 67.0 74.6 69.5 73.9 80.5 82.0 [71] 89.8 106.7 97.2 105.3 101.1 104.1 109.6 121.8 150.3 155.8 [81] 145.0 176.7 255.2 211.9 218.4 227.5 243.7 233.4 218.7 200.3 [91] 191.4 228.3 212.3 205.9 217.4 219.6 268.5 278.6 306.5 325.3 Warning message: In predict.quadFuncEst(ggResShifterLogiRan) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > all.equal( predict( ggResShifterLogiRan ), + fitted( ggResShifterLogiRan ), check.attributes = FALSE ) [1] "Mean relative difference: 0.302" Warning message: In predict.quadFuncEst(ggResShifterLogiRan) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > round( predict( ggResShifterLogiRan, newdata = ggData ), 2 ) 1 2 3 4 5 6 7 8 9 10 11 263.8 404.1 498.1 283.2 397.4 428.4 433.2 327.3 390.1 402.9 463.1 12 13 14 15 16 17 18 19 20 21 22 526.1 493.6 512.5 594.5 627.7 801.5 904.5 1257.9 1386.4 74.8 102.8 23 24 25 26 27 28 29 30 31 32 33 108.9 80.5 82.4 86.1 81.2 64.8 76.5 83.3 92.8 115.9 95.3 34 35 36 37 38 39 40 41 42 43 44 105.0 102.2 111.7 125.6 131.7 161.9 148.7 137.4 201.2 265.3 212.1 45 46 47 48 49 50 51 52 53 54 55 216.2 208.9 191.4 183.5 202.5 197.6 224.0 262.3 236.7 249.5 249.1 56 57 58 59 60 61 62 63 64 65 66 271.9 297.1 335.2 383.4 448.4 59.2 80.3 95.2 85.1 67.0 74.6 67 68 69 70 71 72 73 74 75 76 77 69.5 73.9 80.5 82.0 89.8 106.7 97.2 105.3 101.1 104.1 109.6 78 79 80 81 82 83 84 85 86 87 88 121.8 150.3 155.8 145.0 176.7 255.2 211.9 218.4 227.5 243.7 233.4 89 90 91 92 93 94 95 96 97 98 99 218.7 200.3 191.4 228.3 212.3 205.9 217.4 219.6 268.5 278.6 306.5 100 325.3 Warning message: In predict.quadFuncEst(ggResShifterLogiRan, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > all.equal( predict( ggResShifterLogiRan, newdata = ggData ), + fitted( ggResShifterLogiRan ), check.attributes = FALSE ) [1] "Mean relative difference: 0.302" Warning message: In predict.quadFuncEst(ggResShifterLogiRan, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > all.equal( predict( ggResShifterLogiRan, newdata = ggData ), + predict( ggResShifterLogiRan ), check.attributes = FALSE ) [1] TRUE Warning messages: 1: In predict.quadFuncEst(ggResShifterLogiRan, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects 2: In predict.quadFuncEst(ggResShifterLogiRan) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > > ## panel data with a factor as shifter > ggData$decade <- as.factor( ifelse( ggData$yearInt <= 1939, "30s", + ifelse( ggData$yearInt <= 1949, "40s", "50s" ) ) ) > # fixed effects > ggResShifterFac <- quadFuncEst( "invest", c( "value", "capital" ), ggData, + shifterNames = "decade" ) > coef( ggResShifterFac ) a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 d_1_40s d_1_50s 8.22e+01 2.57e-02 -1.15e-01 9.01e-06 4.92e-05 2.05e-04 6.31e+01 1.08e+02 > printQuadFuncEst( ggResShifterFac ) $call quadFuncEst(yName = "invest", xNames = c("value", "capital"), data = ggData, shifterNames = "decade") $nExog [1] 2 $nShifter [1] 1 $est Model Formula: y ~ 1 + a_1 + a_2 + b_1_1 + b_1_2 + b_2_2 + d_1_ Coefficients: a_1 a_2 b_1_1 b_1_2 b_2_2 d_1_40s d_1_50s 2.57e-02 -1.15e-01 9.01e-06 4.92e-05 2.05e-04 6.31e+01 1.08e+02 $residuals 1 2 3 4 5 6 7 8 2.572 -25.333 -77.790 -51.433 -80.982 -39.435 11.035 38.034 9 10 11 12 13 14 15 16 35.740 67.921 35.159 130.424 62.138 12.917 -32.813 -18.301 17 18 19 20 21 22 23 24 -72.020 -37.161 2.591 36.738 15.340 34.395 27.974 29.642 25 26 27 28 29 30 31 32 23.278 -24.333 -21.873 -35.780 -41.474 -33.579 -10.007 -24.665 33 34 35 36 37 38 39 40 -23.795 -0.498 -4.805 -30.936 25.870 16.256 33.105 45.886 41 42 43 44 45 46 47 48 40.515 14.460 4.653 12.270 3.865 -26.616 27.134 17.820 49 50 51 52 53 54 55 56 -22.706 -23.712 -5.470 47.078 62.197 58.825 16.675 -47.927 57 58 59 60 61 62 63 64 -24.098 -29.007 -42.317 -83.639 37.666 41.146 44.137 38.260 65 66 67 68 69 70 71 72 35.945 -20.668 3.019 -1.022 -7.595 -6.690 -9.173 3.774 73 74 75 76 77 78 79 80 13.984 6.138 -7.763 -54.400 -36.041 -23.443 -18.328 -38.947 81 82 83 84 85 86 87 88 -103.205 23.187 93.443 -70.698 -113.307 -156.904 43.447 26.938 89 90 91 92 93 94 95 96 -46.350 -109.113 -138.922 10.352 24.560 106.830 13.623 -18.140 97 98 99 100 114.892 172.719 160.134 -33.486 $fitted 1 2 3 4 5 6 7 8 9 10 315.03 417.13 488.39 309.13 411.78 500.64 500.96 409.97 463.86 479.58 11 12 13 14 15 16 17 18 19 20 526.04 557.68 506.76 516.28 587.91 661.20 827.92 928.36 1301.81 1449.96 21 22 23 24 25 26 27 28 29 30 24.95 38.37 38.29 21.96 29.13 93.74 90.22 82.58 88.87 93.15 31 32 33 34 35 36 37 38 39 40 98.79 98.78 86.48 89.86 83.79 131.60 134.75 128.74 141.83 126.60 41 42 43 44 45 46 47 48 49 50 -7.42 30.54 72.55 32.33 44.23 101.02 85.87 74.08 84.01 80.51 51 52 53 54 55 56 57 58 59 60 99.07 112.82 85.00 87.48 81.62 141.43 159.30 186.31 221.82 273.24 61 62 63 64 65 66 67 68 69 70 -24.74 -15.25 -9.09 -15.37 -17.11 49.24 45.49 44.36 44.61 44.50 71 72 73 74 75 76 77 78 79 80 48.44 49.69 41.58 43.42 39.80 86.64 90.42 95.22 108.41 107.55 81 82 83 84 85 86 87 88 89 90 313.10 332.11 376.46 333.00 343.71 418.50 429.35 418.66 407.95 397.31 91 92 93 94 95 96 97 98 99 100 397.62 409.95 395.94 387.67 391.48 436.94 473.31 472.48 480.87 492.79 $coef a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 d_1_40s d_1_50s 8.22e+01 2.57e-02 -1.15e-01 9.01e-06 4.92e-05 2.05e-04 6.31e+01 1.08e+02 $coefCov a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 d_1_40s a_0 NA NA NA NA NA NA NA a_1 NA 1.60e-03 -3.18e-04 -4.26e-07 1.19e-07 9.57e-08 -4.09e-02 a_2 NA -3.18e-04 7.30e-03 3.24e-07 -1.25e-06 -5.33e-07 -6.41e-01 b_1_1 NA -4.26e-07 3.24e-07 1.40e-10 -1.14e-10 1.14e-10 5.34e-07 b_1_2 NA 1.19e-07 -1.25e-06 -1.14e-10 6.55e-10 -2.07e-09 3.26e-05 b_2_2 NA 9.57e-08 -5.33e-07 1.14e-10 -2.07e-09 1.13e-08 3.70e-04 d_1_40s NA -4.09e-02 -6.41e-01 5.34e-07 3.26e-05 3.70e-04 2.75e+02 d_1_50s NA -2.20e-01 -1.59e+00 1.51e-05 1.65e-04 3.86e-04 3.11e+02 d_1_50s a_0 NA a_1 -2.20e-01 a_2 -1.59e+00 b_1_1 1.51e-05 b_1_2 1.65e-04 b_2_2 3.86e-04 d_1_40s 3.11e+02 d_1_50s 7.51e+02 $r2 [1] 0.867 $r2bar [1] 0.851 $nObs [1] 100 $yName [1] "invest" $xNames [1] "value" "capital" $shifterNames [1] "decade" $regScale [1] 1 attr(,"class") [1] "quadFuncEst" > round( fitted( ggResShifterFac ), 2 ) 1 2 3 4 5 6 7 8 9 10 315.03 417.13 488.39 309.13 411.78 500.64 500.96 409.97 463.86 479.58 11 12 13 14 15 16 17 18 19 20 526.04 557.68 506.76 516.28 587.91 661.20 827.92 928.36 1301.81 1449.96 21 22 23 24 25 26 27 28 29 30 24.95 38.37 38.29 21.96 29.13 93.74 90.22 82.58 88.87 93.15 31 32 33 34 35 36 37 38 39 40 98.79 98.78 86.48 89.86 83.79 131.60 134.75 128.74 141.83 126.60 41 42 43 44 45 46 47 48 49 50 -7.42 30.54 72.55 32.33 44.23 101.02 85.87 74.08 84.01 80.51 51 52 53 54 55 56 57 58 59 60 99.07 112.82 85.00 87.48 81.62 141.43 159.30 186.31 221.82 273.24 61 62 63 64 65 66 67 68 69 70 -24.74 -15.25 -9.09 -15.37 -17.11 49.24 45.49 44.36 44.61 44.50 71 72 73 74 75 76 77 78 79 80 48.44 49.69 41.58 43.42 39.80 86.64 90.42 95.22 108.41 107.55 81 82 83 84 85 86 87 88 89 90 313.10 332.11 376.46 333.00 343.71 418.50 429.35 418.66 407.95 397.31 91 92 93 94 95 96 97 98 99 100 397.62 409.95 395.94 387.67 391.48 436.94 473.31 472.48 480.87 492.79 > all.equal( predict( ggResShifterFac ), + fitted( ggResShifterFac ), check.attributes = FALSE ) [1] TRUE Warning message: In predict.quadFuncEst(ggResShifterFac) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > round( predict( ggResShifterFac, newdata = ggData ), 2 ) 1 2 3 4 5 6 7 8 9 10 11 204.1 306.2 377.5 198.2 300.9 389.7 390.0 299.0 352.9 368.6 415.1 12 13 14 15 16 17 18 19 20 21 22 446.8 395.8 405.4 477.0 550.3 717.0 817.4 1190.9 1339.0 92.7 106.1 23 24 25 26 27 28 29 30 31 32 33 106.0 89.7 96.9 161.5 158.0 150.3 156.6 160.9 166.6 166.6 154.2 34 35 36 37 38 39 40 41 42 43 44 157.6 151.6 199.4 202.5 196.5 209.6 194.4 113.8 151.7 193.8 153.5 45 46 47 48 49 50 51 52 53 54 55 165.4 222.2 207.1 195.3 205.2 201.7 220.3 234.0 206.2 208.7 202.8 56 57 58 59 60 61 62 63 64 65 66 262.6 280.5 307.5 343.0 394.4 87.1 96.6 102.7 96.4 94.7 161.1 67 68 69 70 71 72 73 74 75 76 77 157.3 156.2 156.4 156.3 160.3 161.5 153.4 155.2 151.6 198.4 202.2 78 79 80 81 82 83 84 85 86 87 88 207.0 220.2 219.4 123.3 142.3 186.6 143.2 153.9 228.7 239.5 228.8 89 90 91 92 93 94 95 96 97 98 99 218.1 207.5 207.8 220.1 206.1 197.8 201.6 247.1 283.5 282.6 291.0 100 302.9 Warning message: In predict.quadFuncEst(ggResShifterFac, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > all.equal( predict( ggResShifterFac, newdata = ggData ), + fitted( ggResShifterFac ), check.attributes = FALSE ) [1] "Mean relative difference: 0.483" Warning message: In predict.quadFuncEst(ggResShifterFac, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > all.equal( predict( ggResShifterFac, newdata = ggData ), + predict( ggResShifterFac ), check.attributes = FALSE ) [1] "Mean relative difference: 0.483" Warning messages: 1: In predict.quadFuncEst(ggResShifterFac, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects 2: In predict.quadFuncEst(ggResShifterFac) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > > # random effects > ggResShifterFacRan <- quadFuncEst( "invest", c( "value", "capital" ), ggData, + shifterNames = "decade", model = "random", random.method = "amemiya" ) > coef( ggResShifterFacRan ) a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 d_1_40s d_1_50s 6.05e+01 4.14e-02 -1.04e-01 5.97e-06 4.88e-05 2.00e-04 6.15e+01 1.02e+02 > printQuadFuncEst( ggResShifterFacRan ) $call quadFuncEst(yName = "invest", xNames = c("value", "capital"), data = ggData, shifterNames = "decade", model = "random", random.method = "amemiya") $nExog [1] 2 $nShifter [1] 1 $est Model Formula: y ~ 1 + a_1 + a_2 + b_1_1 + b_1_2 + b_2_2 + d_1_ Coefficients: (Intercept) a_1 a_2 b_1_1 b_1_2 b_2_2 6.05e+01 4.14e-02 -1.04e-01 5.97e-06 4.88e-05 2.00e-04 d_1_40s d_1_50s 6.15e+01 1.02e+02 $residuals 1 2 3 4 5 6 7 8 9 10 17.41 -17.13 -70.69 -36.53 -73.33 -30.84 19.41 50.89 45.29 77.05 11 12 13 14 15 16 17 18 19 20 43.09 137.35 70.53 21.88 -26.35 -8.21 -64.53 -30.09 12.33 45.43 21 22 23 24 25 26 27 28 29 30 12.58 25.84 18.56 26.16 16.28 -30.39 -26.86 -37.46 -45.62 -39.17 31 32 33 34 35 36 37 38 39 40 -17.51 -33.09 -28.11 -6.54 -9.78 -33.36 21.52 12.19 25.00 41.06 41 42 43 44 45 46 47 48 49 50 36.58 1.32 -15.17 -1.58 -12.10 -39.98 16.32 8.98 -33.51 -33.89 51 52 53 54 55 56 57 58 59 60 -18.82 31.68 51.25 47.78 6.96 -55.64 -34.11 -41.83 -58.08 -102.79 61 62 63 64 65 66 67 68 69 70 33.40 32.14 32.12 28.45 26.64 -29.89 -5.04 -9.67 -17.26 -16.56 71 72 73 74 75 76 77 78 79 80 -20.55 -7.86 4.54 -4.61 -17.54 -60.71 -43.49 -32.90 -32.19 -53.12 81 82 83 84 85 86 87 88 89 90 -78.62 42.97 104.89 -52.80 -97.39 -141.15 57.61 42.63 -28.99 -89.88 91 92 93 94 95 96 97 98 99 100 -119.48 27.53 44.09 127.77 33.76 5.95 133.29 191.46 178.76 -15.93 $fitted 1 2 3 4 5 6 7 8 9 10 300.19 408.93 481.29 294.23 404.13 492.04 492.59 397.11 454.31 470.45 11 12 13 14 15 16 17 18 19 20 518.11 550.75 498.37 507.32 581.45 651.11 820.43 921.29 1292.07 1441.27 21 22 23 24 25 26 27 28 29 30 27.71 46.92 47.70 25.44 36.13 99.80 95.21 84.26 93.02 98.74 31 32 33 34 35 36 37 38 39 40 106.29 107.21 90.79 95.90 88.76 134.02 139.10 132.81 149.93 131.43 41 42 43 44 45 46 47 48 49 50 -3.48 43.68 92.37 46.18 60.20 114.38 96.68 82.92 94.81 90.69 51 52 53 54 55 56 57 58 59 60 112.42 128.22 95.95 98.52 91.34 149.14 169.31 199.13 237.58 292.39 61 62 63 64 65 66 67 68 69 70 -20.47 -6.24 2.93 -5.56 -7.80 58.46 53.55 53.01 54.28 54.37 71 72 73 74 75 76 77 78 79 80 59.82 61.32 51.02 54.17 49.58 92.95 97.87 104.68 122.27 121.72 81 82 83 84 85 86 87 88 89 90 288.52 312.33 365.01 315.10 327.79 402.75 415.19 402.97 390.59 378.08 91 92 93 94 95 96 97 98 99 100 378.18 392.77 376.41 366.73 371.34 412.85 454.91 453.74 462.24 475.23 $coef a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 d_1_40s d_1_50s 6.05e+01 4.14e-02 -1.04e-01 5.97e-06 4.88e-05 2.00e-04 6.15e+01 1.02e+02 $coefCov a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 d_1_40s a_0 5.56e+03 -1.59e+00 -4.49e-01 3.68e-04 4.64e-05 -1.10e-04 -3.96e+01 a_1 -1.59e+00 1.45e-03 -4.68e-04 -3.99e-07 1.34e-07 1.35e-07 -2.16e-02 a_2 -4.49e-01 -4.68e-04 7.18e-03 3.52e-07 -1.24e-06 -4.99e-07 -6.24e-01 b_1_1 3.68e-04 -3.99e-07 3.52e-07 1.35e-10 -1.17e-10 1.08e-10 -3.04e-06 b_1_2 4.64e-05 1.34e-07 -1.24e-06 -1.17e-10 6.55e-10 -2.08e-09 3.08e-05 b_2_2 -1.10e-04 1.35e-07 -4.99e-07 1.08e-10 -2.08e-09 1.14e-08 3.66e-04 d_1_40s -3.96e+01 -2.16e-02 -6.24e-01 -3.04e-06 3.08e-05 3.66e-04 2.74e+02 d_1_50s 2.43e+02 -1.55e-01 -1.53e+00 3.18e-06 1.59e-04 3.71e-04 3.04e+02 d_1_50s a_0 2.43e+02 a_1 -1.55e-01 a_2 -1.53e+00 b_1_1 3.18e-06 b_1_2 1.59e-04 b_2_2 3.71e-04 d_1_40s 3.04e+02 d_1_50s 7.25e+02 $r2 [1] 0.864 $r2bar [1] 0.853 $nObs [1] 100 $yName [1] "invest" $xNames [1] "value" "capital" $shifterNames [1] "decade" $regScale [1] 1 attr(,"class") [1] "quadFuncEst" > round( fitted( ggResShifterFacRan ), 2 ) 1 2 3 4 5 6 7 8 9 10 300.19 408.93 481.29 294.23 404.13 492.04 492.59 397.11 454.31 470.45 11 12 13 14 15 16 17 18 19 20 518.11 550.75 498.37 507.32 581.45 651.11 820.43 921.29 1292.07 1441.27 21 22 23 24 25 26 27 28 29 30 27.71 46.92 47.70 25.44 36.13 99.80 95.21 84.26 93.02 98.74 31 32 33 34 35 36 37 38 39 40 106.29 107.21 90.79 95.90 88.76 134.02 139.10 132.81 149.93 131.43 41 42 43 44 45 46 47 48 49 50 -3.48 43.68 92.37 46.18 60.20 114.38 96.68 82.92 94.81 90.69 51 52 53 54 55 56 57 58 59 60 112.42 128.22 95.95 98.52 91.34 149.14 169.31 199.13 237.58 292.39 61 62 63 64 65 66 67 68 69 70 -20.47 -6.24 2.93 -5.56 -7.80 58.46 53.55 53.01 54.28 54.37 71 72 73 74 75 76 77 78 79 80 59.82 61.32 51.02 54.17 49.58 92.95 97.87 104.68 122.27 121.72 81 82 83 84 85 86 87 88 89 90 288.52 312.33 365.01 315.10 327.79 402.75 415.19 402.97 390.59 378.08 91 92 93 94 95 96 97 98 99 100 378.18 392.77 376.41 366.73 371.34 412.85 454.91 453.74 462.24 475.23 > unname( round( predict( ggResShifterFacRan ), 2 ) ) [1] 216.4 325.2 397.5 210.5 320.4 408.3 408.8 313.3 370.6 386.7 [11] 434.4 467.0 414.6 423.6 497.7 567.4 736.7 837.5 1208.3 1357.5 [21] 77.5 96.7 97.5 75.2 85.9 149.6 145.0 134.0 142.8 148.5 [31] 156.1 157.0 140.6 145.7 138.5 183.8 188.9 182.6 199.7 181.2 [41] 109.4 156.6 205.3 159.1 173.1 227.3 209.6 195.8 207.7 203.6 [51] 225.3 241.1 208.9 211.4 204.2 262.1 282.2 312.0 350.5 405.3 [61] 68.4 82.6 91.8 83.3 81.1 147.3 142.4 141.9 143.2 143.2 [71] 148.7 150.2 139.9 143.0 138.4 181.8 186.7 193.6 211.1 210.6 [81] 120.7 144.6 197.2 147.3 160.0 235.0 247.4 235.2 222.8 210.3 [91] 210.4 225.0 208.6 198.9 203.6 245.1 287.1 286.0 294.5 307.4 Warning message: In predict.quadFuncEst(ggResShifterFacRan) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > all.equal( predict( ggResShifterFacRan ), + fitted( ggResShifterFacRan ), check.attributes = FALSE ) [1] "Mean relative difference: 0.404" Warning message: In predict.quadFuncEst(ggResShifterFacRan) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > round( predict( ggResShifterFacRan, newdata = ggData ), 2 ) 1 2 3 4 5 6 7 8 9 10 11 216.4 325.2 397.5 210.5 320.4 408.3 408.8 313.3 370.6 386.7 434.4 12 13 14 15 16 17 18 19 20 21 22 467.0 414.6 423.6 497.7 567.4 736.7 837.5 1208.3 1357.5 77.5 96.7 23 24 25 26 27 28 29 30 31 32 33 97.5 75.2 85.9 149.6 145.0 134.0 142.8 148.5 156.1 157.0 140.6 34 35 36 37 38 39 40 41 42 43 44 145.7 138.5 183.8 188.9 182.6 199.7 181.2 109.4 156.6 205.3 159.1 45 46 47 48 49 50 51 52 53 54 55 173.1 227.3 209.6 195.8 207.7 203.6 225.3 241.1 208.9 211.4 204.2 56 57 58 59 60 61 62 63 64 65 66 262.1 282.2 312.0 350.5 405.3 68.4 82.6 91.8 83.3 81.1 147.3 67 68 69 70 71 72 73 74 75 76 77 142.4 141.9 143.2 143.2 148.7 150.2 139.9 143.0 138.4 181.8 186.7 78 79 80 81 82 83 84 85 86 87 88 193.6 211.1 210.6 120.7 144.6 197.2 147.3 160.0 235.0 247.4 235.2 89 90 91 92 93 94 95 96 97 98 99 222.8 210.3 210.4 225.0 208.6 198.9 203.6 245.1 287.1 286.0 294.5 100 307.4 Warning message: In predict.quadFuncEst(ggResShifterFacRan, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > all.equal( predict( ggResShifterFacRan, newdata = ggData ), + fitted( ggResShifterFacRan ), check.attributes = FALSE ) [1] "Mean relative difference: 0.404" Warning message: In predict.quadFuncEst(ggResShifterFacRan, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > all.equal( predict( ggResShifterFacRan, newdata = ggData ), + predict( ggResShifterFacRan ), check.attributes = FALSE ) [1] TRUE Warning messages: 1: In predict.quadFuncEst(ggResShifterFacRan, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects 2: In predict.quadFuncEst(ggResShifterFacRan) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > > ## linear estimations with panel data > # fixed effects > ggResultLin <- quadFuncEst( "invest", c( "value", "capital" ), ggData, + linear = TRUE ) > coef( ggResultLin ) a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 -62.594 0.106 0.347 0.000 0.000 0.000 > vcov( ggResultLin ) a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 a_0 NA NA NA 0 0 0 a_1 NA 0.000253 -0.000143 0 0 0 a_2 NA -0.000143 0.000584 0 0 0 b_1_1 0 0.000000 0.000000 0 0 0 b_1_2 0 0.000000 0.000000 0 0 0 b_2_2 0 0.000000 0.000000 0 0 0 > print( ggResultLin ) $call quadFuncEst(yName = "invest", xNames = c("value", "capital"), data = ggData, linear = TRUE) $nExog [1] 2 $nShifter [1] 0 $est Model Formula: y ~ 1 + a_1 + a_2 Coefficients: a_1 a_2 0.106 0.347 $residuals 1 2 3 4 5 6 7 8 66.4369 -44.4141 -138.6486 -34.6716 -120.7564 -26.7213 17.2634 74.9768 9 10 11 12 13 14 15 16 54.5032 89.5623 32.3638 105.3433 7.2473 -59.4249 -114.6076 -60.0303 17 18 19 20 21 22 23 24 -98.8950 -50.5703 102.8538 198.1892 21.7770 9.8077 -10.0712 16.6080 25 26 27 28 29 30 31 32 -12.5412 -1.6095 3.4461 7.8749 -8.8459 -6.0457 9.5246 -20.6280 33 34 35 36 37 38 39 40 -2.8654 6.9180 -5.3040 -0.0383 33.7106 -3.4131 -21.8142 -16.4906 41 42 43 44 45 46 47 48 117.3074 37.3452 -18.6286 16.4553 -8.6746 25.9137 84.2159 66.0060 49 50 51 52 53 54 55 56 7.1731 8.7797 12.2025 48.0911 55.5784 30.0618 -25.6109 -59.4373 57 58 59 60 61 62 63 64 -48.1617 -72.6452 -107.1029 -168.8689 49.9103 28.8364 13.1248 15.1237 65 66 67 68 69 70 71 72 13.4940 10.6746 36.9385 20.6866 0.2505 -2.3236 -12.9903 0.9490 73 74 75 76 77 78 79 80 13.3288 -8.0048 -21.0880 -24.5674 -9.3906 -12.3368 -39.1037 -73.5119 81 82 83 84 85 86 87 88 -45.6759 53.7388 52.7869 -111.4046 -177.9735 -152.5226 37.3595 19.6862 89 90 91 92 93 94 95 96 -45.9411 -93.3282 -104.0384 27.9938 45.7519 123.2695 14.1808 24.4559 97 98 99 100 134.4282 169.8222 117.0075 -89.5970 $fitted 1 2 3 4 5 6 7 8 9 10 251.16 436.21 549.25 292.37 451.56 487.92 494.74 373.02 445.10 457.94 11 12 13 14 15 16 17 18 19 20 528.84 582.76 561.65 588.62 669.71 702.93 854.79 941.77 1201.55 1288.51 21 22 23 24 25 26 27 28 29 30 18.51 62.95 76.33 34.99 64.95 71.02 64.90 38.93 56.25 65.62 31 32 33 34 35 36 37 38 39 40 79.26 94.75 65.55 82.44 84.28 100.70 126.91 148.41 196.74 188.98 41 42 43 44 45 46 47 48 49 50 -84.21 7.65 95.83 28.14 56.77 48.49 28.78 25.89 54.13 48.02 51 52 53 54 55 56 57 58 59 60 81.40 111.81 91.62 116.24 123.91 152.94 183.36 229.95 286.60 358.47 61 62 63 64 65 66 67 68 69 70 -36.98 -2.94 21.93 7.77 5.35 17.90 11.57 22.65 36.77 40.13 71 72 73 74 75 76 77 78 79 80 52.26 52.51 42.23 57.56 53.13 56.81 63.77 84.12 129.18 142.11 81 82 83 84 85 86 87 88 89 90 255.58 301.56 417.11 373.70 408.37 414.12 435.44 425.91 407.54 381.53 91 92 93 94 95 96 97 98 99 100 362.74 392.31 374.75 371.23 390.92 394.34 453.77 475.38 523.99 548.90 $coef a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 -62.594 0.106 0.347 0.000 0.000 0.000 $coefCov a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 a_0 NA NA NA 0 0 0 a_1 NA 0.000253 -0.000143 0 0 0 a_2 NA -0.000143 0.000584 0 0 0 b_1_1 0 0.000000 0.000000 0 0 0 b_1_2 0 0.000000 0.000000 0 0 0 b_2_2 0 0.000000 0.000000 0 0 0 $r2 [1] 0.8 $r2bar [1] 0.787 $nObs [1] 100 $yName [1] "invest" $xNames [1] "value" "capital" $regScale [1] 1 attr(,"class") [1] "quadFuncEst" > round( fitted( ggResultLin ), 2 ) 1 2 3 4 5 6 7 8 9 10 251.16 436.21 549.25 292.37 451.56 487.92 494.74 373.02 445.10 457.94 11 12 13 14 15 16 17 18 19 20 528.84 582.76 561.65 588.62 669.71 702.93 854.79 941.77 1201.55 1288.51 21 22 23 24 25 26 27 28 29 30 18.51 62.95 76.33 34.99 64.95 71.02 64.90 38.93 56.25 65.62 31 32 33 34 35 36 37 38 39 40 79.26 94.75 65.55 82.44 84.28 100.70 126.91 148.41 196.74 188.98 41 42 43 44 45 46 47 48 49 50 -84.21 7.65 95.83 28.14 56.77 48.49 28.78 25.89 54.13 48.02 51 52 53 54 55 56 57 58 59 60 81.40 111.81 91.62 116.24 123.91 152.94 183.36 229.95 286.60 358.47 61 62 63 64 65 66 67 68 69 70 -36.98 -2.94 21.93 7.77 5.35 17.90 11.57 22.65 36.77 40.13 71 72 73 74 75 76 77 78 79 80 52.26 52.51 42.23 57.56 53.13 56.81 63.77 84.12 129.18 142.11 81 82 83 84 85 86 87 88 89 90 255.58 301.56 417.11 373.70 408.37 414.12 435.44 425.91 407.54 381.53 91 92 93 94 95 96 97 98 99 100 362.74 392.31 374.75 371.23 390.92 394.34 453.77 475.38 523.99 548.90 > all.equal( predict( ggResultLin ), + fitted( ggResultLin ), check.attributes = FALSE ) [1] TRUE Warning message: In predict.quadFuncEst(ggResultLin) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > round( predict( ggResultLin, newdata = ggData ), 2 ) 1 2 3 4 5 6 7 8 9 10 264.64 449.69 562.72 305.84 465.03 501.39 508.21 386.50 458.57 471.41 11 12 13 14 15 16 17 18 19 20 542.31 596.23 575.13 602.10 683.18 716.40 868.27 955.24 1215.02 1301.98 21 22 23 24 25 26 27 28 29 30 -14.71 29.73 43.11 1.77 31.73 37.80 31.68 5.70 23.03 32.39 31 32 33 34 35 36 37 38 39 40 46.03 61.53 32.32 49.22 51.06 67.48 93.69 115.19 163.52 155.76 41 42 43 44 45 46 47 48 49 50 95.37 187.23 275.40 207.72 236.35 228.06 208.36 205.47 233.70 227.60 51 52 53 54 55 56 57 58 59 60 260.97 291.39 271.20 295.81 303.49 332.51 362.94 409.52 466.18 538.05 61 62 63 64 65 66 67 68 69 70 -41.68 -7.63 17.23 3.07 0.65 13.20 6.88 17.96 32.07 35.44 71 72 73 74 75 76 77 78 79 80 47.57 47.82 37.54 52.87 48.43 52.11 59.08 79.42 124.49 137.42 81 82 83 84 85 86 87 88 89 90 100.44 146.43 261.98 218.57 253.24 258.99 280.31 270.78 252.41 226.40 91 92 93 94 95 96 97 98 99 100 207.61 237.17 219.62 216.10 235.79 239.21 298.64 320.24 368.86 393.76 Warning message: In predict.quadFuncEst(ggResultLin, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > all.equal( predict( ggResultLin, newdata = ggData ), + fitted( ggResultLin ), check.attributes = FALSE ) [1] "Mean relative difference: 0.309" Warning message: In predict.quadFuncEst(ggResultLin, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > all.equal( predict( ggResultLin, newdata = ggData ), + predict( ggResultLin ), check.attributes = FALSE ) [1] "Mean relative difference: 0.309" Warning messages: 1: In predict.quadFuncEst(ggResultLin, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects 2: In predict.quadFuncEst(ggResultLin) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > # random effects > ggResultLinRan <- quadFuncEst( "invest", c( "value", "capital" ), ggData, + linear = TRUE, model = "random", random.method = "amemiya" ) > coef( ggResultLinRan ) a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 -60.388 0.105 0.346 0.000 0.000 0.000 > vcov( ggResultLinRan ) a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 a_0 3083.3469 -0.380620 0.077853 0 0 0 a_1 -0.3806 0.000220 -0.000135 0 0 0 a_2 0.0779 -0.000135 0.000587 0 0 0 b_1_1 0.0000 0.000000 0.000000 0 0 0 b_1_2 0.0000 0.000000 0.000000 0 0 0 b_2_2 0.0000 0.000000 0.000000 0 0 0 > print( ggResultLinRan ) $call quadFuncEst(yName = "invest", xNames = c("value", "capital"), data = ggData, linear = TRUE, model = "random", random.method = "amemiya") $nExog [1] 2 $nShifter [1] 0 $est Model Formula: y ~ 1 + a_1 + a_2 Coefficients: (Intercept) a_1 a_2 -60.388 0.105 0.346 $residuals 1 2 3 4 5 6 7 8 63.197 -45.963 -139.373 -38.086 -122.579 -28.195 15.722 72.094 9 10 11 12 13 14 15 16 52.445 87.808 31.132 104.259 4.940 -61.919 -116.575 -61.891 17 18 19 20 21 22 23 24 -99.559 -51.002 104.015 198.944 25.952 14.424 -5.392 20.830 25 26 27 28 29 30 31 32 -8.058 2.926 7.898 12.080 -4.457 -1.545 14.177 -15.908 33 34 35 36 37 38 39 40 1.532 11.445 -0.864 4.520 38.414 1.258 -16.822 -11.769 41 42 43 44 45 46 47 48 90.745 11.674 -43.466 -9.160 -34.052 0.414 58.425 39.997 49 50 51 52 53 54 55 56 -18.647 -17.104 -13.346 22.769 29.745 4.226 -51.582 -85.203 57 58 59 60 61 62 63 64 -73.693 -97.870 -131.977 -193.281 49.818 29.084 13.600 15.429 65 66 67 68 69 70 71 72 13.760 11.056 37.230 21.019 0.656 -1.904 -12.454 1.505 73 74 75 76 77 78 79 80 13.713 -7.524 -20.683 -24.112 -8.846 -11.635 -38.039 -72.428 81 82 83 84 85 86 87 88 -24.361 75.518 75.520 -89.503 -155.876 -130.204 59.869 41.996 89 90 91 92 93 94 95 96 -23.822 -71.402 -82.114 50.158 67.651 145.015 35.997 46.287 97 98 99 100 156.892 192.212 139.372 -67.116 $fitted 1 2 3 4 5 6 7 8 9 10 254.40 437.76 549.97 295.79 453.38 489.39 496.28 375.91 447.15 459.69 11 12 13 14 15 16 17 18 19 20 530.07 583.84 563.96 591.12 671.67 704.79 855.46 942.20 1200.39 1287.76 21 22 23 24 25 26 27 28 29 30 14.34 58.34 71.65 30.77 60.47 66.48 60.45 34.72 51.86 61.12 31 32 33 34 35 36 37 38 39 40 74.60 90.03 61.15 77.92 79.84 96.14 122.21 143.74 191.75 184.26 41 42 43 44 45 46 47 48 49 50 -57.64 33.33 120.67 53.76 82.15 73.99 54.58 51.90 79.95 73.90 51 52 53 54 55 56 57 58 59 60 106.95 137.13 117.46 142.07 149.88 178.70 208.89 255.17 311.48 382.88 61 62 63 64 65 66 67 68 69 70 -36.89 -3.18 21.45 7.46 5.08 17.51 11.28 22.32 36.36 39.71 71 72 73 74 75 76 77 78 79 80 51.72 51.95 41.85 57.08 52.72 56.35 63.23 83.42 128.12 141.03 81 82 83 84 85 86 87 88 89 90 234.26 279.78 394.38 351.80 386.28 391.80 412.93 403.60 385.42 359.60 91 92 93 94 95 96 97 98 99 100 340.81 370.14 352.85 349.48 369.10 372.51 431.31 452.99 501.63 526.42 $coef a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 -60.388 0.105 0.346 0.000 0.000 0.000 $coefCov a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 a_0 3083.3469 -0.380620 0.077853 0 0 0 a_1 -0.3806 0.000220 -0.000135 0 0 0 a_2 0.0779 -0.000135 0.000587 0 0 0 b_1_1 0.0000 0.000000 0.000000 0 0 0 b_1_2 0.0000 0.000000 0.000000 0 0 0 b_2_2 0.0000 0.000000 0.000000 0 0 0 $r2 [1] 0.799 $r2bar [1] 0.795 $nObs [1] 100 $yName [1] "invest" $xNames [1] "value" "capital" $regScale [1] 1 attr(,"class") [1] "quadFuncEst" > round( fitted( ggResultLinRan ), 2 ) 1 2 3 4 5 6 7 8 9 10 254.40 437.76 549.97 295.79 453.38 489.39 496.28 375.91 447.15 459.69 11 12 13 14 15 16 17 18 19 20 530.07 583.84 563.96 591.12 671.67 704.79 855.46 942.20 1200.39 1287.76 21 22 23 24 25 26 27 28 29 30 14.34 58.34 71.65 30.77 60.47 66.48 60.45 34.72 51.86 61.12 31 32 33 34 35 36 37 38 39 40 74.60 90.03 61.15 77.92 79.84 96.14 122.21 143.74 191.75 184.26 41 42 43 44 45 46 47 48 49 50 -57.64 33.33 120.67 53.76 82.15 73.99 54.58 51.90 79.95 73.90 51 52 53 54 55 56 57 58 59 60 106.95 137.13 117.46 142.07 149.88 178.70 208.89 255.17 311.48 382.88 61 62 63 64 65 66 67 68 69 70 -36.89 -3.18 21.45 7.46 5.08 17.51 11.28 22.32 36.36 39.71 71 72 73 74 75 76 77 78 79 80 51.72 51.95 41.85 57.08 52.72 56.35 63.23 83.42 128.12 141.03 81 82 83 84 85 86 87 88 89 90 234.26 279.78 394.38 351.80 386.28 391.80 412.93 403.60 385.42 359.60 91 92 93 94 95 96 97 98 99 100 340.81 370.14 352.85 349.48 369.10 372.51 431.31 452.99 501.63 526.42 > unname( round( predict( ggResultLinRan ), 2 ) ) [1] 263.61 446.97 559.18 304.99 462.59 498.60 505.48 385.11 456.36 [10] 468.90 539.27 593.05 573.17 600.33 680.88 714.00 864.67 951.41 [19] 1209.59 1296.96 -12.95 31.05 44.37 3.49 33.18 39.20 33.17 [28] 7.44 24.57 33.83 47.32 62.74 33.86 50.63 52.56 68.86 [37] 94.92 116.46 164.47 156.98 96.29 187.26 274.60 207.69 236.09 [46] 227.92 208.51 205.84 233.88 227.84 260.88 291.06 271.39 296.01 [55] 303.81 332.64 362.83 409.10 465.41 536.81 -39.67 -5.97 18.67 [64] 4.68 2.30 14.73 8.50 19.54 33.58 36.93 48.94 49.17 [73] 39.06 54.30 49.94 53.57 60.44 80.63 125.34 138.25 101.19 [82] 146.71 261.31 218.73 253.20 258.73 279.86 270.53 252.35 226.53 [91] 207.74 237.07 219.78 216.41 236.03 239.44 298.23 319.91 368.55 [100] 393.34 Warning message: In predict.quadFuncEst(ggResultLinRan) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > all.equal( predict( ggResultLinRan ), + fitted( ggResultLinRan ), check.attributes = FALSE ) [1] "Mean relative difference: 0.261" Warning message: In predict.quadFuncEst(ggResultLinRan) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > round( predict( ggResultLinRan, newdata = ggData ), 2 ) 1 2 3 4 5 6 7 8 9 10 263.61 446.97 559.18 304.99 462.59 498.60 505.48 385.11 456.36 468.90 11 12 13 14 15 16 17 18 19 20 539.27 593.05 573.17 600.33 680.88 714.00 864.67 951.41 1209.59 1296.96 21 22 23 24 25 26 27 28 29 30 -12.95 31.05 44.37 3.49 33.18 39.20 33.17 7.44 24.57 33.83 31 32 33 34 35 36 37 38 39 40 47.32 62.74 33.86 50.63 52.56 68.86 94.92 116.46 164.47 156.98 41 42 43 44 45 46 47 48 49 50 96.29 187.26 274.60 207.69 236.09 227.92 208.51 205.84 233.88 227.84 51 52 53 54 55 56 57 58 59 60 260.88 291.06 271.39 296.01 303.81 332.64 362.83 409.10 465.41 536.81 61 62 63 64 65 66 67 68 69 70 -39.67 -5.97 18.67 4.68 2.30 14.73 8.50 19.54 33.58 36.93 71 72 73 74 75 76 77 78 79 80 48.94 49.17 39.06 54.30 49.94 53.57 60.44 80.63 125.34 138.25 81 82 83 84 85 86 87 88 89 90 101.19 146.71 261.31 218.73 253.20 258.73 279.86 270.53 252.35 226.53 91 92 93 94 95 96 97 98 99 100 207.74 237.07 219.78 216.41 236.03 239.44 298.23 319.91 368.55 393.34 Warning message: In predict.quadFuncEst(ggResultLinRan, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > all.equal( predict( ggResultLinRan, newdata = ggData ), + fitted( ggResultLinRan ), check.attributes = FALSE ) [1] "Mean relative difference: 0.261" Warning message: In predict.quadFuncEst(ggResultLinRan, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > all.equal( predict( ggResultLinRan, newdata = ggData ), + predict( ggResultLinRan ), check.attributes = FALSE ) [1] TRUE Warning messages: 1: In predict.quadFuncEst(ggResultLinRan, newdata = ggData) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects 2: In predict.quadFuncEst(ggResultLinRan) : predictions with panel data models may not return what you expect as it may ignore individual and/or time effects > > ## compute partial derivatives of linear estimation results with panel data > # fixed effects > margProducts <- quadFuncDeriv( c( "value", "capital" ), + data = ggData, coef = coef( ggResultLin ), coefCov = vcov( ggResultLin ) ) > sapply( margProducts, sd ) value capital 0 0 > all.equal( margProducts[1,], coef( ggResultLin )[2:3], + check.attributes = FALSE ) [1] TRUE > all.equal( attributes( margProducts )$variance[1,], diag( vcov( ggResultLin ) )[2:3], + check.attributes = FALSE ) [1] TRUE > # random effects > margProducts <- quadFuncDeriv( c( "value", "capital" ), + data = ggData, coef = coef( ggResultLinRan ), coefCov = vcov( ggResultLinRan ) ) > sapply( margProducts, sd ) value capital 0 0 > all.equal( margProducts[1,], coef( ggResultLinRan )[2:3], + check.attributes = FALSE ) [1] TRUE > all.equal( attributes( margProducts )$variance[1,], diag( vcov( ggResultLinRan ) )[2:3], + check.attributes = FALSE ) [1] TRUE > > ## compute elasticities using results of estimations with panel data > ggElaObs <- quadFuncEla( xNames = c( "value", "capital" ), + data = ggData, coef = coef( ggResult ), yName = "invest" ) > all.equal( ggElaObs, elas( ggResult, yObs = TRUE ) ) [1] TRUE > print( ggElaObs ) value capital 1 0.720 0.00180 2 1.044 0.03458 3 1.265 0.11168 4 0.849 0.17910 5 1.169 0.16335 6 0.929 0.12403 7 0.827 0.13916 8 0.613 0.16666 9 0.726 0.14026 10 0.721 0.09847 11 0.824 0.13652 12 0.713 0.17991 13 0.623 0.41583 14 0.635 0.56173 15 0.731 0.63896 16 0.657 0.61381 17 0.792 0.64684 18 0.725 0.69829 19 0.726 0.70486 20 0.603 0.82819 21 0.563 0.03251 22 0.663 0.01925 23 0.782 0.07423 24 0.473 0.13093 25 0.752 0.17083 26 0.613 0.13634 27 0.546 0.15347 28 0.493 0.20142 29 0.712 0.19371 30 0.680 0.14151 31 0.562 0.08798 32 0.726 0.16956 33 0.538 0.21653 34 0.462 0.17923 35 0.447 0.27392 36 0.421 0.24615 37 0.318 0.20303 38 0.327 0.33770 39 0.394 0.36323 40 0.280 0.44037 41 2.218 0.46722 42 3.104 0.42773 43 2.748 0.32058 44 3.249 0.67054 45 3.432 0.71764 46 2.082 0.49655 47 1.159 0.37775 48 1.237 0.60773 49 2.105 1.05867 50 2.178 1.13793 51 1.624 0.71910 52 1.078 0.47579 53 0.869 0.67241 54 0.871 0.83942 55 1.170 1.44681 56 1.422 1.65469 57 1.142 1.23238 58 1.170 1.21298 59 1.228 1.25144 60 1.434 1.42181 61 0.776 0.01627 62 1.092 0.00391 63 1.178 0.02823 64 1.363 0.10277 65 1.533 0.16142 66 1.242 0.12341 67 0.621 0.09812 68 0.738 0.18973 69 0.969 0.31879 70 0.968 0.33999 71 1.112 0.33982 72 0.843 0.23219 73 0.614 0.28402 74 0.800 0.38703 75 1.086 0.64565 76 1.179 0.62247 77 0.802 0.35445 78 0.744 0.31373 79 0.864 0.32657 80 1.149 0.53815 81 0.408 0.04062 82 0.336 0.02437 83 0.426 0.05176 84 0.497 0.19552 85 0.638 0.28262 86 0.633 0.20253 87 0.387 0.11868 88 0.371 0.14269 89 0.412 0.17338 90 0.460 0.19348 91 0.510 0.15937 92 0.362 0.11162 93 0.310 0.12438 94 0.238 0.12260 95 0.305 0.17700 96 0.298 0.17545 97 0.306 0.12903 98 0.270 0.15869 99 0.269 0.24196 100 0.401 0.37460 > ggElaObsRan <- quadFuncEla( xNames = c( "value", "capital" ), + data = ggData, coef = coef( ggResultRan ), yName = "invest" ) > all.equal( ggElaObsRan, elas( ggResultRan, yObs = TRUE ) ) [1] TRUE > print( ggElaObsRan ) value capital 1 0.751 0.00181 2 1.040 0.03505 3 1.240 0.11325 4 0.894 0.17915 5 1.178 0.16479 6 0.928 0.12529 7 0.829 0.14040 8 0.636 0.16689 9 0.737 0.14116 10 0.725 0.09937 11 0.820 0.13787 12 0.710 0.18131 13 0.643 0.41433 14 0.661 0.55793 15 0.752 0.63542 16 0.676 0.61011 17 0.798 0.64520 18 0.731 0.69539 19 0.719 0.70310 20 0.606 0.82206 21 0.660 0.03182 22 0.758 0.01897 23 0.892 0.07317 24 0.552 0.12817 25 0.866 0.16782 26 0.703 0.13403 27 0.630 0.15067 28 0.575 0.19704 29 0.824 0.19003 30 0.782 0.13907 31 0.642 0.08665 32 0.826 0.16702 33 0.621 0.21231 34 0.531 0.17600 35 0.515 0.26847 36 0.482 0.24155 37 0.362 0.19945 38 0.372 0.33107 39 0.443 0.35703 40 0.318 0.43109 41 2.489 0.46171 42 3.363 0.42624 43 2.893 0.32128 44 3.514 0.66766 45 3.682 0.71559 46 2.243 0.49452 47 1.263 0.37503 48 1.358 0.60138 49 2.296 1.04864 50 2.382 1.12651 51 1.755 0.71384 52 1.156 0.47286 53 0.949 0.66429 54 0.951 0.82808 55 1.285 1.42406 56 1.551 1.63064 57 1.237 1.21618 58 1.256 1.19864 59 1.307 1.23815 60 1.510 1.40881 61 0.921 0.01586 62 1.272 0.00383 63 1.356 0.02778 64 1.583 0.10084 65 1.783 0.15828 66 1.436 0.12121 67 0.721 0.09623 68 0.855 0.18607 69 1.118 0.31281 70 1.116 0.33363 71 1.275 0.33399 72 0.965 0.22830 73 0.708 0.27845 74 0.919 0.37979 75 1.251 0.63278 76 1.355 0.61055 77 0.919 0.34812 78 0.846 0.30864 79 0.966 0.32240 80 1.285 0.53095 81 0.454 0.04026 82 0.368 0.02427 83 0.450 0.05182 84 0.542 0.19394 85 0.691 0.28046 86 0.680 0.20157 87 0.413 0.11826 88 0.399 0.14188 89 0.445 0.17212 90 0.500 0.19187 91 0.555 0.15827 92 0.391 0.11102 93 0.337 0.12335 94 0.261 0.12133 95 0.333 0.17512 96 0.326 0.17358 97 0.327 0.12832 98 0.290 0.15743 99 0.290 0.23928 100 0.430 0.37049 > # with shifter variables > ggShifterElaObs <- quadFuncEla( xNames = c( "value", "capital" ), + data = ggData, coef = coef( ggResShifter ), yName = "invest" ) > all.equal( ggShifterElaObs, elas( ggResShifter, yObs = TRUE ) ) [1] TRUE > print( ggShifterElaObs ) value capital 1 0.719 0.0018 2 1.043 0.0346 3 1.264 0.1118 4 0.848 0.1790 5 1.168 0.1635 6 0.929 0.1241 7 0.827 0.1392 8 0.612 0.1666 9 0.726 0.1403 10 0.720 0.0985 11 0.824 0.1366 12 0.713 0.1800 13 0.623 0.4154 14 0.635 0.5609 15 0.731 0.6382 16 0.657 0.6130 17 0.792 0.6463 18 0.726 0.6975 19 0.727 0.7042 20 0.604 0.8269 21 0.562 0.0324 22 0.661 0.0192 23 0.780 0.0741 24 0.472 0.1306 25 0.750 0.1704 26 0.611 0.1360 27 0.545 0.1531 28 0.492 0.2008 29 0.710 0.1932 30 0.678 0.1412 31 0.560 0.0878 32 0.724 0.1692 33 0.536 0.2160 34 0.461 0.1788 35 0.446 0.2732 36 0.420 0.2455 37 0.317 0.2025 38 0.326 0.3368 39 0.394 0.3623 40 0.280 0.4390 41 2.212 0.4664 42 3.099 0.4274 43 2.744 0.3205 44 3.243 0.6699 45 3.427 0.7171 46 2.079 0.4961 47 1.158 0.3773 48 1.235 0.6067 49 2.102 1.0570 50 2.176 1.1361 51 1.622 0.7181 52 1.076 0.4752 53 0.868 0.6711 54 0.870 0.8376 55 1.169 1.4433 56 1.421 1.6509 57 1.142 1.2298 58 1.170 1.2106 59 1.228 1.2491 60 1.435 1.4194 61 0.773 0.0162 62 1.089 0.0039 63 1.175 0.0282 64 1.359 0.1025 65 1.528 0.1610 66 1.238 0.1231 67 0.619 0.0979 68 0.736 0.1892 69 0.966 0.3180 70 0.965 0.3391 71 1.110 0.3390 72 0.841 0.2317 73 0.612 0.2833 74 0.798 0.3860 75 1.083 0.6439 76 1.176 0.6208 77 0.800 0.3536 78 0.742 0.3130 79 0.862 0.3259 80 1.147 0.5371 81 0.407 0.0406 82 0.335 0.0243 83 0.425 0.0517 84 0.496 0.1952 85 0.637 0.2822 86 0.633 0.2023 87 0.386 0.1186 88 0.371 0.1425 89 0.411 0.1731 90 0.459 0.1932 91 0.509 0.1592 92 0.361 0.1115 93 0.309 0.1242 94 0.238 0.1224 95 0.304 0.1767 96 0.297 0.1751 97 0.305 0.1289 98 0.270 0.1585 99 0.269 0.2415 100 0.401 0.3739 > ggShifterElaObs2 <- quadFuncEla( xNames = c( "value", "capital" ), + data = ggData, coef = coef( ggResShifter ), yName = "invest", + shifterNames = "tech" ) > all.equal( ggShifterElaObs, ggShifterElaObs2 ) [1] TRUE > ggShifterElaObsRan <- quadFuncEla( xNames = c( "value", "capital" ), + data = ggData, coef = coef( ggResShifterRan ), yName = "invest" ) > all.equal( ggShifterElaObsRan, elas( ggResShifterRan, yObs = TRUE ) ) [1] TRUE > print( ggShifterElaObsRan ) value capital 1 0.758 0.0018 2 1.046 0.0348 3 1.245 0.1123 4 0.899 0.1796 5 1.182 0.1641 6 0.932 0.1246 7 0.831 0.1398 8 0.639 0.1672 9 0.740 0.1408 10 0.728 0.0989 11 0.822 0.1372 12 0.711 0.1808 13 0.642 0.4170 14 0.659 0.5631 15 0.749 0.6407 16 0.672 0.6155 17 0.793 0.6491 18 0.726 0.7006 19 0.712 0.7076 20 0.598 0.8307 21 0.669 0.0324 22 0.768 0.0192 23 0.903 0.0741 24 0.559 0.1306 25 0.876 0.1705 26 0.712 0.1361 27 0.637 0.1532 28 0.583 0.2009 29 0.834 0.1933 30 0.792 0.1413 31 0.649 0.0879 32 0.836 0.1694 33 0.628 0.2161 34 0.537 0.1789 35 0.520 0.2734 36 0.487 0.2458 37 0.365 0.2028 38 0.374 0.3372 39 0.445 0.3630 40 0.319 0.4398 41 2.515 0.4671 42 3.392 0.4284 43 2.913 0.3215 44 3.541 0.6716 45 3.708 0.7190 46 2.259 0.4974 47 1.271 0.3782 48 1.367 0.6081 49 2.309 1.0596 50 2.395 1.1388 51 1.764 0.7201 52 1.161 0.4766 53 0.952 0.6729 54 0.954 0.8399 55 1.287 1.4471 56 1.553 1.6555 57 1.238 1.2334 58 1.256 1.2144 59 1.305 1.2533 60 1.507 1.4245 61 0.935 0.0162 62 1.290 0.0039 63 1.374 0.0282 64 1.604 0.1025 65 1.807 0.1610 66 1.455 0.1232 67 0.730 0.0979 68 0.865 0.1893 69 1.131 0.3182 70 1.129 0.3393 71 1.290 0.3393 72 0.976 0.2318 73 0.716 0.2835 74 0.928 0.3864 75 1.265 0.6444 76 1.370 0.6213 77 0.929 0.3539 78 0.854 0.3134 79 0.975 0.3265 80 1.295 0.5380 81 0.459 0.0406 82 0.371 0.0244 83 0.453 0.0519 84 0.545 0.1957 85 0.695 0.2830 86 0.684 0.2029 87 0.415 0.1189 88 0.401 0.1429 89 0.448 0.1736 90 0.503 0.1937 91 0.559 0.1596 92 0.393 0.1118 93 0.340 0.1245 94 0.263 0.1227 95 0.335 0.1771 96 0.327 0.1756 97 0.328 0.1293 98 0.291 0.1589 99 0.290 0.2422 100 0.431 0.3751 > > ## imposing homogeneity on linear functions with panel data > ggResultLinHom <- quadFuncEst( "invest", + xNames = c( "value", "capital" ), data = ggData, + linear = TRUE, homWeights = c( value = 0.3, capital = 0.7 ) ) > coef( ggResultLinHom ) a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 516 -123 123 0 0 0 > all.equal( coef( ggResultLinHom )[2], - coef( ggResultLinHom )[3], + check.attributes = FALSE ) [1] TRUE > vcov( ggResultLinHom ) a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 a_0 NA NA NA 0 0 0 a_1 NA 475 -475 0 0 0 a_2 NA -475 475 0 0 0 b_1_1 0 0 0 0 0 0 b_1_2 0 0 0 0 0 0 b_2_2 0 0 0 0 0 0 > all.equal( vcov( ggResultLinHom )[ -1, 2 ], + - vcov( ggResultLinHom )[ -1, 3 ] ) [1] TRUE > all.equal( vcov( ggResultLinHom )[ 2, -1 ], + - vcov( ggResultLinHom )[ 3, -1 ] ) [1] TRUE > > ## imposing homogeneity on quadratic functions with panel data > ggResultHom <- quadFuncEst( "invest", + xNames = c( "value", "capital" ), data = ggData, + homWeights = c( value = 0.3, capital = 0.7 ) ) > coef( ggResultHom ) a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 627 -239 239 55 -55 55 > all.equal( coef( ggResultHom )[2], - coef( ggResultHom )[3], + check.attributes = FALSE ) # a_1:2 [1] TRUE > all.equal( coef( ggResultHom )[4], - coef( ggResultHom )[5], + check.attributes = FALSE ) # b_1_1:2 [1] TRUE > all.equal( coef( ggResultHom )[5], - coef( ggResultHom )[6], + check.attributes = FALSE ) # b_2_1:2 [1] TRUE > vcov( ggResultHom ) a_0 a_1 a_2 b_1_1 b_1_2 b_2_2 a_0 NA NA NA NA NA NA a_1 NA 17697 -17697 -8153 8153 -8153 a_2 NA -17697 17697 8153 -8153 8153 b_1_1 NA -8153 8153 3860 -3860 3860 b_1_2 NA 8153 -8153 -3860 3860 -3860 b_2_2 NA -8153 8153 3860 -3860 3860 > all.equal( vcov( ggResultHom )[ -1, 2 ], + - vcov( ggResultHom )[ -1, 3 ] ) # a_1:2 [1] TRUE > all.equal( vcov( ggResultHom )[ -1, 4 ], + - vcov( ggResultHom )[ -1, 5 ] ) # b_1_1:2 [1] TRUE > all.equal( vcov( ggResultHom )[ -1, 5 ], + - vcov( ggResultHom )[ -1, 6 ] ) # b_2_1:2 [1] TRUE > all.equal( vcov( ggResultHom )[ 2, -1 ], + - vcov( ggResultHom )[ 3, -1 ] ) # a_1:2 [1] TRUE > all.equal( vcov( ggResultHom )[ 4, -1 ], + - vcov( ggResultHom )[ 5, -1 ] ) # b_1_1:2 [1] TRUE > all.equal( vcov( ggResultHom )[ 5, -1 ], + - vcov( ggResultHom )[ 6, -1 ] ) # b_2_1:2 [1] TRUE > > ########## many coefficients ############## > set.seed( 123 ) > nObs <- 200 > testData <- data.frame( y = rep( 3, nObs ) ) > for( i in 1:15 ) { + xName <- paste( "x", i, sep = "_" ) + testData[[ xName ]] <- rnorm( nObs ) + testData$y <- testData$y + log( i + 1 ) * testData[[ xName ]] + } > testData$y <- testData$y + 0.1 * rnorm( nObs ) > testResult <- quadFuncEst( yName = "y", + xNames = paste( "x", 1:15, sep = "_" ), + data = testData, linear = TRUE ) > coef( testResult ) a_0 a_1 a_2 a_3 a_4 a_5 a_6 a_7 a_8 a_9 2.988 0.687 1.095 1.379 1.605 1.795 1.945 2.077 2.200 2.299 a_10 a_11 a_12 a_13 a_14 a_15 b_1_1 b_1_2 b_1_3 b_1_4 2.408 2.488 2.558 2.643 2.699 2.774 0.000 0.000 0.000 0.000 b_1_5 b_1_6 b_1_7 b_1_8 b_1_9 b_1_10 b_1_11 b_1_12 b_1_13 b_1_14 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 b_1_15 b_2_2 b_2_3 b_2_4 b_2_5 b_2_6 b_2_7 b_2_8 b_2_9 b_2_10 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 b_2_11 b_2_12 b_2_13 b_2_14 b_2_15 b_3_3 b_3_4 b_3_5 b_3_6 b_3_7 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 b_3_8 b_3_9 b_3_10 b_3_11 b_3_12 b_3_13 b_3_14 b_3_15 b_4_4 b_4_5 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 b_4_6 b_4_7 b_4_8 b_4_9 b_4_10 b_4_11 b_4_12 b_4_13 b_4_14 b_4_15 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 b_5_5 b_5_6 b_5_7 b_5_8 b_5_9 b_5_10 b_5_11 b_5_12 b_5_13 b_5_14 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 b_5_15 b_6_6 b_6_7 b_6_8 b_6_9 b_6_10 b_6_11 b_6_12 b_6_13 b_6_14 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 b_6_15 b_7_7 b_7_8 b_7_9 b_7_10 b_7_11 b_7_12 b_7_13 b_7_14 b_7_15 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 b_8_8 b_8_9 b_8_10 b_8_11 b_8_12 b_8_13 b_8_14 b_8_15 b_9_9 b_9_10 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 b_9_11 b_9_12 b_9_13 b_9_14 b_9_15 b_10_10 b_10_11 b_10_12 b_10_13 b_10_14 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 b_10_15 b_11_11 b_11_12 b_11_13 b_11_14 b_11_15 b_12_12 b_12_13 b_12_14 b_12_15 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 0.000 b_13_13 b_13_14 b_13_15 b_14_14 b_14_15 b_15_15 0.000 0.000 0.000 0.000 0.000 0.000 > rownames( vcov( testResult ) ) [1] "a_0" "a_1" "a_2" "a_3" "a_4" "a_5" "a_6" [8] "a_7" "a_8" "a_9" "a_10" "a_11" "a_12" "a_13" [15] "a_14" "a_15" "b_1_1" "b_1_2" "b_1_3" "b_1_4" "b_1_5" [22] "b_1_6" "b_1_7" "b_1_8" "b_1_9" "b_1_10" "b_1_11" "b_1_12" [29] "b_1_13" "b_1_14" "b_1_15" "b_2_2" "b_2_3" "b_2_4" "b_2_5" [36] "b_2_6" "b_2_7" "b_2_8" "b_2_9" "b_2_10" "b_2_11" "b_2_12" [43] "b_2_13" "b_2_14" "b_2_15" "b_3_3" "b_3_4" "b_3_5" "b_3_6" [50] "b_3_7" "b_3_8" "b_3_9" "b_3_10" "b_3_11" "b_3_12" "b_3_13" [57] "b_3_14" "b_3_15" "b_4_4" "b_4_5" "b_4_6" "b_4_7" "b_4_8" [64] "b_4_9" "b_4_10" "b_4_11" "b_4_12" "b_4_13" "b_4_14" "b_4_15" [71] "b_5_5" "b_5_6" "b_5_7" "b_5_8" "b_5_9" "b_5_10" "b_5_11" [78] "b_5_12" "b_5_13" "b_5_14" "b_5_15" "b_6_6" "b_6_7" "b_6_8" [85] "b_6_9" "b_6_10" "b_6_11" "b_6_12" "b_6_13" "b_6_14" "b_6_15" [92] "b_7_7" "b_7_8" "b_7_9" "b_7_10" "b_7_11" "b_7_12" "b_7_13" [99] "b_7_14" "b_7_15" "b_8_8" "b_8_9" "b_8_10" "b_8_11" "b_8_12" [106] "b_8_13" "b_8_14" "b_8_15" "b_9_9" "b_9_10" "b_9_11" "b_9_12" [113] "b_9_13" "b_9_14" "b_9_15" "b_10_10" "b_10_11" "b_10_12" "b_10_13" [120] "b_10_14" "b_10_15" "b_11_11" "b_11_12" "b_11_13" "b_11_14" "b_11_15" [127] "b_12_12" "b_12_13" "b_12_14" "b_12_15" "b_13_13" "b_13_14" "b_13_15" [134] "b_14_14" "b_14_15" "b_15_15" > colnames( vcov( testResult ) ) [1] "a_0" "a_1" "a_2" "a_3" "a_4" "a_5" "a_6" [8] "a_7" "a_8" "a_9" "a_10" "a_11" "a_12" "a_13" [15] "a_14" "a_15" "b_1_1" "b_1_2" "b_1_3" "b_1_4" "b_1_5" [22] "b_1_6" "b_1_7" "b_1_8" "b_1_9" "b_1_10" "b_1_11" "b_1_12" [29] "b_1_13" "b_1_14" "b_1_15" "b_2_2" "b_2_3" "b_2_4" "b_2_5" [36] "b_2_6" "b_2_7" "b_2_8" "b_2_9" "b_2_10" "b_2_11" "b_2_12" [43] "b_2_13" "b_2_14" "b_2_15" "b_3_3" "b_3_4" "b_3_5" "b_3_6" [50] "b_3_7" "b_3_8" "b_3_9" "b_3_10" "b_3_11" "b_3_12" "b_3_13" [57] "b_3_14" "b_3_15" "b_4_4" "b_4_5" "b_4_6" "b_4_7" "b_4_8" [64] "b_4_9" "b_4_10" "b_4_11" "b_4_12" "b_4_13" "b_4_14" "b_4_15" [71] "b_5_5" "b_5_6" "b_5_7" "b_5_8" "b_5_9" "b_5_10" "b_5_11" [78] "b_5_12" "b_5_13" "b_5_14" "b_5_15" "b_6_6" "b_6_7" "b_6_8" [85] "b_6_9" "b_6_10" "b_6_11" "b_6_12" "b_6_13" "b_6_14" "b_6_15" [92] "b_7_7" "b_7_8" "b_7_9" "b_7_10" "b_7_11" "b_7_12" "b_7_13" [99] "b_7_14" "b_7_15" "b_8_8" "b_8_9" "b_8_10" "b_8_11" "b_8_12" [106] "b_8_13" "b_8_14" "b_8_15" "b_9_9" "b_9_10" "b_9_11" "b_9_12" [113] "b_9_13" "b_9_14" "b_9_15" "b_10_10" "b_10_11" "b_10_12" "b_10_13" [120] "b_10_14" "b_10_15" "b_11_11" "b_11_12" "b_11_13" "b_11_14" "b_11_15" [127] "b_12_12" "b_12_13" "b_12_14" "b_12_15" "b_13_13" "b_13_14" "b_13_15" [134] "b_14_14" "b_14_15" "b_15_15" > round( fitted( testResult ), 2 ) 1 2 3 4 5 6 7 8 9 10 11 9.01 -11.24 -4.45 13.96 4.65 10.28 0.16 5.40 7.08 0.55 -6.47 12 13 14 15 16 17 18 19 20 21 22 4.75 5.37 8.96 0.28 -4.15 -1.90 -9.01 0.09 8.23 -6.02 17.35 23 24 25 26 27 28 29 30 31 32 33 11.16 -3.31 -1.15 14.01 8.53 7.81 7.67 10.44 -16.77 1.21 -3.02 34 35 36 37 38 39 40 41 42 43 44 3.46 -3.26 4.08 3.20 16.36 10.68 2.01 -18.96 14.04 3.34 0.69 45 46 47 48 49 50 51 52 53 54 55 12.12 -3.63 -10.66 -10.50 13.48 -9.53 -2.11 12.14 19.86 6.99 25.00 56 57 58 59 60 61 62 63 64 65 66 3.41 1.04 11.83 8.00 -2.92 18.71 -0.94 3.99 0.35 -4.14 11.38 67 68 69 70 71 72 73 74 75 76 77 2.73 16.45 5.25 12.28 11.60 -1.13 0.01 -16.25 1.12 6.65 16.58 78 79 80 81 82 83 84 85 86 87 88 -9.93 -0.56 2.60 2.20 -3.18 0.24 -6.85 -0.50 0.47 1.18 -9.55 89 90 91 92 93 94 95 96 97 98 99 -1.13 -8.56 15.66 10.51 0.06 12.03 -2.73 7.83 7.96 1.54 14.41 100 101 102 103 104 105 106 107 108 109 110 3.14 -12.03 -8.83 -11.84 13.49 4.93 -2.17 8.75 4.57 -6.60 11.00 111 112 113 114 115 116 117 118 119 120 121 21.13 2.37 6.26 -3.29 2.18 8.54 10.28 -7.63 15.41 5.20 1.68 122 123 124 125 126 127 128 129 130 131 132 -6.92 -0.16 14.67 4.62 13.86 9.89 -6.69 5.23 -6.80 23.52 -0.67 133 134 135 136 137 138 139 140 141 142 143 -4.76 -2.16 -3.37 -6.41 9.08 -0.01 2.98 -0.19 6.52 0.22 -7.98 144 145 146 147 148 149 150 151 152 153 154 12.71 -4.31 -4.93 -3.91 9.24 9.80 -1.19 0.76 6.23 6.16 12.10 155 156 157 158 159 160 161 162 163 164 165 20.10 5.20 3.58 -5.90 -8.92 11.23 -0.65 18.25 2.76 16.63 -10.01 166 167 168 169 170 171 172 173 174 175 176 -2.64 16.64 6.72 5.08 13.17 11.49 -20.79 4.35 0.93 -10.59 21.78 177 178 179 180 181 182 183 184 185 186 187 2.35 11.26 4.41 1.42 5.78 12.16 0.85 -0.80 3.98 1.69 2.58 188 189 190 191 192 193 194 195 196 197 198 0.36 3.72 5.94 -0.89 -12.88 22.26 2.40 4.03 8.62 1.27 5.55 199 200 2.30 10.26 > all.equal( predict( testResult ), fitted( testResult ) ) [1] TRUE > all.equal( predict( testResult, newdata = testData ), fitted( testResult ) ) [1] TRUE > > ########## scaling regressors ########### > germanFarms$landAr <- germanFarms$land * 100 > germanFarms$timeCent <- germanFarms$time / 100 > germanFarmsMeans <- colMeans( germanFarms[ , + - which( names( germanFarms ) %in% c( "year", "decade" ) ) ] ) > > ## standard quadratic function > # estimation > estResultAr <- quadFuncEst( "qOutput", + xNames = c( "qLabor", "landAr", "qVarInput", "time" ), data = germanFarms ) > print( coef( estResult ) / coef( estResultAr ) ) a_0 a_1 a_2 a_3 a_4 b_1_1 b_1_2 b_1_3 b_1_4 b_2_2 b_2_3 b_2_4 b_3_3 1 1 100 1 1 1 100 1 1 10000 100 100 1 b_3_4 b_4_4 1 1 > # fitted values > fitted <- quadFuncCalc( xNames = c( "qLabor", "landAr", "qVarInput", "time" ), + data = germanFarms, coef = coef( estResultAr ) ) > all.equal( fitted, estResult$fitted ) [1] TRUE > # derivatives > margProductsMeanAr <- quadFuncDeriv( + xNames = c( "qLabor", "landAr", "qVarInput", "time" ), + data = germanFarmsMeans, coef = coef( estResultAr ), + coefCov = vcov( estResultAr ) ) > print( margProductsMean / margProductsMeanAr ) qLabor land qVarInput time 1 1 100 1 1 > print( attributes( margProductsMean )$variance / attributes( margProductsMeanAr )$variance ) qLabor land qVarInput time 1 1 10000 1 1 > print( attributes( margProductsMean )$stdDev / attributes( margProductsMeanAr )$stdDev ) qLabor land qVarInput time 1 1 100 1 1 > # elasticities > estElaFitAr <- elas( estResultAr ) > all.equal( estElaFit, estElaFitAr, check.attributes = FALSE ) [1] TRUE > estElaObsAr <- elas( estResultAr, yObs = TRUE ) > all.equal( estElaObs, estElaObsAr, check.attributes = FALSE ) [1] TRUE > > ## estimation with homogeneity imposed (non-homogenous variable scaled) > # estimation > estResultHomCent <- quadFuncEst( yName = "qOutput", + xNames = c( "timeCent", "qLabor", "land", "qVarInput" ), + data = germanFarms, + homWeights = c( qLabor = 0.7, land = 0.1, qVarInput = 0.2 ) ) > print( coef( estResultHomCent ) / coef( estResultHom ) ) a_0 a_1 a_2 a_3 a_4 b_1_1 b_1_2 b_1_3 b_1_4 b_2_2 b_2_3 b_2_4 b_3_3 1 100 1 1 1 10000 100 100 100 1 1 1 1 b_3_4 b_4_4 1 1 > # fitted values > fitted <- quadFuncCalc( + xNames = c( "timeCent", "qLabor", "land", "qVarInput" ), + data = germanFarms, coef( estResultHomCent ), + homWeights = c( qLabor = 0.7, land = 0.1, qVarInput = 0.2 ) ) > all.equal( fitted, estResultHom$fitted ) [1] TRUE > # derivatives > estResultHomDerivCent <- quadFuncDeriv( + xNames = c( "timeCent", "qLabor", "land", "qVarInput" ), + coef = coef( estResultHomCent ), data = germanFarms, + homWeights = c( qLabor = 0.7, land = 0.1, qVarInput = 0.2 ) ) > print( estResultHomDerivCent / estResultHomDeriv ) timeCent qLabor land qVarInput 1 100 1 1 1 2 100 1 1 1 3 100 1 1 1 4 100 1 1 1 5 100 1 1 1 6 100 1 1 1 7 100 1 1 1 8 100 1 1 1 9 100 1 1 1 10 100 1 1 1 11 100 1 1 1 12 100 1 1 1 13 100 1 1 1 14 100 1 1 1 15 100 1 1 1 16 100 1 1 1 17 100 1 1 1 18 100 1 1 1 19 100 1 1 1 20 100 1 1 1 > # elasticities > estResultHomElaCent <- elas( estResultHomCent ) > all.equal( estResultHomEla, estResultHomElaCent, check.attributes = FALSE ) [1] TRUE > estResultHomElaObsCent <- elas( estResultHomCent, yObs = TRUE ) > all.equal( estResultHomElaObs, estResultHomElaObsCent, check.attributes = FALSE ) [1] TRUE > > proc.time() user system elapsed 2.43 0.28 2.73