Re: [R] Optimization to fit data to custom density distribution

2015-03-23 Thread Johannes Radinger
On Sat, Mar 21, 2015 at 3:41 PM, Prof Brian Ripley rip...@stats.ox.ac.uk wrote: On 21/03/2015 14:27, Johannes Radinger wrote: Thanks for the fast response. The fitdistr() function works well for the predefined density functions. However, what is the recommended approach to optimize/fit a

Re: [R] Optimization to fit data to custom density distribution

2015-03-21 Thread Prof Brian Ripley
On 21/03/2015 14:27, Johannes Radinger wrote: Thanks for the fast response. The fitdistr() function works well for the predefined density functions. However, what is the recommended approach to optimize/fit a density function described by two superimposed normal distributions? In my case it is

Re: [R] Optimization to fit data to custom density distribution

2015-03-21 Thread Prof Brian Ripley
One way using the standard R distribution: library(MASS) ?fitdistr No optimization is needed to fit a normal distribution, though. On 21/03/2015 13:05, Johannes Radinger wrote: Hi, I am looking for a way to fit data (vector of values) to a density function using an optimization (ordinary

Re: [R] Optimization to fit data to custom density distribution

2015-03-21 Thread Johannes Radinger
Thanks for the fast response. The fitdistr() function works well for the predefined density functions. However, what is the recommended approach to optimize/fit a density function described by two superimposed normal distributions? In my case it is N1(mean=0,sd1)*p+N2(mean=0,sd2)*(1-p). With

[R] Optimization to fit data to custom density distribution

2015-03-21 Thread Johannes Radinger
Hi, I am looking for a way to fit data (vector of values) to a density function using an optimization (ordinary least squares or maximum likelihood fit). For example if I have a vector of 100 values generated with rnorm: rnorm(n=100,mean=500,sd=50) How can I fit these data to a Gaussian density