TSMNgenerator: Generator of Truncated Scale Mixtures of Normal Distributions

Description Usage Arguments Value See Also Examples

View source: R/TSMNgenerator.R

Description

TSMNgenerator this function generate random TSMN samples from Normal, Student-t, Slash and Contaminated Normal, using the the inverse method.

Usage

1
2
TSMNgenerator(n, mu, sigma2, nu = NULL, lower = -Inf, upper = Inf,
  dist = "Normal")

Arguments

n

Number of observations.

mu

Location parameter.

sigma2

Scale parameter.

nu

Parameter of the scale variable of the SMN family. Must be NULL in case of Normal distribution. Must be a bidimensional vector and each component of the bidimensional vector "nu" must lie on (0,1) in case of contaminated normal distribution (CNormal).

lower

Lower bounds.

upper

Upper bounds.

dist

Distribution to be used: "Normal" for Normal model, "T" for Student-t model, "Slash" for slash model and "CNormal" for contaminated Normal model.

delta

Second parameter of Pearson VII. Must not be provided in case of Normal, Student-t or Slash distribution.

Value

Returns the sample generated according to the parameters.

See Also

TSMNmoments

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
 ## A test sample to compare theoretical and empirical moments, considering the following parameters:

 mu = 2
 sigma2 = 4
 nu = 5
 lower = -3
 upper = 10
 dist = "T"
 n = 10000

 ## Theoretical moments with TSMNmoments
 theor<-TSMNmoments(mu=mu, sigma2=sigma2, nu=nu, lower=lower, upper=upper, dist=dist)

 ## Generate the sample with TSMNgenerator to compute the empirical moments
 empir<-TSMNgenerator(n=n, mu=mu, sigma2=sigma2, nu=nu, lower=lower, upper=upper, dist=dist)

 ## Compare the results
 data.frame("1st" = c("Theoretic" = theor$EY1, "Empirical" = mean(empir)),
            "2nd" = c("Theoretic" = theor$EY2, "Empirical" = mean(empir^2)),
            "3rd" = c("Theoretic" = theor$EY3, "Empirical" = mean(empir^3)),
            "4th" = c("Theoretic" = theor$EY4, "Empirical" = mean(empir^4)))

EBDAF1/TSMN documentation built on May 23, 2019, 10:32 p.m.