# \donttest{
# Example 1: Approximating the asymptotic standard error and 95 percent confidence interval
# for the parameters of fitted three-component normal mixture model to iris data.
Y <- as.matrix( iris[, 1:4] )
colnames(Y) <- NULL
rownames(Y) <- NULL
G <- 3
weight <- c( 0.334, 0.300, 0.366 )
mu1 <- c( 5.0060, 3.428, 1.462, 0.246 )
mu2 <- c( 5.9150, 2.777, 4.204, 1.298 )
mu3 <- c( 6.5468, 2.949, 5.482, 1.985 )
sigma1 <- matrix( c( 0.133, 0.109, 0.019, 0.011, 0.109, 0.154, 0.012, 0.010,
0.019, 0.012, 0.028, 0.005, 0.011, 0.010, 0.005, 0.010 ), nrow = 4 , ncol = 4)
sigma2 <- matrix( c( 0.225, 0.076, 0.146, 0.043, 0.076, 0.080, 0.073, 0.034,
0.146, 0.073, 0.166, 0.049, 0.043, 0.034, 0.049, 0.033 ), nrow = 4 , ncol = 4)
sigma3 <- matrix( c( 0.429, 0.107, 0.334, 0.065, 0.107, 0.115, 0.089, 0.061,
0.334, 0.089, 0.364, 0.087, 0.065, 0.061, 0.087, 0.086 ), nrow = 4 , ncol = 4)
mu <- list( mu1, mu2, mu3 )
sigma <- list( sigma1, sigma2, sigma3 )
sigma <- list( sigma1, sigma2, sigma3 )
lambda <- list( rep(0, 4), rep(0, 4), rep(0, 4) )
out1 <- sefm( Y, G, weight, model = "restricted", mu, sigma, lambda, family = "constant",
skewness = "FALSE")
# Example 2: Approximating the asymptotic standard error and 95 percent confidence interval
# for the parameters of fitted two-component restricted skew t mixture model to
# AIS data.
data( AIS )
Y <- as.matrix( AIS[, 2:3] )
G <- 2
weight <- c( 0.5075, 0.4925 )
mu1 <- c( 19.9827, 17.8882 )
mu2 <- c( 21.7268, 5.7518 )
sigma1 <- matrix( c(3.4915, 8.3941, 8.3941, 28.8113 ), nrow = 2, ncol = 2 )
sigma2 <- matrix( c(2.2979, 0.0622, 0.0622, 0.0120 ), nrow = 2, ncol = 2 )
lambda1 <- ( c( 2.5186, -0.2898 ) )
lambda2 <- ( c( 2.1681, 3.5518 ) )
theta1 <- c( 68.3088 )
theta2 <- c( 3.8159 )
mu <- list( mu1, mu2 )
sigma <- list( sigma1, sigma2 )
lambda <- list( lambda1, lambda2 )
theta <- list( theta1, theta2 )
param <- c( "nu" )
PDF <- quote( (nu/2)^(nu/2)*w^(-nu/2 - 1)/gamma(nu/2)*exp( -nu/(w*2) ) )
tick <- c( 1, 1 )
out2 <- sefm( Y, G, weight, model = "restricted", mu, sigma, lambda, family = "igamma",
skewness = "TRUE", param, theta, tick, h = 0.001, N = 3000, level = 0.05, PDF )
# Example 3: Approximating the asymptotic standard error and 95 percent confidence interval
# for the parameters of fitted two-component restricted skew sub-Gaussian
# alpha-stable mixture model to bankruptcy data.
data( bankruptcy )
Y <- as.matrix( bankruptcy[, 2:3] ); colnames(Y) <- NULL; rownames(Y) <- NULL
G <- 2
weight <- c( 0.553, 0.447 )
mu1 <- c( -3.649, -0.085 )
mu2 <- c( 40.635, 19.042 )
sigma1 <- matrix( c(1427.071, -155.356, -155.356, 180.991 ), nrow = 2, ncol = 2 )
sigma2 <- matrix( c( 213.938, 9.256, 9.256, 74.639 ), nrow = 2, ncol = 2 )
lambda1 <- c( -41.437, -21.750 )
lambda2 <- c( -3.666, -1.964 )
theta1 <- c( 1.506 )
theta2 <- c( 1.879 )
mu <- list( mu1, mu2 )
sigma <- list( sigma1, sigma2 )
lambda <- list( lambda1, lambda2 )
theta <- list( theta1, theta2 )
param <- c( "alpha" )
tick <- c( 1 )
out3 <- sefm( Y, G, weight, model = "restricted", mu, sigma, lambda, family = "pstable",
skewness = "TRUE", param, theta, tick, h = 0.01, N = 3000, level = 0.05 )
# Example 4: Approximating the asymptotic standard error and 95 percent confidence interval
# for the parameters of fitted two-component restricted generalized inverse-Gaussian
# mixture model to AIS data.
data( wheat )
Y <- as.matrix( wheat[, 1:7] ); colnames(Y) <- NULL; rownames(Y) <- NULL
G <- 3
weight <- c( 0.325, 0.341, 0.334 )
mu1 <- c( 18.8329, 16.2235, 0.9001, 6.0826, 3.8170, 1.6604, 6.0260 )
mu2 <- c( 11.5607, 13.1160, 0.8446, 5.1873, 2.7685, 4.9884, 5.2203 )
mu3 <- c( 13.8071, 14.0720, 0.8782, 5.5016, 3.1513, 0.6575, 4.9111 )
lambda1 <- diag( c( 0.1308, 0.2566,-0.0243, 0.2625,-0.1259, 3.3111, 0.1057) )
lambda2 <- diag( c( 0.7745, 0.3084, 0.0142, 0.0774, 0.1989,-1.0591,-0.2792) )
lambda3 <- diag( c( 2.0956, 0.9718, 0.0042, 0.2137, 0.2957, 3.9484, 0.6209) )
theta1 <- c( -3.3387, 4.2822 )
theta2 <- c( -3.6299, 4.5249 )
theta3 <- c( -3.9131, 5.8562 )
sigma1 <- matrix( c(
1.2936219, 0.5841467,-0.0027135, 0.2395983, 0.1271193, 0.2263583, 0.2105204,
0.5841467, 0.2952009,-0.0045937, 0.1345133, 0.0392849, 0.0486487, 0.1222547,
-0.0027135,-0.0045937, 0.0003672,-0.0033093, 0.0016788, 0.0056345,-0.0033742,
0.2395983, 0.1345133,-0.0033093, 0.0781141, 0.0069283,-0.0500718, 0.0747912,
0.1271193, 0.0392849, 0.0016788, 0.0069283, 0.0266365, 0.0955757, 0.0002497,
0.2263583, 0.0486487, 0.0056345,-0.0500718, 0.0955757, 1.9202036,-0.0455763,
0.2105204, 0.1222547,-0.0033742, 0.0747912, 0.0002497,-0.0455763, 0.0893237 ), nrow = 7, ncol = 7 )
sigma2 <- matrix( c(
0.9969975, 0.4403820, 0.0144607, 0.1139573, 0.1639597,-0.2216050, 0.0499885,
0.4403820, 0.2360065, 0.0010769, 0.0817149, 0.0525057,-0.0320012, 0.0606147,
0.0144607, 0.0010769, 0.0008914,-0.0023864, 0.0049263,-0.0122188,-0.0042375,
0.1139573, 0.0817149,-0.0023864, 0.0416206, 0.0030268, 0.0490919, 0.0407972,
0.1639597, 0.0525057, 0.0049263, 0.0030268, 0.0379771,-0.0384626,-0.0095661,
-0.2216050,-0.0320012,-0.0122188, 0.0490919,-0.0384626, 4.0868766, 0.1459766,
0.0499885, 0.0606147,-0.0042375, 0.0407972,-0.0095661, 0.1459766, 0.0661900 ), nrow = 7, ncol = 7 )
sigma3 <- matrix( c(
1.1245716, 0.5527725,-0.0005064, 0.2083688, 0.1190222,-0.4491047, 0.2494994,
0.5527725, 0.3001219,-0.0036794, 0.1295874, 0.0419470,-0.1926131, 0.1586538,
-0.0005064,-0.0036794, 0.0004159,-0.0034247, 0.0019652,-0.0026687,-0.0044963,
0.2083688, 0.1295874,-0.0034247, 0.0715283, 0.0055925,-0.0238820, 0.0867129,
0.1190222, 0.0419470, 0.0019652, 0.0055925, 0.0243991,-0.0715797, 0.0026836,
-0.4491047,-0.1926131,-0.0026687,-0.0238820,-0.0715797, 1.5501246,-0.0048728,
0.2494994, 0.1586538,-0.0044963, 0.0867129, 0.0026836,-0.0048728, 0.1509183 ), nrow = 7, ncol = 7 )
mu <- list( mu1, mu2, mu3 )
sigma <- list( sigma1 , sigma2, sigma3 )
lambda <- list( lambda1, lambda2, lambda3 )
theta <- list( theta1 , theta2, theta3 )
tick <- c( 1, 1, 0 )
param <- c( "a", "b" )
PDF <- quote( 1/( 2*besselK( b, a ) )*w^(a - 1)*exp( -b/2*(1/w + w) ) )
out4 <- sefm( Y, G, weight, model = "unrestricted", mu, sigma, lambda, family = "gigaussian",
skewness = "TRUE", param, theta, tick, h = 0.001, N = 3000, level = 0.05, PDF )
# }
Run the code above in your browser using DataLab