Learn R Programming

bda (version 1.2.7-31)

gof: To perform goodness-of-fit test.

Description

To perform goodness-of-fit test.

Usage

gof(object, x,...)

Arguments

x
A sample data.
object
An R object obtained from fitting a distribution to a data set. Supported classes include 'gamma','norm','weibull','bde', 'em'.
...
Controls

See Also

mediation.test,perm.test.

Examples

Run this code
x = rnorm(1000,34.5,1.5)
y = round(x,0)
##  fit by histospline: class=bde
out1 = histospline(y)
gof(out1,x)
gof(out1,y)
out2 = smkde(y)
gof(out2,x)
gof(out2,y)

## fit by em-alg: class=em
out3 = bfmm(y)
##gof(out3,x)
##gof(out3,y)
##  Naive estimates
gof("normal",x)
gof("weibull",x)
gof("gamma",x)

x0 = seq(min(x),max(x),length=100)
f0 = dnorm(x0,34.5,1.5)
plot(f0~x0,col=2,lwd=2,type='l')
lines(out1, col=3)
lines(out2, col=4)
lines(density(out3), col=5)
legend(min(x),max(f0),xjust=0,yjust=1,
  legend=c("True","Histospline","Smoothed KDE","Bin-EM"),
  col=c(2,3,4,5), lwd=c(2,1,1,1))

Run the code above in your browser using DataLab