Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Assignment 3

For Stat 231 - Summer 2022

You will submit answers/results from R in the Crowdmark pdf submission. The nal results should be typed within the written responses and images inserted. Your assignment submission must be typed and submitted as a pdf. There are no exceptions. Any submitted answer which is not typed will not be marked and given a mark of zero. Further, all written answers must be in full sentences.

Written answers which are not in full sentences will receive a deduction of 50% of the marks in that question part.  Additionally, all plots should have titles and axes labelled appropriately to receive full marks.  The feedback you receive will be focused on your R output and interpretations, not the detailed code itself. Thus, no R code should be included in your pdf solution le.

Your assignment solutions are to be submitted as a pdf le to two places :

●  To Crowdmark for marking

●  To the Assignment 3 LEARN dropbox to facilitate the running of your assignment through plagiarism detection software

Try to do this one day in advance in case something goes wrong.  Assume that LEARN is out

to get you.

You can upload your assignment as one document or individually for each problem.  If you upload one document then you must drag and drop the pages for each problem to the appropriate question as indicated in Crowdmark. You can resubmit your assignment any number of times before the deadline. Therefore, to ensure that there are no issues, we advise you to upload well in advance of the due time. Assignments which are left as a single document and not uploaded to the appropriate places in Crowdmark will receive a 10% penalty. A penalty of 1% per minute late to either Crowdmark or the LEARN dropbox is applied for late assignments.

Checklist to complete for this assignment:

● _______ Work on the assignment throughout the week, answering the questions related to analysis of our dataset from the mobile game and those that do not.

  _______ Upload the PDF of your assignment solutions to Crowdmark by the deadline.

● _______ Upload the PDF of your assignment solutions to the appropriate LEARN dropbox by the deadline

[42 marks total]

Q1:  Chi-squared Goodness-of-fit (GOF) test - Skill Grade

dat  =  read .csv ( "User  Data  All  Rows  2022-04-27 .csv")

table(dat$skill_grade)

##

##

##

A      B      C      D      E 59  313  890  848  333

F

57

Recall the skill_grade distribution, and its expected and observed counts from Assignment 2.

pregame_skill

skill_grade

observed counts

expected counts

(-inf, 70)

[70, 85)

[85, 100)

[100, 115)

[115, 130)

[130, +inf)

F

E

D

C

B

A

57

57.92

333

343.36

848

856.33

890

850.34

313

336 19

59

55.86

If the observed values came from the distribution that we hypothesized (in this case, it was the Gaussian), then the a statistic based on the differences between the observed counts and the expected counts follows a chi-squared distribution with n - 1 degrees of freedom.

More specically, when using the chi-squared distribution to test for goodness of t, the sum

n    (Oi - Ei )2

, where n is the number categories, and Oi  and Ei  are the observed and expected counts for the ith category, respectively.

If the differences are too large, then the sum XG(2)OF  is too large to come from the chi-squared and we reject the null.

a)  (4 marks) Find the observed/obtained chi-squared test statistic. That is, find the sum described above. (Hint: The sum has six terms, and the rst term is ≈ 0.0146)

b)  (1 mark) Find the p-value for this test statistic using 1  -  pchisq().  (Explainer: It’s 1  -  pchisq, not pchisq because we want 1 - CDF. Large test statistics give large pchisq values, which are equivalent to small p-values.)

c)  (1 mark) At the 0.05 significance level, is there sufficient evidence to reject the null that normal distribution is a good t for skill_grade?

Q2:  Chi-Squared Independence Test - Blackjack

(8 marks total)

Recall the blackjack player example from Test 1 Tutorial.

If the player’s bet size was independent of their actions, then the expected count for the number of bets would be:

Bet Amount

Hit

Stand

Double

Split

$10

$500

470.59 121.41

227.34 58.66

162.96

42.04

139.11 35.89

However, the actual counts for the actions and bet amounts were:

Bet Amount

Hit

Stand

Double

Split

$10

$500

496

96

205

81

158

47

141

34

We informally showed that there was some differences between these values.  Now, with the chi-squared distribution, we can do a formal hypothesis test.

When using the chi-squared distribution to test for independence, the sum

R     C    (Oi,j  - Ei,j )2

, where n is the number categories, and Oi,j  and Ei,j  are the observed and expected counts for the ith row and jth column, respectively, and where R and C are the number of rows and columns in the cross-table, respectively.

a)  (1 mark) How many degrees of freedom does the null hypothesis χ2  distribution have, in this case?

b)  (1 mark) Is the hypothesis test one-tailed or two-tailed, how do you know?

c)  (4 marks) Find the chi-squared test statistic. That is, find the sum described above.  (Hint: The sum has eight terms, and the rst term is ≈ 1.3720)

d)  (1 mark) Find the p-value of this data against the null hypothesis of independence.

e)  (1 mark) For a significance level of α = 0.05, is there sufficient evidence to reject the null hypothesis that bet amount and game action are independent?

Q3:  One-sample t-test of binomial proportions.

(10 marks total)

For this question, use the spender variables from the mobile games dataset.

Before a recent expansion, 45% of users were spenders, meaning they had spent any non-zero amount on the game. Now that the expansion is 3 months old, we want to nd evidence that the proportion of spenders has increased.  (The mobile users dataset is based entirely on data gathered after the expansion.)

a)  (2 marks) What are the null and alternative hypotheses?   Make sure to incorporate whether the alternative is one-tailed or two-tailed into your answer.

b)  (2 marks) What is the standard error of the proportion?  (Hint: Consider what θ we should use.)

c)  (3 marks) State the relevant test statistic formula, the distribution of this quantity, and the observed value of the test statistics for this dataset.  (n is very large, so use the normal approximation, and ignore continuity correction.)

d)  (2 marks) If we are okay with a false rejection of the null with only probability 0.001, then what is the critical z-statistic?

e)  (1 mark) Is there sufficient evidence to say that the spending rate has increased since the expansion was introduced?

Q4:  One-sample t-test of means.

(12 marks total)

For this question, use the money_spent variables from the mobile games dataset.

Before a recent expansion, the average amount spent per user, including among those that didn’t spend anything, was $3.00.  Now that the expansion is 3 months old, we want to nd evidence that the mean amount spent per user has changed.  (The mobile users dataset is based entirely on data gathered after the expansion.)

a)  (2 marks) Make a histogram of money_spent, is this distribution reasonably close to normal?

b)  (1 mark) Is it reasonable to model the sample mean amount spent as coming from the normal distribution? Why or why not?

c)  (2 marks) What are the null and alternative hypotheses?   Make sure to incorporate whether the alternative is one-tailed or two-tailed into your answer.

d)  (2 marks) What is the standard error of the mean?

e)  (3 marks) State the relevant test statistic formula, the distribution of this quantity, and the observed value of the test statistics for this dataset.

f)  (1 marks) If we are okay with a false rejection of the null with only probability 0.001, then what is the critical t-statistic or z-statistic?  (Either one because df is so large)

g)  (1 mark) Is there sufficient evidence to say that the average (mean) spending amount has changed since the expansion was introduced?

Q5: T-Distribution Sample size

(6 marks total) In one of our classes, we estimated the necessary sample size from a t-distribution by assuming a known value for σ and using a critical based on the z (standard Normal) distribution.

2

Its recommended to add a little bitto n because we dont really know σ, but what counts as a little bit’?

We improved upon that initial guess by. . .

1.  calculating a new df_new  =  n- 1 from the initial suggested sample size, and. . .

2.  calculating a new critical value from the t distribution using t_new  =  qt( .975,  df=NEW)

3.  calculating a new sample size with original formula, but a new critical value t_new instead of 1.96.

a)  (1 mark) Assuming a known σ = 5 (e.g., from some previous, related study), and a margin of error m = 2, get an initial sample size estimate n.

b)  (2 marks) Update your suggested sample size n with one iteration (one cycle) of the t-distribution update method described above.

c)  (3 marks) Update your suggested sample size n until you get an iteration that does not change your suggested sample size.  (i.e., you converge on a final answer)