2017-10-28 2 views
1

Ich würde gerne wissen, wie die alternative Parametrisierung in EvaStats Paket (basierend auf AM, GM, log10) usw. getan hat; Ich habe log10 versucht; aber scheiterte! HilfeLognormalverteilung (Alternative Parametrierung)

x=c(1151, 453, 1530, 2852, 1382) 
meanx=mean(x);sdx=sd(x); cvx=sd/mean; 
meanx; sdx; cvx 

[1] 1473.6; [1] 874.2501; [1] 0,5932751

y1=log(x) # log(e) base 
mean1=mean(y1);sd1=sd(y1); cv1=sd1/mean1; 
mean1; sd1; cv1; 

[1] 7.136873; [1] 0,6648726; [1] 0.09316022

Jetzt die Lognormalverteilung (Alternative Parametrisierung);

library(EnvStats) 
(p=seq(0.1,1,0.1)); 
qlnormAlt(p, mean =meanx, cv=cvx) 

P [X ≤ x] ==> [1] 626,9803 798,3150 950,2311 1102,7414 1267,3461 1456,5211 # 1690,2899 [8] 2011,9454 2561,7490 Inf

qlnorm(p, meanlog = mean1, sdlog = sd1, lower.tail =TRUE, log.p = FALSE) 

P [X ≤ x] ==> [ 1] 536,3594 718,5980 887,3269 1062,5527 1257,4901 1488,1910 1782,0729 # [8] 2200,5088 2948,1747 Inf (gleiches Ergebnis in Excel)

Antwort

1

Fall: Konvertieren in Basis R lügt-normal zu EnvStats Lognormal

# For base R log-normal parameters 
meanlog <- 0 
sdlog <- 1 

# convert to log-normal alt parameters 
alt_cv <- sqrt(exp(sdlog^2) - 1) 
alt_mean <- exp(meanlog + (sdlog^2)/2) 

#Generate random variate 
x <- rlnorm(10, meanlog = meanlog, sdlog = sdlog) 

#The densities from ALT parameterization EnvStats 
dlnormAlt(x, mean = alt_mean, cv = alt_cv, log = FALSE) 
#0.07143345 0.02845393 0.65249008 0.55945034 0.12051190 0.51631108 
#0.60456145 0.61928177 0.18041191 0.64513395 

# From dlnorm 
dlnorm(x, meanlog = meanlog, sdlog = sdlog, log = FALSE) 
#0.07143345 0.02845393 0.65249008 0.55945034 0.12051190 0.51631108 
#0.60456145 0.61928177 0.18041191 0.64513395 

Fall: Konvertieren EnvStats log-normal zur Basis R log-normal

library(EnvStats) 

# in log-normal alt 
alt_mean <- 1.648721  # = exp(1/2) 
alt_cv <- 1.310832  # = sqrt(exp(1) - 1) 

# convert to base R log-normal 
sdlog <- sqrt(log(1 + alt_cv^2)) 
meanlog <- log(alt_mean) - (sdlog^2)/2 

# Check if this is correct by generating a sample and 
# estimating density 

#Generate random variate 
x <- rlnormAlt(10, mean = alt_mean, cv = alt_cv) 

#The densities from ALT parameterization EnvStats 
dlnormAlt(x, mean = alt_mean, cv = alt_cv, log = FALSE) 
#0.40210537 0.12318313 0.65370439 0.21540401 0.59956874 0.63914847 
#0.05152114 0.04156760 0.48919495 0.05110028 

# From dlnorm 
dlnorm(x, meanlog = meanlog, sdlog = sdlog, log = FALSE) 
#0.40210537 0.12318313 0.65370439 0.21540401 0.59956874 0.63914847 
#0.05152114 0.04156760 0.48919495 0.05110028 
+0

Mittel1 = exp (1/2); cv1 = sqrt (exp (1) - 1); nicht die Meanx & cvx: Ich habe verwendet; Danke! –

+0

Kannst du es ausarbeiten? Ich verstehe nicht, was du meinst? – Suren

+0

In der klassischen für SND verwenden wir (0,1); hier Annahme ist Mittelwert = exp (0,5) statt zero; & sd behält die selbe 1! –

Verwandte Themen