Question

In: Statistics and Probability

R code to obtain the goodness of fit G^2, its p-value, and its AIC value given...

R code to obtain the goodness of fit G^2, its p-value, and its AIC value given a dataset?

Solutions

Expert Solution

1. In case of discrete data (for example Goodness-of-fit test for poisson distribution) :

library(vcd)

gf<-goodfit(x.poi,type= "poisson",method= "MinChisq")

summary(gf)

plot(gf,main="Count data vs Poisson distribution")

2. In case of continuous data (for example Goodness-of-fit test for gamma distribution) :

x.gam.cut<-cut(x.gam,breaks=c(0,3,6,9,12,18))

table(x.gam.cut)

## computing expected frequencies

(pgamma(3,shape=a.est,rate=l.est)-pgamma(0,shape=a.est,rate=l.est))*200

(pgamma(6,shape=a.est,rate=l.est)-pgamma(3,shape=a.est,rate=l.est))*200

(pgamma(9,shape=a.est,rate=l.est)-pgamma(6,shape=a.est,rate=l.est))*200

(pgamma(12,shape=a.est,rate=l.est)-pgamma(9,shape=a.est,rate=l.est))*200

(pgamma(18,shape=a.est,rate=l.est)-pgamma(12,shape=a.est,rate=l.est))*200

f.ex<-c(20,71,61,31,17) ## expected frequencies vector

f.os<-vector()

for(i in 1:5) f.os[i]<- table(x.gam.cut)[[i]]   ## empirical frequencies

X2<-sum(((f.os-f.ex)^2)/f.ex)   ## chi-square statistic

gdl<-5-2-1   ## degrees of freedom

1-pchisq(X2,gdl)   ## p-value


Related Solutions

Describe how to obtain a p-value for a chi-squared test for goodness of fit. Then describe...
Describe how to obtain a p-value for a chi-squared test for goodness of fit. Then describe how to obtain a p-value for a chi-squared test for independence. Make sure how to point out the differences from your answer to the question above. Please use simple terms! I have no idea what's going on.
Test the following hypotheses by using the χ 2 goodness of fit test. H 0: p...
Test the following hypotheses by using the χ 2 goodness of fit test. H 0: p A = 0.2, p B = 0.4, and p C = 0.4 Ha: The population proportions are not p A = 0.2 , p B = 0.4 , and p C = 0.4 A sample of size 200 yielded 60 in category A, 120 in category B, and 20 in category C. Use  = .01 and test to see whether the proportions are as stated...
Given a data set with 100 observations, a goodness of fit test to see if a...
Given a data set with 100 observations, a goodness of fit test to see if a sample follows a uniform distribution or a poisson distribution or a normal distribution will have the same number of degrees of freedom. true or false and When a contingency table of expected frequencies is constructed, the null hypothesis is that all of the cells in the table are equally likely. true or false thank you :)
Which of the given is not a requirement for the validity of the chi‑square goodness‑of‑fit test?...
Which of the given is not a requirement for the validity of the chi‑square goodness‑of‑fit test? 1) independent observations 2) all observations falling into one of k outcome classes 3) a fixed number of observations 4) normally distributed data
A. What is the critical value for a goodness of fit test with 7 categories assuming...
A. What is the critical value for a goodness of fit test with 7 categories assuming α = 5%? B. A goodness of fit test where the Ho is accepted would have a conclusion of? C. A goodness of fit test with a test statistic of 2.56 and a critical value of 3.325 would result in a conclusion of? D. The symbol used for the test statistic in a goodness of fit test is?
Please Provide R code as well Use R to find probability (p-value). Find probability P(X>12.3), where...
Please Provide R code as well Use R to find probability (p-value). Find probability P(X>12.3), where X follows F-distribution with degree of freedom in numerator 4 and degree of freedom in numerator 10.
The power dissipated in a resistor is given by P = V 2 / R ,...
The power dissipated in a resistor is given by P = V 2 / R , which means power decreases if resistance increases. Yet this power is also given by P = I 2 R , which means power increases if resistance increases. Explain.
Chi-Square Goodness of Fit Test (how your work) (NO HAND WRITING ITS HARD TO READ) A...
Chi-Square Goodness of Fit Test (how your work) (NO HAND WRITING ITS HARD TO READ) A researcher has four prototypes for a small Unmanned Aerial System controller and wants to know which one that users prefer. The researcher asks 120 participants to use each controller and annotate which one they liked best. At the conclusion of the study, the researcher hopes to have a clearly identified prototype that is best preferred among the four. The table below represents the number...
Obtain the general solution of the following equations: r Utt − c^2 r Urr − 2...
Obtain the general solution of the following equations: r Utt − c^2 r Urr − 2 c^2 Ur = 0, c = constant,
Profit = Revenue - Cost P(x) = R(x) - C(x) Given: R(x) = x^2 - 30x...
Profit = Revenue - Cost P(x) = R(x) - C(x) Given: R(x) = x^2 - 30x Given: C(x) = 5x + 100 X is hundreds of items sold / P, R, C are in hundreds of dollars (1) Determine the Initial Cost? (2) Determine the maximum Profit and number of items required for that profit? (3) Determine the maximum Revenue and number of items required for that revenue? (4) Find the break even points, P(x) = 0. What do the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT