search for: meanlog

Displaying 20 results from an estimated 52 matches for "meanlog".

2008 Feb 18
0
Solved (??) Behaviour of integrate (was 'Poisson-lognormal probab ility calculations')
...9;m wrong, or you can see a better way! A plot of the integrand showed a very sharp peak, so I was running into the integrand "feature" mentioned in the note. I resolved it by limiting the range of integration as shown here: -------------------------------------------------- function (x, meanlog = 0, sdlog = 1, sdlim=6, rel.tol = .Machine$double.eps^0.5,...) { #+ # K. Jewell Feb 2008 # Based on VGAM::dpolono, modified to cover wider range of x # Some simplification, but major change is to avoid integration problems by # limiting range of integration to sdlim (default = 6) standard deviati...
2008 Feb 15
0
Behaviour of integrate (was 'Poisson-lognormal probability calcul ations')
Hi again, Adding further information to my own query, this function gets to the core of the problem, which I think lies in the behaviour of 'integrate'. ------------------------------------- function (x, meanlog = 0, sdlog = 1, ...) { require(stats) integrand <- function(t, x, meanlog, sdlog) dpois(x,t)*dlnorm(t, meanlog, sdlog) mapply(function(x, meanlog, sdlog, ...) # (1/gamma(x+1))* integrate(function(t, x, meanlog, sdlog) # gamma(x+1)*...
2008 Feb 15
0
Poisson-lognormal probability calculations
...tidied up a little (to my eyes only, no offence intended to the estimable authors of VGAM) and avoided the gamma overflow by using logs - OK so far, it agrees almost perfectly with VGAM::dpolono for x up to 170, and now extends the range up to 173 (wow!!). ------------- dApolono <- function (x, meanlog = 0, sdlog = 1, ...) { require(stats) integrand <- function(t, x, meanlog, sdlog) exp(-t+x*log(t)-log(sdlog*t*sqrt(2*pi))-0.5*((log(t)-meanlog)/sdlog)^2) mapply(function(x, meanlog, sdlog, ...){ temp <- try( integrate(f = integrand, lower = 0, upper = Inf, x = x, m...
2010 Apr 28
0
Truncated Lognormal Distribution
...n.edu/Rhelp10/2008-October/176136.html) library(MASS) x <- c(600.62,153.05,70.26,530.42,3440.29,97.45,174.51,168.47, 116.63,36.51, 219.77, 231.67,110.62,173.11,202.85,689.27,23.82,234.15,625.89,192.88,29.53,109.99, 80.53, 46.85,82.69,231.53,75.38,217.52,85.29,182.18) ltlnorm <- function(x, meanlog, sdlog, log=FALSE) { dlnorm(x, meanlog, sdlog, log = FALSE) / plnorm(1, meanlog, sdlog, lower.tail = TRUE, log.p = FALSE) } meanlog = mean(log(x)) sdlog = sd(log(x)) ltlnormfit <- fitdistr(x,ltlnorm, start=list(meanlog,sdlog)) I get following error - Error in dlnorm(x, meanlog, sdlog, log...
2013 May 10
1
rlnorm(n, meanlog = 0, sdlog = 1)
Hi list, Does anyone know the code behind rlnorm(n, meanlog = 0, sdlog = 1)? I am going to write it in c#. thanks Alireza [[alternative HTML version deleted]]
2008 May 04
1
Is my understanding of rlnorm correct?
rlnorm takes two 'shaping' parameters: meanlog and sdlog. meanlog would appear from the documentation to be the log of the mean. eg if the desired mean is 1 then meanlog=0. So to generate random values that fit a lognormal distribution I would do this: rlnorm(N , meanlog = log(mean) , sdlog = log(sd)) But when I check the mean I don'...
2003 Jul 25
5
named list 'start' in fitdistr
...39;, `uniform', `weibull'. " However I cannot fit an univariate distribution named 'test' I get this: >fitdistr(test,"lognormal") Error in fitdistr(test, "lognormal") : `start' must be a named list > fitdistr(test,"lognormal",start$meanlog=0,start$sdlog=1) Error: syntax error How I am supposed to type a value for start depending on the distribution on which I am fitting my set thanks ****************************************************************** The sender's email address has changed to firstname.lastname@ sgcib.com. Y...
2002 Dec 10
1
Lognormal distribution
I am trying to fit a lognormal distribution to a set of data and test its goodness of fit with regard to predicted values. I managed to get so far: > y <- c(2,6,2,3,6,7,6,10,11,6,12,9,15,11,15,8,9,12,6,5) > library(MASS) > fitdistr(y,"lognormal",start=list(meanlog=0.1,sdlog=0.1)) meanlog sdlog 1.94810515 0.57091032 (0.12765945) (0.09034437) But I would now also like to generate the predicted values, so that I can make a comparison using e.g. the Cramer test in the cramer package. I'd also like to plot the curves for both sets of valu...
2005 Jun 29
2
MLE with optim
Hello, I tried to fit a lognormal distribution by using optim. But sadly the output seems to be incorrect. Who can tell me where the "bug" is? test = rlnorm(100,5,3) logL = function(parm, x,...) -sum(log(dlnorm(x,parm,...))) start = list(meanlog=5, sdlog=3) optim(start,logL,x=test)$par Carsten. [[alternative HTML version deleted]]
2002 Jul 12
1
Minor bug in dlnorm (PR#1781)
The density of a lognormal should be 0 for negative arguments, but > dlnorm(-1) [1] NaN Warning message: NaNs produced in: dlnorm(x, meanlog, sdlog, log) A simple fix is to change dlnorm's definition to: function (x, meanlog = 0, sdlog = 1, log = FALSE) .Internal(dlnorm(x*(x>0), meanlog, sdlog, log)) It might be faster to put the same sort of adjustment into the internal code, but I couldn't spot where that lives. Dunca...
2003 Aug 28
2
ks.test()
...if (mode(x) != "numeric") stop("need numeric data") x <- x[!is.na(x)] x <- sort(x) y <- log(x-b) n <- length(y) mu <- mean(y) sigma <- sd(y) if(plot.it) { lines(x, dlnormt(x, meanlog=mu,sdlog=sigma,b=b), lty = lty,col="red")} result <- list(mu=mu,sigma=sigma,b=b) class(result) <- "lnormt" result} dlnormt<-function(x,mu,sigma,b) dlnorm(x-b,meanlog=mu,sdlog=sigma) plnormt<-function(x,mu,sigma,b) plnorm(x-b,meanlog=mu...
2014 Oct 15
2
Test K-S con distribuciones LogNormales
...o al test KS, ten en cuenta que lo que hace es comparar > funciones de distribución empíricas: > # La de los datos originales: > curve(ecdf(sample)(x), type="s") > # Esta se parece mucho a la teórica como sería de esperar con una muestra > tan grande: > # curve(plnorm(x, meanlog = mean, sdlog = sd), lwd=2,add=TRUE) > > # con la de las medias de las submuestras: > curve(ecdf(sample_bucket$mean)(x),type="s",lty = 2, add = TRUE) > > Lo que creo que ocurre es que la segunda muestra es muy pequeña y el > test de KS no tiene evidencias para rechaz...
2004 May 01
2
Generating Lognormal Random variables (PR#6843)
Full_Name: Anthony Gichangi Version: 1.90 OS: Windows XP Pro Submission from: (NULL) (130.225.131.206) The function rlnorm generates negative values for lognormal distribution. x- rlnorm(1000, meanlog = 0.6931472, sdlog = 1) Regards Anthony
2007 Oct 03
1
offset in survreg
Hello, I have a question regarding the use of an offset term with survreg(), in the Survival library. In particular, I am trying to figure out on what scale the offset term should be. Here's a simple example with no censoring and no coefficients: --------- y = rlnorm(1000, meanlog = 10, sdlog = 2) delta = rep(1, 1000) int = rep(1, 1000) survreg(Surv(y,delta)~offset(10*int), dist = "lognormal") Call: survreg(formula = Surv(y, delta) ~ offset(10 * int), dist = "lognormal") Coefficients: (Intercept) -0.1317181 Scale= 1.985558 Loglik(model)= -11973.1...
2010 Jul 13
1
Batch file export
Dear all, I have a code that generates data vectors within R. For example assume: z <- rlnorm(1000, meanlog = 0, sdlog = 1) Every time a vector has been generated I would like to export it into a csv file. So my idea is something as follows: for (i in 1:100) { z <- rlnorm(1000, meanlog = 0, sdlog = 1) write.csv(z, "c:/z_i.csv") Where "z_i.csv" is a filename that is related to th...
2009 Aug 07
0
Fitting Truncated Distribution
...threshold are removed from the observations and I do not know any longer that there are any observations ruled out by a threshold). (1) Consider the following snippet (along the lines of the suggestion in the link above) rm(list=ls()) library(MASS) set.seed(1234) lt_lognormal <- function(x, meanlog, sdlog ){ dlnorm(x, meanlog , sdlog )/plnorm(0.5, meanlog , sdlog ) } my_seq <- rlnorm(10000) my_fit <- fitdistr(my_seq,"lognormal") cut_low <- my_seq[which(my_seq>0.5)] my_fit_low <- fitdistr(cut_low,lt_lognormal,list(meanlog=0.2,sdlog=0.7), lower=0.5 ) However, w...
2009 Feb 11
3
Generating Numbers With Certain Distribution in R
Dear all, Is there a way to generate K numbers of integer (K = 10^6). The maximum value of the integer is 200,000 and minimum is 1. And the occurrences of this integer follows a lognormal distribution. - Gundala Viswanath Jakarta - Indonesia
2003 Aug 05
1
error message in fitdistr
Hi R lovers Here is a numerical vector test > test [1] 206 53 124 112 92 77 118 75 48 176 90 74 107 126 99 84 114 147 99 114 99 84 99 99 99 99 99 104 1 159 100 53 [33] 132 82 85 106 136 99 110 82 99 99 89 107 99 68 130 99 99 110 99 95 153 93 136 51 103 95 99 72 99 50 110 37 [65] 102 104 92 90 94 99 76 81 109 91 98 96 104 104 93 99 125 89
2012 Jun 03
0
Bug in truncgof package?
...implementation of the truncgof package are just fine. I've done Carlos' experiment (repeatedly generating samples and testing them with AD) and the test never rejected the null hypothesis. @Carlos: in the first piece of code you are using ad.test (> ad.test(xt, "plnorm", list(meanlog = 2, sdlog = 2), H = 10)), but in the function that you are later defining for iteration purposes, you are use the KS test (> ks.test(xt, "plnorm", list(meanlog = 2, sdlog = 2), H = 10)$p.value)... This may have something to do with the contradictory results that you thought you...
2009 May 31
1
Bug in truncgof package?
...sending my query here. I installed package truncgof and run the example for function ad.test. I got the following output: set.seed(123) treshold <- 10 xc <- rlnorm(100, 2, 2) # complete sample xt <- xc[xc >= treshold] # left truncated sample ad.test(xt, "plnorm", list(meanlog = 2, sdlog = 2), H = 10) Supremum Class Anderson-Darling Test data: xt AD = 3.124, p-value = 0.12 alternative hypothesis: two.sided treshold = 10, simulations: 100 So I cannot reject the hipothesis (at a standard confidence level) that the original sample comes from a lognormal distributi...