[R] help neede fast

Sarah Goslee sarah.goslee at gmail.com
Tue Nov 18 12:57:27 CET 2008

On Tue, Nov 18, 2008 at 3:41 AM, gauravbhatti <gaurav15984 at hotmail.com> wrote:
> Hi all can any one of you write a script for the following problem

Well, yes, but that sounds remarkably like a homework problem,
and we can't and won't do your school assignments for you.

Your instructor gave you some suggestions on where to start;
you can use RSiteSearch or Google to find more information.

Beyond that, someone here may be inclined to assist if you
run into a specific problem, but really, that's what your
instructor is paid to do.


> Let X be a matrix of random normal values (mean =0; sd=1) (see rnorm()
> function) having 10 columns and N=100 rows. Let the first row in the matrix
> be (1,1.5,1.4,3,1.9,4,4.9,2.6,3.2,2.4). Assume that the first 5 columns of
> data for each row correspond to a group A, while the remaining 5 to another
> group B.
> For each row of the matrix X, compute:
> a) the t-statistic comparing the groups A and B assuming equal variance
> b) Compute the probability to observe such a t-statistics only by chance,
> using a permutation analysis. The following strategy will be used: the
> columns will be randomly permuted nk=100 times, and at each iteration the
> t-statistic will be computed again and recorded in a vector. At the end,
> compute the p-value as the number of times out of nk when the t-statistic
> with the permuted data was at least as or more extreme than the t-statistics
> obtained with the real (non-permuted data).
> Present the result as a dataframe with 3 columns: ID= Row number, t=
> t-score, p=p-value;
> --

Sarah Goslee

More information about the R-help mailing list