Displaying 3 results from an estimated 3 matches for "dtnorm".
Did you mean:
dnorm
2006 Aug 16
3
fitting truncated normal distribution
Hello,
I am a new user of R and found the function dtnorm() in the package msm.
My problem now is, that it is not possible for me to get the mean and sd out of a sample when I want a left-truncated normal distribution starting at "0".
fitdistr(x,dtnorm, start=list(mean=0, sd=1))
returns the error message
"Fehler in "[<-"(`*...
2008 Oct 30
1
Is possible, on biological grounds, suggest to fitdistr (MASS library) that the estimated parameters must be between two values?
Sorry if it is a silly question, I haven't found documentation on this and I
don't know if it is possible.
library(MASS) ## for fitdistr
library(msm) ## for dtnorm
#prepare truncated normal distribution
dtnorm0 <- function(x, mean, sd , log = FALSE) {
dtnorm(x, mean, sd, 105, 135, log)
}
set.seed(1)
#Generate normal distribution with the TRUE population mean (day 106 of the
year) that I don't know a priori
x <- rnorm(100, mean=106, sd=40)...
2006 Aug 18
0
Fitting Truncated Lognormal to a truncated data set (was: fitting truncated normal distribution)
Dear List,
I am trying to fit Truncated Lognormal to a data set that is
'truncated' from above a certain value, say, 0.01. Below is what I
was able to come up with. I would appreciate it if you could review
and make any necessary changes.
# This is modified off the code for 'dtnorm' of library(msm).
dtlnorm <- function (n, mean = 0, sd = 1, lower = -Inf, upper = Inf)
{
ret <- numeric()
if (length(n) > 1)
n <- length(n)
while (length(ret) < n) {
y <- rlnorm(n - length(ret), mean, sd)
y <- y[y >= lower & y <= uppe...