Skip to content

Commit 435f2c8

Browse files
committed
split demo up into three separate demos
1 parent 4d71564 commit 435f2c8

File tree

1 file changed

+30
-11
lines changed

1 file changed

+30
-11
lines changed

inst/randtest.m

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -267,28 +267,47 @@
267267

268268
%!demo
269269
%!
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)
272271
%! X = [212 435 339 251 404 510 377 335 410 335 ...
273272
%! 415 356 339 188 256 296 249 303 266 300]';
274273
%! Y = [247 461 526 302 636 593 393 409 488 381 ...
275274
%! 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)
281275
%!
282276
%! % 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)
285279
%! [pval, stat] = randtest (X, Y, 5000) % Default value of FUNC is @mldivide
286280
%!
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)
289294
%! X1 = cat (2, ones (N, 1), X);
290295
%! [pval, stat] = randtest (X1, Y, 5000) % Default value of FUNC is @mldivide
291296

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+
292311
%!test
293312
%!
294313
%! % Test various capabilities of randtest

0 commit comments

Comments
 (0)