Learn R Programming

bda (version 3.2.0-3)

bnmm: Fit a Normal Mixture Model to binned data

Description

Fit a finite normal mixture model for pre-binned data

Usage

bnmm(breaks,freq,mu, s, p, k,trunc, lognormal=FALSE,from,to,gridsize=512L)

Arguments

breaks
Bin boundaries. Numeric, order vector
freq
A vector of frequencies/counts.
k
number of components
trunc
Whether the data is truncted or not. If trunc is missing, no truncation. Otherwise, trunc can be left, right, or both.
mu,s,p
Initial parameters of the Normal components.
from,to
The range when the density will be evaluated.
gridsize
The size of grid where the densities will be evaluated.
lognormal
An indicator shows whether or not to fit a normal mixture for log-normal data.

Details

If the data are top-headed (or truncated), nl, nu will used to store the frequencies of the lower and uper bins. If the data are not truncated, the two variables will be used to return the predicted frequencies in these two bins instead.

References

AS 254, ...

Examples

Run this code
y <- c(10, 21, 56,79,114,122,110,85,85,61,47,49,47,44,31,20,11,4,4)
 x <- 14.5 + c(0:length(y))
 mu <- c(20.0, 26.0)
 p <- c(0.5, 0.5)
 sig <- c(2.0, 2.8)
 bnmm(x,y,mu=mu, p=p, s=sig)

Run the code above in your browser using DataLab