Assignment 6 Part 1e and 1f

Assignment 6 Part 1e and 1f

par Ujas Patel,
Nombre de réponses : 8

Hello, 

I would like to clarify a few points in relation to the sub-parts of section 1 of the assignment. They are as follows:

1) For 1e, avg.many.n.birthdays, is there a specific format for the output of the function? Currently, my function returns a vector of average probabilities and has a length of n -- is this okay or should it be different?

2) For 1f, run.chisq.test, should Feb. 29 be excluded from the data file before a sample of n birthdays are generated? I.e., we are to only include 365 dates -- is that correct?

3) For 1f, once again, my function first generates a sample of n birthdays and then I convert it to a frequency table to feed into chisq.test(). I see a chi-square output, however, I am not sure if the frequency table is the correct input for this test. Am I on the right track?

I greatly appreciate all clarifications, thank you!

En réponse à Ujas Patel

Re: Assignment 6 Part 1e and 1f

par Erik Spence,
1) Yes, it should return a vector of averages.

2) Yes.

3) You need some sort of frequency calculation. However, the calculation must include those values that have zero counts.
En réponse à Erik Spence

Re: Assignment 6 Part 1e and 1f

par Iciar Iturmendi Sabater,
As a follow up of q 3)(1f) - I am struggling to figure out how to calculate frequencies including the values that have zero counts. I have used the factor and summary functions to come up with frequency counts for both the randomly sampled and bdata sampled birthday vectors, but these don't include zero counts. I have thought of creating a 3rd vector (days<-1:365) to count frequencies of birthdays based on days, but can't figure out how to incorporate it to the factor and summary functions. I was wondering if you could advice whether I am on a right path to solve this problem, or if you could give some alternative advice on how to count frequencies accounting for values from 1:365 with zero counts.

Thank you for your help
En réponse à Iciar Iturmendi Sabater

Re: Assignment 6 Part 1e and 1f

par Erik Spence,
I just used a vector and a loop to build the input data. Probably using a table first would be more efficient.
En réponse à Erik Spence

Re: Assignment 6 Part 1e and 1f

par Erik Spence,
Confirmed, as other students have noted, it's more efficient to use table without using a loop.
En réponse à Erik Spence

Re: Assignment 6 Part 1e and 1f

par Ujas Patel,
Hi Erik,

Agreed, using a table without using a loop would be more efficient as chisq.test can directly take this as an input. However, I am having trouble creating a table which includes both zero and non-zero counts for birthdays. I am able to create a data frame but not a table. Can you hint at how I can achieve this?

Thank you!
En réponse à Ujas Patel

Re: Assignment 6 Part 1e and 1f

par Erik Spence,
No, I didn't originally figure it out myself, so I'll leave this question unanswered. Any technique you can figure out to get the correct input, including loops, will be accepted.
En réponse à Erik Spence

Re: Assignment 6 Part 1e and 1f

par Edgardo Torres,
Just to clarify, when we say zero count, we mean that if the length of the frequency table is <365, we should add "0"s to the frequency table, up-to 365, correct?
En réponse à Edgardo Torres

Re: Assignment 6 Part 1e and 1f

par Erik Spence,
Yes, sort of. But you need to add them to the correct birthdays that have zero counts.