Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error "func_nested_reg(): 3301 subscript invalid" using asdoc to export the output from the pv package for estimation with plausible values.

    Good day,

    I am trying to export a nested regression table to word using the adoc package.

    I am using data from the Trends in International Mathematics and Science Study (TIMSS) data set and my dependent variable is the student mathematics test achievement, which is presented as five plausible values of student achievement. I am using the user-written pv package to run the regression with plausible values.

    When attempting to export the nested output tables using the asdoc package I have had limited success: the first regression model successfully exports to word, my code is:
    Code:
    *Install pv package if not installed yet using ssc install pv
    *Step 1: Regress math results on MathPR to see if the relationship runs in the expected direction
    asdoc pv MathPR [aw=TOTWGT], cmd("reg") pv(math_pv*) jkzone(JKZONE) jkrep(JKREP) jrr timss nest save(analyses.doc) replace
    (I have left my notes attached to provide some context)
    The problem arises when I run my second model with more independent variables using the code:
    Code:
    *Step 2: let's add some more independent vars -  see syntax 1 in the pv package using "help pv", syntax 2 above can't do factor and time series variables
    *We are going to add school and teacher characteristics
    asdoc pv , pv(math_pv*) jkzone(JKZONE) jkrep(JKREP) weight(TOTWGT) jrr timss: xi: reg @pv MathPR i.school_location School_SES i.School_safety Math_class_size Teacher_accountability Math_teacher_experience i.Math_Teacher_edu [aw=@w] nest
    The regression successfully produces an output table but it comes with the error:

    func_nested_reg(): 3301 subscript invalid
    <istmt>: - function returned error

    and no link to a word document is produced.

    I read in the asdoc help file that the "isreg" option may fix this problem when using asdoc with other user-written packages but this was to no avail.

    Any help would be greatly appreciated, a sample of my data is provided:
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input double(math_pv1 math_pv2 math_pv3 math_pv4 math_pv5) float MathPR byte school_location float School_SES byte School_safety int Math_class_size float Teacher_accountability byte(Math_teacher_experience Math_Teacher_edu)
    335.81047 357.11223 355.26841 296.51929 359.36787   -4.2216215 1   .9589698 . 78   .1932887 13 2
    377.10301 365.39178 349.27001 385.33007 339.01502            . 3  -1.277245 . 41  -2.502051 22 2
    409.91308 415.00785 392.05875 404.32623 379.16402     .6767668 4    .112849 3  .   .1932887 20 .
    406.74474  320.2474 373.75498 350.81256 367.35251     .6767668 1    -.86637 3 37  .04985677  . 2
    435.52683 426.20966   459.402 449.19592 479.50855     -1.31774 4  1.9266647 3 39   .7751996  3 2
     462.4522 463.16529 452.21089 517.38828 515.74395    -.9184296 2   .3617906 3 30   .7751996  3 2
    361.29883 409.47568   310.519 376.58739 416.69505     .3326921 3 -1.9937522 1 26   .7751996 18 1
    352.19725 347.64904 373.95728 386.38912  373.4518    -.3684841 3 -1.5109755 3 47  -1.377403 13 .
     338.1048 332.49179 364.58619 330.41888 286.11809     .6767668 3   .1816664 3 54   .7167283  6 2
    421.84917  416.9911 443.79607  389.4063 402.28755    -.6159893 1  -.5482584 3  .   1.298639 13 2
    430.00715 388.57242 360.47835 464.43884 438.01081     .6767668 4  -.7047233 1 54  -.5320541 25 2
    532.58506 497.86527  510.6955 495.41406 481.66819     .6767668 4  1.9266647 2 39   .7751996  3 2
    334.36911 350.97101 339.61559  338.0911 371.90636   -1.6011224 2  -.7348295 2 48   .1932887 25 2
    292.64197 378.63866 302.14036 201.21449 320.99561     .6767668 3  -.4580047 3  .  -.5320541 29 2
    504.75304 491.25504  498.5407 492.96914 482.77411   -1.6636016 3   1.579819 2 32  -1.377403 34 2
    323.73942 311.37547 316.47379 382.79257 282.62528    -3.443324 0  -.1246363 3 50  -1.377403  7 2
    424.09495 395.68501 382.97088  350.5357  408.9336   -1.2018394 4  -.7030157 2 48   .7751996  3 1
    488.74988 474.47694   443.366 406.32314 396.79975     .6767668 3   .4227846 2 20  -1.963472  2 2
     403.1468 379.10408  373.4322 327.24547 352.33475    -4.682324 2 -1.1189737 3 44  -.5320541  7 2
    456.15817   444.148 458.86228 450.84983  429.0108   -1.0195557 4   1.944772 1 26   1.298639  6 2
    385.36298 427.24272 382.22649 381.63562 354.41747    -3.716785 1 -1.0530101 3 47   .7751996  5 1
    333.85589 345.63343  313.2706 328.81403 400.51137    -1.696142 1 -1.0902709 3 50  -.5320541  3 .
    479.62424 396.48553 461.98815 483.66822 429.18606     .6767668 2  -1.295133 1 47  .04985677 22 2
    347.96504 356.69977 365.48024 292.40565 405.09184    -3.472204 2  -1.295133 2 47  .04985677 22 2
    447.36014 435.98836 407.49879 431.27271 434.61194   -1.7787747 4  -.6951488 2  .  -1.377403  . 1
    403.49144 397.21786 359.63117 338.03616 338.53007   -4.0363555 3  -.5634719 3 48   .1932887 19 2
    317.70329 343.25909 296.54295 315.63777 359.77591    -4.116095 2  -.8103322 2 44  -2.502051  4 2
    328.98963 292.47058 295.65036 361.65649 237.13284   -1.5394515 0   .4496706 3 49  -1.963472 26 1
    414.25742 410.81786 492.21986  379.0608 376.39413   -.25160727 2  -1.295133 3 47  .04985677 22 2
     360.9101 375.10386 406.87927 413.46176 422.14821   -.08936088 4  -1.448729 1 35  -1.377403  9 2
    485.14815 483.42512 462.29966 507.73612 426.66666   -1.2374536 2  2.0338387 2 29   1.298639  5 2
    439.28111 391.06185 452.10675 459.12438 406.21728    -.1876462 3  .09070285 3 40  -1.118123  5 2
    490.78642  514.3058 489.55718  479.4933 523.66431    -3.695085 4  2.0338387 3 28   1.298639 27 2
     398.1428 355.10042 396.96868 385.13834 383.42048   -1.0380422 4   .9951934 3 35   .7167283  3 2
    474.35132 464.48329 503.32947 472.36304 470.26708   -1.0905311 3   1.987029 3 31   .7751996 28 1
    361.76329 336.67629 351.18683 388.28236 396.08078    .27745634 2  .53477436 2 39  -2.502051  1 2
    293.51665 363.93866 321.30821 348.70385 268.91228     .6767668 0     .37448 3 67   1.298639  1 2
    414.18115 296.54055 321.24961 325.03105 338.60067     .6767668 1  .16738828 3 31 -1.0898385  7 2
    558.34112 506.29865 532.06395 505.06578 515.40911    -.3684841 4 -1.0720055 1 49  -1.963472 12 2
    361.98811 315.56468 334.67128 321.90116 354.70427    -4.682324 1  1.3559382 0 62   1.298639  2 2
    449.38565 418.73007 443.58948 407.20097 401.74654   -1.4373527 2 -.28386402 1 32  -.5320541  5 2
    528.93779 476.89058 484.60228 476.58239 478.10545    -4.682324 3  1.1820003 2 30   .1932887 27 2
    413.15358 424.86637 439.48187 410.72698 406.98001    -4.682324 3   1.579819 3 32  -1.377403 34 2
    314.66969 290.20944 286.99594 280.71848 346.56084    -4.682324 4   -.952426 1  .   .1932887  1 2
    268.72057 296.23524 254.67227 246.13019 263.10554    -4.682324 0  -.0807123 0 57   .1932887  7 2
    403.09034 451.91444 466.42947 382.19397 463.03243     .6767668 1 -1.0530101 2 47   .7751996  5 1
    376.44858 361.78813 370.07969 310.69638 291.67694     .6767668 4  -1.873688 3  .   .1932887 17 2
    372.57604 364.76962  345.5671 427.96749 391.44854     .6767668 1 -2.0939927 3  .   1.298639 22 2
    571.99394 576.73949 482.58291 511.93817 560.56004   -2.0035813 4  2.0338387 2 29   1.298639 18 2
    355.68484 315.96863 327.43351  341.4143 343.43794    -.4886714 0   1.156245 3 83   1.298639  9 2
    394.59597 433.57696 398.68771 431.28571 417.75564     .6767668 . -.13027506 3 44   .1932887 21 .
    445.75598  453.3398 445.29116 429.77221 418.85062   -.28877237 3 -1.9534374 3 49  -1.377403 30 2
    435.44576 378.08356 396.31907 401.67308 377.12179    -.7677947 4   .9951934 3 35   .7167283  3 2
    448.18593 445.98907 408.24566 417.24768 408.90833     .6767668 1   .7694524 3 24   1.298639  2 2
    422.26975 363.00435  397.4604 368.89053 379.96341   -4.0095525 2 -.28617406 2  .   .1932887  . 2
    425.47796 415.21273 395.31885  419.8615 392.74608    -3.003895 1  -.5442922 3  .   1.298639 34 2
    454.05883 476.58728 424.51078 414.51346  433.6612    -.1876462 4   .9951934 1 35   .7167283  3 2
    555.09895 576.58789 593.30838 592.19337  516.1371    .27745634 4  1.7927363 3 27   1.298639  4 2
    396.66636 453.27061 422.01288 367.95448 387.91851 -.0022673565 2  -.7266554 3 35   .7751996  9 2
    378.88466  439.1875 329.82356 339.45741 366.61019     .3326921 3  -1.277245 0 41  -2.502051 22 2
    429.43746  438.7241 469.17419 418.82088 462.60804    -.7683951 0  1.3706818 2 53   .1932887 11 2
    359.65125 404.75366 328.06948 286.33048 292.98722    .17044565 4 -.07562536 2 57   .1932887 21 1
     392.0325 362.53087 346.52303 350.24561 347.72631     .6767668 1  1.1333549 3 45   1.298639 18 1
    304.07908 282.74048 335.21281 262.40084 300.98123    -2.948092 0 -1.0717528 0 80   1.298639 12 2
    326.27149 355.14868 334.75581 359.82566  334.6194     .6767668 0   .8576604 3  .   .7751996 11 2
    277.82761 270.86522 252.61086 265.57866 223.58191   -1.4633082 1  -.0778435 3  .  -.5320541  . .
     467.5307 421.84591 383.07761 461.55834 456.45292     .6767668 2  .18727326 . 43   .1932887  4 2
    459.90844 454.20133 494.08281 467.33596 477.39256     .6767668 2   .7505084 3 52   .1932887  2 2
    283.28783 339.98236 267.95363 354.10908 398.12357     -3.59406 1 -1.5778704 3 86   .1932887 28 2
    417.45126 380.55441 365.03857 371.66149 379.41767     -.453327 4   -.686666 3 37  -2.502051 18 2
    320.44136 341.14092 362.34761 338.05967 373.00372    .25471392 1  1.3559382 3 62   1.298639  2 2
    456.56316 485.55594 450.62575 472.46806 503.92804   -.08936088 1  -.5800027 1 15   1.298639  4 2
    329.34663 288.60494  324.9382 272.95751 306.05692    -4.682324 2  -.3531912 0 34  -.5320541 29 .
    406.45366 340.66901 322.76746 265.42469 347.01749   -1.1522664 0 -1.7040594 1 68  -.5320541  5 2
    421.85362 369.76169 370.55021 384.85018 384.73392   -3.7457144 1  -.5442922 1  .   1.298639 34 2
    318.83386 231.03133 250.50109 268.06134 301.55832    -4.682324 1 -1.5778704 3 86   .1932887 28 2
    293.22657 315.22745  318.8662 329.02826 264.77876    -4.682324 1 -.53387904 2  .   .1932887  5 2
    555.68589 496.97149 481.93837 490.56899  442.8385    -3.517111 2  2.0338387 2 29   1.298639  5 2
    294.43687 287.67456 293.36681 292.59726 307.08412     .6767668 0   .8743905 3  .   .1932887  4 2
    499.27557 504.38693  477.8915 505.25208 498.88325    -3.718951 3   .3224723 3 26   .1932887  1 2
    453.49838 508.19592 434.45169 481.71495 464.39381     .6767668 4 .030073727 1 31   .7751996 25 2
    422.21229 315.86283  374.9362 429.68075 339.90983    -4.367856 2  -.7677328 1 43   .1932887  2 2
    493.43831 480.71043 492.06907 498.89678 463.02138     .6767668 3   .3416315 0 55  -1.118123 15 2
    416.02149 405.18761 365.53795 354.95232 327.68046    .25907955 1  1.3559382 3 62   1.298639  2 2
    428.82981 477.09121  439.2115 445.35959 454.18817     .6767668 2 -2.2992392 2 27   .1932887  4 1
    399.69406 394.52287 431.41541 379.98589 424.46834   -1.2107552 4    .486218 3 50  -1.377403 19 1
    314.20156 331.36223 354.76565 322.15067 313.47134   -3.1407034 4  -.4297769 3 40   .1932887  4 2
    483.04313 483.28506 500.47521 498.48076 495.04002   -3.1516714 3   1.987029 3 31   .7751996 28 1
    321.97681 381.40575 364.96148 308.88103 332.62149   -1.4373527 2 -.28617406 0  .   .1932887  . 2
    514.48199 541.55036 494.01879  464.5667 461.40986            . 2  -.3616959 2  .   .1932887 31 2
    384.71491 370.68962 425.25619 418.41774 429.27933     .6767668 4 -.55001754 2 50   .1932887  3 2
    584.11087 590.13337 593.78691   598.905 601.68899   -2.0954525 4  2.0338387 3 32   1.298639  3 2
    449.45982 470.23422 469.40286 454.50947 455.75289   -1.7170764 3  -.8441862 1 42  -.5320541 32 1
    389.99662 403.07661 411.94834 386.39455 370.56585    -1.766049 3 -1.5109755 0 47  -1.377403 13 .
    437.40636 434.40569 432.57375  469.2318 456.58758     .6767668 4   1.944772 2 26   1.298639  6 2
    481.63785 484.48168 458.04778 455.02905 449.51545     -2.37798 3  -1.803754 1 34   .1932887  4 2
    364.81616 302.65939 383.53788 318.12757 406.87219   -3.4622176 1  -.3173436 3  .   .1932887  . 2
    357.73586 356.65577  351.7385 308.95394 339.23574     .6767668 0 -.18842967 0 38   .1932887  7 2
    387.44997 382.09229 372.50727 402.93346 424.94867   -.10966805 1 -1.2793634 3 57  -.5320541 25 1
     401.3029 351.21329 278.66485 323.24668 359.91463    -4.682324 4   .7938003 3 64   .1932887  3 2
    end
    label values math_pv1 labels1185
    label values math_pv2 labels1186
    label values math_pv3 labels1187
    label values math_pv4 labels1188
    label values math_pv5 labels1189
    label values school_location BCBG05B
    label def BCBG05B 0 "Remote rural", modify
    label def BCBG05B 1 "Small town", modify
    label def BCBG05B 2 "Medium City", modify
    label def BCBG05B 3 "Suburban", modify
    label def BCBG05B 4 "Urban", modify
    label values School_safety agreedisagree_4op_pos
    label def agreedisagree_4op_pos 0 "Disagree a lot", modify
    label def agreedisagree_4op_pos 1 "Disagree a little", modify
    label def agreedisagree_4op_pos 2 "Agree a little", modify
    label def agreedisagree_4op_pos 3 "Agree a lot", modify
    label values Math_Teacher_edu education
    label def education 1 "Short-cycle Tertiary", modify
    label def education 2 "Tertiary", modify
    P.S. this is my first time posting code and data on the forum, please let me know if there are any errors regarding these.


  • #2
    I realised that I forgot the comma before the "nest" command, but now I have run into another issue, my code is:
    Code:
    asdoc pv , pv(math_pv*) jkzone(JKZONE) jkrep(JKREP) weight(TOTWGT) jrr timss: xi: reg @pv MathPR i.school_location School_SES i.School_safety Math_class_size Teacher_accountability Math_teacher_experience i.Math_Teacher_edu Math_IC [aw=@w], nest
    which gives the error:
    system limit exceeded
    you need to drop one or more models
    r(1000);
    Any help would be appreciated!

    Comment

    Working...
    X