Re: [R] Problem in applying if statment

2008-06-26 Thread Gabor Grothendieck
Try:

RSiteSearch("rejection sampling")


On Thu, Jun 26, 2008 at 11:52 PM, Nadeem Shafique
<[EMAIL PROTECTED]> wrote:
> Respected All,
>
> I am writing a program in R and facing some problem with applying "if 
> statment".
>
> Program first draw random numbers from bivariate normal distribution
> then compute variable say Pi and Pij from that sample and
> then further computation
> ..
> .
> .
> In some samples Pij is appearing with negitive sign and ultimately
> resulted in an negative variance estimator.  Now i want to design the
> program like this if the Pij is negative then go back and draw another
> sample until we get a sample that produces positive Pij and then move
> forward for further processing.
>
> Best Regards,
>
> Nadeem Shafique Butt

__
R-help@r-project.org 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.


[R] question on affylmGUI / oneChannelGUI

2008-06-26 Thread Bogdan Tanasa
Hi everyone.

I installed affylmGUI and oneChannelGUI package on R 2.7.1 with the
latest version of BioC.
After I start R,  I do get an error that says "Error in
loadNamespace(name) : there is no package
called 'affylmGUI'" and a pop-up window with a message "fatal error :
unable to restore saved data
in .Rdata". I would really appreciate your suggestions on how to fix
it. Thanks very much in advance,

Bogdan

__
R-help@r-project.org 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.


Re: [R] unstructured correlation matrix in lme

2008-06-26 Thread David Hajage
I answer my own question.

I was disturbed by the syntax of the SAS code for "proc mixed", which uses
the same procedure for mixed or non mixed effect model. Moreover, the type
of variance-covariance structure is indicate by one parameter.

R is more intuitive and supple : there is two different functions (gls and
lme), and two parameters (one for variance structure, one for correlation
structure). I needed too much time to understand this.

My mistake.

david

2008/6/25 David Hajage <[EMAIL PROTECTED]>:

> I would like to make clear that the SAS "unstructured" correlation matrix
> in the second model was :
> Estimated R Correlation Matrix for id 1
>
> 1  1.  0.8575  0.6984  0.4657  0.3165
> 2  0.8575  1.  0.8557  0.5670  0.4039
> 3  0.6984  0.8557  1.  0.8717  0.7551
> 4  0.4657  0.5670  0.8717  1.  0.9333
> 5  0.3165  0.4039  0.7551  0.9333  1.
>
> which seems to be equal to :
>
> > cov2cor(cov(datares))
>   [,1]  [,2]  [,3]  [,4]  [,5]
> [1,] 1.000 0.8574841 0.6984365 0.4657120 0.3165061
> [2,] 0.8574841 1.000 0.8557224 0.5670489 0.4038805
> [3,] 0.6984365 0.8557224 1.000 0.8716642 0.7550925
> [4,] 0.4657120 0.5670489 0.8716642 1.000 0.9333166
> [5,] 0.3165061 0.4038805 0.7550925 0.9333166 1.000
>
> but not to :
>
> > cov2cor(extract.lme.cov(fm2,rats)[1:5, 1:5]) # corClasses in fm2 :
> corSymm
>   1 2 3 4 5
> 1 1.000 0.9153199 0.8424135 0.6222813 0.2125583
> 2 0.9153199 1.000 0.9344902 0.6960017 0.3115286
> 3 0.8424135 0.9344902 1.000 0.8709635 0.5573176
> 4 0.6222813 0.6960017 0.8709635 1.000 0.8218556
> 5 0.2125583 0.3115286 0.5573176 0.8218556 1.000
>
>
> 2008/6/25 David Hajage <[EMAIL PROTECTED]>:
>
> Hello R users,
>>
>> I'm student and I'm actually having a lecture introducing repeated mesures
>> analysis. Unfortunately, all examples use SAS system...
>>
>> I'm working with lme function (package "nlme"), and I'm using
>> extract.lme.cov (package "mgcv") to extract covariance structure of models.
>>
>> One example is about weight evolution of rats (3 treatment groups) :
>>
>> > summary(rats)
>>id  trt  y s
>>  1  :  5   1:50   Min.   : 46.0   0:27
>>  10 :  5   2:50   1st Qu.: 71.0   1:27
>>  11 :  5   3:35   Median :100.0   2:27
>>  12 :  5  Mean   :100.8   3:27
>>  13 :  5  3rd Qu.:122.5   4:27
>>  14 :  5  Max.   :189.0
>>  (Other):105
>>
>> id : subjects
>> trt : treatment groups (1, 2 or 3)
>> y : weights
>> s : weeks (Week 0 to Week 4)
>>
>> There are 5 mesearements of weight (on week 0, 1, 2, 3 and 4) for each
>> rat.
>>
>> I first fit a model with a compound symmetry correlation structure :
>>
>> > library(nlme)
>> > library(mgcv)
>> > fm1 <- lme(y ~ as.factor(s) * as.factor(trt), data = rats, random = ~
>> 1|id, correlation = corCompSymm())
>> > summary(fm1)
>> ...
>> Fixed effects: y ~ as.factor(s) * as.factor(trt)
>>   Value Std.Error DF  t-value p-value
>> (Intercept)54.0  3.469019 96 15.56636  0.
>> as.factor(s)1  24.5  3.125974 96  7.83756  0.
>> as.factor(s)2  52.0  3.125974 96 16.63481  0.
>> as.factor(s)3  76.1  3.125974 96 24.34441  0.
>> as.factor(s)4 106.6  3.125974 96 34.10137  0.
>> as.factor(trt)2 0.7  4.905934 24  0.14268  0.8877
>> as.factor(trt)3 1.57143  5.406076 24  0.29068  0.7738
>> as.factor(s)1:as.factor(trt)2  -2.9  4.420795 96 -0.65599  0.5134
>> as.factor(s)2:as.factor(trt)2 -10.9  4.420795 96 -2.46562  0.0155
>> as.factor(s)3:as.factor(trt)2 -22.6  4.420795 96 -5.11220  0.
>> as.factor(s)4:as.factor(trt)2 -37.3  4.420795 96 -8.43740  0.
>> as.factor(s)1:as.factor(trt)3  -4.21429  4.871479 96 -0.86509  0.3891
>> as.factor(s)2:as.factor(trt)3  -2.71429  4.871479 96 -0.55718  0.5787
>> as.factor(s)3:as.factor(trt)3   1.04286  4.871479 96  0.21407  0.8309
>> as.factor(s)4:as.factor(trt)3   0.68571  4.871479 96  0.14076  0.8884
>> ...
>>
>> > extract.lme.cov(fm1,rats)[1:5, 1:5]
>>   1 2 3 4 5
>> 1 120.34095  71.48238  71.48238  71.48238  71.48238
>> 2  71.48238 120.34095  71.48238  71.48238  71.48238
>> 3  71.48238  71.48238 120.34095  71.48238  71.48238
>> 4  71.48238  71.48238  71.48238 120.34095  71.48238
>> 5  71.48238  71.48238  71.48238  71.48238 120.34095
>>
>> As you can see, I obtain exactly the same solutions for fixed parameters
>> and estimated covariance matrix in SAS :
>> proc mixed data = rat ;
>> class id trt s ;
>> format trt ftrt. s fs. ;
>> model y = trt s trt * s / solution ddfm = satterth ;
>> repeated s / type = cs subject = id r rcorr;
>> run ;
>>
>>   

Re: [R] How to solve empty cells in the contingency table?

2008-06-26 Thread David Duffy




Hi,Dear all R experts,

   I am trying to do the 2-way contingency table analysis by fitting 
the loglinear models. However, I found my table has several empty 
cells which are theoretically missing values.I have no idea of how 
to solve them coz we cannot compute the simulated p-value with zero 
marginals.Does someone have some suggestions? Please help me out, 
thanks a lot!


Cheers,
Yan


One approach: if they are *structural zeroes*,

tab <- as.data.frame(table(x,y))

then use the exactLoglinTest package's mcexact function

David Duffy.

__
R-help@r-project.org 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.


[R] Superimposing Multiple Vectors Plots in One Figure

2008-06-26 Thread Gundala Viswanath
Hi,

I have 3 vectors which I want to plot as in one plot.
I was wondering why this code of mine only show the last vector:

__BEGIN__
library(lattice)

out_fname <- paste("MyPlot.png",sep="")

trellis.device("png", color=TRUE)
png(out_fname)
plot(vect1,type="l",col="red",xlab="Nof Genes", ylab="RMSD")
plot(vect2,type="l",col="blue")
plot(vect3,type="l",col="green")  # final graph only showed this one.
dev.off()

__END__

- Gundala Viswanath
Jakarta - Indonesia

__
R-help@r-project.org 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.


<    1   2