Description Usage Arguments Details Value Note Author(s) References See Also Examples

The function simulates a data set with specified input correlation matrix
`cor_matrix`

and pre-specified marignals `invcdfnames`

using
bounding RA and NORTA methods.

1 2 3 | ```
genNORTARA(n, cor_matrix, invcdfnames, paramslists = NULL,
defaultindex = NULL, m1 = 60, c1 = 2, c2 = 1, delta1 = 1e-04,
sigma0 = 0.01, epsilon = 1e+50, maxit = 1000)
``` |

`n` |
Number of observations. |

`cor_matrix` |
specified input correlation matrix. |

`invcdfnames` |
A character sequence of the marginals' inverse cdf(cumulative distribution function) names. |

`paramslists` |
A list contains lists of params of the marginals excluded
the index(es) in |

`defaultindex` |
The index number sequence which indicates the corresponding inverse cdfs use the default argument values. |

`m1` |
The initial sample size. |

`c1` |
The sample-size multiplier(c1>1). |

`c2` |
The step-size multiplier(c2>0). |

`delta1` |
The initial step size(detla1>0). |

`sigma0` |
The standard error tolerance. |

`epsilon` |
The initial error tolerance. |

`maxit` |
The maximum number of numerical searches. |

The function simulates a date set with varibles from arbitrary(continuous or
discrete) marginal distributions which have a correlation matrix
`cor_matrix`

. The pre-specified marignals are described by
`invcdfnames`

,`paramslists`

,`defaultindex`

, the later two
arguments will be combined into a full paramslists which has the same length
as `invcdfnames`

. The function uses result of the function
`BoundingRA`

which is an implementation of a specific RA(Retrospective
Approximation) algorithm called bounding RA. With the result, the function
uses the NORTA(NORmal To Anything) approach which generates a standard normal
random vector and then transforms it into a random vector with specified
marginal to generates the wanted samples.

A matrix of size n * (`ncol(cor_matrix)`

) from pre-specified
marignals which also have an asymptotically correlation matrix to specified
input correlation matrix `cor_matrix`

.

The inverse cdf functions should have its first argument as a vector.

The inverse cdf functions like

`qweibull`

should not use default values because the`shape`

argument does not has a default value.So we should not put its index in`invcdfnames`

into`defaultindex`

.The function won't accept the invcdfnames all be 'qnorm", you can generate multi-normal varibles by other packages.The function will give you a error message, but if you use a = qnorm, then using new name, the function won't find it, just be careful.

You may get a warning message indicate the Nearest positive definite matrix is used. It happens when your inputs won't generate a positive definite intermediate normal correlation matrix. And in this case, the cor(res) may not very close to cor_matrix.

Po Su

Huifen Chen, (2001) Initialization for NORTA: Generation of Random
Vectors with Specified Marginals and Correlations. INFORMS Journal on
Computing **13(4):312-331.**'

`BoundingRA`

, `valid_input_cormat`

,
`check_input_cormat`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | ```
## Not run:
invcdfnames <- c("qt","qpois","qnorm","qweibull","qunif")
# The following usage :
# a <- qt; b <- qnorm; f <- stats::qweibull (It is also the way you can use functions
# from other packages)
# invcdfnames <- c("a","qpois","b","f","qunif") will also be ok!
paramslists <- list(
m1 = list(df = 3),
m2 = list(lambda = 5),
m4 = list(shape = 1)
)
defaultindex <- c(3,5)
#It means the 3rd and 5th invcdf should use its default arguments.
#That means qnorm using mean = 0, sd = 1, qunif using min =0 ,max =1 and so on.
cor_matrix <- matrix(c(1.0,-0.4,0.1,0.7,-0.2,-0.4,
1.0,0.4,0.4,0.9,0.1,0.4,1.0,
0.5,0.5,0.7, 0.4,0.5,1.0,
0.7,-0.2,0.9,0.5,0.7,1.0),5,5)
res <- genNORTARA(10000,cor_matrix,invcdfnames,paramslists,defaultindex)
#May get warning message indicating nearest positive definite is used,It's
#normal but the cor(res) may not very close to cor_matrix.
cor(res)
invcdfnames <- c("qt","qpois","qnorm")
paramslists <- list(
m1 = list(df = 3),
m2 = list(lambda = 5)
)
defaultindex <- 3
cor_matrix <- matrix(c(1,0.5,-0.3,0.5,1,0.4,-0.3,0.4,1), 3)
res <- genNORTARA(10000,cor_matrix,invcdfnames,paramslists,defaultindex)
cor(res) #This time cor(res) may very close to cor_matrix.
## End(Not run)
``` |

```
Warning message:
In BoundingRA(cor_matrix, invcdfnames, paramslists, m1, c1, c2, :
The estimator of the target Normal correlation matrix is not positive definite. It was replaced by Nearest positive definite matrix by using function Matrix::nearPD !
[,1] [,2] [,3] [,4] [,5]
[1,] 1.0000000 -0.4194910 0.1109767 0.5356647 -0.1259400
[2,] -0.4194910 1.0000000 0.4042447 0.3456482 0.9090878
[3,] 0.1109767 0.4042447 1.0000000 0.4864106 0.5116813
[4,] 0.5356647 0.3456482 0.4864106 1.0000000 0.5806454
[5,] -0.1259400 0.9090878 0.5116813 0.5806454 1.0000000
[,1] [,2] [,3]
[1,] 1.0000000 0.4721175 -0.2730548
[2,] 0.4721175 1.0000000 0.4051253
[3,] -0.2730548 0.4051253 1.0000000
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.