Displaying 2 results from an estimated 2 matches for "dtnorm0".
Did you mean:
dtnorm
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 "[<-"(`*tmp*`, x >= lower & x <= upper,
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)
#truncated sample simulating those records th...