sampleUnivSNMoE: Draw a sample from a skew-normal mixture of linear experts...

Description Usage Arguments Value Examples

View source: R/sampleUnivSNMoE.R

Description

Draw a sample from a skew-normal mixture of linear experts model.

Usage

1
sampleUnivSNMoE(alphak, betak, sigmak, lambdak, x)

Arguments

alphak

The parameters of the gating network. alphak is a matrix of size (q + 1, K - 1), with K - 1, the number of regressors (experts) and q the order of the logistic regression

betak

Matrix of size (p + 1, K) representing the regression coefficients of the experts network.

sigmak

Vector of length K giving the standard deviations of the experts network.

lambdak

Vector of length K giving the skewness parameter of each experts.

x

A vector og length n representing the inputs (predictors).

Value

A list with the output variable y and statistics.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
n <- 500 # Size of the sample
alphak <- matrix(c(0, 8), ncol = 1) # Parameters of the gating network
betak <- matrix(c(0, -2.5, 0, 2.5), ncol = 2) # Regression coefficients of the experts
lambdak <- c(3, 5) # Skewness parameters of the experts
sigmak <- c(1, 1) # Standard deviations of the experts
x <- seq.int(from = -1, to = 1, length.out = n) # Inputs (predictors)

# Generate sample of size n
sample <- sampleUnivSNMoE(alphak = alphak, betak = betak, sigmak = sigmak,
                          lambdak = lambdak, x = x)

# Plot points and estimated means
plot(x, sample$y, pch = 4)
lines(x, sample$stats$Ey_k[, 1], col = "blue", lty = "dotted", lwd = 1.5)
lines(x, sample$stats$Ey_k[, 2], col = "blue", lty = "dotted", lwd = 1.5)
lines(x, sample$stats$Ey, col = "red", lwd = 1.5)

fchamroukhi/SNMoE documentation built on Sept. 23, 2019, 11:25 a.m.