Subhamitra Patra
2020-May-08 07:24 UTC
[R] [R ] Writing loop to estimate ARCH test for a multiple columns of a data frame?
Dear Sir, Herewith I am pasting a part of my sample data having 12 columns below, and want to calculate ARCH test for the 12 columns by using a loop. Please help me in this regard. Thank you very much for your help. Year_Month A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 94-Jan 0.051197 7.05E-05 0.058806 -0.00818 0.538001 0.009766 0.025787 0.035478 0.056663 0.014665 0.23132 0.008644 94-Feb 0.06424 -0.01086 0.049823 -0.04989 0.557945 0.00974 0.027757 0.021494 0.016947 0.014584 0.229776 -0.02317 94-Mar 0.056168 -0.00626 0.061555 -0.03427 0.524705 0.009694 0.027632 -0.00656 0.008358 0.014499 0.190421 0.003026 94-Apr 0.129051 0.043813 0.060453 0.017469 0.545895 0.009615 0.01932 0.01171 0.016003 0.014412 0.140396 0.017556 94-May 0.142182 -0.03848 0.059938 0.015054 0.525178 0.009479 0.027741 0.000605 0.0185 0.014327 0.093228 -0.03989 94-Jun 0.152981 -0.03227 0.071485 -0.01025 0.363882 0.009323 0.030762 0.013005 0.03634 0.014239 0.035625 -0.01355 94-Jul 0.16216 0.046374 0.073669 0.020508 0.3405 0.00926 0.044822 -0.00954 0.042422 0.014154 0.037954 0.00097 94-Aug 0.124355 -0.06952 0.091429 0.015932 0.38519 0.009269 0.071701 0.000623 0.051954 0.01407 0.055852 0.007522 94-Sep 0.059405 0.057487 0.086265 -0.01169 0.401963 0.009171 0.086685 -0.01058 0.054404 0.013986 0.07285 0.002022 94-Oct 0.0594 0.021166 0.080765 0.006442 0.438915 0.009041 0.070351 0.006776 0.033622 0.013906 0.068344 -0.01532 94-Nov 0.072064 -0.03104 0.079567 -0.03295 0.521214 0.008986 0.066044 -0.01853 0.035202 0.013826 0.067093 -0.02278 94-Dec 0.068208 0.01024 0.069919 -0.01507 0.461059 0.008856 0.050985 0.009514 0.008638 0.013744 0.040348 0.00423 95-Jan 0.079074 -0.00153 0.070458 -0.04205 0.506227 0.00883 0.046561 -0.03907 0.015322 0.013662 0.034103 -0.00888 95-Feb 0.074231 -0.05728 0.062612 0.035992 0.487126 0.008815 0.052816 -0.01344 0.06728 0.013583 0.063281 -0.0054 95-Mar 0.065212 0.056084 0.095783 0.006825 0.476386 0.008774 0.047498 0.015178 0.040273 0.013499 0.060805 0.006099 95-Apr 0.081238 0.024283 0.098827 0.005791 0.432363 0.008748 0.06047 0.011613 0.013068 0.013417 0.058321 -0.01281 95-May 0.093726 0.008623 0.076698 0.027274 0.321103 0.008679 0.037962 0.00115 0.013647 0.013339 0.066724 -0.00271 95-Jun 0.113998 0.005484 0.073392 -0.00252 0.38195 0.008684 0.042794 -0.01133 0.054244 0.013261 0.055655 0.015941 95-Jul 0.097076 0.008842 0.090776 0.006378 0.622055 0.008728 0.036476 0.016159 0.055301 0.013188 0.057034 -0.0036 95-Aug 0.075751 0.002437 0.094687 -0.00398 0.637972 0.008839 0.052791 -0.00819 0.327487 0.013114 0.067734 0.00565 95-Sep 0.074714 0.001279 0.091216 0.013169 0.656225 0.008956 0.086582 -0.0013 0.690172 0.01304 0.059523 0.028675 95-Oct 0.048771 -0.01775 0.098525 0.003447 0.68386 0.009071 0.091073 -0.01597 0.640065 0.012967 0.030469 0.005139 95-Nov 0.069776 -0.00164 0.077763 0.00158 0.559675 0.008808 0.094129 0.01832 0.726821 0.012893 0.030908 -0.00955 95-Dec 0.135469 0.001886 0.074658 0.01263 0.563716 0.008888 0.113828 0.011372 0.737532 0.012822 0.224459 -0.00186 96-Jan 0.175166 0.00068 0.071721 0.030701 0.534648 0.009114 0.086481 0.016228 0.687297 0.013112 0.349764 0.000727 96-Feb 0.167327 0.013771 0.055352 -0.03142 0.556339 0.009119 0.080475 -0.00691 0.696365 0.013077 0.342758 -4.90E-05 96-Mar 0.158759 -0.02094 0.042232 -0.00331 0.532126 0.009041 0.077231 0.009009 0.579396 0.012271 0.342196 -0.002 96-Apr 0.116956 0.02624 0.051037 -0.01496 0.575416 0.009123 0.079496 0.017197 0.557262 0.012094 0.299566 0.022657 96-May 0.109049 -0.02648 0.059972 0.00658 0.616302 0.009086 0.095365 -0.01682 0.521757 0.011933 0.074309 0.021621 96-Jun 0.102001 2.71E-05 0.060901 -0.00372 0.593491 0.009213 0.095232 0.001363 0.523983 0.011757 0.070504 -0.00507 96-Jul 0.079941 -0.02107 0.046018 -0.00708 0.562537 0.009136 0.094451 -0.01132 0.534417 0.011413 0.073706 -0.00615 96-Aug 0.109775 0.005178 0.051713 0.007174 0.54939 0.009008 0.088945 -0.01136 0.445843 0.010925 0.066559 0.009937 96-Sep 0.089581 -0.0005 0.049835 0.016873 0.54664 0.008887 0.082659 0.011384 0.435423 0.010697 0.091269 0.00687 96-Oct 0.07429 -0.01499 0.063584 0.008829 0.485504 0.008965 0.072986 -0.01695 0.54066 0.010649 0.325364 0.012261 96-Nov 0.060441 0.021057 0.100844 0.018152 0.415023 0.009033 0.072366 -0.00222 0.646444 0.010653 0.323194 0.01409 96-Dec 0.061482 0.0218 0.142038 -6.42E-06 0.492536 0.008947 0.081333 -0.02433 0.661019 0.010555 0.367988 -0.00023 97-Jan 0.053437 0.025314 0.137257 -0.00659 0.578904 0.008841 0.074613 -0.0068 0.628154 0.010609 0.355763 0.00581 97-Feb 0.080489 -0.01411 0.123644 0.009692 0.571364 0.008794 0.07673 0.005832 0.549697 0.010781 0.21588 0.070824 97-Mar 0.097621 0.00073 0.115192 -0.04503 0.639719 0.008686 0.065906 -0.01063 0.543819 0.010442 0.129773 0.004692 97-Apr 0.112502 -0.00052 0.064499 0.007382 0.648139 0.008674 0.038621 0.006408 0.591661 0.010283 0.079461 0.009395 97-May 0.109789 0.028968 0.079382 0.032543 0.530901 0.008884 0.029301 0.039566 0.492504 0.01004 0.042617 -0.00151 97-Jun 0.087521 -0.03031 0.037389 0.001738 0.500643 0.00886 0.028772 0.0146 0.47233 0.009869 0.033241 0.001504 97-Jul 0.085527 0.01424 0.029224 0.018015 0.496859 0.008725 0.036717 -0.00956 0.443577 0.009995 0.026995 0.014942 97-Aug 0.077215 -0.00935 0.025766 -0.05705 0.424685 0.008555 0.034725 -0.02395 0.481891 0.010128 0.029444 0.021642 97-Sep 0.08778 0.012634 0.064433 0.012569 0.495125 0.008406 0.06119 0.002597 0.515191 0.010241 0.056915 0.002897 97-Oct 0.067236 -0.07837 0.100233 -0.08455 0.603348 0.008296 0.065799 -0.02425 0.545503 0.010191 0.071548 0.002394 97-Nov 0.074344 0.008919 0.169394 -0.00212 0.615421 0.008215 0.076836 -0.04056 0.552007 0.01035 0.131526 0.001346 97-Dec 0.066797 0.001889 0.180801 -0.0114 0.607294 0.008081 0.11593 -0.01879 0.573696 0.01082 0.283244 0.002348 98-Jan 0.050659 -0.01722 0.163617 0.074366 0.52707 0.007969 0.091612 0.027019 0.583443 0.011549 0.267086 -0.02785 98-Feb 0.049803 0.015915 0.04491 0.054682 0.38982 0.008092 0.092166 0.002436 0.61572 0.011637 0.275094 -0.0145 98-Mar 0.047308 0.017094 0.047185 0.000772 0.455737 0.008007 0.087419 -0.01693 0.594474 0.012426 0.286536 -0.01181 98-Apr 0.047385 0.003939 0.048202 -0.03154 0.567806 0.007983 0.060277 -0.00191 0.597842 0.013039 0.127336 0.107101 98-May 0.064783 0.025706 0.060724 -0.03807 0.684579 0.007976 0.048987 -0.01964 0.518052 0.013439 0.069782 0.006585 98-Jun 0.159381 -0.01328 0.052821 -0.01119 0.684776 0.007913 0.038652 0.002138 0.543559 0.012967 0.110726 -0.00548 98-Jul 0.151487 0.004139 0.051838 -0.00775 0.70082 0.007946 0.048077 -0.00496 0.585499 0.012684 0.075913 0.000926 98-Aug 0.148411 -0.04313 0.047802 -0.0209 0.66453 0.007953 0.046124 -0.02537 0.69816 0.012255 0.072707 -0.00505 98-Sep 0.16881 -0.03613 0.052287 0.018093 0.595134 0.008081 0.044761 -0.00243 0.677852 0.012169 0.075073 -0.0052 98-Oct 0.070201 -0.07938 0.055037 0.062009 0.549705 0.007892 0.051584 0.034295 0.691742 0.011869 0.052704 -0.0219 98-Nov 0.049853 0.028386 0.068794 0.005291 0.442349 0.007833 0.045537 0.030026 0.669312 0.0117 0.219442 -0.0081 98-Dec 0.069926 0.000449 0.101457 -0.00323 0.356563 0.007826 0.05571 0.000408 0.529556 0.0108 0.390611 -0.004 99-Jan 0.07435 -0.01122 0.096968 -0.01734 0.343742 0.007695 0.078749 0.012134 0.541906 0.010943 0.41004 0.008279 99-Feb 0.082127 0.021732 0.114963 -0.00191 0.345825 0.007578 0.083706 -0.00624 0.546338 0.011204 0.425059 -0.01535 99-Mar 0.081221 0.040004 0.111538 0.023871 0.358622 0.007456 0.079843 0.032283 0.566893 0.011074 0.401445 0.102554 99-Apr 0.086991 0.02926 0.065761 0.097698 0.301239 0.007323 0.097955 0.01104 0.529548 0.010871 0.076728 0.027323 99-May 0.077475 0.023956 0.074776 -0.02335 0.321715 0.007218 0.063023 0.011379 0.397527 0.01031 0.073261 -0.00508 99-Jun 0.076112 0.020359 0.068651 0.033434 0.4018 0.007095 0.06711 0.021294 0.408022 0.010055 0.06967 0.006254 99-Jul 0.080411 -0.01148 0.060564 -0.00474 0.39331 0.007002 0.066918 0.02464 0.478281 0.010005 0.066309 0.015189 99-Aug 0.068091 -0.01721 0.060539 0.004914 0.37717 0.006855 0.062521 0.007325 0.482744 0.010036 0.088398 0.007067 99-Sep 0.086042 0.008278 0.077601 -0.01802 0.403218 0.006718 0.067205 0.000943 0.628366 0.009918 0.147324 0.005286 99-Oct 0.075385 0.010131 0.061047 -0.00448 0.372075 0.00665 0.060542 0.0217 0.780534 0.009656 0.131252 0.005054 99-Nov 0.055049 0.020592 0.068442 0.035127 0.399578 0.006527 0.065934 0.025071 0.772524 0.009266 0.157148 0.027663 99-Dec 0.062593 0.046883 0.067727 0.04049 0.502933 0.006406 0.053723 0.014904 0.728022 0.008887 0.167636 0.018708 00-Jan 0.057252 0.004454 0.065601 -0.02153 0.558368 0.006257 0.049291 0.009493 0.605325 0.008994 0.09732 0.037374 00-Feb 0.065328 0.045896 0.075552 0.026155 0.555294 0.006163 0.057978 -0.00837 0.504593 0.009741 0.130217 0.00261 00-March 0.065141 -0.02182 0.068206 0.003206 0.596057 0.006076 0.054416 0.011653 0.529128 0.009573 0.090386 -0.01596 00-Apr 0.080721 0.023865 0.059405 -0.03907 0.5262 0.005846 0.057356 -0.02115 0.468138 0.009582 0.034706 0.004283 00-May 0.074753 0.016991 0.063155 -0.00071 0.575856 0.005665 0.066024 -0.01439 0.402228 0.009809 0.030408 0.002116 00-Jun 0.14341 0.004936 0.054784 0.026521 0.616701 0.005597 0.049632 0.013278 0.471112 0.009514 0.034816 0.006285 00-Jul 0.141626 -0.0135 0.053571 0.010033 0.600591 0.005475 0.055653 -0.02939 0.483099 0.009243 0.034094 0.00531 00-Aug 0.127419 0.0245 0.061189 0.003298 0.568755 0.005432 0.067319 0.014447 0.513747 0.009217 0.22144 0.015615 00-Sep 0.122004 -0.00474 0.050212 -0.02615 0.503157 0.005269 0.087926 -0.01138 0.581831 0.009141 0.367495 0.001285 00-Oct 0.078788 -0.10172 0.044231 -0.0075 0.432512 0.0051 0.089254 -0.01574 0.656075 0.009038 0.359533 0.000368 00-Nov 0.053822 0.010106 0.034679 -0.01469 0.513539 0.00498 0.100637 -0.01064 0.622279 0.008928 0.377782 -0.00477 00-Dec 0.069006 -0.0005 0.051647 0.025002 0.546061 0.004794 0.103877 -0.02231 0.610257 0.00881 0.333657 0.09513 1-Jan 0.071511 -0.00837 0.057658 0.017076 0.553587 0.004638 0.095702 -0.02487 0.56779 0.00868 0.250782 0.008235 1-Feb 0.076866 0.00833 0.060892 -0.02218 0.59127 0.0045 0.093535 -0.0101 0.533402 0.008675 0.240717 0.003711 1-Mar 0.07557 -0.0462 0.074634 -0.03465 0.595882 0.004429 0.068847 0.002673 0.479236 0.008611 0.091359 0.034367 1-Apr 0.070519 0.033694 0.060347 0.003217 0.480071 0.004227 0.04972 0.03196 0.561474 0.008402 0.052372 0.002317 1-May 0.064918 0.011544 0.031374 0.009111 0.551824 0.004201 0.023617 0.001112 0.560844 0.008168 0.043051 0.009939 1-Jun 0.104019 -0.00345 0.024989 -0.01172 0.568941 0.004169 0.020633 -0.0132 0.560457 0.008024 0.049529 0.007287 1-Jul 0.090489 0.017047 0.021945 -0.01905 0.557895 0.004073 0.022649 -0.02304 0.56767 0.007859 0.048501 0.004123 1-Aug 0.099604 -0.02219 0.028166 -0.02333 0.625414 0.004008 0.033092 -0.00533 0.604529 0.007885 0.054362 0.007967 1-Sep 0.107159 -0.07639 0.029653 -0.02712 0.622213 0.004059 0.060953 -0.02039 0.597122 0.007776 0.059832 -0.03705 1-Oct 0.092227 0.008594 0.063975 -0.01046 0.60189 0.004079 0.092008 -0.00481 0.559119 0.007765 0.073072 0.00552 1-Nov 0.133317 0.017435 0.092959 0.026051 0.502762 0.004133 0.103452 -0.00171 0.54558 0.007544 0.051221 0.001584 1-Dec 0.148023 0.019271 0.104346 0.012594 0.490295 0.003975 0.107077 -0.01876 0.533209 0.007311 0.056159 0.012704 2-Jan 0.150961 -0.01348 0.10693 -0.01523 0.426876 0.003902 0.100983 -0.00865 0.512898 0.007222 0.045519 0.006621 2-Feb 0.129901 -0.00175 0.078699 0.007048 0.352362 0.003811 0.086475 0.022773 0.559536 0.007018 0.051134 0.001665 2-Mar 0.122265 -0.06762 0.042505 0.008784 0.410423 0.003871 0.067548 0.005427 0.568946 0.006885 0.044913 0.009651 2-Apr 0.075202 -0.01114 0.04052 0.003142 0.46432 0.003887 0.06172 0.005093 0.525967 0.006694 0.049629 0.032768 2-May 0.072844 -0.00547 0.022389 -0.00371 0.449056 0.003853 0.040507 0.004051 0.557733 0.00658 0.036551 0.005127 2-Jun 0.066132 0.005908 0.058852 -0.0166 0.461077 0.00388 0.049413 -0.01205 0.552187 0.00646 0.022301 -0.00198 2-Jul 0.059293 0.007211 0.059812 -0.01172 0.501559 0.003894 0.060857 -0.01298 0.55335 0.006188 0.022222 -0.00236 2-Aug 0.088299 -0.01081 0.068442 -0.00538 0.526355 0.003923 0.082171 -0.00367 0.632755 0.006052 0.022559 -0.00173 2-Sep 0.085233 -0.00312 0.07763 -0.02517 0.519692 0.00395 0.115502 -0.01224 0.77597 0.006027 0.047021 0.00225 2-Oct 0.079523 0.010872 0.057461 0.020658 0.506263 0.003923 0.125037 -0.00671 0.776439 0.005841 0.241231 -0.00458 2-Nov 0.092114 0.019084 0.056722 0.015734 0.482294 0.003937 0.132646 0.01848 0.776393 0.005798 0.241103 -0.01662 2-Dec 0.100498 -0.01973 0.058859 -0.01878 0.452742 0.003915 0.12689 0.003786 0.676371 0.005501 0.264177 0.019179 3-Jan 0.129572 -0.00262 0.048539 0.00309 0.544448 0.003876 0.094442 0.027311 0.556401 0.004892 0.254185 0.004473 3-Feb 0.132895 -0.00044 0.058255 -0.00171 0.600125 0.003869 0.078469 0.005541 0.679645 0.004928 0.115786 0.110436 3-Mar 0.136859 0.027562 0.058904 -0.01381 0.556289 0.003903 0.070073 0.004383 0.700573 0.004891 0.032592 0.03212 3-Apr 0.136273 0.068605 0.064695 -0.00261 0.613031 0.003871 0.071458 0.005898 0.699115 0.0048 0.029105 0.009723 3-May 0.099559 0.071864 0.0722 0.019948 0.626308 0.003719 0.078507 0.016676 0.648559 0.00479 0.023664 0.026138 3-Jun 0.065194 -0.02172 0.063345 0.001001 0.57964 0.003541 0.074453 0.015788 0.495185 0.004489 0.020389 0.019138 3-Jul 0.064383 -0.0382 0.05803 0.011462 0.582394 0.00346 0.055675 0.002646 0.500264 0.004442 0.015041 0.016287 3-Aug 0.070518 -0.01549 0.063356 0.017911 0.465972 0.00349 0.066048 0.022058 0.581051 0.004493 0.012775 0.025527 3-Sep 0.059538 0.000566 0.064277 0.014528 0.441227 0.003367 0.076711 0.024424 0.605593 0.004563 0.034063 0.012428 3-Oct 0.071278 0.016929 0.07425 0.023864 0.438028 0.003189 0.066948 0.014291 0.546467 0.004617 0.081215 -0.00357 3-Nov 0.078345 0.014875 0.082316 0.002779 0.545115 0.003026 0.090011 -0.00223 0.519579 0.004587 0.137425 0.006393 3-Dec 0.086351 0.016485 0.083428 0.009423 0.550845 0.002851 0.088829 0.02042 0.492655 0.004664 0.093447 0.010691 4-Jan 0.081329 0.006615 0.070349 0.011773 0.503661 0.002664 0.0562 0.023223 0.513912 0.004819 0.04145 0.009952 4-Feb 0.06281 0.006856 0.06135 0.011275 0.295814 0.002551 0.048915 0.001594 0.523612 0.00499 0.023872 -0.00975 4-Mar 0.049264 -0.00044 0.05989 -0.02068 0.056343 0.002607 0.04823 0.027175 0.609287 0.005025 0.023252 0.01872 4-Apr 0.049299 0.009245 0.052224 -0.00065 0.158436 0.00264 0.044182 -0.0123 0.607031 0.004961 0.024989 0.023746 4-May 0.07551 0.005179 0.046009 0.009392 0.206344 0.002588 0.036726 -0.01127 0.576678 0.005017 0.030117 0.000588 4-Jun 0.106293 0.012995 0.051612 -0.00029 0.200992 0.002555 0.053382 0.009459 0.469148 0.005189 0.031416 0.009538 4-Jul 0.108154 -0.00959 0.047847 0.001517 0.227312 -0.00647 0.05747 -0.01319 0.476149 0.005079 0.314022 0.013775 4-Aug 0.081915 0.004152 0.053783 0.011214 0.198439 0.045954 0.062876 0.003317 0.44414 0.005068 0.303724 0.00769 4-Sep 0.081102 0.009467 0.062976 0.00507 0.093854 -0.00086 0.070439 -0.01041 0.439919 0.004963 0.286094 0.011138 4-Oct 0.060353 -0.0099 0.044424 0.006191 0.10147 0.012374 0.050592 0.002093 0.461951 0.004918 0.286624 0.014818 4-Nov 0.061972 0.016949 0.054118 0.017346 0.108899 -0.00125 0.048133 0.009199 0.556459 0.005029 0.174995 0.089482 4-Dec 0.067244 0.023686 0.070182 0.00137 0.089756 0.004985 0.055462 0.021193 0.672079 0.005 0.075406 -0.0024 5-Jan 0.07898 -0.00534 0.08631 -0.0093 0.091402 0.009871 0.073969 0.006254 0.66872 0.004962 0.048242 0.040205 5-Feb 0.076154 0.014852 0.079967 0.012873 0.079875 0.01805 0.080537 0.006993 0.677289 0.004799 0.031595 0.026168 5-Mar 0.077074 0.00191 0.090161 -0.01357 0.052445 -0.00301 0.071842 -0.00201 0.603639 0.00486 0.038924 0.027139 5-Apr 0.079171 0.016211 0.081519 0.008182 0.067475 0.017158 0.084696 -0.00711 0.482537 0.004869 0.032052 -0.00649 5-May 0.08762 0.001995 0.061132 -0.00617 0.108894 -0.00095 0.036985 0.011574 0.499607 0.004559 0.036882 0.02224 5-Jun 0.112654 -0.02902 0.062165 0.005573 0.150261 -0.00456 0.051033 0.000359 0.454388 0.004385 0.047875 0.031248 5-Jul 0.114144 0.014178 0.05508 0.009906 0.133826 -0.00185 0.049361 0.001181 0.535222 0.004236 0.051302 -0.0007 5-Aug 0.118755 0.009505 0.045739 0.000422 0.134694 0.002732 0.048689 0.013723 0.65319 0.004264 0.050513 0.025555 5-Sep 0.126867 0.01075 0.060408 0.013722 0.120036 0.006571 0.063265 0.020154 0.656104 0.004173 0.070757 0.002251 5-Oct 0.089795 -0.01696 0.055212 -0.02112 0.107882 0.011945 0.059214 0.006303 0.690117 0.004071 0.045845 0.020133 5-Nov 0.090791 0.008801 0.05865 0.008551 0.117452 0.003818 0.061104 0.005212 0.641982 0.004077 0.049325 0.010303 5-Dec 0.118981 0.016034 0.081244 -0.00309 0.124691 -0.00724 0.072101 0.020097 0.578578 0.004283 0.04876 0.013458 6-Jan 0.070068 -0.01575 0.054248 0.013942 0.102255 0.056449 0.080795 0.019344 0.586796 0.00406 0.047243 0.043854 6-Feb 0.073022 -0.00889 0.052663 0.002691 0.109722 -0.01689 0.087112 -0.00481 0.601005 0.003781 0.048973 0.007074 6-Mar 0.104843 0.00397 0.052227 -0.00155 0.081988 -0.0331 0.113525 0.005888 0.515759 0.003533 0.06839 0.013283 6-Apr 0.104731 0.032016 0.04815 0.026012 0.08035 0.003807 0.115429 0.005909 0.338814 0.003188 0.066514 -0.01532 6-May 0.09766 0.001961 0.035253 -0.01271 0.103763 -0.01503 0.081776 0.002416 0.330045 0.003131 0.069321 -0.03033 6-Jun 0.119052 -0.02364 0.039689 0.005487 0.114745 0.010777 0.081682 -0.00304 0.236855 0.003015 0.095066 0.097317 6-Jul 0.088549 0.008985 0.036248 0.010201 0.093526 0.009576 0.054863 -0.01742 0.102126 0.002985 0.134684 -0.1041 6-Aug 0.067978 0.019824 0.044921 0.005189 0.07627 0.030992 0.047808 0.003101 0.155821 0.002881 0.167384 0.033159 6-Sep 0.066656 0.007713 0.060278 0.001498 0.102424 0.004677 0.057565 -0.00311 0.205756 0.002718 0.161339 0.002583 6-Oct 0.068295 0.026603 0.053452 0.010615 0.099656 0.000584 0.058789 -0.00066 0.199022 -0.02302 0.155059 -0.06468 6-Nov 0.089642 0.001217 0.067761 0.007713 0.086734 -0.00508 0.054733 0.000595 0.196888 -0.01408 0.125395 -0.05451 6-Dec 0.099192 -0.00135 0.059676 0.022421 0.099908 0.027104 0.050893 0.0043 0.245125 0.0489 0.13109 -0.00058 7-Jan 0.105593 0.00331 0.039473 0.003456 0.047097 -0.00912 0.055139 0.019326 0.117142 0.028954 0.109013 -0.05588 7-Feb 0.118889 0.004966 0.040191 -0.00952 0.041858 0.009777 0.05421 0.012598 0.113921 4.07E-05 0.114541 0.075385 7-Mar 0.08916 0.015319 0.025478 0.001806 0.038149 0.007381 0.053036 -0.00099 0.123744 0.011148 0.118334 0.013907 7-Apr 0.080799 0.038111 0.0491 0.011014 0.049405 -0.00921 0.022374 -0.00828 0.128256 0.024402 0.109033 -0.00633 7-May 0.088313 0.00604 0.044642 0.000793 0.031703 0.020668 0.019772 0.011723 0.113827 0.041275 0.122305 -0.01308 7-Jun 0.07316 -0.01507 0.042463 0.014393 0.043263 0.009882 0.021969 -0.00014 0.117902 0.011965 0.214639 -0.00689 7-Jul 0.065668 -0.0048 0.046214 0.01654 0.037575 0.017381 0.024748 -0.00012 0.101637 0.019989 0.205776 0.05221 7-Aug 0.070372 -0.02158 0.043537 0.007309 0.042105 -0.00364 0.044089 -0.00605 0.095848 -0.00647 0.180665 0.001296 7-Sep 0.047904 0.03766 0.033164 0.031409 0.048308 0.001623 0.033734 -0.00284 0.127852 0.008018 0.160366 0.012009 7-Oct 0.05138 0.041531 0.059524 0.034967 0.04954 0.014953 0.029942 0.001174 0.123522 0.004083 0.141225 0.077784 7-Nov 0.037378 0.000217 0.054199 -0.01968 0.041879 0.009651 0.028309 -0.00059 0.107465 -0.01076 0.132328 0.045576 7-Dec 0.042732 -0.00199 0.064209 -0.00477 0.049397 0.014798 0.023225 -0.01046 0.094376 0.02261 0.149627 0.049116 8-Jan 0.035948 -0.01236 0.060851 -0.03168 0.040511 0.002253 0.026289 -0.00212 0.085185 0.017828 0.130155 0.01301 8-Feb 0.037398 -0.00124 0.054232 -0.03426 0.050906 0.014738 0.0282 0.002013 0.069707 0.021845 0.15015 -0.01344 8-Mar 0.042094 -0.0305 0.032707 -0.00876 0.05264 -0.01032 0.024265 -0.00324 0.05907 0.013726 0.152467 -0.05545 8-Apr 0.04852 0.01582 0.031455 0.026955 0.063245 0.011327 0.025647 0.015876 0.067814 -0.00104 0.124019 0.05047 8-May 0.059497 -0.00208 0.038082 -0.00581 0.037738 0.006043 0.028794 0.017551 0.071995 -0.00976 0.104521 -0.0247 8-Jun 0.096974 -0.05471 0.041072 -0.03588 0.085357 -0.00082 0.035479 -0.01578 0.119341 0.00171 0.099164 -0.01334 8-Jul 0.092663 -0.03785 0.045204 0.004457 0.118828 -0.00513 0.037903 -0.00115 0.145136 0.007081 0.093327 0.001238 8-Aug 0.110892 -0.00404 0.042687 -0.02514 0.192407 -0.00432 0.028538 -0.01015 0.13363 -0.00083 0.164095 -0.0194 8-Sep 0.101492 -0.04277 0.064079 -0.043 0.190126 -0.02691 0.03497 -0.03088 0.137926 -0.03217 0.176231 -0.02584 8-Oct 0.084709 -0.06177 0.050796 -0.06637 0.202988 -0.00546 0.017852 -0.01142 0.128956 -0.04807 0.194271 -0.17044 8-Nov 0.057129 -0.08266 0.068863 -0.00142 0.204409 -0.03338 0.031681 0.007806 0.117484 -0.02477 0.234215 -0.07913 8-Dec 0.079164 0.020009 0.106671 0.018427 0.146101 0.041635 0.051961 0.011684 0.104922 -0.05998 0.180431 0.174908 9-Jan 0.063432 -0.00669 0.093999 0.018161 0.105719 -0.03781 0.082073 -0.03367 0.106395 -0.05258 0.12232 -0.01428 9-Feb 0.05705 -0.01499 0.083275 -0.00843 0.101315 -0.01958 0.095826 -0.03223 0.087682 -0.09934 0.12882 0.012371 9-Mar 0.061702 0.030318 0.088468 0.012107 0.108591 0.001889 0.095932 0.011516 0.057128 0.036127 0.146176 0.037564 9-Apr 0.059506 0.082299 0.08067 0.061903 0.086351 -0.02017 0.095266 0.0144 0.050497 0.017112 0.124557 0.062549 9-May 0.049584 0.050675 0.04681 0.055353 0.059368 0.008474 0.038863 0.062884 0.162174 0.010617 0.249354 0.019946 9-Jun 0.050694 0.005618 0.044184 0.002126 0.078106 -0.01453 0.043025 0.005721 0.182842 0.01024 0.307549 -0.00516 9-Jul 0.066973 0.030587 0.038676 0.020141 0.084477 -0.02209 0.034024 0.015118 0.171025 0.000822 0.333595 -0.00769 9-Aug 0.062135 0.010437 0.053099 -0.00917 0.096394 0.010992 0.05032 0.007868 0.186191 0.012318 0.353648 -0.02295 9-Sep 0.050647 0.033668 0.059205 0.012482 0.111134 0.009082 0.067715 0.010795 0.138849 0.05987 0.292975 0.137462 9-Oct 0.055956 0.013449 0.055734 0.000706 0.086458 -0.00339 0.053182 -0.00297 0.079412 -0.02269 0.163511 -0.01146 9-Nov 0.058756 -0.01045 0.059039 0.001159 0.073077 -0.02239 0.057373 -0.01219 0.077946 -0.03549 0.165941 0.02084 9-Dec 0.054019 0.016576 0.10987 0.001472 0.045507 -0.00868 0.05764 0.001159 0.056954 0.003272 0.093262 -0.00356 10-Jan 0.065299 -0.0012 0.07959 -0.014 0.046484 0.007152 0.030854 0.01432 0.038635 -0.00133 0.124903 0.01488 10-Feb 0.080965 -0.00718 0.075793 0.0106 0.050117 -0.00315 0.025844 0.003503 0.028887 0.029483 0.138384 0.01319 10-Mar 0.087112 0.019504 0.08891 0.005904 0.056132 0.008442 0.036296 0.01051 0.038374 0.020292 0.138234 0.027963 10-Apr 0.088547 -0.02642 0.039839 0.026567 0.069717 0.006489 0.041708 -0.00507 0.041266 0.00206 0.147216 0.012707 10-May 0.101039 -0.05872 0.037815 -0.00875 0.083237 -0.04479 0.030418 -0.005 0.051597 -0.01986 0.128739 -0.02404 10-Jun 0.095199 -0.00342 0.057961 0.004086 0.123835 -0.0142 0.035956 -0.00352 0.091948 0.005044 0.135558 0.021432 10-Jul 0.075234 0.025279 0.063847 0.009611 0.116717 -0.0035 0.031698 0.002359 0.252143 0.011422 0.287141 0.000121 10-Aug 0.079156 -0.00047 0.051437 -0.00546 0.112914 0.004803 0.02562 -0.00573 0.261809 0.013716 0.309455 -0.01186 10-Sep 0.059055 0.042768 0.057365 0.019033 0.075016 0.0137 0.023117 0.008312 0.249929 0.029749 0.313657 0.01661 10-Oct 0.054609 0.009678 0.063531 0.005707 0.081634 0.000622 0.02408 -0.00129 0.189048 0.000912 0.25145 -0.00483 10-Nov 0.068635 -0.00222 0.060139 -0.0012 0.094356 0.011296 0.051482 0.006082 0.107408 -0.0728 0.172865 -0.05986 10-Dec 0.081359 0.024868 0.069255 -0.0048 0.088267 -0.00047 0.05896 0.011501 0.06167 0.003235 0.151708 0.013402 11-Jan 0.073495 -0.01786 0.067798 0.003442 0.099323 0.009847 0.067582 0.007326 0.06768 -0.00637 0.149 -0.01795 11-Feb 0.063406 -0.01603 0.069918 0.006861 0.088746 -0.01965 0.076099 0.01099 0.052349 -0.03146 0.12507 -0.02541 11-Mar 0.048697 0.019537 0.078758 0.001983 0.033649 -0.00549 0.0742 -0.00639 0.044473 0.007343 0.078477 0.055442 11-Apr 0.038096 -0.00979 0.072229 0.002315 0.031185 -0.00677 0.093811 0.007807 0.047309 0.018028 0.231757 0.017197 11-May 0.047878 -0.0032 0.066941 0.001751 0.089032 -0.01206 0.057944 0.002471 0.064242 -0.0069 0.325707 0.006877 11-Jun 0.039098 -0.00809 0.073197 -0.01205 0.11624 -0.00688 0.060207 0.004771 0.070361 -0.00677 0.333381 -0.01486 11-Jul 0.037719 0.001729 0.062112 0.006542 0.114612 -0.00613 0.054476 0.005025 0.094604 0.000269 0.373547 -0.00403 11-Aug 0.034513 -0.05368 0.05377 -0.01739 0.121313 -0.0161 0.068306 -0.01597 0.122455 -0.01018 0.363369 0.079906 11-Sep 0.02704 -0.01352 0.053927 -0.04383 0.103685 -0.02907 0.088478 -0.01848 0.131231 0.003976 0.330517 0.054048 11-Oct 0.038786 0.027062 0.029992 0.031106 0.079689 -0.00876 0.083739 0.006048 0.10505 0.006914 0.348418 0.006048 11-Nov 0.041044 -0.01657 0.03751 -0.02094 0.054133 0.019163 0.088931 -0.01241 0.072494 -0.01463 0.133484 0.074594 11-Dec 0.103128 -0.01263 0.046591 0.008993 0.048258 -0.0251 0.074848 -0.00018 0.07466 -0.00086 0.087007 0.028796 12-Jan 0.118227 0.026444 0.052006 0.041587 0.046611 0.001658 0.01574 0.035412 0.063587 0.002389 0.074204 0.016416 12-Feb 0.122598 -0.00084 0.069188 0.01369 0.050482 0.001776 0.023857 0.009134 0.06617 0.005087 0.093116 0.030493 12-Mar 0.104265 0.017232 0.076994 -0.01145 0.052082 0.003762 0.027545 -0.00288 0.076327 0.004981 0.099453 0.037708 12-Apr 0.098936 0.022583 0.06595 0.000605 0.057745 0.002054 0.037188 -0.01349 0.064687 0.000578 0.138139 -0.01452 12-May 0.089141 -0.01862 0.053403 -0.02149 0.040155 6.19E-05 0.043449 -0.01936 0.056818 -0.0068 0.163505 -0.04733 12-Jun 0.099204 0.0029 0.055061 0.009495 0.033332 0.005187 0.070085 0.011337 0.070332 -0.00277 0.225889 -0.01912 12-Jul 0.097595 0.01046 0.039244 0.011626 0.078823 -0.00086 0.059504 -0.0049 0.082291 -0.0082 0.250106 0.002272 12-Aug 0.102617 -0.00756 0.033855 -0.00345 0.084789 0.005599 0.063005 -0.00181 0.081742 0.005522 0.229006 0.040341 12-Sep 0.102183 0.039397 0.04452 0.015495 0.081538 0.00815 0.041798 9.62E-05 0.077269 0.01068 0.190494 -0.02643 12-Oct 0.063156 0.009069 0.075626 0.008326 0.094997 -0.00238 0.028839 -0.00493 0.091971 -0.00171 0.183817 0.026617 12-Nov 0.059478 0.014209 0.069961 0.00384 0.071881 0.000951 0.022743 0.007659 0.093547 0.006532 0.118919 0.007045 12-Dec 0.04359 -0.0137 0.076152 0.007972 0.061429 0.003239 0.028688 0.013573 0.055046 -0.00359 0.08988 0.012686 13-Jan 0.042402 0.003296 0.071592 0.013726 0.055347 0.000777 0.017266 0.017428 0.025965 0.010131 0.077671 0.022031 13-Feb 0.053014 -0.00078 0.068647 0.005744 0.066683 0.005203 0.028252 0.010783 0.030288 -0.00102 0.062858 0.003411 13-Mar 0.062571 0.010994 0.067563 -0.01074 0.049167 -0.00132 0.027015 0.015522 0.03963 -0.00144 0.057604 0.016195 13-Apr 0.087643 0.001583 0.0732 0.000713 0.048623 0.008947 0.030543 0.01957 0.039617 0.01346 0.107268 0.001796 13-May 0.155529 -3.78E-05 0.070439 -0.0007 0.047366 0.022614 0.024684 -0.00973 0.088442 0.004269 0.114926 0.011779 13-Jun 0.144978 -0.00465 0.057574 -0.02281 0.108893 -0.00518 0.035611 0.00317 0.279286 -0.00842 0.1939 -0.00194 13-Jul 0.130431 0.011634 0.072031 0.014305 0.130615 0.003684 0.045301 0.003532 0.304674 0.010773 0.227933 0.012467 13-Aug 0.120132 -0.00195 0.068647 -0.00052 0.122781 0.001305 0.057854 -0.00476 0.311714 -0.00642 0.203608 0.017791 13-Sep 0.06575 -0.00545 0.080394 0.016555 0.119251 0.000583 0.084581 0.014775 0.297759 0.010611 0.250571 0.00938 13-Oct 0.047298 0.005285 0.120425 0.004647 0.101134 0.022547 0.067475 0.001918 0.150446 0.043009 0.145828 0.041185 13-Nov 0.058826 0.017242 0.109948 0.006176 0.071817 0.008307 0.062375 0.00121 0.053042 -0.00604 0.05076 0.011435 13-Dec 0.047956 -0.00802 0.103437 -0.00066 0.084003 0.009607 0.066285 0.004847 0.050402 0.000148 0.054412 0.006267 14-Jan 0.06039 -0.0104 0.107847 -0.01456 0.088995 0.008308 0.049891 0.004923 0.060003 0.00252 0.04058 0.008332 14-Feb 0.048697 0.016089 0.064049 -0.00105 0.095994 0.015907 0.063598 0.002466 0.062014 -0.00279 0.040226 0.009207 14-Mar 0.048803 0.012027 0.066596 -0.00688 0.092639 0.000271 0.071203 -0.00798 0.063202 0.016329 0.063374 0.010131 14-Apr 0.054393 -2.77E-05 0.068392 0.001996 0.100696 0.019122 0.07642 -0.0071 0.094228 0.004257 0.061417 0.005074 14-May 0.082217 -0.00517 0.06419 0.002143 0.074215 0.008081 0.029942 -0.01012 0.111502 -0.00381 0.165315 0.008571 14-Jun 0.159199 0.001468 0.064119 0.005526 0.096729 -0.0062 0.030144 0.01206 0.140136 -0.01303 0.339514 -0.00723 14-Jul 0.161122 -0.00064 0.055495 0.016062 0.086379 0.003641 0.032367 0.001952 0.136925 -0.00857 0.329419 0.014535 14-Aug 0.149222 -0.01024 0.065349 -6.26E-05 0.091117 0.010869 0.024955 -0.00442 0.128269 0.003591 0.296628 0.017301 14-Sep 0.150027 0.005866 0.059474 -0.02036 0.103996 0.002301 0.033988 -0.00461 0.136176 -0.00337 0.291533 -0.00818 14-Oct 0.073368 -0.04392 0.067435 0.008965 0.080492 -0.01163 0.020897 -0.01229 0.113464 -0.01768 0.133705 -0.23033 14-Nov 0.089288 -0.00557 0.084815 -0.00035 0.082332 -0.01346 0.032396 0.008304 0.124252 -0.01689 0.092065 -0.03321 14-Dec 0.094367 0.000647 0.142574 0.006715 0.054609 0.000543 0.047399 -0.00105 0.113318 -0.01409 0.067618 0.011339 15-Jan 0.084719 -0.00414 0.138934 0.01119 0.035142 0.005869 0.050001 0.010183 0.105044 -0.00425 0.047547 0.020317 15-Feb 0.081396 0.020125 0.11201 0.004226 0.038827 0.018429 0.064911 0.014608 0.093223 -0.00763 0.044216 0.005959 15-Mar 0.070694 0.005148 0.090721 0.000676 0.04484 -0.00662 0.068016 0.002282 0.071088 -0.0235 0.050961 -0.00289 15-Apr 0.046477 0.009808 0.039194 0.042848 0.051099 -0.00654 0.058671 0.004364 0.049306 0.005851 0.036681 0.021859 15-May 0.114129 -0.00053 0.04534 -0.00301 0.067418 -0.00534 0.080592 0.000444 0.04979 -0.01078 0.03599 0.000393 15-Jun 0.155868 0.000911 0.055488 -0.00909 0.110349 0.003204 0.09499 -0.00218 0.045165 0.000869 0.042706 -0.01044 15-Jul 0.143998 0.01204 0.055155 -0.00927 0.105175 -0.01308 0.082481 0.005026 0.048215 -0.00283 0.043197 0.0185 15-Aug 0.139796 -0.011 0.053131 -0.02828 0.112001 -0.00753 0.066901 -0.01171 0.040166 -0.01927 0.044748 -0.01313 15-Sep 0.13442 -0.04179 0.049929 -0.01784 0.125934 -0.00807 0.047968 -0.04907 0.082883 -0.00433 0.088255 -0.00258 15-Oct 0.058975 0.019236 0.096952 0.021717 0.116633 -0.00389 0.044177 0.023988 0.110388 -0.01154 0.087908 -0.02361 15-Nov 0.059629 -0.00198 0.097191 -0.00652 0.111808 -0.00195 0.035322 -0.00198 0.103403 0.006467 0.097863 -7.92E-05 15-Dec 0.065516 0.000394 0.107856 -0.00221 0.109277 -0.00446 0.045038 -0.00139 0.105924 -0.00173 0.094134 -0.00311 16-Jan 0.069967 -0.01648 0.124405 -0.02534 0.080609 -0.00782 0.045002 -0.03628 0.067507 -0.02547 0.061998 -0.03317 16-Feb 0.059642 -0.01092 0.093536 -0.04365 0.065717 -0.00534 0.033701 -0.01313 0.052069 0.012975 0.07676 0.00127 16-Mar 0.085488 0.009066 0.097588 0.00784 0.066972 -0.01077 0.035102 0.009299 0.041685 0.00368 0.097081 0.003638 16-Apr 0.077174 -0.02227 0.076671 -0.00295 0.067276 -0.00647 0.021694 0.005411 0.049655 0.005316 0.088254 0.022902 16-May 0.069195 -0.00497 0.067416 -0.00932 0.082775 0.004632 0.033202 -0.00077 0.196307 -0.01142 0.119456 -0.00425 16-Jun 0.097455 -0.0136 0.061482 -0.00162 0.129515 0.012956 0.029188 -0.00652 0.176014 -0.00397 0.125573 0.006204 16-Jul 0.104777 0.014497 0.045435 0.016457 0.100695 0.014244 0.036942 0.018711 0.177081 0.000672 0.09933 -0.00171 16-Aug 0.099126 0.008854 0.050532 0.008233 0.101403 -0.00082 0.040107 -0.00017 0.180629 -0.00393 0.0904 -0.00772 16-Sep 0.095867 0.001927 0.058721 0.006162 0.092854 -0.00179 0.032254 0.007411 0.082157 -0.02736 0.083736 0.006736 16-Oct 0.071165 -0.02676 0.055384 -0.00487 0.07185 0.014646 0.020497 0.00806 0.058031 -0.00201 0.06654 0.033218 16-Nov 0.046141 0.002952 0.063315 -0.00122 0.073631 0.011232 0.027677 -0.01164 0.057347 0.010014 0.056544 0.033138 16-Dec 0.066547 0.000778 0.091166 -0.00091 0.086377 0.02276 0.036674 0.002547 0.06248 0.01014 0.073954 0.008925 17-Jan 0.062046 -0.00505 0.070734 0.01391 0.073518 0.014533 0.049839 0.007438 0.06157 0.022513 0.069436 0.002046 17-Feb 0.048757 0.017769 0.063187 0.003425 0.079388 0.012774 0.056143 0.00427 0.058395 -0.00668 0.164802 -0.00184 17-Mar 0.042455 -0.00482 0.062797 0.002898 0.071547 -0.00202 0.062613 0.001129 0.072438 0.0018 0.237231 0.010924 [image: Mailtrack] <https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender notified by Mailtrack <https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 05/08/20, 12:53:17 PM On Fri, May 8, 2020 at 2:54 AM Jim Lemon <drjimlemon at gmail.com> wrote:> Hi Subhamitra, > For some reason, your data didn't make it through. Maybe you tried to > send an .xls or .xlsx file. If so, export it as CSV or if it's not too > big, just paste the text into your email. > > Jim > > On Thu, May 7, 2020 at 10:30 PM Subhamitra Patra > <subhamitra.patra at gmail.com> wrote: > > > > Dear R-users, > > > > I want to estimate ARCH test for multiple columns (i.e., from 2:21 > COLUMNS > > ) in my data. For this purpose, I want to run a loop to calculate ARCH > test > > results for each column in the data frame. I tried by using for loop and > > lapply function, but unable to write a loop for computing the ARCH test > > simultaneously for each column (i.e., from 2:21 columns) of my data > frame. > > > > Below is my ARCH test code which I want to estimate for multiple columns > of > > the data frame in a loop. > > > > library(tseries) > > > > library(FinTS) > > > > ArchTest (A, lags=1, demean = FALSE) > > > > Hence, A is a vector for which the ARCH test result is calculated. Here, > I > > want to write a loop so that the ArchTest can be calculated > simultaneously > > for each column of my data frame. From ARCH test result, I require only > the > > calculated Chi-square value and its p-value for each column that stored > in > > another matrix or object for each column as an output file. > > > > For your convenience, I attached my sample data below. Please find it. > > > > Please help me for which I shall be always grateful to you. > > > > Thank you. > > > > -- > > *Best Regards,* > > *Subhamitra Patra* > > *Phd. Research Scholar* > > *Department of Humanities and Social Sciences* > > *Indian Institute of Technology, Kharagpur* > > *INDIA* > > > > [image: Mailtrack] > > < > https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5& > > > > Sender > > notified by > > Mailtrack > > < > https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5& > > > > 05/07/20, > > 05:51:03 PM > > ______________________________________________ > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. >-- *Best Regards,* *Subhamitra Patra* *Phd. Research Scholar* *Department of Humanities and Social Sciences* *Indian Institute of Technology, Kharagpur* *INDIA* [[alternative HTML version deleted]]
Jim Lemon
2020-May-08 09:07 UTC
[R] [R ] Writing loop to estimate ARCH test for a multiple columns of a data frame?
Hi Subhamitra, This isn't too hard: # read in the sample data that was # saved in the file "sp_8_5.tab" sp_8_5<-read.table("sp_8_5.tab",sep="\t", header=TRUE,stringsAsFactors=FALSE) library(tseries) library(FinTS) # using "sapply", run the test on each column spout<-sapply(sp_8_5[,2:12],ArchTest) The list "spout" contains the test results. If you really want to use a loop: spout<-list() for(i in 2:12) spout[[i-1]]<-ArchTest(sp_8_5[,i]) Jim On Fri, May 8, 2020 at 5:27 PM Subhamitra Patra <subhamitra.patra at gmail.com> wrote:> Dear Sir, > > Herewith I am pasting a part of my sample data having 12 columns below, > and want to calculate ARCH test for the 12 columns by using a loop. > >[[alternative HTML version deleted]]
Subhamitra Patra
2020-May-08 10:23 UTC
[R] [R ] Writing loop to estimate ARCH test for a multiple columns of a data frame?
Dear Sir, Thank you very much for such an excellent solution to my problem. I was trying sapply function since last days, but was really unable to write properly. Now, I understood my mistake in using sapply function in the code. Therefore, I have two queries regarding this which I want to discuss here just for my learning purpose. 1. While using sapply function for estimating one method across the columns of a data frame, one needs to define the list of the output table after using sapply so that the test results for each column will be consistently stored in an output object, right? 2. In the spout<- list() command, what spout[[i-1]] indicates? Sir, one more possibility which I would like to ask related to my above problem just to learn for further R programming language. After running your suggested code, all the results for each column are being stored in the spout object. From this, I need only the statistics and P-value for each column. So, my queries are: 1. Is there any way to extract only two values (i.e., statistics and p-value) for each column that stored in spout object and save these two values in another R data frame for each column? or 2. Is there any possibility that the statistics and p-value calculated for each column can directly export to a word file in a table format (having 4 columns and 3 rows). In particular, is it possible to extract both statistic and p-value results for each column to an MS word file with the format of A1, A2, A3, A4 column results in 1st row, A5, A6, A7, A8 column results in 2nd row, and A9, A10, A11, A12 column results in the 3rd row of the table? Like before, your suggestion will definitely help me to learn the advanced R language. Thank you very much for your help. [image: Mailtrack] <https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> Sender notified by Mailtrack <https://mailtrack.io?utm_source=gmail&utm_medium=signature&utm_campaign=signaturevirality5&> 05/08/20, 03:47:26 PM On Fri, May 8, 2020 at 2:37 PM Jim Lemon <drjimlemon at gmail.com> wrote:> Hi Subhamitra, > This isn't too hard: > > # read in the sample data that was > # saved in the file "sp_8_5.tab" > sp_8_5<-read.table("sp_8_5.tab",sep="\t", > header=TRUE,stringsAsFactors=FALSE) > library(tseries) > library(FinTS) > # using "sapply", run the test on each column > spout<-sapply(sp_8_5[,2:12],ArchTest) > > The list "spout" contains the test results. If you really want to use a > loop: > > spout<-list() > for(i in 2:12) spout[[i-1]]<-ArchTest(sp_8_5[,i]) > > Jim > > > On Fri, May 8, 2020 at 5:27 PM Subhamitra Patra < > subhamitra.patra at gmail.com> wrote: > >> Dear Sir, >> >> Herewith I am pasting a part of my sample data having 12 columns below, >> and want to calculate ARCH test for the 12 columns by using a loop. >> >>-- *Best Regards,* *Subhamitra Patra* *Phd. Research Scholar* *Department of Humanities and Social Sciences* *Indian Institute of Technology, Kharagpur* *INDIA* [[alternative HTML version deleted]]