[R] Inflated Array

2006-07-18 Thread Hadassa Brunschwig
Hi R-users!

I am trying to create a what I call inflated array (maybe there is
already some other name for that). It is an array that changes
dinamically its dimensions, e.g. the higher the number of third
dimensions, the more rows in the array. So for example the array could
look like the following:

, ,1

1 2 3 4

, , 2

5   6   7  8
9 10 11 12

, , 3

13 14 15 16
17 18 19 20
21 22 23 24

Has anybody a comment on how to build this in the most efficient
manner (I know i could do looping)?

Thanks!

Hadassa

__
R-help@stat.math.ethz.ch 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] Negative Binomial: Simulation

2006-07-14 Thread Hadassa Brunschwig
Addition to last email:

The problem basically arises also when I want to calculate (plot) the
cumulative distribution of the negative binomial with the calculated
parameters mu and theta!

On 7/14/06, Hadassa Brunschwig <[EMAIL PROTECTED]> wrote:
> Hi R-Users!
>
> (sorry about the last email)
> I fitted a negative binomial distribution to my count data using the
> function glm.nb() and obtained the calculated parameters
> theta (dispersion) and mu.
>
> I would like to simulate values from this negative binomial distribution.
> Looking at the function rnbinom() I was looking at the relationship
> between the two possible parametrizations of the negative binomial and found
> that for this fuction I must use:
>
> prob = theta/(theta+mu) and   size = theta
>
> Theta, however, is not an integer. So how can size (which is the number of
> successes) equal theta?
>
> I know there is a function rnegbin which does what I want. I would still
> like to raise the above question (probably a more statistical one
> than R).
>
> Thanks a lot for any comments.
>
> Hadassa
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Negative Binomial: Simulation

2006-07-14 Thread Hadassa Brunschwig
Hi R-Users!

(sorry about the last email)
I fitted a negative binomial distribution to my count data using the
function glm.nb() and obtained the calculated parameters
theta (dispersion) and mu.

I would like to simulate values from this negative binomial distribution.
Looking at the function rnbinom() I was looking at the relationship
between the two possible parametrizations of the negative binomial and found
that for this fuction I must use:

prob = theta/(theta+mu) and   size = theta

Theta, however, is not an integer. So how can size (which is the number of
successes) equal theta?

I know there is a function rnegbin which does what I want. I would still
like to raise the above question (probably a more statistical one
than R).

Thanks a lot for any comments.

Hadassa

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Negative Binomial: Simulation

2006-07-14 Thread Hadassa Brunschwig
Hi R-Users!

I fitted a negative binomial distribution to my count data using the
function glm.nb() and obtained the calculated parameters
theta (dispersion) and mu.

I would like to simulate values from this negative binomial distribution.
Looking at the function rnbinom() I was looking at the relationship
between the two possible parametrizations of the negative binomial and found
that for this fuction I must use:

prob = theta/(theta+mu) and   size = theta

Theta, however, is not an integer. So how can size (which is the number of
successes) equal theta?

I know there is a function rnegbin which does what I want. I would still
like to raise the above question (probably a more statistical one
than R).

Thanks a lot for any comments.

Hadassa

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] tick mark intervals

2006-03-19 Thread Hadassa Brunschwig
Hi everyone!

This must be a common question but I have not found an answer to it in the
archives yet.

I am producing four plots with par(mfrow=c(2,2)). The x-axis is the same for
all of them but the y-axis is different.
What I would like to do is to have a different range of the y-axis and
different intervals between tick marks. BUT
I would like to have the same number of tick marks and I would like the
y-axis to look the same.

EXAMPLE (with two plots):

plot1: number of tick marks = 11
 interval between tick marks = 5 (i.e. tick marks at
0,5,10,15, etc.)
 range of y-axis = (0, 50)

plot2: number of tick marks = 11
 interval between tick marks = 10 (i.e. tick marks at
0,10,20,etc.)
 range of y-axis = (0,100)


Now I can obtain the values at which there should be tick marks for each of
the above plots. The problem is that
when I plot them with par(mfrow=c(1,2)) I obtain the same graphical height
for each y-axis but the y-axis of plot1
has no tick marks after the value of 50 which looks ugly. I would like to
stretch the 50 of plot1 to where the 100
of plot2 is such that the it looks evenly distributed. But that means that
an interval between tick mark 1 and 2 of plot1
(which is 5) is as long (graphically) as the interval between tick mark 1
and 2 of plot2 (which is 10).

Any ideas on how to do this?

Thanks a lot!!

Cheers,

Hadassa

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] R2WinBUGS: Comparison to WinBUGS

2005-11-01 Thread Hadassa Brunschwig
Hi R-Users!

I know I posted the question before (see archives) but I have not been able to
find the mistake. Again using R2WinBUGS and WinBUGS does not yield the same
result (although to my opinion the commands are the same). The variance of the
parameters is much bigger and the parameter estimates are a bit different, too.
If anybody has the time and interest to get the files and data and see if he/she
has the same problems, I would be happy to provide these (and to discuss it
further). It seems though that it must be my mistake SOMEWHERE because nobody
else reported any problems yet... 

Thanks.

Hadassa
-- 

Hadassa Brunschwig
Birmannsgasse 10A
CH-4055 Basel
Switzerland
Phone: +41 78 797 6065
Email: [EMAIL PROTECTED]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] [Fwd: R2WinBUGS: Comparison to WinBUGS]

2005-09-28 Thread Hadassa Brunschwig
Thanks for the tip. That was already helpful. But I am still not satisfied with
the results. I now really changed n.thin to the same I had in WinBUGS. It looks
like the commands should now be the same. However, I still get differences of
0.6 in the means of interesting parameters which should not be. The plot as well
looks completely different. While in WinBUGS I get an approximately Gaussian
posterior, this is not the case in R2WinBUGS, it is rather skewed. Does anyone
know where the problem could be? As getting a Gaussian posterior is crucial for
my work, I dont really know which results i should rely on.

Thanks a lot.
-- 

Hadassa Brunschwig
Birmannsgasse 10A
CH-4055 Basel
Switzerland
Phone: +41 78 797 6065
Email: [EMAIL PROTECTED]



Quoting Sibylle Sturtz <[EMAIL PROTECTED]>:

> This is due to the following:
> 
> In bugs(), the default for thinning is
> 
> n.thin = max(1, floor(n.chains * (n.iter - n.burnin)/1000))
> 
> which is 29 for n.iter=12000 and n.burnin=2001 as in your example. 
> Therefore, the number of iterations used for calculation of posterior 
> values is
> 
> (12000-2001)/29 = 344.7931
> 
> which corresponds to the number of iterations given in your plot. If you 
> specify the thinning parameter directly in bugs() it should be fine.
> 
> Sibylle
> 
> >  Original Message 
> > Subject: [R] R2WinBUGS: Comparison to WinBUGS
> > Date: Wed, 28 Sep 2005 03:55:08 -0400
> > From: Hadassa Brunschwig <[EMAIL PROTECTED]>
> > To: r-help@stat.math.ethz.ch
> > 
> > Hi R-Help!
> > 
> > 
> > I used R2WinBUGS and WinBUGS directly on the same model just to compare.
> It
> > seems I am still making a mistake: after running the function bugs() I 
> > tried to
> > plot the posteriors of the parameters by using read.bugs() to convert 
> > the output
> > to an mcmc object and then plot.mcmc() to plot the densities. Using the 
> > same
> > model, the same number of iterations, the same initial values and the 
> > same data
> > I get completely different plots for the densities (e.g. the range of one
> > parameter in R2WinBUGS is from 0 to 8 but in WinBUGS only from 1.5 to 
> > 3)??? That
> > means my results are different, too.
> > Also, on the plot it says N=345 which is not what I specified in the
> bugs()
> > function (I specified 12000 iterations).
> > Below I put some of the code I used (if that helps):
> > 
> > parameters <-
> >
> c("tau","C0","st90","C0.pop","st90.pop","tau.cpop","tau.stpop","st90.pop80")
> 
> > 
> > inits  <- inits <- function(){
> > list(tau = rep(1, 17),tau.cpop = 0.2, tau.stpop = 1)
> >   }
> > 
> > mcmcA  <-
> >
> bugs(dataA,inits,parameters,modelA,n.chains=3,debug=T,n.iter=12000,n.burnin=2001,
> 
> > 
> >bugs.directory="c:/Program
> > Files/WinBUGS14",working.directory="C:/Documents and
> > Settings/Daikon/Roche/R2WinBUGS Output",codaPkg=T)
> > 
> > codaA1  <- read.bugs(mcmcA[1])
> > plot(codaA1)
> > 
> > 
> > THANKS A LOT!!
> 
> -- 
> Dipl.-Stat. Sibylle Sturtz
> Mathematische Statistik und biometrische Anwendungen
> Fachbereich Statistik
> Universität Dortmund
> 44221 Dortmund
> Tel.: 0231/755 4391
> FAX : 0231/755 5303
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] R2WinBUGS: Comparison to WinBUGS

2005-09-28 Thread Hadassa Brunschwig
Hi R-Help!


I used R2WinBUGS and WinBUGS directly on the same model just to compare. It
seems I am still making a mistake: after running the function bugs() I tried to
plot the posteriors of the parameters by using read.bugs() to convert the output
to an mcmc object and then plot.mcmc() to plot the densities. Using the same
model, the same number of iterations, the same initial values and the same data
I get completely different plots for the densities (e.g. the range of one
parameter in R2WinBUGS is from 0 to 8 but in WinBUGS only from 1.5 to 3)??? That
means my results are different, too.
Also, on the plot it says N=345 which is not what I specified in the bugs()
function (I specified 12000 iterations).
Below I put some of the code I used (if that helps):

parameters <-
c("tau","C0","st90","C0.pop","st90.pop","tau.cpop","tau.stpop","st90.pop80")
inits  <- inits <- function(){
list(tau = rep(1, 17),tau.cpop = 0.2, tau.stpop = 1)
  }
  
mcmcA  <-
bugs(dataA,inits,parameters,modelA,n.chains=3,debug=T,n.iter=12000,n.burnin=2001,
   bugs.directory="c:/Program
Files/WinBUGS14",working.directory="C:/Documents and
Settings/Daikon/Roche/R2WinBUGS Output",codaPkg=T)
 
codaA1  <- read.bugs(mcmcA[1])
plot(codaA1)


THANKS A LOT!!
-- 

Hadassa Brunschwig
Birmannsgasse 10A
CH-4055 Basel
Switzerland
Phone: +41 78 797 6065
Email: [EMAIL PROTECTED]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] R2WinBUGS: Data loading error

2005-09-22 Thread Hadassa Brunschwig
Thank you for your answer. I found out the mistake and it finally works!!

Hadassa
-- 

Hadassa Brunschwig
Birmannsgasse 10A
CH-4055 Basel
Switzerland
Phone: +41 78 797 6065
Email: [EMAIL PROTECTED]



Quoting Uwe Ligges <[EMAIL PROTECTED]>:

> Hadassa Brunschwig wrote:
> 
> > Hi R-Help!
> > 
> > I am trying to use R2WinBUGS but I get the following error message in
> WinBUGS
> > (and there must be something wrong with my R statement as I tried it
> directly in
> > WinBUGS and it worked):
> > 
> > display(log)
> > check(C:/Documents and Settings/Daikon/Roche/pop_model.txt)
> > model is syntactically correct
> > data(C:/Documents and Settings/Daikon/Roche/data.txt)
> > expected key word structure
> > compile(7)
> > ...(and of course nothing works after that)
> > 
> > and when I close WinBUGS i get:
> > Error in file(file, "r") : unable to open connection
> > In addition: Warning message:
> > cannot open file 'codaIndex.txt' 
> > 
> > Does anyone know what this 'expected key word structure' means?
> > This is my R code (and I guess my model file is ok):
> > 
> > modelA <- c("C:/Documents and Settings/Daikon/Roche/pop_model.txt")
> > n  <- length(unique(subsetA$subject))#number of subjects
> > nt <- 13 #number of days
> > Y  <- subsetA$concentr   #concentration per
> day/subject
> > t  <- 1:13   #days
> > dataA  <- list("n","nt","Y","t")
> > parameters <-
> c("tau","C0","st90","C0.pop","st90.pop","tau.cpop","tau.stpop")
> > inits  <-
> >
>
list(tau=c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),C0=5,st90=4,C0.pop=5,st90.pop=4,tau.cpop=0.2,tau.stpop=1)
> > mcmcA  <-
> >
> bugs(dataA,inits,parameters,modelA,debug=T,n.chains=7,bugs.directory="c:/Program
> > Files/WinBUGS14",working.directory="C:/Documents and
> Settings/Daikon/Roche")
> 
> 
> 
> Which versions of R, WinBUGS and R2WinBUGS?
> Your example is not reproducible for us.
> 
> I'd take a look whether dimensions are OK and whether subsetA$concentr 
> is in appropriate object, but without data and model file I am unable to 
> help for the data part.
> 
> 
> For the inits part, please see ?bugs:
> 
> inits: a list with n.chains elements; each element of the list is itself 
> a list of starting values for the WinBUGS model, or a function creating 
> (possibly random) initial values. Alternatively, if inits = NULL, 
> initial values are generated by WinBUGS
> 
> Looks like you want to have the same inits for each chain. In order not 
> to repeat the inits 7 times, you might want to specify them simply as a 
> function such as:
> 
>   inits <- function(){
> list(tau = rep(1, 17), C0 = 5, st90 = 4, C0.pop = 5, st90.pop = 4,
>  tau.cpop = 0.2, tau.stpop = 1)
>   }
> 
> 
> Uwe Ligges
> 
> 
> [Further correspondence on this particular topic, please respond to to 
> the package maintainer (Sibylle) and me directly rather than to R-help.]
> 
> 
> > 
> > Thanks so much...
> > 
> > Hadassa
> > 
> > 
> 
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] R2WinBUGS: Data loading error

2005-09-22 Thread Hadassa Brunschwig
Hi R-Help!

I am trying to use R2WinBUGS but I get the following error message in WinBUGS
(and there must be something wrong with my R statement as I tried it directly in
WinBUGS and it worked):

display(log)
check(C:/Documents and Settings/Daikon/Roche/pop_model.txt)
model is syntactically correct
data(C:/Documents and Settings/Daikon/Roche/data.txt)
expected key word structure
compile(7)
...(and of course nothing works after that)

and when I close WinBUGS i get:
Error in file(file, "r") : unable to open connection
In addition: Warning message:
cannot open file 'codaIndex.txt' 

Does anyone know what this 'expected key word structure' means?
This is my R code (and I guess my model file is ok):

modelA <- c("C:/Documents and Settings/Daikon/Roche/pop_model.txt")
n  <- length(unique(subsetA$subject))#number of subjects
nt <- 13 #number of days
Y  <- subsetA$concentr   #concentration per day/subject
t  <- 1:13   #days
dataA  <- list("n","nt","Y","t")
parameters <- c("tau","C0","st90","C0.pop","st90.pop","tau.cpop","tau.stpop")
inits  <-
list(tau=c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),C0=5,st90=4,C0.pop=5,st90.pop=4,tau.cpop=0.2,tau.stpop=1)
mcmcA  <-
bugs(dataA,inits,parameters,modelA,debug=T,n.chains=7,bugs.directory="c:/Program
Files/WinBUGS14",working.directory="C:/Documents and Settings/Daikon/Roche")


Thanks so much...

Hadassa


-- 

Hadassa Brunschwig
Birmannsgasse 10A
CH-4055 Basel
Switzerland
Phone: +41 78 797 6065
Email: [EMAIL PROTECTED]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] survreg: fitting different location parameters

2005-01-24 Thread Hadassa Brunschwig
Hi R-Help!

My question: I have lifetime/failure data of machines with different
stress levels and i think an weibull/extreme value distribution would
fit this data. So I did:

model1  <- survreg(Surv(lfailure)~stress,data=steel,dist="extreme")

(where lfailure=log(failure))

Now I would like to do a likelihood ratio test to test the hypothesis 

H0: location parameters of the extreme value distribution are equal
for each stress level.

So in order to perform the likelihood ratio test I need the likelood
of the model under

HA: location parameters are not equal (i.e. each stress level has its
slope and intercept).

How can I do this? 

Thanks for any help!

Hadassa

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] adding to Trellis plot

2003-08-14 Thread Hadassa Brunschwig
Hello everyone
(Im not sure if i already posted this problem)
I have grouped data and i used a Trellis plot to show the curve of a fitted 
model for each group. Additionally i have a vector whose values are the 
highest points the curve can reach (the curve rises exponetially). Each 
value of the vector is the corresponding highest point for each group/plot. 
Now i want to show this highest point by adding to each plot a horizontal 
line. Obviously i should use panel.abline or something equal. How can i tell 
R that each value of this vector corresponds to the different plots in the 
Trellis plot?

Thanks a lot for answers

Dassy

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] function "lme"

2003-08-12 Thread Hadassa Brunschwig
Thanks to everyone who replied to my first problem. Here is the second one: 
Is the function "lme" (Mixed Model) also in a foreign library(shouldnt, as 
this is a basic statistical function)? I am trying to use lme in R and it 
replies that it couldnt find the function lme...weird...

Thanks for replying!

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Importing Data

2003-08-08 Thread Hadassa Brunschwig
Im trying to import data from an excel sheet or a sas file to R...im not 
succeeding. Apparently the function read.xport for reading a SAS file doesnt 
exist. What do i have to type in EXACTLY to read from an excel sheet(i guess 
i would be using read.table?)?

Thanks in advance for an answer

Dassy

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help