August 28, 2007

Power calculations in R

Filed under: R project, University — izabela @ 11:01 am

My first huge disappointment with R. My boss wanted me to do simple power calculations to see how adding 2 animals to one of groups will improve statistical power. Yeah, I know, you are not supposed to do “retrospective power calculations”. Tell it to people providing lab animals, they always give you couple more just in case something happened to one or two you have. So, sometimes we have to do just that. Well, not in R.
There is this nice and simple power.t.test function, with
n= for number of subjects in a group
delta = for difference between groups
sd= for standard deviation
sig.level= for desired alpha
power= for power, obviously
All you need to do is to define all but one and the remaining is calculated. Great, but how about if your groups are of unequal sizes? There is always Google? Not this time.
There is nice package pwr, if you happen to work on proportions and can use beauty of binomial distribution. That’s it.
Solution? I opened SAS and did what I needed in 1 min.
Proc power works like power.t.test, but you can do calculations with different sd’s in groups, different group sizes and different experimental design. Wonder, when R catches up…

Technorati Tags: , , ,

August 25, 2007

New York anecdotes in mystery setting

Filed under: Books, Life — izabela @ 8:43 pm

It is no mystery to people who know me even a little bit, that I can read everything in the form of book, phone book included, if I am desperate, but I definitely prefer mystery books. If I read one book of an author I like, I will check out from the library every single other book by same author, as long as supplies last. Sometimes, in chronological order, but it doesn’t make any sense if I started from the latest ;). It makes me instantly open my New York guide book or Google, whatever results in better photos, and read more.
Last fascination- Linda Fairstein. And, believe me, these are not ordinary mystery books. I am reading a lot of comments about her works, none mentioning what I am finding the most fascinating about them. From “Bad blood” describing Saint Hogs, through Smallpox Hospital on Roosevelt Island in “The Deadhouse”, and Edgar Allan Poe’s short episode in New York in “Entombed”, Cloisters in “Bone vault “- I am learning incredible stories, places and historical anecdotes.
I wonder, as the histories are not necessary part of the book stories, why all this interesting material get into the books? Is author doing the research with the story in mind, or she finds the “pearls” by accident and research out of her own curiosity?

Anyway, I am finishing off “The Deadhouse” tonight, already wondering what I am going to learn from “Death dance”.

Technorati Tags: Linda Fairstein, ,

August 22, 2007

Dunnett all-to-control test in R

Filed under: R project, University — izabela @ 1:24 pm

OK, it is going to be a first of series of blog entries on my struggle with R project. I consider myself an amateur in statistics and in R, so they are going to be without any theoretical background and discussions of the math underneath the stuff I am going to write about, so any comments are welcome.

Anyway, my task was to run Dunnett test on set of data from some animal study. If it was my experiment, I would run one-way ANOVA and maybe happily discover some other relationships significant and were unable to make sense out of it in the paper. This time, not my project, and I was told Dunnett is all they need.

OK, thanks God for Google, I found nice article in R News from December 2002, where the stuff was quite well explained, read my data into R, one line of code:
simint (variable1~group, conf.level=0.95, alternative=’two.sided’

got my results and….disturbing:

Warning message:
’simint.default’ is deprecated.
Use ‘glht’ instead.
See help(”Deprecated”) and help(”multcomp-deprecated”).

Great! In plain English, I just wasted my time discovering something that maybe next time I need to run same test won’t be there any more.

OK, count down from 150, and start looking for glht.

Of course, something I just minutes ago did in one line, now requires no less then three:

model <- aov(variable1~group)
results <- glht(model, linefc=mcp(group='Dunnett'), alternative='t' )
summary(results)

Maybe it is better though, as I got all significance levels at once.

Technorati Tags: R project, ,

Powered by WordPress.
Theme by Ron and Andrea. Background image from Gimp Patterns. Theme images created using The GIMP 2.2.8.