rfactor {FactorCopula} | R Documentation |
Simulation of factor copula models for mixed continuous and discrete data
Description
Simulating standard uniform and ordinal response data from factor copula models.
Usage
r1factor(n, d1, d2, categ, theta, copF1)
r2factor(n, d1, d2, categ, theta, delta, copF1, copF2)
Arguments
n |
Sample size. |
d1 |
Number of standard uniform variables. |
d2 |
Number of ordinal variables. |
categ |
A vector of categories for the ordinal variables. |
theta |
Copula parameters for the 1st factor. |
delta |
Copula parameters for the 2nd factor. |
copF1 |
|
copF2 |
|
Value
Data matrix of dimension n\times d
, where n
is the sample size, and d=d_1+d_2
is the total number of variables.
Author(s)
Sayed H. Kadhem s.kadhem@uea.ac.uk
Aristidis K. Nikoloulopoulos a.nikoloulopoulos@uea.ac.uk
References
Kadhem, S.H. and Nikoloulopoulos, A.K. (2021) Factor copula models for mixed data. British Journal of Mathematical and Statistical Psychology, 74, 365–403. doi:10.1111/bmsp.12231.
Examples
# ---------------------------------------------------
# ---------------------------------------------------
# One-factor copula model
# ---------------------------------------------------
# ---------------------------------------------------
#Sample size ----------------------------------------
n = 100
#Continuous Variables ------------------------------
d1 = 5
#Ordinal Variables ---------------------------------
d2 = 3
#Categories for ordinal ----------------------------
categ = c(3,4,5)
#Copula parameters ---------------------------------
theta = rep(2, d1+d2)
#Copula names --------------------------------------
copnamesF1 = rep("gum", d1+d2)
#----------------- Simulating data ------------------
datF1 = r1factor(n, d1=d1, d2=d2, categ, theta, copnamesF1)
#------------ Plotting continuous data -------------
pairs(qnorm(datF1[, 1:d1]))
# ---------------------------------------------------
# ---------------------------------------------------
# Two-factor copula model
# ---------------------------------------------------
# ---------------------------------------------------
#Sample size ----------------------------------------
n = 100
#Continuous Variables ------------------------------
d1 = 5
#Ordinal Variables ---------------------------------
d2 = 3
#Categories for ordinal ----------------------------
categ = c(3,4,5)
#Copula parameters ---------------------------------
theta = rep(2.5, d1+d2)
delta = rep(1.5, d1+d2)
#Copula names --------------------------------------
copnamesF1 = rep("gum", d1+d2)
copnamesF2 = rep("gum", d1+d2)
#----------------- Simulating data ------------------
datF2 = r2factor(n, d1=d1, d2=d2, categ, theta, delta,
copnamesF1, copnamesF2)
#----------------- Plotting data ------------------
pairs(qnorm(datF2[,1:d1]))