random.general(rportfolios)
random.general()所属R语言包:rportfolios
Random general portfolio
随机一般组合
译者:生物统计家园网 机器人LoveR
描述----------Description----------
This function generates a general random portfolio of n investments with k long or short positiobs, The probability that a a non-zero investment weight is positive is p. The maximum absolute exposure for any investment is x.u. The default value is 1 / k.
这个函数生成有k个长或短positiobs的,一般随机的n投资组合的概率是一个非零的投资权重是肯定的。任何投资的最大绝对曝光许默认值是1 / k。
用法----------Usage----------
random.general(n = 2, k=n, p = 0.5, x.u = 1/k)
参数----------Arguments----------
参数:n
A positive integer value for the number of investments in the portfolio
投资组合中的一个正整数的值
参数:k
A positive integer value for the number of non-zero positions
非零位置的数目的一个正整数的值
参数:p
A positive numeric value for the probability that an investment weight is positive
一个正数的投资权重值的概率是积极的
参数:x.u
A positive numeric value for the maximum absolute exposure to an investment
正数值的最大绝对的投资风险
Details
详细信息----------Details----------
If k < n the function random.general is recursively called with n set equal to k to obtain a k \times 1 vector of non-zero long and short weights. The R function sample is used to generate a simple random sample without replacement of k values from the integers 1,2, … ,n. These are the subscripts into an n \times 1 zero vector to assign the k non-zero weights. This vector is returned.
如果 k < n的功能random.general被递归调用n设定长度等于k,得到k \times 1非零的长和短的权重向量。 R的功能sample没有更换的整数1,2, … ,nk值是用来生成一个简单的随机抽样。这些是成n \times 1零矢量分配的k非零重量的下标。该向量被返回。
If k = n , the R function rbinom is used to generate a vector of plus and minus ones corresponding to the long and short positions. The R function runif is used to generate uniformly distributed values between 0 and 1. These are scaled by x.u and then multiplied by the signs. The sum of the investment weights is not restricted.
如果 k = n ,R函数rbinom是用来产生相应的多头和空头头寸的加号和减号的一个向量。 R函数runif是用来产生均匀分布的值在0和1之间。这些比例由徐,然后乘以迹象。的投资权重的总和是没有限制。
值----------Value----------
An n \times 1 numeric vector of investment weights for the equal weighted portfolio.
一个n \times 1的数字等权投资组合的投资权重向量。
(作者)----------Author(s)----------
Frederick Novomestky <a href="mailto:fnovomes@poly.edu">fnovomes@poly.edu</a>
实例----------Examples----------
###[##]
### long only portfolio of 30 investments with 30 non zero positions[##30投资组合与30个非零位]
###[##]
x.long <- random.general( 30, p=1.0 )
###[##]
### long only portfolio of 30 investments with 10 non zero positions[##30投资组合与10个非零位]
###[##]
y.long <- random.general( 30, 10, p=1.0 )
###[##]
### short only portfolio of 30 investments with 30 non zero positions[##短的只有30投资组合与30个非零位]
###[##]
x.short <- random.general( 30, p=0.0 )
###[##]
### short only portfolio of 30 investments with 10 non zero positions[##短的只有30投资组合与10个非零位]
###[##]
y.short <- random.general( 30, 10, p=1.0 )
###[##]
### long short portfolio of 30 investments with 30 non zero positions[##30投资组合的长的短的30个非零位]
###[##]
x.long.short <- random.general( 30, p=0.5 )
###[##]
### long short portfolio of 30 investments with 10 non zero positions[##长的短的30与10个非零位的投资组合]
###[##]
y.long.short <- random.general( 30, 10, p=0.5 )
###[##]
### long bias portfolio of 30 investments with 30 non zero positions[##长投资的30个与30个非零位偏差投资组合]
###[##]
x.long.bias <- random.general( 30, p=0.7 )
###[##]
### long bias portfolio of 30 investments with 10 non zero positions[##长投资的30个与10个非零位偏差投资组合]
###[##]
y.long.bias <- random.general( 30, 10, p=0.7 )
###[##]
### short bias portfolio of 30 investments with 30 non zero positions[##短的偏压组合投资的30个与30个非零位]
###[##]
x.short.bias <- random.general( 30, p=0.3 )
###[##]
### short bias portfolio of 30 investments with 10 non zero positions[##短的偏压组合投资的30个与10个非零位]
###[##]
y.short.bias <- random.general( 30, 10, p=0.3 )
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|