2

I wanted to generate random variables from a multivariate t distribution in R. i am using the mvtnorm package which has the command rmvt for generating random variables from the multivariate t-distribution. Now my question is about the syntax of the function and being able to manipulate it to do what I want. The function requires the following

rmvt(n, sigma = diag(2), df = 1, delta = rep(0, nrow(sigma)),
     type = c("shifted", "Kshirsagar"), ...)

where sigma is a correlation matrix. Now what I am having trouble with is how to sample from a multivariate t-distribution with mean m and covariance matrix S. Is the following the appropriate syntax?

rmvt(1,S,df=n) + m

or

rmvt(1,R,df=n)*sigma + m

where my covariance matrix can be decomposed as S = sigma*R (i.e., R is my correlation matrix). I am getting different results when I run the two lines of code so that is partially where my confusion stems from.

4

1 に答える 1

4

rmvtのヘルプ ファイルを参照してください。sigmaはスケール (相関ではない) 行列であり、 に対してのみ定義されている相関行列df>2は で与えられると言われていsigma * df/(df-2)ます。したがって、事前に指定された共分散行列があるS場合は、設定する必要があります

sigma=S*(D-2)/D

D自由度です。平均と共分散行列を使用nして多変量 t 分布からサンプルを生成するには、指定したように、呼び出しの外側に平均を追加できます。mSrmvt

rmvt(n, sigma=S*(D-2)/D, df=D) + m 

またはmu引数を使用して:

rmvt(n, mu=m, sigma=S*(D-2)/D, df=D)

編集:何らかの理由で、rmvt私のマシンに適切にロードされていないため、最初にこれを入力して関数を適切にロードする必要があります:

rmvt <- bfp:::rmvt
于 2013-08-09T18:47:37.803 に答える