0

ドルコスト平均法を適用した投資スキームの年次を見積もろうとしています。値の増分は以下のとおりです (MathJax がギリシャ語のように見えるので、使用しませんでした)。

x: regular contribution, which is 1500 in my case
y: rate of return PLUS 100% (e.g 1.07 for a 7% return), which is the parameters that I want to estimate.

Time 1: xy
Time 2: (x + xy)*y
Time 3: (x + (x + xy)*y)*y
Time 4: (x + (x + (x + xy)*y)*y)*y
Time 5: (x + (x + (x + (x + xy)*y)*y)*y)*y
Time 6: (x + (x + (x + (x + (x + xy)*y)*y)*y)*y)*y

そして、リストは続きます。

方程式を単純化した後、正しく計算すると、ベキ級数になるはずです。

xy(1 + y + y^2 + y^3 + y^4 + y^5 +y^6)

http://www.walkingrandomly.com/?p=5254nlsで提案されているように、上記の式をRの関数に使用できることを知っています。しかし、問題は、投資スキームが 6 回以上取引されており、取引回数が可変であり、数式で取引回数を固定したくないことです。

R はべき級数の可変長の式、関数のようなものを作成できるのだろうか?

更新 01

コメント@Rolandをありがとう、私はdput以下のようなデータフレームを持っています:

structure(list(date = 1:62, value = c(1500, 3008.1048, 4279.09223337264, 
5701.16001583254, 7545.25391699441, 8883.87795645887, 11192.7249445628, 
13043.5267669473, 14396.3707754063, 16677.2027610312, 18474.8268536672, 
20225.6882177597, 21889.6372952495, 24090.0451286292, 25305.8719822623, 
26293.5164474925, 27470.5608573055, 26851.4637959011, 25610.4708389126, 
29781.3033136099, 30244.449772352, 31757.1977515, 35216.3065708333, 
38661.857424377, 40153.0021899712, 41453.1839013205, 39626.0241467687, 
42464.6515262833, 44415.7606695956, 46456.2932413184, 49539.1291983018, 
51223.0944673951, 53534.0828137635, 56511.2727118443, 60750.8112270199, 
62420.4165280642, 64561.1738159384, 67269.7609015725, 69582.2433935286, 
68461.4426685366, 72790.7668201147, 73029.1128824367, 77963.2040906503, 
81782.8304828104, 84781.7088147301, 87010.8577769314, 85461.5060309602, 
90165.7453255817, 91340.1347579196, 92918.1083054977, 96713.3387975151, 
99841.2477244806, 101538.099862003, 104946.468993318, 103233.508326534, 
106416.67466519, 109991.955526668, 110800.989092493, 112258.758666778, 
118567.887527905, 120872.966926589, 127711.586247323), expected_value = c(1511.96121064336, 
3035.97901230344, 4572.1495459301, 6120.56971911465, 7681.33721220313, 
9254.55048445835, 10840.3087802712, 12438.7121354211, 14049.861383387, 
15673.8581617081, 17310.8049183956, 18960.8049183956, 20623.9622501033, 
22300.3818319294, 23990.1694189188, 25693.4316094218, 27410.2758518191, 
29140.8104512998, 30885.1445766939, 32643.3882673588, 34415.6524401213, 
36202.0488962746, 38002.6903286308, 39817.6903286308, 41647.1633935093, 
43491.224933518, 45349.9912792063, 47223.5796887596, 49112.1083553966, 
51015.6964148254, 52934.4639527589, 54868.5320124903, 56818.0226025291, 
58783.0587042976, 60763.7642798896, 62760.2642798896, 64772.6846512559, 
66801.1523452654, 68845.7953255225, 70906.7425760312, 72984.1241093319, 
75078.0709747036, 77188.7152664305, 79316.190132135, 81460.6297811776, 
83622.169493123, 85800.9456262742, 87997.0956262742, 90210.7580347771, 
92442.0724981876, 94691.1797764704, 96958.2217520299, 99243.3414386608, 
101546.68299057, 103868.391711469, 106208.614063744, 108567.497677691, 
110945.191360831, 113341.845107297, 115757.610107297, 118192.63875665, 
120647.084666402)), .Names = c("date", "value", "expected_value"
), row.names = c("63", "62", "61", "60", "59", "58", "57", "56", 
"55", "54", "53", "52", "51", "50", "49", "48", "47", "46", "45", 
"44", "43", "42", "41", "40", "39", "38", "37", "36", "35", "34", 
"33", "32", "31", "30", "29", "28", "27", "26", "25", "24", "23", 
"22", "21", "20", "19", "18", "17", "16", "15", "14", "13", "12", 
"11", "10", "9", "8", "7", "6", "5", "4", "510", "410"), class = c("tbl_df", 
"tbl", "data.frame"))
4

0 に答える 0