[0]前提
Rで、時価総額順位ごとに、トップから各順位に関して、R^2と線形近似式の切片と傾きを得る。
R^2, the cut of the linear approximation type, and the inclination of each
aggregate market value order are obtained from the top for each order by R.
~~~
[1]準備
[1-0]サンプルデータ,Example Data
http://humanbeing-etcman.blogspot.com/2008/12/power-law35rlinear-approximation1.html
Power Law:(35)のファイル:20081212-foods.txt を使用する。
The file of Power Law:(35): 20081212- foods.txt is used.
---
[1-1]トップから指定順位までのデータを用意する。
:方針)新たなデータセットを用意する。
Data from the top to a specified order is prepared.
:The policy) A new data set is prepared.
===
参考)
http://cse.naro.affrc.go.jp/takezawa/r-tips/r/39.html
データフレームの考え方
===
[1-1-1]動作確認:データ範囲を指定する。
confirm the operation: The data range is specified.
> foods = read.csv("20081212-foods.txt");
> foods$LN_order
[1] 0.0000000 0.6931472 1.0986123 1.3862944 1.6094379 1.7917595 1.9459101
[8] 2.0794415 2.1972246 2.3025851 2.3978953 2.4849067 2.5649494 2.6390573
[15] 2.7080502 2.7725887 2.8332133 2.8903718 2.9444390 2.9957323 3.0445224
[22] 3.0910425 3.1354942 3.1780538 3.2188758 3.2580965 3.2958369 3.3322045
[29] 3.3672958 3.4011974 3.4339872 3.4657359 3.4965076 3.5263605 3.5553481
[36] 3.5835189 3.6109179 3.6375862 3.6635616 3.6888795 3.7135721 3.7376696
[43] 3.7612001 3.7841896 3.8066625 3.8286414 3.8501476 3.8712010 3.8918203
[50] 3.9120230 3.9318256 3.9512437 3.9702919 3.9889840 4.0073332 4.0253517
[57] 4.0430513 4.0604430 4.0775374 4.0943446 4.1108739 4.1271344 4.1431347
[64] 4.1588831 4.1743873 4.1896547 4.2046926 4.2195077 4.2341065
> foods$LN_order[1:10]
[1] 0.0000000 0.6931472 1.0986123 1.3862944 1.6094379 1.7917595 1.9459101
[8] 2.0794415 2.1972246 2.3025851
>
[1-1-2]LN_order, LN_jika で10位までの別のデータセットを作成する。
Another data set to 10th place is made with LN_order and LN_jika.
> foods_LN_order_10 = foods$LN_order[1:10]
> foods_LN_jika_10 = foods$LN_jika[1:10]
> foods_10 = data.frame(LN_order=foods_LN_order_10, LN_jika=foods_LN_jika_10)
> foods_10
LN_order LN_jika
1 0.0000000 21.85789
2 0.6931472 20.78646
3 1.0986123 20.43241
4 1.3862944 20.30689
5 1.6094379 19.85423
6 1.7917595 19.54624
7 1.9459101 19.49664
8 2.0794415 19.46040
9 2.1972246 19.43079
10 2.3025851 19.41820
>
~~~
[2]
データを3位から、ラストまで、1つの位ごとに、R^2、切片、傾きを求める。
:2位は、2点を結んだ直線なので、近似として意味がないから、3位から行う。
:結果は、別のデータセット(この場合、kinji_ALL)に格納した。
Data is requested and R^2, the cut, and the inclination are requested from 3th
place to last in each of the one place.
:It does from 3rd place because it is not significant because 2nd place is a
straight line that connects two points as the approximation.
:The result was stored in another data set (in this case, kinji_ALL).
> foods = read.csv("20081212-foods.txt");
kinji_r2 = c()
kinji_a = c()
kinji_b = c()
for (i in 3:length(foods$LN_order)){
foods_LN_order_XX = foods$LN_order[1:i]
foods_LN_jika_XX = foods$LN_jika[1:i]
foods_XX = data.frame(LN_order=foods_LN_order_XX, LN_jika=foods_LN_jika_XX)
result = summary(result <- lm(LN_jika ~ LN_order, data = foods_XX))
kinji_r2[i] = result$r.squared
kinji_b[i] = result$coefficients[1]
kinji_a[i] = result$coefficients[2]
}
kinji_ALL = data.frame(KINJI_A=kinji_a, KINJI_B=kinji_b, KINJI_R2=kinji_r2)
---
> kinji_ALL
KINJI_A KINJI_B KINJI_R2
1 NA NA NA
2 NA NA NA
3 -1.3242540 21.81650 0.9824892
4 -1.1462126 21.75659 0.9565357
5 -1.1694590 21.76733 0.9707778
6 -1.2092634 21.79003 0.9768168
7 -1.1938098 21.77974 0.9807814
8 -1.1583033 21.75306 0.9794489
9 -1.1165969 21.71849 0.9746122
10 -1.0722442 21.67858 0.9668070
11 -1.0602637 21.66701 0.9695117
12 -1.0459431 21.65231 0.9709022
13 -1.0290555 21.63402 0.9709299
14 -1.0165604 21.61981 0.9717328
15 -1.0048458 21.60591 0.9723224
16 -0.9999210 21.59983 0.9740801
17 -0.9928455 21.59077 0.9751474
18 -0.9851746 21.58063 0.9758356
19 -0.9761357 21.56830 0.9759397
20 -0.9775813 21.57033 0.9774987
21 -0.9798449 21.57359 0.9788664
22 -0.9823583 21.57730 0.9800693
23 -0.9833038 21.57873 0.9811715
24 -0.9841772 21.58008 0.9821641
25 -0.9862398 21.58333 0.9830372
26 -0.9904291 21.59007 0.9836339
27 -0.9957354 21.59876 0.9839738
28 -0.9994923 21.60502 0.9844921
29 -1.0098870 21.62264 0.9831402
30 -1.0228158 21.64491 0.9806215
31 -1.0349416 21.66612 0.9786022
32 -1.0464358 21.68652 0.9769389
33 -1.0572030 21.70590 0.9756323
34 -1.0665177 21.72290 0.9749226
35 -1.0772230 21.74268 0.9736195
36 -1.0867300 21.76047 0.9728248
37 -1.0980279 21.78187 0.9712340
38 -1.1079675 21.80092 0.9702756
39 -1.1162712 21.81701 0.9699321
40 -1.1236683 21.83151 0.9698507
41 -1.1304121 21.84486 0.9699205
42 -1.1373462 21.85872 0.9698911
43 -1.1434774 21.87111 0.9700475
44 -1.1501606 21.88473 0.9700077
45 -1.1557605 21.89626 0.9702260
46 -1.1625077 21.91027 0.9700864
47 -1.1702470 21.92648 0.9695829
48 -1.1785092 21.94394 0.9688642
49 -1.1870856 21.96221 0.9680108
50 -1.1958832 21.98110 0.9670627
51 -1.2037496 21.99812 0.9664935
52 -1.2113017 22.01460 0.9660299
53 -1.2196549 22.03295 0.9652395
54 -1.2278521 22.05109 0.9645104
55 -1.2398628 22.07787 0.9618342
56 -1.2510759 22.10304 0.9597209
57 -1.2630408 22.13008 0.9572346
58 -1.2742355 22.15555 0.9552742
59 -1.2852405 22.18075 0.9534707
60 -1.2992184 22.21296 0.9498893
61 -1.3120443 22.24270 0.9472154
62 -1.3246901 22.27220 0.9447482
63 -1.3366441 22.30025 0.9427655
64 -1.3530451 22.33896 0.9378681
65 -1.3717735 22.38343 0.9313413
66 -1.3896256 22.42605 0.9259591
67 -1.4093466 22.47339 0.9193602
68 -1.4303375 22.52405 0.9121090
69 -1.4540328 22.58154 0.9029087
>
---
結果をファイルに出力する。中断!
The result is output to the file. pending or TODO)
~~~
[3]
最大のR^2を求めるには、R^2をグラフ化する?
To obtain maximum R^2, R^2 is graphed?
> plot(kinji_ALL$KINJI_R2)
> abline(v = 3, col="red")
> abline(v = 7, col="red")
> abline(v = 28, col="red")
>
---
考察):最終結論は未決!
単純なグラフでないので、視覚化して判断するしかない?
最大値が1つではない、、、
:ある値以上で、最大順位を採用するか?
consideration): The final conclusion is undecided.
Because it is not a simple graph, it visualizes and it can do nothing but judge it?
The maximum value is not one...
:Is the maximum order adopted more than a certain value?
---
Excelの手作業では、10位ごとに飛び飛びに行って、ピークがありそうな部分に関しては
1つ1つ行った。これは、単純に頂点が1つしかないと判断してのこと。
In the hand work of Excel, it went in each 10th place here and there, and it
went for the part with the peak seemed one by one. This is judged for only one
the top to exist simply.
~~~
end
0 件のコメント:
コメントを投稿