random permuted block randomization

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

random permuted block randomization

Ayesha
Hi,
I am very new to R. Just started yesterday. I have to generate a sequence of
40 random treatments using permuted block randomization with a block size of
8. Then I have to plot moving averages for the resulting sequence. I have
tried the sample function but I dont know if wht i did is right or not
> sample(c(1,1,1,1,2,2,2,2),8)
Any ideas please?

--
Ayesha Khan

MS Bioinformatics
Dept. of Bioengineering
Rice University, TX

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: random permuted block randomization

Greg Snow-2

Take a look at the blockrand package, it may do what you want.

> library(blockrand) #after installing
> myrand <- blockrand(40, block.sizes=4)
> myrand

hope this helps,
________________________________________
From: [hidden email] [[hidden email]] On Behalf Of Ayesha Khan [[hidden email]]
Sent: Thursday, January 28, 2010 5:12 PM
To: [hidden email]
Subject: [R] random permuted block randomization

Hi,
I am very new to R. Just started yesterday. I have to generate a sequence of
40 random treatments using permuted block randomization with a block size of
8. Then I have to plot moving averages for the resulting sequence. I have
tried the sample function but I dont know if wht i did is right or not
> sample(c(1,1,1,1,2,2,2,2),8)
Any ideas please?

--
Ayesha Khan

MS Bioinformatics
Dept. of Bioengineering
Rice University, TX

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: random permuted block randomization

Ayesha
I have tried blockrand but it works in a way that it keeps altering the block size.. like it alternates between 8,6,12. I want a constant block size of 8 :(
Reply | Threaded
Open this post in threaded view
|

Re: random permuted block randomization

Greg Snow-2
Sorry, that is a stupid bug in the blockrand function.  I will hunt down the author and slap him upside the head until he fixes it (actually I will probably just raid his freezer and eat his ice cream).

In the mean time there is a simple work around, if you run blockrand like:

> blockrand(40, block.sizes=c(4,4))

Then it will force all the block sizes to be 8.

Look for a new version of blockrand on CRAN soon with this fixed.

________________________________________
From: [hidden email] [[hidden email]] On Behalf Of Ayesha [[hidden email]]
Sent: Thursday, January 28, 2010 8:06 PM
To: [hidden email]
Subject: Re: [R] random permuted block randomization

I have tried blockrand but it works in a way that it keeps altering the block
size.. like it alternates between 8,6,12. I want a constant block size of 8
:(
--
View this message in context: http://n4.nabble.com/random-permuted-block-randomization-tp1401407p1401496.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: random permuted block randomization

Ayesha
oki :D

and do you know if there is an inbuilt R pacakage that calculate moving averages  over time?
i found this ,
"Calculate various moving averages (MA) of a series."
Usage

  SMA(x, n=10)
  EMA(x, n=10, wilder=FALSE)

but when i tried SMA , R wouldnt recognize it! and there isnt such a package as SMA in the install packages list either.
Reply | Threaded
Open this post in threaded view
|

Re: random permuted block randomization

Greg Snow-2
you might want to look at the rollmean function in the zoo package if you want a fixed window.  If you want a cumulative mean then you can do something like

> cumsum(x)/seq_along(x)

If neither of those work, then give us some more detail.

________________________________________
From: [hidden email] [[hidden email]] On Behalf Of Ayesha [[hidden email]]
Sent: Thursday, January 28, 2010 8:38 PM
To: [hidden email]
Subject: Re: [R] random permuted block randomization

oki :D

and do you know if there is an inbuilt R pacakage that calculate moving
averages  over time?
i found this ,
"Calculate various moving averages (MA) of a series."
Usage

  SMA(x, n=10)
  EMA(x, n=10, wilder=FALSE)

but when i tried SMA , R wouldnt recognize it! and there isnt such a package
as SMA in the install packages list either.

--
View this message in context: http://n4.nabble.com/random-permuted-block-randomization-tp1401407p1401504.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: random permuted block randomization

dr.vinay.muc
This post has NOT been accepted by the mailing list yet.
In reply to this post by Ayesha
Hello

I am a novice R user. I have seen your reply on block randomization.  I have a problem in creating a randomization table using block systems. I tried the "blockrand" and "psych" packages, but couldn't achieve the results I wanted....

We are making an in-vitro study. This employs 330 teeth which have to be cut into 4 pieces (A, B, C and D) = 1320 pieces. Now, these have to be randomly allotted into 33 groups (40 pieces each), but a tooth must contribute only one piece out of these 40. And out of these 40 pieces, it should contain 10As, 10Bs, 10Cs, and 10Ds (I repeat, no teeth number should be repeated in a group, irrespective whether it is A, B, C or D). I hope some experts can guide me.


Thank you in advance.

Vinay