I want to confirm that my data is fit on the Poisson distribution or not. I think I should use qqplot, but I can't figure out how show it by R code
count | frequency |
0 | 229 |
1 | 221 |
2 | 93 |
3 | 35 |
4 | 7 |
7 | 1 |
:Use the following code to plot qqplot
#import excel file of data in R
>D1=read.table("<FileName>.txt",header = TRUE)
Attach(D1)
>ybar=mean(D1)
> p=ncol(D1)
> sig=matrix(nrow=p,ncol=p)
> for(i in 1:p)
+ {
+ for(j in 1:p)
+ {
+ sig[i,j]=cov(D1[,i],D1[,j])
+ }
+ }
> sig
> #to find sample quantiles
> chisq=c()
> for(i in 1:n)
+ {
+ chisq[i]=t(D1[i,]-ybar)%*%solve(sig)%*%(D1[i,]-ybar)
+ }
> chisq
> sq=sort(chisq)
> #to find population quantiles
> i=1:n
> s=(i-0.5)/n
> pq=qchisq(s,p)
> #QQ plot
> plot(sq,pq)
> abline(0,1)
#Output given following
Get Answers For Free
Most questions answered within 1 hours.