[R-SIG-Finance] FPortfolio / MAxReturnPortfolio

alexios ghalanos alexios at 4dscape.com
Wed Jul 9 13:05:20 CEST 2014


ok, thats a bug which defaults to targetType='inequality' irrespective
of value passed.

1. Download latest (fixed) version from either r-forge (you'll have to
wait until it rebuilds) or immediately from bitbucket (assuming you can
build from source):
library(devtools)
install_bitbucket("parma","alexiosg")

2. Make sure to set targetType='equality'.

Regards,

Alexios

PS Try to create a minimally reproducible example next time which does
not need so much data to be included in the email.

On 09/07/2014 11:16, u0055 at wolke7.net wrote:
> Thanks Alexios,
> 
> parma is great and
> 
> #############
> library(parma)
> c = cov( datamatrix )
> if( ! is.positive.definite( c )) c = make.positive.definite( c )
> spec = parmaspec( S=c, risk="EV", riskType="minrisk", target=0.000057,
> forecast=colMeans( datamatrix ))
> weights(parmasolve( spec, solver="SOCP" ))
> #############
> 
> worked out for me.
> The only issue with parma is,
> that the target set in parmaspec()
> is not always equal to the "Reward" in the resulting "PARMA Portfolio".
> Please find my attached example,
> where the target was set to 0.000057 and
> parmareward is 0.0008336 .
> 
> Shouldn't the target return of the optimized portfolio
> be equal to the parmareward (parmareward:
> "Extracts the expected reward of the optimized portfolio"),
> or did I get something wrong ?
> 
> Thanks in advance,
> Uwe
> 
> 
> #############
> require( corpcor )
> require( parma )
> x = c(
> 0, 0, 0.002626900972751926, -0.004651670127579728, 0.002811887470333338,
> -0.008096147062518157, 0.005687190619310368, 0.005425791256111988,
> -0.01368150533402819, -0.003634388004548671, 0.0025648466285168323,
> -0.0006334949050101481, 0.0004735784414639808, -0.0018703955387240913,
> 0.037384943082805426, -0.0012265590632451221, 0.03870767619245188,
> -0.026893230996311645, 0.012195443499031582, 0.010442198329463508,
> 0.03703245081869636, 0.0005165302317106237, -0.027967056834254163,
> -0.002166502086674518, -0.02200604876582455, 0.014886204727195701,
> 0.00000762952609082907, 0.033535917842535935, 0.007453936274707527,
> 0.03528170093486842, -0.0044733578692161815, -0.0070889396437022615,
> 0.005046331832589623,
> 0, 0, 0.0026735804398232655, -0.005450549385288055,
> 0.005905095435528848, -0.005636808078392704, 0.003548761554728186,
> 0.003639422387326808, -0.01143127698216372, -0.0033800680722703477,
> 0.0016521334579031068, -0.0008102892682083494, -0.0023035419952529474,
> -0.0012498383490797311, 0.032035635560114115, -0.003090259161178727,
> 0.01834605266070127, -0.02585586395070751, 0.011123773471797327,
> 0.008631840278607165, 0.030760846293804246, 0.012938723579635629,
> -0.02266942964336796, -0.012598767801654186, -0.020401390528317652,
> 0.028183182056325386, 0.0013368970239209228, 0.028771260172201513,
> 0.006412473489823854, 0.018803309313281436, -0.0051934303303143425,
> -0.014700625477502637, 0.03113752390369849,
> 0, 0, 0.0022392375257311685, -0.004488149449633533,
> 0.0025992065074906356, -0.0073523219193142334, 0.0049532099156933945,
> 0.005122919641519685, -0.011247204548620658, -0.0024767692343022787,
> 0.002707204525558023, -0.00048103183011147677, 0.0006131252694661922,
> -0.0015272567357329503, 0.03104049320762557, -0.002382181742317426,
> 0.022297080386879678, -0.0226689212701502, 0.010294279998115444,
> 0.009113137008980804, 0.03392898791764368, 0.0018488113998938879,
> -0.027031585912522034, -0.0006499940200819236, -0.019784277874540825,
> 0.012394870635087547, 0.0007550345679040608, 0.032066934800107014,
> 0.006602593626471261, 0.04146416947563461, -0.002581889263848951,
> -0.008094583656598608, -0.0017426153439798753,
> 0, 0, 0.0027504258465288933, -0.003874378115827679,
> 0.004226496340492257, -0.007823516314137312, 0.004840696907796814,
> 0.005419539153597611, -0.013468274420662655, -0.0031911974336257176,
> 0.003208657493590492, -0.0006488071595788727, 0.00014307712429758478,
> -0.0020308868174715774, 0.03657058353869104, -0.0019950078992211568,
> 0.034941262016579905, -0.02693558207101126, 0.013089627910204581,
> 0.0056231613089763235, 0.03596968844767194, -0.00767739388810322,
> -0.02615767368446281, -0.003211770477689525, -0.023289630517109975,
> 0.014907037827663425, -0.00009343147550549141, 0.03343466549037982,
> 0.006829318461961503, 0.03140330913857898, -0.006098528232914019,
> -0.007222216079271492, 0.003963916533514356,
> 0, -0.004962608713128447, 0.00651501451569684, 0.0037736285598725843,
> -0.002103270938131628, -0.0022946946683208144, 0.011409645338876473,
> -0.009099465877408104, 0.0056262601568110825, 0.006593279784179638,
> 4.8404187232792294e-17, -0.0006597463139954885, 0.01153025704199422,
> -0.00024041820310423905, 0.008505691012201961, -0.0038974624344401305,
> 0.08083731344853264, 0.030189195107346117, -0.01261722579220082,
> 0.03633766386795118, 0.0017962860418272329, 0.022779178187142854,
> -0.0018272512644430773, -0.006405978001578142, -0.034072103166739934,
> 0.031778046606175135, -0.017223343266811585, 0.0471732062493369,
> -0.0069321188687848445, -0.12040697478444749, 0.008849761358635492,
> 0.03776610172684411, -0.03401688527825439,
> 0, 0, 0.0023810160995254475, -0.0037880692307967197,
> 0.0038198223884249117, -0.007253376810171589, 0.0042934989242776,
> 0.005178111785009931, -0.011118377538462312, -0.0019752824176964287,
> 0.003458150096355774, -0.0003251142181542887, 0.0002455407914759298,
> -0.0017176759921837858, 0.030591496613247185, -0.003027526359857558,
> 0.0191776279232834, -0.02263281812840497, 0.011094654492357001,
> 0.004832024724285659, 0.03321296872031677, -0.006035902511273208,
> -0.025315749676041534, -0.0014833253390330575, -0.02072096868909912,
> 0.01240417481845325, 0.0007155401968537887, 0.03206967730910546,
> 0.006367411772657192, 0.03860882577028918, -0.004220638484911972,
> -0.008116476951941242, -0.002418533574420359,
> 0, 0, 0.0010740365723649443, -0.0030249301790239527,
> 0.0014494658061336998, -0.009442879271067406, 0.003912807537592503,
> 0.005735381361174858, -0.009514188465677583, 0.0008361620547465522,
> 0.0037751412004314888, -0.0005957756795493012, 0.0006844218678090265,
> -0.00210297882124566, 0.012383506934470063, -0.0015311488726225226,
> 0.002536097953329469, -0.009500927467669467, 0.008969694673235773,
> 0.013792953512672504, 0.03216189217913182, 0.0002287318499777624,
> -0.02900025128295019, 0.0009717802468302461, -0.014385634904270058,
> 0.008482023360893653, 0.005734041238105664, 0.031115768402791958,
> 0.008369006763839682, 0.049839341109902346, -0.0024626849384762318,
> 0.0038636737026609617, -0.027211746954634353,
> 0, 0, 0.0023372932527562073, -0.005258416446074964,
> 0.005481183136214499, -0.00512309911576579, 0.002979044435783182,
> 0.0034250662377738016, -0.009335427866414085, -0.0023784344983329357,
> 0.0017972396907285414, -0.0006347787644515546, -0.0021294358978136405,
> -0.001016849187692114, 0.026812869706426285, -0.003819272823728538,
> 0.004784149905524516, -0.020711856922305344, 0.00931497175999165,
> 0.007621110058377527, 0.028142841972826127, 0.013408369347340349,
> -0.021923287864364684, -0.011459557227990788, -0.018647361493872232,
> 0.02300228657180063, 0.00216548683730409, 0.027923504491814605,
> 0.00560894841661691, 0.021934067837820134, -0.0035835908908241204,
> -0.0146028583160898, 0.019673920629340327,
> 0, 0, 0.001573315150045051, -0.0031868592285909185,
> 0.0016615110957920788, -0.011324627170940574, 0.004938023227565608,
> 0.00625611114735139, -0.01328793599650315, -0.0007176741205027982,
> 0.0036069075915353185, -0.0008436535566495516, 0.00042613280768177695,
> -0.0029753295794374295, 0.016513333427867528, 0.001050950676584112,
> 0.02489491474993907, -0.013073207292070961, 0.011772904028704788,
> 0.017844488345106324, 0.03698722375751522, -0.002456097501253425,
> -0.0317304659605383, -0.0027385780663545297, -0.017821425294712114,
> 0.012684954809489321, 0.005318157332520829, 0.033835445131507574,
> 0.00978042119717415, 0.012131036611807117, -0.005687276730748033,
> 0.010799930962646111, -0.024292350318105213,
> 0, 0, 0.0011757989008024763, -0.0024357332210485005,
> 0.002084728079010735, -0.009208499887641605, 0.003650334909458171,
> 0.005802087007519423, -0.009514188465677583, 0.0009951307851831473,
> 0.0037230303442594244, -0.0004492405895455943, 0.0006184914041200815,
> -0.0018851640473372111, 0.01291667859568179, -0.002152965492240513,
> 0.0012047991893237434, -0.009372979888351746, 0.00850284565494668,
> 0.011491397166873302, 0.031906385820210735, -0.004615186267441387,
> -0.025102714380157855, 0.0005559855396819668, -0.015906481980680877,
> 0.00846942997100348, 0.005713122002758813, 0.0320508767314311,
> 0.008117616509895129, 0.048854790537557286, -0.004029204027482041,
> 0.003489165670688012, -0.0267552781811482,
> 0, 0, 0.0019004287009389146, -0.003292950674858931,
> 0.001800437320051016, -0.012557496484650587, 0.005609716265823847,
> 0.006597278938294634, -0.0157603912753199, -0.0017357047180799577,
> 0.0034966855719136864, -0.001006056303715236, 0.0002569089407018556,
> -0.003546869731356178, 0.019219081820093457, 0.0027426710708919047,
> 0.03954379472013158, -0.015413666487368494, 0.013609489468494823,
> 0.02049894220083883, 0.04014864789507675, -0.004215123627922137,
> -0.03351922730102707, -0.005169502478441095, -0.020072460378105183,
> 0.01543859955167268, 0.005045681670241104, 0.03561730229859711,
> 0.010705140998324314, -0.01257440426625527, -0.007799940318788177,
> 0.015344375374360526, -0.022379642176930933,
> 0, 0, 0.0016475406855415919, -0.0042385652569788155,
> 0.0022745881957833528, -0.006217009858634568, 0.003832923578593805,
> 0.0046606419139840595, -0.0075316928235249474, -0.0007098774270840972,
> 0.002924487631568259, -0.0002483250315819229, 0.000826117796416936,
> -0.0010035185627464743, 0.021356859187614194, -0.004146026884059365,
> -0.002750671105835753, -0.016221290635482728, 0.007392504128296068,
> 0.007084569730349301, 0.029192123489721146, 0.003882293182910453,
> -0.025603761874088794, 0.001664676186822569, -0.016393153882581446,
> 0.00859230807344878, 0.001895810684355845, 0.02982480278797865,
> 0.005303175900215923, 0.0509005688273304, 0.00030508913381681156,
> -0.009629513992071992, -0.01210469261348067,
> 0, 0, 0.0029983327869394683, -0.005757095271620889,
> 0.008259609235448525, -0.005620592803263748, 0.003145928835778438,
> 0.003728228170827728, -0.011260465102672397, -0.002877238505503342,
> 0.0021824413880556386, -0.00003565038381008753, -0.002270835686244205,
> -0.0015257273763423084, 0.03120891972002798, -0.003151489437286643,
> 0.012380849088919477, -0.025288628574023857, 0.012245416477637572,
> -0.0013740035970067365, 0.03021231182553681, -0.005243320510867623,
> -0.02414238886884155, -0.013384857791019245, -0.019726426528391336,
> 0.028118742243602536, 0.0012286327187295712, 0.02660269558122618,
> 0.006136488666732359, 0.01666324613463323, -0.006449919173472458,
> -0.014266675342364194, 0.029342825372708284,
> 0, 0, 0.0016497141811927696, -0.0025061511903902802,
> 0.002492617176805438, -0.010715921122159215, 0.0044418154697143,
> 0.006191089790517165, -0.013115684833936646, -0.0007489797925822873,
> 0.003416893718752093, -0.0009183398079189262, 0.0004634375782052584,
> -0.0026705303683753835, 0.01681345141294844, 0.00023703766149890638,
> 0.022818271573628958, -0.013129530425995833, 0.011324328503053475,
> 0.014663792197450268, 0.03604277237128459, -0.007558787576715028,
> -0.02786025701119017, -0.0034611099896382593, -0.02012002900454508,
> 0.012649651875919266, 0.005170662715894224, 0.03472797591893575,
> 0.008781069690345374, 0.009502465110866635, -0.007116844378897773,
> 0.009571174116911592, -0.02395957627837128,
> 0, 0, 0.0015651081439543712, -0.001465950607791438,
> 0.0027091136312055964, -0.008084984711778848, 0.0033432249644846914,
> 0.004477338578049312, -0.018259154880781517, 0.0009735825691574943,
> 0.003100330517943717, -0.00043075621477225355, 0.00017746636599376368,
> -0.0015092112444491732, 0.013880640373033989, -0.002632152450743659,
> 0.004742778861789411, -0.008030452832936802, 0.007390457391629667,
> 0.009630978921657207, 0.030188237789555494, -0.009364737199211435,
> -0.018049180652342164, -0.001298445134716803, -0.01718055136574525,
> 0.008401094921335842, 0.005678623850436861, 0.031637003578036185,
> 0.007807537103275285, 0.04678624133952586, -0.008269370273253617,
> 0.0014759358679188033, -0.023559589425191207,
> 0, 0, 0.0018171801698886074, -0.003656334616802099,
> 0.0031991095142168565, -0.006383163883066014, 0.003458302002064065,
> 0.004809617380323468, -0.0075316928235249474, -0.00011941213022540247,
> 0.0038389545953133072, 0.00016894342928323438, 0.00040193270453761437,
> -0.0012396173641129459, 0.02146552183230657, -0.00460347558924996,
> -0.004882655692800729, -0.01606544158442694, 0.008049695065115955,
> 0.0036245004634420136, 0.029005343873300973, -0.003530468304532667,
> -0.024030707768451166, 0.0011548277673373414, -0.01680037958318782,
> 0.008584015488606149, 0.0019502864336126788, 0.02998627429558144,
> 0.005662396299508508, 0.04960671957658368, -0.0013543857116456622,
> -0.009481401441805612, -0.012160167949689146,
> 0, 0, 0.0033246965545264467, -0.0024147717314886756,
> 0.0055744142429533464, -0.008045367022919062, 0.003849632239587134,
> 0.006117551228706688, -0.02203512444991986, -0.0034763000933806672,
> 0.0032621233252168153, -0.000998524864244611, -0.0016863418412042595,
> -0.0017818985509956732, 0.03581656086828025, -0.0023571322784787657,
> 0.038024895696301284, -0.02516372063362861, 0.012482128759746622,
> 0.0018377675069138877, 0.03178466349310234, -0.015414423552878219,
> -0.017621284584039526, -0.0073426856445562875, -0.023608023991937892,
> 0.014642251631214917, -0.0004720076859799823, 0.029741720122136082,
> 0.0056703444402036425, 0.025580654476395855, -0.010887660507394,
> -0.01147017491451925, 0.0003642374673108739,
> 0, 0, 0.0019602103993795134, -0.0025522871013383425,
> 0.002759854861567484, -0.0117035419309811, 0.004960371698847626,
> 0.006445953682826033, -0.015475285902796034, -0.0018916729297389489,
> 0.0032163214468679782, -0.00122568067512904, 0.0003618505888127891,
> -0.0031850807166417705, 0.019366509465640377, 0.001802901796707493,
> 0.03697882244610479, -0.01559071870927989, 0.01317288623112344,
> 0.016742257907138614, 0.03875281873233296, -0.009487353951756382,
> -0.029666922872900993, -0.006093000164020476, -0.022880628778800934,
> 0.015388417951553747, 0.004815258355534668, 0.03648193745557673,
> 0.00921574591201968, -0.016280092927310027, -0.0091397811608598,
> 0.013555938271333954, -0.02212790951448293,
> 0, 0, 0.003001314953618509, -0.0023863344023501067,
> 0.004972807200832523, -0.007467972856070279, 0.0035279979631178096,
> 0.0058793490734322254, -0.019283042631066866, -0.002074680658508253,
> 0.003536733738311503, -0.00047253516937147605, -0.0015525441943082582,
> -0.001522660944903657, 0.030009164479417535, -0.003411974807642765,
> 0.022636470746408476, -0.02079740018784451, 0.010803051326655287,
> 0.0015987094949107617, 0.029792668361274564, -0.013590388062910018,
> -0.0167963749586434, -0.004663859133633861, -0.020978750753957612,
> 0.012290144840830975, 0.0005409108785577259, 0.028884406694033953,
> 0.005728742476633499, 0.03418553080510448, -0.00937013079893645,
> -0.01215053464877582, -0.0047129218610194035,
> 0, 0, 0.002672927342724835, -0.0056224200171662445,
> 0.007454828602277196, -0.005227812245754737, 0.0027215172727971266,
> 0.0035442069675758674, -0.00923222902255474, -0.0018612241880502857,
> 0.002421055424786525, 0.00025796905710791544, -0.0021191596238268762,
> -0.0013062676754853767, 0.026324266184152408, -0.0037734721914197506,
> -0.000556612579300684, -0.020127922689986227, 0.010380658353434982,
> -0.0014448322630305072, 0.02785734934088595, -0.0040409675361023105,
> -0.023653763149538536, -0.012130460799276347, -0.017763501203116126,
> 0.02296141818214931, 0.0021252040253055948, 0.025843532710371212,
> 0.005626636983983799, 0.020685550632856632, -0.00480107173199142,
> -0.01424424374768006, 0.01851508157568791,
> 0, 0, 0.001824012809338066, -0.004965160907276035, 0.004834159100418911,
> -0.004339017014914186, 0.0021094762016039626, 0.003097891062140264,
> -0.006136500268690957, -0.0008496253591653064, 0.0020187176250410464,
> -0.00036689431134907585, -0.001863695012248384, -0.0006612341518899625,
> 0.018841279719218555, -0.00493197788762035, -0.015915596405008402,
> -0.012860477773691535, 0.006554169147235611, 0.006078416564342821,
> 0.0241469406408069, 0.01412519709804754, -0.020784439885885995,
> -0.009720762141872966, -0.015970159283402903, 0.015094603990157577,
> 0.003430176552467878, 0.026629561611224064, 0.004382515410143144,
> 0.026712594006852882, -0.0011264675358127387, -0.014453634753933372,
> 0.002176841947425248,
> 0, 0, 0.002507732510127447, -0.0023429300578754484,
> 0.004054564873384953, -0.006586687022458981, 0.00303708248850674,
> 0.0055157773627501575, -0.015082496697028085, 0.00006463321577070008,
> 0.003955875947771817, 0.0003302912070138335, -0.0013483267332564663,
> -0.001126982493500058, 0.021145243675363915, -0.005021997615314132,
> -0.000851125229743673, -0.014133016349542489, 0.008240248928779047,
> 0.001233831476590206, 0.026752254739011116, -0.010806333894011196,
> -0.015537302372512473, -0.0005751239327522621, -0.01696564949598771,
> 0.00870008710813969, 0.002086944477062649, 0.027575875672193877,
> 0.005817876321710672, 0.04731928941208083, -0.0070539012439222995,
> -0.013188978453693722, -0.012462270309523502,
> 0, 0, 0.0019442794960072968, -0.001476534808605923,
> 0.0033331354831961676, -0.009409578129144908, 0.003854095916792674,
> 0.004785923900753689, -0.022516698930245844, -0.0012235229750768473,
> 0.002789917082440547, -0.0011208424344858858, 0.000006559730434971118,
> -0.002166948069157325, 0.01876507496080625, -0.00025977609503699886,
> 0.02598048877957794, -0.012063163162484044, 0.00949258317282966,
> 0.011639943542441399, 0.033119079705675465, -0.012397412837003942,
> -0.020735942055599945, -0.006405833628181736, -0.021678397432225327,
> 0.01212499781456832, 0.004677472674067592, 0.03368852324160947,
> 0.0076088774216753995, 0.004525725601295659, -0.010693039497456152,
> 0.0057874435745926085, -0.022140029374458442,
> 0, 0, 0.003878239869857272, -0.004637911273805305, 0.009611715695950842,
> -0.00699010563926517, 0.002660326669926074, 0.005598099450597097,
> -0.017476324925484496, -0.002998434082157966, 0.0027408848715897672,
> -0.000324618237464186, -0.004593064799902035, -0.0016474325411779587,
> 0.03021551835121268, -0.0033572759327906015, 0.008286361289651737,
> -0.021809412695829953, 0.012951912115330338, -0.005771330528494664,
> 0.02864138814332697, -0.02261069821952223, -0.021035812684384425,
> -0.010477443577043506, -0.01857993485046607, 0.027823459674900717,
> 0.0007433470183589192, 0.02094596962612688, 0.005363675924892543,
> 0.01581544994867558, -0.006029773351345414, -0.015832309499222406,
> 0.022943367477989425,
> 0, 0, 0.0021927021059730068, -0.00148346928500162,
> 0.0037419773862244756, -0.01027741519569509, 0.004188804471753079,
> 0.004988100491491041, -0.025306124341963856, -0.0026630059178510686,
> 0.002586542762628121, -0.001572967888781024, -0.00010541358251734102,
> -0.002597879092241973, 0.02196522175969151, 0.0012945394483570198,
> 0.039894850449853185, -0.0147052837232219, 0.010869837994995177,
> 0.012956161742265524, 0.0350392864783058, -0.014384338254868002,
> -0.022496234009458483, -0.009752053675624279, -0.024625262096470892,
> 0.01456479626185856, 0.0040215460412739296, 0.0350326223315368,
> 0.0074787210785582335, -0.023162198503062052, -0.012280960713312979,
> 0.008612224485861653, -0.02120997278949559,
> 0, 0, 0.0035733492759273187, -0.004577954699701702,
> 0.008599119283710915, -0.0065366112410860655, 0.002416780299941397,
> 0.005388392836671636, -0.015175532741244297, -0.0018688651358211483,
> 0.003096051016769398, 0.0001337732803734455, -0.004437863812410551,
> -0.0014473143798770173, 0.02560948371072111, -0.0040232929773356164,
> -0.003765189491525712, -0.016681734743640132, 0.011306747611973783,
> -0.005309528754058492, 0.026900884957706393, -0.020792123714573254,
> -0.020856385450024474, -0.008244476322024562, -0.01661761887586736,
> 0.022844172922902712, 0.0018879268881353578, 0.020689666122897105,
> 0.0052807909692540395, 0.020866332156576538, -0.0046785163362643035,
> -0.015966095495487907, 0.013699686172011775,
> 0, 0, 0.0021762558752393426, -0.0054168630498407306,
> 0.006226479214805164, -0.004628305079030459, 0.0020737312029835493,
> 0.003263332499454605, -0.006136500268690957, -0.0003104654929903576,
> 0.00278525579663893, 0.000706125045877499, -0.001887654054874107,
> -0.000971302868914273, 0.01886874236623705, -0.004722814289833442,
> -0.020303264599215658, -0.012251055814349848, 0.0075344485849152395,
> -0.0015529391743299469, 0.024262932916945163, -0.002205797206197364,
> -0.022907965999023398, -0.010215854864510869, -0.014767457285590813,
> 0.015089713035720707, 0.0034936549669216336, 0.024684810433803113,
> 0.004848442310314937, 0.026824857498566005, -0.002284409847625611,
> -0.014210006050530596, 0.001988525253919987,
> 0, 0, 0.0031079899483500203, -0.004486442033964626,
> 0.007053577391344709, -0.005844435580707438, 0.0020450516299647865,
> 0.0050683143206801465, -0.011663797302140835, -0.00014478621772811082,
> 0.0036381467120435713, 0.0008334234918098296, -0.0042009780946603925,
> -0.0011418708705229492, 0.018579220312076056, -0.005039845308483261,
> -0.02215966173648072, -0.008855278921876725, 0.008795707054219044,
> -0.004604673414129599, 0.024244327463864464, -0.018016404733335344,
> -0.020582522829159292, -0.004836263143311435, -0.013622505019900907,
> 0.015244208933011025, 0.003634917215688871, 0.020298466039020073,
> 0.005154282352753169, 0.028575573421267455, -0.00261607141850892,
> -0.016170295173998418, -0.0004090905581646473 )
> m = matrix( x, ncol=28 ) # nrow=33
> c = cov( m )
> if( ! is.positive.definite( c )) c = make.positive.definite( c )
> spec = parmaspec( S=c, risk="EV", riskType="minrisk", target=0.000057,
> forecast=colMeans( m ) )
> parmasolve( spec, solver="SOCP" )
> #############
> 
> 
>> I believe Pat has already addressed this issue in his previous email to
>> you and the list.
>>
>> If on the other hand you want to "jiggle" your matrix a little to make
>> it PD, then use the 'make.positive.definite' function from the corpcor
>> package.
>>
>> Regards,
>>
>> Alexios
>>
>> On 08/07/2014 09:02, u0055 at wolke7.net wrote:
>>> Hello Alexios,
>>>
>>> I read the parma docu and the parma package seems to be great stuff.
>>>
>>> "S" needs to be a
>>> "m-by-m positive definite covariance matrix",
>>> but in general a covariance matrix can also be not PD.
>>>
>>> Do you know any R snippet or package,
>>> which works for any covariance matrix
>>> (including not PD ones, like the attached one) ?
>>>
>>> Thanks in Advance
>>> Uwe
>>>
>>>
>>>> I'm not too familiar with how fPortfolio works, but since you asked for
>>>> "alternative code" here is how you can do this with parma:
>>>>
>>>> ###############
>>>> library(parma)
>>>> spec = parmaspec(S = cov(datamatrix), riskB=0.1,
>>>> risk="EV",riskType="maxreward", LB = rep(0,8), UB = rep(1,8), budget=1,
>>>> forecast=colMeans(datamatrix))
>>>> weights(parmasolve(spec, solver="SOCP"))
>>>> #############
>>>>
>>>> Note the following:
>>>> 1. The risk (riskB) is an upper bound since this is an inequality
>>>> constraint (less than or equal to), and is available to solve for
>>>> covariance inputs using an SOCP solver (you can also solve QCQP
>>>> problems
>>>> as well).
>>>> 2. The solution can be completely dominated by one asset (as in the
>>>> case above) unless you change risk bound or constraints (UB, LB or some
>>>> other linear combinations ... see documentation)
>>>> 3. You MUST provide a forecast vector (which is not all zeros).
>>>>
>>>> Regards,
>>>>
>>>> Alexios
>>>
>>> ############
>>> library(parma)
>>> x = c(
>>> 0.0004101995964433642, -0.00018580025947176148, 0.0001921211753136999,
>>> -0.0009374090928287272, 0.02179035825399216, -0.0008010181637519165,
>>> 0.02762103313486072, -0.02059593202791299, 0.009890131347811582,
>>> 0.008874502330834042, 0.03270962505025148, 0.0004709525370067878,
>>> -0.026172393520773156, -0.002070884888637307, -0.021394084189246338,
>>> 0.014663881480845464, 0.000007589055248672503, 0.03357767208442292,
>>> 0.007489994621009966, 0.0354779091735148, -0.004488890361817627,
>>> 0.0006037637415494107, -0.0001747374366735466, 0.0002776560800516695,
>>> -0.0010539757116864686, 0.007217907272059155, -0.0009999339576310352,
>>> 0.0018097094037338678, -0.0072761973581043134, 0.007274147797504215,
>>> 0.011722205826326859, 0.0284076103749228, 0.00020854896466472906,
>>> -0.027139287243448704, 0.0009288913408461102, -0.013985585851090089,
>>> 0.008355345607646895, 0.005703625000569552, 0.031154509412550213,
>>> 0.008409491754987508, 0.050116507149955865, -0.002471235927845941,
>>> 0.0004329670989004567, -0.00014108375322680291, 0.00024873249512844,
>>> -0.0007654340066147783, 0.018092403293930987, -0.0015557105255950537,
>>> 0.015910756127921546, -0.01736078352542159, 0.008348345947451275,
>>> 0.007744974101786212, 0.029968431702077265, 0.0016856756212381618,
>>> -0.0252969523459683, -0.0006213069455005302, -0.01923409835975207,
>>> 0.012209755091657625, 0.0007510294849596395, 0.03210686006944077,
>>> 0.006634533610756534, 0.04169475959584361, -0.0025908541571262045,
>>> 0.0005954295776526556, -0.00013175957287530423, 0.0002509094271978344,
>>> -0.0009448108075862921, 0.007528674135685146, -0.0014060182806468655,
>>> 0.0008597209029989182, -0.007178209888799298, 0.00689554753496824,
>>> 0.009766184066262252, 0.02818192946497762, -0.004207950567021389,
>>> -0.023491857691380978, 0.0005314474698686129, -0.015464139804048354,
>>> 0.008342940298155603, 0.005682816731364199, 0.03209078200750012,
>>> 0.00815688540306469, 0.04912648130491875, -0.004043194319244131,
>>> 0.0004677174973875975, -0.00007283224369502313, 0.0003351392464246223,
>>> -0.0005029457171303313, 0.012448156249627087, -0.002707609393671422,
>>> -0.001962824566880327, -0.012422925284776823, 0.005995094546901327,
>>> 0.006020957331134253, 0.025784505012758727, 0.0035397266445386837,
>>> -0.023960752658108264, 0.0015912067571819243, -0.015937277883155545,
>>> 0.008463983234476183, 0.001885754351360598, 0.029861936467625895,
>>> 0.005328829963527624, 0.05118363655624024, 0.0003061484710870088 )
>>> m = matrix( x, ncol=5 ) # nrow=21
>>> spec = parmaspec(S = cov(m), riskB=0.1,
>>> risk="EV",riskType="maxreward", LB = rep(0,8), UB = rep(1,8), budget=1,
>>> forecast=colMeans(m))
>>> parmasolve(spec, solver="SOCP")
>>> ############
>>>
>>>
>>
> 
> 
>



More information about the R-SIG-Finance mailing list