Topic 5B: Study design with R


These are the solutions for the Topic 5B Computer Lab.

1 Simple random sampling: Generating random numbers

1.1

Answers will vary.

1.2

No solution required.

1.3

Answers will vary.

1.4

Answers will vary.

1.5

Answers will vary, but here is an example:

sample(1:100, size = 20, replace = FALSE)
##  [1] 95 65 63 72 35 32  8 96 64 85 53 82 52 22 19 21 88 57 51  2

1.6

Answers will vary, but here is an example:

sample(101:500, size = 50, replace = FALSE)
##  [1] 349 315 286 123 328 271 375 132 267 206 284 220 378 455 461 240 179 275 490
## [20] 413 381 449 487 263 235 241 290 414 164 227 276 169 155 411 292 323 361 106
## [39] 127 185 233 486 345 330 377 355 309 145 471 392

1.7

No solution required.

2 Experimenal Design with R

2.1

No solution required.

2.2

No solution required.

2.3

Randomly allocating.

2.4

No solution required.

2.5

The following code can be used:

set.seed(1)
Groups <- c("Himalaya", "Refined cereal")
design <- design.crd(trt = Groups, r = 25)
design$book

2.6

set.seed(1)
Groups <- c("Himalaya", "Refined cereal", "Wholemeal wheat")
design <- design.crd(trt = Groups, r = 20)
design$book

3 Catching up

No solution required.

References


These notes have been prepared by Amanda Shaker. The copyright for the material in these notes resides with the authors named above, with the Department of Mathematics and Statistics and with La Trobe University. Copyright in this work is vested in La Trobe University including all La Trobe University branding and naming. Unless otherwise stated, material within this work is licensed under a Creative Commons Attribution-Non Commercial-Non Derivatives License BY-NC-ND.