rfactor {FactorCopula} | R Documentation |
Simulating standard uniform and ordinal response data from factor copula models.
r1factor(n, d1, d2, categ, theta, copF1)
r2factor(n, d1, d2, categ, theta, delta, copF1, copF2)
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 |
|
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.
Sayed H. Kadhem s.kadhem@uea.ac.uk
Aristidis K. Nikoloulopoulos a.nikoloulopoulos@uea.ac.uk
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.
# ---------------------------------------------------
# ---------------------------------------------------
# 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]))