|
267 | 267 |
|
268 | 268 | %!demo
|
269 | 269 | %!
|
270 |
| -%! % Example data from: |
271 |
| -%! % https://www.biostat.wisc.edu/~kbroman/teaching/labstat/third/notes18.pdf |
| 270 | +%! % Randomization or permutation test for linear regression (without intercept) |
272 | 271 | %! X = [212 435 339 251 404 510 377 335 410 335 ...
|
273 | 272 | %! 415 356 339 188 256 296 249 303 266 300]';
|
274 | 273 | %! Y = [247 461 526 302 636 593 393 409 488 381 ...
|
275 | 274 | %! 474 329 555 282 423 323 256 431 437 240]';
|
276 |
| -%! N = numel (Y); |
277 |
| -%! |
278 |
| -%! % Randomization test to assess the statistical significance of the |
279 |
| -%! % correlation coefficient being different from 0 |
280 |
| -%! [pval, stat] = randtest (X, Y, 5000, @cor) |
281 | 275 | %!
|
282 | 276 | %! % Randomization test to assess the statistical significance of the
|
283 |
| -%! % regression coefficient being different from 0. (Model: y ~ x, i.e. |
284 |
| -%! % linear regression through the origin) |
| 277 | +%! % regression coefficient being different from 0. (Model: y ~ x or y = 0 + x, |
| 278 | +%! % i.e. linear regression through the origin) |
285 | 279 | %! [pval, stat] = randtest (X, Y, 5000) % Default value of FUNC is @mldivide
|
286 | 280 | %!
|
287 |
| -%! % As above but including intercept (Model: y ~ 1 + x, i.e. linear regression |
288 |
| -%! % including an estimate for the intercept) |
| 281 | + |
| 282 | +%!demo |
| 283 | +%! |
| 284 | +%! % Randomization or permutation test for linear regression (with intercept) |
| 285 | +%! X = [212 435 339 251 404 510 377 335 410 335 ... |
| 286 | +%! 415 356 339 188 256 296 249 303 266 300]'; |
| 287 | +%! Y = [247 461 526 302 636 593 393 409 488 381 ... |
| 288 | +%! 474 329 555 282 423 323 256 431 437 240]'; |
| 289 | +%! N = numel (Y); |
| 290 | +%! |
| 291 | +%! % Randomization test to assess the statistical significance of the |
| 292 | +%! % regression coefficients (intercept and slope) being different from 0. |
| 293 | +%! % (Model: y ~ 1 + x, i.e. linear regression with intercept) |
289 | 294 | %! X1 = cat (2, ones (N, 1), X);
|
290 | 295 | %! [pval, stat] = randtest (X1, Y, 5000) % Default value of FUNC is @mldivide
|
291 | 296 |
|
| 297 | +%!demo |
| 298 | +%! |
| 299 | +%! % Randomization or permutation test for the correlation coefficient |
| 300 | +%! % Example data from: |
| 301 | +%! % https://www.biostat.wisc.edu/~kbroman/teaching/labstat/third/notes18.pdf |
| 302 | +%! X = [212 435 339 251 404 510 377 335 410 335 ... |
| 303 | +%! 415 356 339 188 256 296 249 303 266 300]'; |
| 304 | +%! Y = [247 461 526 302 636 593 393 409 488 381 ... |
| 305 | +%! 474 329 555 282 423 323 256 431 437 240]'; |
| 306 | +%! |
| 307 | +%! % Randomization test to assess the statistical significance of the |
| 308 | +%! % correlation coefficient being different from 0 |
| 309 | +%! [pval, stat] = randtest (X, Y, 5000, @cor) |
| 310 | + |
292 | 311 | %!test
|
293 | 312 | %!
|
294 | 313 | %! % Test various capabilities of randtest
|
|
0 commit comments