Goal: Practice statistical concepts and sampling methods.
For the next questions assume the population consists of all infraction details (rows) in the dinesafe
data.
Assume you are interested in the average number of significant/crucial infractions per establishment (SEVERITY equal to “S - Significant” or “C - Crucial”). Find the actual value of the parameter.
Estimate the parameter using SRS of size \(n=150\), where your sampling frame is all establishments in the dinesafe data.
The function replicate()
can be used to run an expression multiple times and return its results in a matrix, one column for each replication. E.g. the following command replicates sampling 5 values from the letters
vector 10 times. The result is a 5-by-10 matrix, where each row contans the sampled letters.
letters
replicate( 10, sample( letters, size = 5 ) )
Use replicate()
to repeat the establishment sampling process 200 times. Plot a histogram of the resulting statistics (avg # of S/C-type infractions per establishment) and overlay it with the parameter value (use geom_vline()
). Do the samples look biased? Justify your answer.
Collect a convenience sample by choosing all establishments whose address is on Kingston road, and caclulate the sample statistic. Briefly explain what can go wrong with approach?
- Consider the following two survey reports published by the City of Toronto.
The first few pages (p. 1 & 3) contain information on the survey. Read them and fill in the following table as well as you can. If you cannot find the relevant information for a field you can leave it blank. The last row is about your personal assessment of the survey.
Target population |
|
|
Sampling frame |
|
|
Sample size |
|
|
Response rate |
|
|
Possible issues |
|
|
- [Extra] Read about two interesting cases of sampling surveys that went terribly wrong!
LS0tDQp0aXRsZTogIlNUQUE1NyAtIFdvcmtTaGVldCA5Ig0KYXV0aG9yOiAnTmFtZTogICAgLCBJRCM6ICAgJw0Kb3V0cHV0OiBodG1sX25vdGVib29rDQotLS0NCg0KKioqIA0KDQoqKkdvYWwqKjogUHJhY3RpY2Ugc3RhdGlzdGljYWwgY29uY2VwdHMgYW5kIHNhbXBsaW5nIG1ldGhvZHMuDQoNCmBgYHtyLCBpbmNsdWRlPUZBTFNFfQ0KbGlicmFyeSh0aWR5dmVyc2UpDQpkaW5lc2FmZSA9IHJlYWRfY3N2KCIuLi9kYXRhL2RpbmVzYWZlLmNzdiIpDQpgYGANCg0KRm9yIHRoZSBuZXh0IHF1ZXN0aW9ucyBhc3N1bWUgdGhlICpwb3B1bGF0aW9uKiBjb25za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