# NOT RUN {
## Simulate grouped data
sim = simDegrossData(n=3500, plotting=TRUE,choice=2,J=3)
print(sim$true.density) ## Display density of the data generating mechanism
## Create a degrossData object
obj.data = with(sim, degrossData(Big.bins=Big.bins, freq.j=freq.j, m.j=m.j))
print(obj.data)
## Estimate the density underlying the grouped data
obj.fit = degross(obj.data)
## Plot the estimated density...
plot(obj.fit)
## ... and compare it with the ('target') density used to simulate the data
curve(sim$true.density(x),add=TRUE,col="red",lwd=2)
legend("topleft",
legend=c("Observed freq.","Target density","Estimated density"),
col=c("grey85","red","black"), lwd=c(10,2,2),
lty=c("solid","solid","dashed"), box.lty=0, inset=.02)
# }
Run the code above in your browser using DataLab