Skip to content
Prev 176159 / 398503 Next

threshold distribution

The data suggest a lognormal threshold to me (and perhaps to the originator,
based on his title).

######
x <- c(0.80010, 0.72299, 0.69893, 0.99597, 0.89200, 0.69312, 0.73613,
1.13559, 0.85009, 0.85804, 0.73324, 1.04826, 0.84002, 1.76330, 0.71980,
0.89416, 0.89450, 0.98670, 0.83571, 0.73833, 0.66549, 
0.93641, 0.80418, 0.95285, 0.76876, 0.82588, 1.09394, 1.00195, 1.14976,
0.80008, 1.11947, 1.09484, 0.81494, 0.68696, 0.82364, 0.84390, 0.71402,
0.80293, 1.02873)

# plot the original density

x.threshold <- 0

qqnorm(log(x - x.threshold), datax = TRUE)

qqline(log(x - x.threshold), datax = TRUE)


# plot the lognormal density with a threshold

x.threshold <- 0.63

qqnorm(log(x - x.threshold), datax = TRUE)

qqline(log(x - x.threshold), datax = TRUE)


# compute and plot the associated log likelihoods

x.threshold <- 0

loglikelihood <- 1/(x-x.threshold) * dnorm(log(x - x.threshold), mean(log(x
- x.threshold)), sd(log(x - x.threshold)))

x.threshold <- 0.63

loglikelihood.63 <- 1/(x-x.threshold) * dnorm(log(x - x.threshold),
mean(log(x - x.threshold)), sd(log(x - x.threshold)))

x.minus.x.threshold <- x - x.threshold

plot(x.minus.x.threshold, loglikelihood.63, xlim = c(0, 2), ylim =c(0, 3.5))

points(x, loglikelihood, col="red")

# compare loglikelihood ratio with chi-square

sum.loglikelihood <- sum(loglikelihood)
print(sum.loglikelihood)
sum.loglikelihood.63 <- sum(loglikelihood.63)
print(sum.loglikelihood.63)

log.likelihiood.ratio <- sum.loglikelihood.63 - sum.loglikelihood

print(log.likelihiood.ratio)

significant.difference <- qchisq(p = 0.95, df = 1)/2

print(significant.difference)
#####



Charles Annis, P.E.

Charles.Annis at StatisticalEngineering.com
phone: 561-352-9699
eFax:  614-455-3265
http://www.StatisticalEngineering.com
 
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Mike Lawrence
Sent: Sunday, April 05, 2009 8:13 AM
To: tura at centroin.com.br
Cc: r-help
Subject: Re: [R] threshold distribution

You didn't properly specify the x-axis coordinates in your call to lines():

plot(density(x))
lines(x,dlnorm(x, -.1348, .1911), col='red')
points(x,dlnorm(x, -.1348, .1911), col='blue')
curve(dlnorm(x, -.1348, .1911), col='green',add=T)


On Sun, Apr 5, 2009 at 6:40 AM, Bernardo Rangel Tura
<tura at centroin.com.br> wrote:
http://www.R-project.org/posting-guide.html