Skip to content

Commit

Permalink
split demo up into three separate demos
Browse files Browse the repository at this point in the history
  • Loading branch information
acp29 committed Apr 18, 2024
1 parent 4d71564 commit 435f2c8
Showing 1 changed file with 30 additions and 11 deletions.
41 changes: 30 additions & 11 deletions inst/randtest.m
Original file line number Diff line number Diff line change
Expand Up @@ -267,28 +267,47 @@

%!demo
%!
%! % Example data from:
%! % https://www.biostat.wisc.edu/~kbroman/teaching/labstat/third/notes18.pdf
%! % Randomization or permutation test for linear regression (without intercept)
%! X = [212 435 339 251 404 510 377 335 410 335 ...
%! 415 356 339 188 256 296 249 303 266 300]';
%! Y = [247 461 526 302 636 593 393 409 488 381 ...
%! 474 329 555 282 423 323 256 431 437 240]';
%! N = numel (Y);
%!
%! % Randomization test to assess the statistical significance of the
%! % correlation coefficient being different from 0
%! [pval, stat] = randtest (X, Y, 5000, @cor)
%!
%! % Randomization test to assess the statistical significance of the
%! % regression coefficient being different from 0. (Model: y ~ x, i.e.
%! % linear regression through the origin)
%! % regression coefficient being different from 0. (Model: y ~ x or y = 0 + x,
%! % i.e. linear regression through the origin)
%! [pval, stat] = randtest (X, Y, 5000) % Default value of FUNC is @mldivide
%!
%! % As above but including intercept (Model: y ~ 1 + x, i.e. linear regression
%! % including an estimate for the intercept)

%!demo
%!
%! % Randomization or permutation test for linear regression (with intercept)
%! X = [212 435 339 251 404 510 377 335 410 335 ...
%! 415 356 339 188 256 296 249 303 266 300]';
%! Y = [247 461 526 302 636 593 393 409 488 381 ...
%! 474 329 555 282 423 323 256 431 437 240]';
%! N = numel (Y);
%!
%! % Randomization test to assess the statistical significance of the
%! % regression coefficients (intercept and slope) being different from 0.
%! % (Model: y ~ 1 + x, i.e. linear regression with intercept)
%! X1 = cat (2, ones (N, 1), X);
%! [pval, stat] = randtest (X1, Y, 5000) % Default value of FUNC is @mldivide

%!demo
%!
%! % Randomization or permutation test for the correlation coefficient
%! % Example data from:
%! % https://www.biostat.wisc.edu/~kbroman/teaching/labstat/third/notes18.pdf
%! X = [212 435 339 251 404 510 377 335 410 335 ...
%! 415 356 339 188 256 296 249 303 266 300]';
%! Y = [247 461 526 302 636 593 393 409 488 381 ...
%! 474 329 555 282 423 323 256 431 437 240]';
%!
%! % Randomization test to assess the statistical significance of the
%! % correlation coefficient being different from 0
%! [pval, stat] = randtest (X, Y, 5000, @cor)

%!test
%!
%! % Test various capabilities of randtest
Expand Down

0 comments on commit 435f2c8

Please sign in to comment.