Re: [R] fitting truncated normal distribution

2006-08-17 Thread Schweitzer, Markus
Sorry, that I forgot an example.

I have demand-data which is either 0 or a positive value.

When I have an article which is not ordered very often, it could look
like this:

x=c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1280,0,0,0,0,640,0,0
,0,0,0,0,0,0,0)


 library(MASS) ## for fitdistr
 library(msm) ## for dtnorm
 
 dtnorm0 - function(x, mean = 0, sd = 1, log = FALSE) {
dtnorm(x, mean, sd, 0, Inf, log)
 }
 fitdistr(x,dtnorm0,start=list(mean=0,sd=1))

Unfortunately I get the same error message.
I found a function, that works for a weibull distribution and tried to
apply it but it didn't work neither

# truncated weibull distribution

#dweibull.trunc -
#function(x, shape, scale=1, trunc.=Inf, log=FALSE){
#ln.dens - (dweibull(x, shape, scale, log=TRUE)
#-pweibull(trunc., shape, scale = 1, lower.tail = TRUE, log.p = 
#TRUE))
#if(any(oops - (xtrunc.)))
#ln.dens[oops] - (-Inf)   
#if(log)ln.dens else exp(ln.dens)
#}
#
#x - rweibull(100, 1)
#range(x)
#x4 - x[x=4]
#fitdistr(x4, dweibull.trunc, start=list(shape=1, scale=1), trunc=4)



# truncated normal distribution

dtnorm0 - function(x, mean, sd, a=0, log = FALSE) {
ln.dens - (dnorm(x, mean, sd)
- pnorm(a, mean, sd, lower.tail=TRUE, log.p =TRUE))

if(any(oops - (xa)))
  ln.dens[oops] - (-Inf)
if(log)ln.dens else exp(ln.dens)
}

fitdistr(x, dtnorm0, start = list(mean = 0, sd = 1))

Maybe, when I alter mean and sd, I get an answer, which is not really
satisfactory. I hope, there is a solution possible
And thank you in advance

markus







Sorry, didn't notice that you *did* mention dtnorm is part of msm. 
Ignore that part of the advice...

--sundar

Sundar Dorai-Raj wrote:
 
 [EMAIL PROTECTED] wrote:
 
Hello,
I am a new user of R and found the function dtnorm() in the package
msm.

My problem now is, that it is not possible for me to get the mean and
sd out of a sample when I want a left-truncated normal distribution
starting at 0.

fitdistr(x,dtnorm, start=list(mean=0, sd=1))

returns the error message 
Fehler in [-(`*tmp*`, x = lower  x = upper, value = numeric(0))
:nichts zu ersetzen

I don't know, where to enter the lower/upper value. Is there a
possibility to program the dtnorm function by myself?

Thank you very much in advance for your help, markus

---
Versendet durch aonWebmail (webmail.aon.at)


__
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.
 
 
 Hi, Markus,
 
 You should always supply the package name where dtnorm is located. My 
 guess is most don't know (as I didn't) it is part of the msm package.
 Also, you should supply a reproducible example so others may 
 understand your particular problem. For example, when I ran your code 
 on data generated from rtnorm (also part of msm) I got warnings 
 related to the NaNs generated in pnorm and qnorm, but no error as you 
 reported. Both of these suggestions are in the posting guide (see
signature above).
 
 So, to answer your problem, here's a quick example.
 
 library(MASS) ## for fitdistr
 library(msm) ## for dtnorm
 
 dtnorm0 - function(x, mean = 0, sd = 1, log = FALSE) {
dtnorm(x, mean, sd, 0, Inf, log)
 }
 
 set.seed(1) ## to others may reproduce my results exactly x - 
 rtnorm(100, lower = 0) fitdistr(x, dtnorm0, start = list(mean = 0, sd 
 = 1))
 
 Note, the help page ?fitdistr suggests additional parameters may be 
 passed to the density function (i.e. dtnorm) or optim. However, this 
 won't work here because lower is an argument for both functions. 
 This is the reason for writing dtnorm0 which has neither a lower or an

 upper argument.
 
 HTH,
 
 --sundar
 
 __
 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.

__
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.





[[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Setting contrasts for polr() to get same result of SAS

2006-08-17 Thread Gregor Gorjanc
T Mu muster at gmail.com writes:
 
 Hi all,
 
 I am trying to do a ordered probit regression using polr(), replicating a
 result from SAS.
 
 polr(y ~ x, dat, method='probit')
 
 suppose the model is y ~ x, where y is a factor with 3 levels and x is a
 factor with 5 levels,
 
 To get coefficients, SAS by default use the last level as reference, R by
 default use the first level (correct me if I was wrong),

Yes.

 I tried relevel, reorder, contrasts, but no success. I found what really
 matters is

I am sure those can help but you need to be carefull to reorder levels 
that the order is the same in SAS and R.

 options(contrasts = c(contr.treatment, contr.poly))
 
 or
 
 options(contrasts = c(contr.SAS, contr.poly))

You can also set contrasts directly to factors via

contrasts(x) - contr.SAS

where x is your factor. You can also set different contrasts to 
different factors.

Gregor

__
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] help about agnes

2006-08-17 Thread Martin Maechler
 Arnau == Arnau Mir Torres [EMAIL PROTECTED]
 on Wed, 16 Aug 2006 19:38:27 +0200 writes:

Arnau Hello.
Arnau I have the following distance matrix between 8 points:
 
Arnau [1,] 0.00 3.162278 7.280110 8.544004 7.071068 9.899495 6.403124 
8.062258
Arnau [2,] 3.162278 0.00 5.00 6.403124 4.472136 8.944272 6.082763 
8.062258

[ .. ]


Arnau So, can somebody say me what do these numbers represent?

I would have helped you if you had followed the last two lines
below

Arnau Thanks in advance,

Arnau Arnau.

 __
 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.

^ these I mean ^

__
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] nls convergence problem

2006-08-17 Thread Dieter Menne
nls not converging for zero-noise cases

 Setzer.Woodrow at epamail.epa.gov writes:

 
 No doubt Doug Bates would gladly accept patches ... .
 

The zero-noise case is irrlevant in practice, but quite often I have uttered
/(!! (vituperation filter on) when nls did not converge with real data. The
dreaded min step reduced And yet, I found that nls is damned right not to
behave nicely in many cases. Recently, a colleague fitted gastric emptying
curves using GraphPad, with 100% success, and nls failed for one third of these.
When we checked GraphPads output more closely, some of the coefficients looked
like 2.1 with a confidence interval in the range  -27128 ... 314141. Nobody
forces you to look at these, though, when using GraphPad.

I only wish nls were a little bit more polite in telling me what went wrong.

Dieter

__
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] separate row averages for different parts of an array

2006-08-17 Thread Gabor Grothendieck
The following reshapes mat so we can take the means of the columns
of the resulting 3d array and then transposes it back to the original
orientation:

   t(colMeans(array(t(mat), c(100, 448, 24

You might want to try it on this test set first where anscombe
is an 11x8 data set built into R.  Here are 4 solutions using
anscombe

1.   This is just the above written for the anscombe data set:

t(colMeans(array(t(anscombe), c(4,2,11

2. Here is a solution using apply instead of colMeans and t.
In this case anscombe is a data.frame, not an array/matrix,
and we need to turn it into one first.  The prior solution
also required a matrix but tranpose will convert a dataframe
to a matrix so we did not have to explicitly do it there.  If
your array is indeed an array as stated in your post then
you can omit the as.matrix part.  In your case the
c(11,4,2) vector would be c(24, 100, 448) :

apply(array(as.matrix(anscombe), c(11,4,2)), c(1,3), mean)

3. Here is another solution.  This one uses the zoo package
and does have the advantage of not having to specify a
bunch of dimensions.  It uses rapply from zoo (which will
be renamed rollapply in the next version of zoo so as not
to conflict with the new rapply that is appearing in R 2.4.0).
In your case both occurrences of 4 would be 100:

library(zoo)
coredata(t(rapply(zoo(t(anscombe)), 4, by = 4, mean)))

4. This is Marc's solution except we use seq instead of : at
the end in order to make use of the length= argument.
In your case c(11, 8, 4) would be c(1, 44800, 100) and length = 4
would be length = 100:

sapply(seq(1, 8, 4), function(i) rowMeans(anscombe[, seq(i, length = 4)]))





On 8/16/06, Spencer Jones [EMAIL PROTECTED] wrote:
 I have an array with 44800 columns and 24 rows I would like to compute the
 row average for the array 100 columns at a time, so I would like to end up
 with an array of 24 rows x 448 columns. I have tried using apply(dataset, 1,
 function(x) mean(x[])), but I am not sure how to get it to take the average
 100 columns at a time. Any ideas would be  welcomed.

 thanks,

 Spencer

[[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
 and provide commented, minimal, self-contained, reproducible code.


__
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] Problem with the special argument '...' within a function

2006-08-17 Thread Jim Lemon
Hans-Joerg Bibiko wrote:
 Dear all,
 
 I wrote some functions using the special argument '...'. OK, it works.
 
 But if I call such a function which also called such a function, then  
 I get an error message about unused arguments.
 
 Here's an example:
 
 fun1 - function(x,a=1)
 {
   print(paste(x=,x))
   print(paste(a=,a))
 }
 fun2 - function(y,b=2)
 {
   print(paste(y=,y))
   print(paste(b=,b))
 }
 myfun - function(c, ...)
 {
   print(paste(c=,c))
   fun1(x=c,...)
   fun2(y=c,...)
 }
 
 This is OK.
   myfun(c=3)
 [1] c= 3
 [1] x= 3
 [1] a= 1
 [1] y= 3
 [1] b= 2
 
   myfun(c=3,a=4)
 [1] c= 3
 [1] x= 3
 [1] a= 4
 Error in fun2(y = c, ...) : unused argument(s) (a ...)
 
 I understand the error message because fun2 has no argument called 'a'.
 
 But how can I avoid this???
 
Try Ben Bolker's clean.args in the plotrix package
  myfun(clean.args(list(c=3,a=4),myfun))
[1] c= 3 c= 4
[1] x= 3 x= 4
[1] a= 1
[1] y= 3 y= 4
[1] b= 2

Jim

__
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] day, month, year functions

2006-08-17 Thread Martin Maechler
 Gregor == Gregor Gorjanc [EMAIL PROTECTED]
 on Fri, 11 Aug 2006 00:27:27 + (UTC) writes:

Gregor Gabor Grothendieck ggrothendieck at gmail.com writes:
 
 Here are three ways:
 
 xx - as.Date(2006-01-05)
 
 # 1. use as.POSIXlt
 as.POSIXlt(xx)$mday
 as.POSIXlt(xx)$mon + 1
 as.POSIXlt(xx)$year + 1900
 
 # 2. use format
 as.numeric(format(xx, %d))
 as.numeric(format(xx, %m))
 as.numeric(format(xx, %Y))
 
 # 3. use month.day.year in chron package
 library(chron)
 month.day.year(unclass(xx))$day
 month.day.year(unclass(xx))$month
 month.day.year(unclass(xx))$year

Gregor Hi,

Gregor it would really be great if there would be

Gregor sec(), min(), hour() day(), month(), year()

Gregor generic functions that would work on all date classes. Where
Gregor applicable of course. I imagine that argument to get out integer
Gregor or character would alse be nice.

I disagree pretty strongly:

- We definitely don't want min() to return minutes instead of
  minimum !

- Why pollute the namespace with 6 (well, actualy 5!) new
  function names, when  as.POSIXlt()  
  *REALLY* is there exactly for this purpose ???

I rather think the authors of each of the other old-fashioned
date classes should provide as.POSIXlt() methods for their
classes.

Then, we'd have uniform interfaces, following's Gabor's # 1.
above.

Martin Maechler, ETH Zurich

__
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] day, month, year functions

2006-08-17 Thread Gregor Gorjanc
Martin Maechler wrote:
 Gregor == Gregor Gorjanc [EMAIL PROTECTED]
 on Fri, 11 Aug 2006 00:27:27 + (UTC) writes:
 
 Gregor Gabor Grothendieck ggrothendieck at gmail.com writes:
  
  Here are three ways:
  
  xx - as.Date(2006-01-05)
  
  # 1. use as.POSIXlt
  as.POSIXlt(xx)$mday
  as.POSIXlt(xx)$mon + 1
  as.POSIXlt(xx)$year + 1900
  
  # 2. use format
  as.numeric(format(xx, %d))
  as.numeric(format(xx, %m))
  as.numeric(format(xx, %Y))
  
  # 3. use month.day.year in chron package
  library(chron)
  month.day.year(unclass(xx))$day
  month.day.year(unclass(xx))$month
  month.day.year(unclass(xx))$year
 
 Gregor Hi,
 
 Gregor it would really be great if there would be
 
 Gregor sec(), min(), hour() day(), month(), year()
 
 Gregor generic functions that would work on all date classes. Where
 Gregor applicable of course. I imagine that argument to get out integer
 Gregor or character would alse be nice.
 
 I disagree pretty strongly:
 
 - We definitely don't want min() to return minutes instead of
   minimum !
 

Pheu, a good catch. You are definitely right!

 - Why pollute the namespace with 6 (well, actualy 5!) new
   function names, when  as.POSIXlt()  
   *REALLY* is there exactly for this purpose ???

 I rather think the authors of each of the other old-fashioned
 date classes should provide as.POSIXlt() methods for their
 classes.
 
 Then, we'd have uniform interfaces, following's Gabor's # 1.
 above.

My proposal above was just a direction to a common way of dealing with
dates within R. If as.POSIXlt() methods is the way, that is perfectly
fine with me.

-- 
Lep pozdrav / With regards,
Gregor Gorjanc

--
University of Ljubljana PhD student
Biotechnical Faculty
Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan
Groblje 3   mail: gregor.gorjanc at bfro.uni-lj.si

SI-1230 Domzale tel: +386 (0)1 72 17 861
Slovenia, Europefax: +386 (0)1 72 17 888

--
One must learn by doing the thing; for though you think you know it,
 you have no certainty until you try. Sophocles ~ 450 B.C.

__
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] rpvm/snow packages on a cluster with dual-processor machi nes

2006-08-17 Thread Ramon Diaz-Uriarte
Dear Paul,

(I forgot to answer over the weekend). With mpi it is essentially the same. 
When using makeCluster, specify the number of slaves. If you have three 
machines, and you want each to run two slave processes, just use a 6.

Before that, though, you should tell LAM/MPI how to set up the lam universe. 
The simplest way is to specify that in a configuration file for LAM. Put 
something like this (using appropriate IPs or host names; cpu=xx indicates 
that you want each physical node to run those many xx slaves; it might, or 
might not, be related to the actual number of CPUs) in a file called, say, 
lamb-conf1.def

192.168.2.2 cpu=2
192.168.2.3 cpu=2
192.168.2.4 cpu=2



Now do (as user, NOT root)

lamboot -v lamb-conf1.def

If that works, then start R, and use snow. 

A very good explanation on how to use mpi with R appeared in R news a while 
ago by the author of Rmpi.


HTH,

R.



On Monday 14 August 2006 16:17, Liaw, Andy wrote:
 That's what I've tried before, on three dual-Xeon boxes, so I know it
 worked (as documented a that time).

 Andy

 From: Paul Y. Peng

  Luke Tierney just reminded me that makeCluster() can take a
  number greater than the number of machines in a cluster. It
  seems to be a solution to this problem. But I haven't tested it yet.
 
  Paul.
 
  Ryan Austin wrote:
   Hi,
  
   Adding a node twice gives a duplicate node error.
   However, adding the parameter sp=2000 to your pvm hostfile should
   enable dual processors.
  
   Ryan
  
   Liaw, Andy wrote:
   Caveat: I've only played with this a couple of years ago...
  
   I believe you can just add each host _twice_ (or as many
 
  times as the
 
   number of CPUs at that host) to get both CPUs to work.
  
   Andy
  
   From: Paul Y. Peng
  
   Hi,
  
   does anybody know how to use the dual processors in the
 
  machines of
 
   a cluster? I am using R with rpvm and snow packages. I
 
  usually start
 
   pvm daemon and add host machines first, and then run R to
 
  start my
 
   computing work. But I find that only one processor in
 
  each machine
 
   is used in this way and the other one always stays idle. Is there
   any simple way to tell pvm to use the two processors at the same
   time? In other words, I would like to see two copies of R
 
  running on
 
   each machine's two processors when using pvm. Any hints/help are
   greatly appreciated.
  
   Paul.
  
   __
   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.
  
   __
   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.
  
   __
   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.
 
  __
  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.

 __
 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.

-- 
Ramón Díaz-Uriarte
Bioinformatics 
Centro Nacional de Investigaciones Oncológicas (CNIO)
(Spanish National Cancer Center)
Melchor Fernández Almagro, 3
28029 Madrid (Spain)
Fax: +-34-91-224-6972
Phone: +-34-91-224-6900

http://ligarto.org/rdiaz
PGP KeyID: 0xE89B3462
(http://ligarto.org/rdiaz/0xE89B3462.asc)



**NOTA DE CONFIDENCIALIDAD** Este correo electrónico, y en s...{{dropped}}

__
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.


[R] tkinser

2006-08-17 Thread julie7\.josse
Dear list,

I 'd like to know if it is possible to delete my text window after running it??

I have add a Menu to my text window and so i can for example open a script; 
then i run it and i have my result on my R console.
But i'd like that after running, the code disappears automatically. i d'like 
something that clean my text window.

I have a second problem:

My text window and all my widgets are not fixed:

I use combo box, message box...and it always moves, it appears on the right of 
my screen, on the bottom..or on the bar tasks. I d'like my text window not move 
at all and after if it's possible that my widgets appear on the same place on 
my sreen.

When they appear on the bottom on my tasks bar, i have to open it each time...


Thanks a lot.
Julie.

Cet été, pensez aux cartes postales de laposte.net !


[[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
and provide commented, minimal, self-contained, reproducible code.


[R] NLME: Limitations of using identify to interact with scatterplots?

2006-08-17 Thread Greg Distiller
I have a quick question regarding the use of identify to interact with 
points on a scatterplot. My question is essentially: can identify be used 
when one is plotting model objects to generate diagnostic plots? 
Specifically I am using NLME.
For example, I am plotting the fitted values on the x axis vs a variable 
called log2game with the following code:

plot(D2C29.nlme, log2game ~ fitted(.), abline=c(0,1))

and then I have tried to use identify as follows:

identify(D2C29.nlme$fitted[,2],Data2$log2game,row.names(Data2))

(if I leave out the [,2] on the fitted attributes then I am told that x and 
y are not the same length and it appears that this is due to the fact that 
the fitted attribute has 2 columns.)

but I get an error message that plot.new has not been called yet.

I am not sure if this is because I am doing something wrong or if identify 
simply cannot be used in this context.

Many thanks

Greg

__
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] glmmPQL question!

2006-08-17 Thread Simon Wood
Will this do? best, Simon

## simulate some data...
set.seed(1)
joint - c(rep(1,20),rep(2,20),rep(3,20))
time - runif(60)+1
subject - factor(rep(1:12,rep(5,12)))
mu - time*joint
joint - factor(joint)
y - rgamma(mu,mu)

## fit model
b - glmmPQL(y~joint*time,random=~1|subject,family=Gamma(link=identity))

## extract fixed effect parameter estimates and covariance matrix
fix.b - b$coefficients$fixed
V.b - b$varFix

## Create a `prediction matrix'
pd - data.frame(time = rep(seq(1,2,length=100),3),
   joint=factor(c(rep(1,100),rep(2,100),rep(3,100

Xp - model.matrix(~joint*time,pd)

## use it to get predictions and associated standard errors
mu - Xp %*% fix.b
mu.se - diag(Xp%*%V.b%*%t(Xp))^.5 ## inefficient for readability
## check this is done right
range(mu - predict(b,pd,level=0))

## produce plot
plot(pd$time[1:100],mu[1:100],main=joint==1,type=l)
lines(pd$time[1:100],mu[1:100]+2*mu.se[1:100],lty=2)
lines(pd$time[1:100],mu[1:100]-2*mu.se[1:100],lty=3)



 [EMAIL PROTECTED] wrote:
  Hello Folks-
 
  Is there a way to create confidence bands with 'glmmPQL' ???
 
  I am performing a stroke study for Northwestern University in Chicago,
  Illinois.  I am trying to decide a way to best plot the model which we
  created with the glmmPQL function in R.   I would like to plot my actual
  averaged data points within 95 % confidence intervals from the model.
  Plotting the model is easy, but determining confidence bands is not.
 
  Here is my model:
 
  ratiomodel-glmmPQL(ratio~as.factor(joint)*time, random = ~ 1 | subject,
  family = Gamma(link = identity),alldata3)
 
  I am used to seeing confidence intervals from models that increase,
  “flair out” in the y direction, at the beginning and ending time points
  (x values) of the simulated data.  If I use 'lm' and pass the command
  'int = c ' 'to create this model I can easily find and plot this type
  of confidence band for 'ratio~time'.  But I need to take into account
  'as.factor(joint)', and in fact I can produce confidence bands with 'glm'
  by passing in 'se.fit = TRUE', but the problem is I need to make subject
  a random variable, and take into account my ratio with the Gamma
  distribution.
 
  Is there a way to create confidence bands with 'glmmPQL' ??? '
  as.factor(joint)' has 3 levels, so I would like to produce this linear
  model with three levels and confidence bands for comparison of the levels
  of 'joint'.
 
  Any Help at all with my problem would be greatly appreciated!!
  LJ
 
 
  
 
  __
  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.

 __
 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.

-- 
 Simon Wood, Mathematical Sciences, University of Bath, Bath, BA2 7AY UK
 +44 1225 386603  www.maths.bath.ac.uk/~sw283

__
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] Specifying Path Model in SEM for CFA

2006-08-17 Thread Rick Bilonick
On Wed, 2006-08-16 at 17:01 -0400, John Fox wrote:
 Dear Rick,
 
 It's unclear to me what you mean by constraining each column of the factor
 matrix to sum to one. If you intend to constrain the loadings on each
 factor to sum to one, sem() won't do that, since it supports only equality
 constraints, not general linear constraints on parameters of the model, but
 why such a constraint would be reasonable in the first place escapes me.
 More common in confirmatory factor analysis would be to constrain more of
 the loadings to zero. Of course, one would do this only if it made
 substantive sense in the context of the research.
 
 Regards,
  John
 
 
 John Fox
 Department of Sociology
 McMaster University
 Hamilton, Ontario
 Canada L8S 4M4
 905-525-9140x23604
 http://socserv.mcmaster.ca/jfox 
  

I'm trying to build a multivariate receptor model as described by
Christensen and Sain (Technometrics, vol 44 (4) pp. 328-337). The model
is

x_t = Af_t + e_t

where A is the matrix of nonnegative source compositions, x_t are the
observed pollutant concentrations at time t, and f_t are the unobserved
factors. The columns of A are supposed to sum to no more than 100%. They
say they are using a latent variable model. If sem can't handle this, do
you know of another R package that could?

Rick B.

__
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] tkinser

2006-08-17 Thread John Fox
Dear Julie,


 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of julie7.josse
 Sent: Thursday, August 17, 2006 4:01 AM
 To: r-help
 Subject: [R] tkinser
 Importance: High
 
 Dear list,
 
 I 'd like to know if it is possible to delete my text window 
 after running it??
 
 I have add a Menu to my text window and so i can for example 
 open a script; then i run it and i have my result on my R console.
 But i'd like that after running, the code disappears 
 automatically. i d'like something that clean my text window.


I think that what you mean is that you'd like to delete the text in the
window rather than the window itself. If the text widget is called txt, then
you can do 

tkdelete(txt, 0.0, end) 


 I have a second problem:
 
 My text window and all my widgets are not fixed:
 
 I use combo box, message box...and it always moves, it 
 appears on the right of my screen, on the bottom..or on the 
 bar tasks. I d'like my text window not move at all and after 
 if it's possible that my widgets appear on the same place on my sreen.
 
 When they appear on the bottom on my tasks bar, i have to 
 open it each time...
 

If the top-level Tk window is named top, then, after creating the window,
e.g., tkwm.geometry(tt, -100+100) will position it 100 pixels 100 pixels
from the right top corner of the display.

More generally, I found it useful to read Welch, Jones, and Hobbs, Practical
Programming in Tcl and Tk, to learn these kinds of things.

I hope this helps,
 John

 
 Thanks a lot.
 Julie.
 
 Cet iti, pensez aux cartes postales de laposte.net !
 
 
   [[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Specifying Path Model in SEM for CFA

2006-08-17 Thread John Fox
Dear Rick,


 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Rick Bilonick
 Sent: Thursday, August 17, 2006 7:07 AM
 To: John Fox
 Cc: 'R Help'; 'Rick Bilonick'
 Subject: Re: [R] Specifying Path Model in SEM for CFA
 

. . .

 
 I'm trying to build a multivariate receptor model as 
 described by Christensen and Sain (Technometrics, vol 44 (4) 
 pp. 328-337). The model is
 
 x_t = Af_t + e_t
 
 where A is the matrix of nonnegative source compositions, x_t 
 are the observed pollutant concentrations at time t, and f_t 
 are the unobserved factors. The columns of A are supposed to 
 sum to no more than 100%. They say they are using a latent 
 variable model. If sem can't handle this, do you know of 
 another R package that could?
 

sem() handles only equality constraints among parameters, and this model
requires linear inequality constraints. 

I'm aware of SEM software that handles inequality constraints, but I'm not
aware of anything in R that will do it out of the box. One possibility is
to write out the likelihood (or fitting function) for your model and
perform a bounded optimization using optim(). It would probably be a fair
amount of work setting up the problem.

Finally, there are tricks that permit the imposition of general constraints
and inequality constraints using software, like sem(), that handles only
equality constraints. It's probably possible to do what you want using such
a trick, but it would be awkward. See the references given in Bollen,
Structural Equations with Latent Variables (Wiley, 1989), pp. 401-403.

I'm sorry that I can't be of more direct help.
 John

__
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] Plots Without Displaying

2006-08-17 Thread Lothar Botelho-Machado
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Thank you,

It seems that a list of plots is just possible using lattice plots. But
that's a good keyword for me to look for, I appreciate your help!

Lothar


Christos Hatzis wrote:
 Yes, you can do that for lattice-based plots.  The functions in the lattice
 package produce objects of class trellis which can be stored in a list and
 processed or updated at a later time:
 
 library(lattice)
 attach(barley)
 plotList - list(length=3)
 plotList[[1]] - xyplot(yield ~ site, data=barley)
 plotList[[2]] - xyplot(yield ~ variety, data=barley) 
 plotList[[3]] - xyplot(yield ~ year, data=barley)
 
 plotList
 plotList[[3]] - update(plotList[[3]], yaxis=Yield (bushels/acre))
 print(plotList[[3]])
 
 Obviously, you can store any lattice-based plot in the list.
 
 HTH.
 
 -Christos
 
 Christos Hatzis, Ph.D.
 Nuvera Biosciences, Inc.
 400 West Cummings Park
 Suite 5350
 Woburn, MA 01801
 Tel: 781-938-3830
 www.nuverabio.com
  
 
 
 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Lothar
 Botelho-Machado
 Sent: Wednesday, August 16, 2006 4:49 PM
 To: r-help@stat.math.ethz.ch
 Subject: Re: [R] Plots Without Displaying
 
 Prof Brian Ripley wrote:
 Yes, see

 ?jpeg
 ?bitmap

 and as you didn't tell us your OS we don't know if these are available 
 to you.

 jpeg(file=test.jpg)
 boxplot(sample(100))
 dev.off()

 may well work.

 'An Introduction to R' explains about graphics devices, including these.


 On Wed, 16 Aug 2006, Lothar Botelho-Machado wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 R Help Mailing List,


 I'd like to generate a plot that I could display and/or store it as e.g.
 jpeg. But unfortunately always a plotting window opens. Is it 
 possible to prevent that?

 I tried the following:
 R bp-boxplot( sample(100), plot=FALSE)

 This works somehow, but it only stores data (as discribed in the 
 help) in bp and it is not possible afaik to display bp later on or 
 store them as a jpeg.

 The next:
 R p-plot(sample(100), sample(100), plot=FALSE)
 ..and also a variant using jpeg() didn't work at all.

 Is there a way to generally store the plots as object, without 
 displaying them, or perhaps directly saving them to disc as jpeg?

 A Yes or No or any further help/links are appreciated!!!

 
 
 
 Thank you for the explanation and your patience in answering me this
 obviously very simple question!!
 
 Originally I tried to store plots directly in a list. So writing them
 directly to disc was just a good alternative. I knew that that jpeg()
 provides functionality for that, but didn't use it correctly.
 
 Hence, is it also possible to store a plot in a list, somehow?
 
 Kind regards,
  Lothar

__
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.





-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFE5HU1HRf7N9c+X7sRAguEAJ4855nuonJaB9VXHkGOr/SZhqow8wCfXcuB
o8oqpYoJ7MXgnVtnuGAE5Yk=
=ZWgN
-END PGP SIGNATURE-

__
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] NLME: Limitations of using identify to interact with scatterplots?

2006-08-17 Thread Douglas Bates
Most plotting functions in the nlme package use lattice graphics
functions based on the grid package.  Identify will not work with
lattice graphics.  I'm not sure if there is a replacement.

On 8/17/06, Greg Distiller [EMAIL PROTECTED] wrote:
 I have a quick question regarding the use of identify to interact with
 points on a scatterplot. My question is essentially: can identify be used
 when one is plotting model objects to generate diagnostic plots?
 Specifically I am using NLME.
 For example, I am plotting the fitted values on the x axis vs a variable
 called log2game with the following code:

 plot(D2C29.nlme, log2game ~ fitted(.), abline=c(0,1))

 and then I have tried to use identify as follows:

 identify(D2C29.nlme$fitted[,2],Data2$log2game,row.names(Data2))

 (if I leave out the [,2] on the fitted attributes then I am told that x and
 y are not the same length and it appears that this is due to the fact that
 the fitted attribute has 2 columns.)

 but I get an error message that plot.new has not been called yet.

 I am not sure if this is because I am doing something wrong or if identify
 simply cannot be used in this context.

 Many thanks

 Greg

 __
 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.


__
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] Plots Without Displaying

2006-08-17 Thread Gabor Grothendieck
Also check out the displaylist:

http://tolstoy.newcastle.edu.au/R/help/04/05/0817.html

On 8/17/06, Lothar Botelho-Machado [EMAIL PROTECTED] wrote:
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1

 Thank you,

 It seems that a list of plots is just possible using lattice plots. But
 that's a good keyword for me to look for, I appreciate your help!

 Lothar


 Christos Hatzis wrote:
  Yes, you can do that for lattice-based plots.  The functions in the lattice
  package produce objects of class trellis which can be stored in a list and
  processed or updated at a later time:
 
  library(lattice)
  attach(barley)
  plotList - list(length=3)
  plotList[[1]] - xyplot(yield ~ site, data=barley)
  plotList[[2]] - xyplot(yield ~ variety, data=barley)
  plotList[[3]] - xyplot(yield ~ year, data=barley)
 
  plotList
  plotList[[3]] - update(plotList[[3]], yaxis=Yield (bushels/acre))
  print(plotList[[3]])
 
  Obviously, you can store any lattice-based plot in the list.
 
  HTH.
 
  -Christos
 
  Christos Hatzis, Ph.D.
  Nuvera Biosciences, Inc.
  400 West Cummings Park
  Suite 5350
  Woburn, MA 01801
  Tel: 781-938-3830
  www.nuverabio.com
 
 
 
  -Original Message-
  From: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED] On Behalf Of Lothar
  Botelho-Machado
  Sent: Wednesday, August 16, 2006 4:49 PM
  To: r-help@stat.math.ethz.ch
  Subject: Re: [R] Plots Without Displaying
 
  Prof Brian Ripley wrote:
  Yes, see
 
  ?jpeg
  ?bitmap
 
  and as you didn't tell us your OS we don't know if these are available
  to you.
 
  jpeg(file=test.jpg)
  boxplot(sample(100))
  dev.off()
 
  may well work.
 
  'An Introduction to R' explains about graphics devices, including these.
 
 
  On Wed, 16 Aug 2006, Lothar Botelho-Machado wrote:
 
  -BEGIN PGP SIGNED MESSAGE-
  Hash: SHA1
 
  R Help Mailing List,
 
 
  I'd like to generate a plot that I could display and/or store it as e.g.
  jpeg. But unfortunately always a plotting window opens. Is it
  possible to prevent that?
 
  I tried the following:
  R bp-boxplot( sample(100), plot=FALSE)
 
  This works somehow, but it only stores data (as discribed in the
  help) in bp and it is not possible afaik to display bp later on or
  store them as a jpeg.
 
  The next:
  R p-plot(sample(100), sample(100), plot=FALSE)
  ..and also a variant using jpeg() didn't work at all.
 
  Is there a way to generally store the plots as object, without
  displaying them, or perhaps directly saving them to disc as jpeg?
 
  A Yes or No or any further help/links are appreciated!!!
 
 
 
 
  Thank you for the explanation and your patience in answering me this
  obviously very simple question!!
 
  Originally I tried to store plots directly in a list. So writing them
  directly to disc was just a good alternative. I knew that that jpeg()
  provides functionality for that, but didn't use it correctly.
 
  Hence, is it also possible to store a plot in a list, somehow?
 
  Kind regards,
   Lothar

 __
 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.





 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.3 (GNU/Linux)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

 iD8DBQFE5HU1HRf7N9c+X7sRAguEAJ4855nuonJaB9VXHkGOr/SZhqow8wCfXcuB
 o8oqpYoJ7MXgnVtnuGAE5Yk=
 =ZWgN
 -END PGP SIGNATURE-

 __
 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.


__
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] fitting truncated normal distribution

2006-08-17 Thread Sundar Dorai-Raj
Hi, Markus,

Are these always integers? Why do you think they should be normal or 
Weibull? Seems more like a mixture with a point mass at 0 and something 
else (e.g. Poisson, negative binomial, normal). Though it's hard to tell 
with what you have provided. If that's the case you'll have to write 
your own likelihood function or, if they are integers, use zip 
(zero-inflated Poisson) or zinb (zero-inflated negative binomial). Do an 
RSiteSearch to find many packages will do these fits.

RSiteSearch(zero-inflated)

Again, this is pure speculation based on your x below alone and no 
other information (I'm not sure what demand-data means).

HTH,

--sundar

Schweitzer, Markus wrote:
 Sorry, that I forgot an example.
 
 I have demand-data which is either 0 or a positive value.
 
 When I have an article which is not ordered very often, it could look
 like this:
 
 x=c(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1280,0,0,0,0,640,0,0
 ,0,0,0,0,0,0,0)
 
 
 
library(MASS) ## for fitdistr
library(msm) ## for dtnorm

dtnorm0 - function(x, mean = 0, sd = 1, log = FALSE) {
   dtnorm(x, mean, sd, 0, Inf, log)
}
fitdistr(x,dtnorm0,start=list(mean=0,sd=1))
 
 
 Unfortunately I get the same error message.
 I found a function, that works for a weibull distribution and tried to
 apply it but it didn't work neither
 
 # truncated weibull distribution
 
 #dweibull.trunc -
 #function(x, shape, scale=1, trunc.=Inf, log=FALSE){
 #ln.dens - (dweibull(x, shape, scale, log=TRUE)
 #-pweibull(trunc., shape, scale = 1, lower.tail = TRUE, log.p = 
 #TRUE))
 #if(any(oops - (xtrunc.)))
 #ln.dens[oops] - (-Inf)   
 #if(log)ln.dens else exp(ln.dens)
 #}
 #
 #x - rweibull(100, 1)
 #range(x)
 #x4 - x[x=4]
 #fitdistr(x4, dweibull.trunc, start=list(shape=1, scale=1), trunc=4)
 
 
 
 # truncated normal distribution
 
 dtnorm0 - function(x, mean, sd, a=0, log = FALSE) {
 ln.dens - (dnorm(x, mean, sd)
 - pnorm(a, mean, sd, lower.tail=TRUE, log.p =TRUE))
 
 if(any(oops - (xa)))
   ln.dens[oops] - (-Inf)
 if(log)ln.dens else exp(ln.dens)
 }
 
 fitdistr(x, dtnorm0, start = list(mean = 0, sd = 1))
 
 Maybe, when I alter mean and sd, I get an answer, which is not really
 satisfactory. I hope, there is a solution possible
 And thank you in advance
 
 markus
 
 
 
 
 
 
 
 Sorry, didn't notice that you *did* mention dtnorm is part of msm. 
 Ignore that part of the advice...
 
 --sundar
 
 Sundar Dorai-Raj wrote:
 
[EMAIL PROTECTED] wrote:


Hello,
I am a new user of R and found the function dtnorm() in the package
 
 msm.
 
My problem now is, that it is not possible for me to get the mean and
 
 sd out of a sample when I want a left-truncated normal distribution
 starting at 0.
 
fitdistr(x,dtnorm, start=list(mean=0, sd=1))

returns the error message 
Fehler in [-(`*tmp*`, x = lower  x = upper, value = numeric(0))
 
 :nichts zu ersetzen
 
I don't know, where to enter the lower/upper value. Is there a
 
 possibility to program the dtnorm function by myself?
 
Thank you very much in advance for your help, markus

---
Versendet durch aonWebmail (webmail.aon.at)


__
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.


Hi, Markus,

You should always supply the package name where dtnorm is located. My 
guess is most don't know (as I didn't) it is part of the msm package.
Also, you should supply a reproducible example so others may 
understand your particular problem. For example, when I ran your code 
on data generated from rtnorm (also part of msm) I got warnings 
related to the NaNs generated in pnorm and qnorm, but no error as you 
reported. Both of these suggestions are in the posting guide (see
 
 signature above).
 
So, to answer your problem, here's a quick example.

library(MASS) ## for fitdistr
library(msm) ## for dtnorm

dtnorm0 - function(x, mean = 0, sd = 1, log = FALSE) {
   dtnorm(x, mean, sd, 0, Inf, log)
}

set.seed(1) ## to others may reproduce my results exactly x - 
rtnorm(100, lower = 0) fitdistr(x, dtnorm0, start = list(mean = 0, sd 
= 1))

Note, the help page ?fitdistr suggests additional parameters may be 
passed to the density function (i.e. dtnorm) or optim. However, this 
won't work here because lower is an argument for both functions. 
This is the reason for writing dtnorm0 which has neither a lower or an
 
 
upper argument.

HTH,

--sundar

__
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] Plots Without Displaying

2006-08-17 Thread Prof Brian Ripley
On Thu, 17 Aug 2006, Lothar Botelho-Machado wrote:

 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 Thank you,
 
 It seems that a list of plots is just possible using lattice plots. But
 that's a good keyword for me to look for, I appreciate your help!

Actually, that is not a list of *plots*.  The objects stored there are 
more sets of instructions to the print method of what to plot, and you can 
do that for any type of plot.

It is possible to store low-level descriptions of plots and replay them: 
see recordPlot and replayPlot.  BUT, it is preferable to run the 
expressions to create the plot on the new device.


 Christos Hatzis wrote:
  Yes, you can do that for lattice-based plots.  The functions in the lattice
  package produce objects of class trellis which can be stored in a list and
  processed or updated at a later time:
  
  library(lattice)
  attach(barley)
  plotList - list(length=3)
  plotList[[1]] - xyplot(yield ~ site, data=barley)
  plotList[[2]] - xyplot(yield ~ variety, data=barley) 
  plotList[[3]] - xyplot(yield ~ year, data=barley)
  
  plotList
  plotList[[3]] - update(plotList[[3]], yaxis=Yield (bushels/acre))
  print(plotList[[3]])
  
  Obviously, you can store any lattice-based plot in the list.
  
  HTH.
  
  -Christos
  
  Christos Hatzis, Ph.D.
  Nuvera Biosciences, Inc.
  400 West Cummings Park
  Suite 5350
  Woburn, MA 01801
  Tel: 781-938-3830
  www.nuverabio.com
   
  
  
  -Original Message-
  From: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED] On Behalf Of Lothar
  Botelho-Machado
  Sent: Wednesday, August 16, 2006 4:49 PM
  To: r-help@stat.math.ethz.ch
  Subject: Re: [R] Plots Without Displaying
  
  Prof Brian Ripley wrote:
  Yes, see
 
  ?jpeg
  ?bitmap
 
  and as you didn't tell us your OS we don't know if these are available 
  to you.
 
  jpeg(file=test.jpg)
  boxplot(sample(100))
  dev.off()
 
  may well work.
 
  'An Introduction to R' explains about graphics devices, including these.
 
 
  On Wed, 16 Aug 2006, Lothar Botelho-Machado wrote:
 
  -BEGIN PGP SIGNED MESSAGE-
  Hash: SHA1
 
  R Help Mailing List,
 
 
  I'd like to generate a plot that I could display and/or store it as e.g.
  jpeg. But unfortunately always a plotting window opens. Is it 
  possible to prevent that?
 
  I tried the following:
  R bp-boxplot( sample(100), plot=FALSE)
 
  This works somehow, but it only stores data (as discribed in the 
  help) in bp and it is not possible afaik to display bp later on or 
  store them as a jpeg.
 
  The next:
  R p-plot(sample(100), sample(100), plot=FALSE)
  ..and also a variant using jpeg() didn't work at all.
 
  Is there a way to generally store the plots as object, without 
  displaying them, or perhaps directly saving them to disc as jpeg?
 
  A Yes or No or any further help/links are appreciated!!!
 
  
  
  
  Thank you for the explanation and your patience in answering me this
  obviously very simple question!!
  
  Originally I tried to store plots directly in a list. So writing them
  directly to disc was just a good alternative. I knew that that jpeg()
  provides functionality for that, but didn't use it correctly.
  
  Hence, is it also possible to store a plot in a list, somehow?
  
  Kind regards,
   Lothar
 
 __
 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.
 
 
 
 
 
 -BEGIN PGP SIGNATURE-
 Version: GnuPG v1.4.3 (GNU/Linux)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
 
 iD8DBQFE5HU1HRf7N9c+X7sRAguEAJ4855nuonJaB9VXHkGOr/SZhqow8wCfXcuB
 o8oqpYoJ7MXgnVtnuGAE5Yk=
 =ZWgN
 -END PGP SIGNATURE-
 
 __
 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.
 

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
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] Variance Components in R

2006-08-17 Thread Iuri Gavronski
Thank you for your reply.
VARCOMP is available at SPSS advanced models, I'm not sure for how long it
exists... I only work with SPSS for the last 4 years...
My model only has crossed random effects, what perhaps would drive me to
lmer().
However, as I have unbalanced data (why it is normally called 'unbalanced
design'? the data was not intended to be unbalanced, only I could not get
responses for all cells...), I'm afraid that REML would take too much CPU,
memory and time to execute, and MINQUE would be faster and provide similar
variance estimates (please, correct me if I'm wrong on that point).
I only found MINQUE on the maanova package, but as my study is very far from
genetics, I'm not sure I can use this package.
Any comment would be appreciated.
Iuri

On 8/16/06, Spencer Graves [EMAIL PROTECTED] wrote:

   I used SPSS over 25 years ago, but I don't recall ever fitting a
 variance components model with it.  Are all your random effects nested?
 If they were, I would recommend you use 'lme' in the 'nlme' package.
 However, if you have crossed random effects, I suggest you try 'lmer'
 associated with the 'lme4' package.

   For 'lmer', documentation is available in Douglas Bates. Fitting
 linear mixed models in R. /R News/, 5(1):27-30, May 2005
 (www.r-project.org - newsletter).  I also recommend you try the
 vignette available with the 'mlmRev' package (see, e.g.,
 http://finzi.psych.upenn.edu/R/Rhelp02a/archive/81375.html).

Excellent documentation for both 'lme' (and indirectly for
 'lmer') is available in Pinheiro and Bates (2000) Mixed-Effects Models
 in S and S-Plus (Springer).  I have personally recommended this book so
 many times on this listserve that I just now got 234 hits for
 RSiteSearch(graves pinheiro).  Please don't hesitate to pass this
 recommendation to your university library.  This book is the primary
 documentation for the 'nlme' package, which is part of the standard R
 distribution.  A subdirectory ~library\nlme\scripts of your R
 installation includes files named ch01.R, ch02.R, ..., ch06.R,
 ch08.R, containing the R scripts described in the book.  These R
 script files make it much easier and more enjoyable to study that book,
 because they make it much easier to try the commands described in the
 book, one line at a time, testing modifications to check you
 comprehension, etc.  In addition to avoiding problems with typographical
 errors, it also automatically overcomes a few minor but substantive
 changes in the notation between S-Plus and R.

   Also, the MINQUE method has been obsolete for over 25 years.  I
 recommend you use method = REML except for when you want to compare
 two nested models with different fixed effects;  in that case, you
 should use method = ML, as explained in Pinheiro and Bates (2000).

   Hope this helps.
   Spencer Graves

 Iuri Gavronski wrote:
  Hi,
 
  I'm trying to fit a model using variance components in R, but if very
  new on it, so I'm asking for your help.
 
  I have imported the SPSS database onto R, but I don't know how to
  convert the commands... the SPSS commands I'm trying to convert are:
  VARCOMP
 RATING BY CHAIN SECTOR RESP ASPECT ITEM
 /RANDOM = CHAIN SECTOR RESP ASPECT ITEM
 /METHOD = MINQUE (1)
 /DESIGN = CHAIN SECTOR RESP ASPECT ITEM
 SECTOR*RESP SECTOR*ASPECT SECTOR*ITEM CHAIN*RESP
  CHAIN*ASPECT CHAIN*ITEM RESP*ASPECT RESP*ITEM
 SECTOR*RESP*ASPECT SECTOR*RESP*ITEM CHAIN*RESP*ASPECT
 /INTERCEPT = INCLUDE.
 
  VARCOMP
 RATING BY CHAIN SECTOR RESP ASPECT ITEM
 /RANDOM = CHAIN SECTOR RESP ASPECT ITEM
 /METHOD = REML
 /DESIGN = CHAIN SECTOR RESP ASPECT ITEM
 SECTOR*RESP SECTOR*ASPECT SECTOR*ITEM CHAIN*RESP
  CHAIN*ASPECT CHAIN*ITEM RESP*ASPECT RESP*ITEM
 SECTOR*RESP*ASPECT SECTOR*RESP*ITEM CHAIN*RESP*ASPECT
 /INTERCEPT = INCLUDE.
 
  Thank you for your help.
 
  Best regards,
 
  Iuri.
 
  ___
  Iuri Gavronski - [EMAIL PROTECTED]
  doutorando
  UFRGS/PPGA/NITEC - www.ppga.ufrgs.br
  Brazil
 
  __
  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.
 


[[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Variance Components in R

2006-08-17 Thread Doran, Harold
Iuri:

The lmer function is optimal for large data with crossed random effects.
How large are your data?

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Iuri Gavronski
 Sent: Thursday, August 17, 2006 11:08 AM
 To: Spencer Graves
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] Variance Components in R
 
 Thank you for your reply.
 VARCOMP is available at SPSS advanced models, I'm not sure 
 for how long it exists... I only work with SPSS for the last 
 4 years...
 My model only has crossed random effects, what perhaps would 
 drive me to lmer().
 However, as I have unbalanced data (why it is normally called 
 'unbalanced design'? the data was not intended to be 
 unbalanced, only I could not get responses for all cells...), 
 I'm afraid that REML would take too much CPU, memory and time 
 to execute, and MINQUE would be faster and provide similar 
 variance estimates (please, correct me if I'm wrong on that point).
 I only found MINQUE on the maanova package, but as my study 
 is very far from genetics, I'm not sure I can use this package.
 Any comment would be appreciated.
 Iuri
 
 On 8/16/06, Spencer Graves [EMAIL PROTECTED] wrote:
 
I used SPSS over 25 years ago, but I don't recall 
 ever fitting a 
  variance components model with it.  Are all your random 
 effects nested?
  If they were, I would recommend you use 'lme' in the 'nlme' package.
  However, if you have crossed random effects, I suggest you 
 try 'lmer'
  associated with the 'lme4' package.
 
For 'lmer', documentation is available in Douglas 
 Bates. Fitting 
  linear mixed models in R. /R News/, 5(1):27-30, May 2005 
  (www.r-project.org - newsletter).  I also recommend you try the 
  vignette available with the 'mlmRev' package (see, e.g., 
  http://finzi.psych.upenn.edu/R/Rhelp02a/archive/81375.html).
 
 Excellent documentation for both 'lme' (and indirectly for
  'lmer') is available in Pinheiro and Bates (2000) 
 Mixed-Effects Models 
  in S and S-Plus (Springer).  I have personally recommended 
 this book 
  so many times on this listserve that I just now got 234 hits for 
  RSiteSearch(graves pinheiro).  Please don't hesitate to pass this 
  recommendation to your university library.  This book is 
 the primary 
  documentation for the 'nlme' package, which is part of the 
 standard R 
  distribution.  A subdirectory ~library\nlme\scripts of your R 
  installation includes files named ch01.R, ch02.R, ..., 
 ch06.R, 
  ch08.R, containing the R scripts described in the book.  These R 
  script files make it much easier and more enjoyable to study that 
  book, because they make it much easier to try the commands 
 described 
  in the book, one line at a time, testing modifications to check you 
  comprehension, etc.  In addition to avoiding problems with 
  typographical errors, it also automatically overcomes a few 
 minor but 
  substantive changes in the notation between S-Plus and R.
 
Also, the MINQUE method has been obsolete for over 
 25 years.  
  I recommend you use method = REML except for when you want to 
  compare two nested models with different fixed effects;  in 
 that case, 
  you should use method = ML, as explained in Pinheiro and 
 Bates (2000).
 
Hope this helps.
Spencer Graves
 
  Iuri Gavronski wrote:
   Hi,
  
   I'm trying to fit a model using variance components in R, but if 
   very new on it, so I'm asking for your help.
  
   I have imported the SPSS database onto R, but I don't know how to 
   convert the commands... the SPSS commands I'm trying to 
 convert are:
   VARCOMP
  RATING BY CHAIN SECTOR RESP ASPECT ITEM
  /RANDOM = CHAIN SECTOR RESP ASPECT ITEM
  /METHOD = MINQUE (1)
  /DESIGN = CHAIN SECTOR RESP ASPECT ITEM
  SECTOR*RESP SECTOR*ASPECT SECTOR*ITEM CHAIN*RESP 
   CHAIN*ASPECT CHAIN*ITEM RESP*ASPECT RESP*ITEM
  SECTOR*RESP*ASPECT SECTOR*RESP*ITEM 
 CHAIN*RESP*ASPECT
  /INTERCEPT = INCLUDE.
  
   VARCOMP
  RATING BY CHAIN SECTOR RESP ASPECT ITEM
  /RANDOM = CHAIN SECTOR RESP ASPECT ITEM
  /METHOD = REML
  /DESIGN = CHAIN SECTOR RESP ASPECT ITEM
  SECTOR*RESP SECTOR*ASPECT SECTOR*ITEM CHAIN*RESP 
   CHAIN*ASPECT CHAIN*ITEM RESP*ASPECT RESP*ITEM
  SECTOR*RESP*ASPECT SECTOR*RESP*ITEM 
 CHAIN*RESP*ASPECT
  /INTERCEPT = INCLUDE.
  
   Thank you for your help.
  
   Best regards,
  
   Iuri.
  
   ___
   Iuri Gavronski - [EMAIL PROTECTED]
   doutorando
   UFRGS/PPGA/NITEC - www.ppga.ufrgs.br Brazil
  
   __
   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.
  
 
 
   [[alternative HTML version deleted]]
 
 

Re: [R] Variance Components in R

2006-08-17 Thread Doran, Harold
This will (should) be a piece of cake for lmer. But, I don't speak SPSS.
Can you write your model out as a linear model and give a brief
description of the data and your problem?
 
In addition to what Spencer noted as help below, you should also check
out the vignette in the mlmRev package. This will give you many
examples.
 
vignette('MlmSoftRev')
 
 
 




From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Iuri Gavronski
Sent: Thursday, August 17, 2006 11:16 AM
To: Doran, Harold
Subject: Re: [R] Variance Components in R


9500 records. It didn`t run in SPSS or SAS on Windows machines,
so I am trying to convert the SPSS script to R to run in a RISC station
at the university.


On 8/17/06, Doran, Harold [EMAIL PROTECTED] wrote: 

Iuri: 

The lmer function is optimal for large data with crossed
random effects.
How large are your data?

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of
Iuri Gavronski
 Sent: Thursday, August 17, 2006 11:08 AM
 To: Spencer Graves
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] Variance Components in R

 Thank you for your reply.
 VARCOMP is available at SPSS advanced models, I'm not
sure 
 for how long it exists... I only work with SPSS for
the last
 4 years...
 My model only has crossed random effects, what perhaps
would
 drive me to lmer().
 However, as I have unbalanced data (why it is normally
called 
 'unbalanced design'? the data was not intended to be
 unbalanced, only I could not get responses for all
cells...),
 I'm afraid that REML would take too much CPU, memory
and time
 to execute, and MINQUE would be faster and provide
similar 
 variance estimates (please, correct me if I'm wrong on
that point).
 I only found MINQUE on the maanova package, but as my
study
 is very far from genetics, I'm not sure I can use this
package.
 Any comment would be appreciated. 
 Iuri

 On 8/16/06, Spencer Graves [EMAIL PROTECTED]
wrote:
 
I used SPSS over 25 years ago, but I don't
recall
 ever fitting a
  variance components model with it.  Are all your
random
 effects nested?
  If they were, I would recommend you use 'lme' in the
'nlme' package.
  However, if you have crossed random effects, I
suggest you 
 try 'lmer'
  associated with the 'lme4' package.
 
For 'lmer', documentation is available in
Douglas
 Bates. Fitting
  linear mixed models in R. /R News/, 5(1):27-30, May
2005 
  (www.r-project.org - newsletter).  I also recommend
you try the
  vignette available with the 'mlmRev' package (see,
e.g.,
 
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/81375.html).
 
 Excellent documentation for both 'lme' (and
indirectly for
  'lmer') is available in Pinheiro and Bates (2000)
 Mixed-Effects Models
  in S and S-Plus (Springer).  I have personally
recommended
 this book
  so many times on this listserve that I just now got
234 hits for
  RSiteSearch(graves pinheiro).  Please don't
hesitate to pass this 
  recommendation to your university library.  This
book is
 the primary
  documentation for the 'nlme' package, which is part
of the
 standard R
  distribution.  A subdirectory
~library\nlme\scripts of your R 
  installation includes files named ch01.R,
ch02.R, ...,
 ch06.R,
  ch08.R, containing the R scripts described in the
book.  These R
  script files make it much easier and more enjoyable
to study that 
  book, because they make it much easier to try the
commands
 described
  in the book, one line at a time, testing
modifications to check you
  comprehension, etc.  In addition to avoiding
problems with 
  typographical errors, it also automatically
overcomes a few
 minor but
  substantive changes in the notation between S-Plus
and R.
 

[R] Fwd: Variance Components in R

2006-08-17 Thread Iuri Gavronski
9500 records. It didn`t run in SPSS or SAS on Windows machines, so I am
trying to convert the SPSS script to R to run in a RISC station at the
university.

On 8/17/06, Doran, Harold [EMAIL PROTECTED] wrote:

 Iuri:

 The lmer function is optimal for large data with crossed random effects.
 How large are your data?

  -Original Message-
  From: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED] On Behalf Of Iuri Gavronski
  Sent: Thursday, August 17, 2006 11:08 AM
  To: Spencer Graves
  Cc: r-help@stat.math.ethz.ch
  Subject: Re: [R] Variance Components in R
 
  Thank you for your reply.
  VARCOMP is available at SPSS advanced models, I'm not sure
  for how long it exists... I only work with SPSS for the last
  4 years...
  My model only has crossed random effects, what perhaps would
  drive me to lmer().
  However, as I have unbalanced data (why it is normally called
  'unbalanced design'? the data was not intended to be
  unbalanced, only I could not get responses for all cells...),
  I'm afraid that REML would take too much CPU, memory and time
  to execute, and MINQUE would be faster and provide similar
  variance estimates (please, correct me if I'm wrong on that point).
  I only found MINQUE on the maanova package, but as my study
  is very far from genetics, I'm not sure I can use this package.
  Any comment would be appreciated.
  Iuri
 
  On 8/16/06, Spencer Graves [EMAIL PROTECTED] wrote:
  
 I used SPSS over 25 years ago, but I don't recall
  ever fitting a
   variance components model with it.  Are all your random
  effects nested?
   If they were, I would recommend you use 'lme' in the 'nlme' package.
   However, if you have crossed random effects, I suggest you
  try 'lmer'
   associated with the 'lme4' package.
  
 For 'lmer', documentation is available in Douglas
  Bates. Fitting
   linear mixed models in R. /R News/, 5(1):27-30, May 2005
   (www.r-project.org - newsletter).  I also recommend you try the
   vignette available with the 'mlmRev' package (see, e.g.,
   http://finzi.psych.upenn.edu/R/Rhelp02a/archive/81375.html).
  
  Excellent documentation for both 'lme' (and indirectly for
   'lmer') is available in Pinheiro and Bates (2000)
  Mixed-Effects Models
   in S and S-Plus (Springer).  I have personally recommended
  this book
   so many times on this listserve that I just now got 234 hits for
   RSiteSearch(graves pinheiro).  Please don't hesitate to pass this
   recommendation to your university library.  This book is
  the primary
   documentation for the 'nlme' package, which is part of the
  standard R
   distribution.  A subdirectory ~library\nlme\scripts of your R
   installation includes files named ch01.R, ch02.R, ...,
  ch06.R,
   ch08.R, containing the R scripts described in the book.  These R
   script files make it much easier and more enjoyable to study that
   book, because they make it much easier to try the commands
  described
   in the book, one line at a time, testing modifications to check you
   comprehension, etc.  In addition to avoiding problems with
   typographical errors, it also automatically overcomes a few
  minor but
   substantive changes in the notation between S-Plus and R.
  
 Also, the MINQUE method has been obsolete for over
  25 years.
   I recommend you use method = REML except for when you want to
   compare two nested models with different fixed effects;  in
  that case,
   you should use method = ML, as explained in Pinheiro and
  Bates (2000).
  
 Hope this helps.
 Spencer Graves
  
   Iuri Gavronski wrote:
Hi,
   
I'm trying to fit a model using variance components in R, but if
very new on it, so I'm asking for your help.
   
I have imported the SPSS database onto R, but I don't know how to
convert the commands... the SPSS commands I'm trying to
  convert are:
VARCOMP
   RATING BY CHAIN SECTOR RESP ASPECT ITEM
   /RANDOM = CHAIN SECTOR RESP ASPECT ITEM
   /METHOD = MINQUE (1)
   /DESIGN = CHAIN SECTOR RESP ASPECT ITEM
   SECTOR*RESP SECTOR*ASPECT SECTOR*ITEM CHAIN*RESP
CHAIN*ASPECT CHAIN*ITEM RESP*ASPECT RESP*ITEM
   SECTOR*RESP*ASPECT SECTOR*RESP*ITEM
  CHAIN*RESP*ASPECT
   /INTERCEPT = INCLUDE.
   
VARCOMP
   RATING BY CHAIN SECTOR RESP ASPECT ITEM
   /RANDOM = CHAIN SECTOR RESP ASPECT ITEM
   /METHOD = REML
   /DESIGN = CHAIN SECTOR RESP ASPECT ITEM
   SECTOR*RESP SECTOR*ASPECT SECTOR*ITEM CHAIN*RESP
CHAIN*ASPECT CHAIN*ITEM RESP*ASPECT RESP*ITEM
   SECTOR*RESP*ASPECT SECTOR*RESP*ITEM
  CHAIN*RESP*ASPECT
   /INTERCEPT = INCLUDE.
   
Thank you for your help.
   
Best regards,
   
Iuri.
   
___
Iuri Gavronski - [EMAIL PROTECTED]
doutorando
UFRGS/PPGA/NITEC - www.ppga.ufrgs.br Brazil
   
__
R-help@stat.math.ethz.ch mailing list

Re: [R] Specifying Path Model in SEM for CFA

2006-08-17 Thread Rick Bilonick
sem() handles only equality constraints among parameters, and this model
 requires linear inequality constraints. 
 
 I'm aware of SEM software that handles inequality constraints, but I'm not
 aware of anything in R that will do it out of the box. One possibility is
 to write out the likelihood (or fitting function) for your model and
 perform a bounded optimization using optim(). It would probably be a fair
 amount of work setting up the problem.
 
 Finally, there are tricks that permit the imposition of general constraints
 and inequality constraints using software, like sem(), that handles only
 equality constraints. It's probably possible to do what you want using such
 a trick, but it would be awkward. See the references given in Bollen,
 Structural Equations with Latent Variables (Wiley, 1989), pp. 401-403.
 
 I'm sorry that I can't be of more direct help.
  John


Thanks. I'll explore the options you mention. I would like to use R
because I need to couple this with block bootstrapping to handle time
dependencies.

Rick

__
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] Plots Without Displaying

2006-08-17 Thread hadley wickham
 Yes, you can do that for lattice-based plots.  The functions in the lattice
 package produce objects of class trellis which can be stored in a list and
 processed or updated at a later time:

Or for ggplot based plots:

install.packages(ggplot)
library(ggplot)

 plotList - list(length=3)
 plotList[[1]] - qplot(yield, site, data=barley)
 plotList[[2]] - qplot(yield, variety, data=barley)
 plotList[[3]] - qplot(yield, year, data=barley)

Which actually stores plot objects which are independent of their
representation as graphics.

Hadley

__
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] Variance Components in R

2006-08-17 Thread Spencer Graves
Hi, Iuri: 

  If you've got an 8086 AND a huge data set, compute time might be a 
problem with 'lmer'.  However, if you a reasonably modern computer and 
only a a few thousand observations, 'lmer' should complete almost in the 
blink of an eye -- or at least in less time than it would talk for a cup 
of coffee. 

  Spencer

Doran, Harold wrote:
 This will (should) be a piece of cake for lmer. But, I don't speak SPSS.
 Can you write your model out as a linear model and give a brief
 description of the data and your problem?
  
 In addition to what Spencer noted as help below, you should also check
 out the vignette in the mlmRev package. This will give you many
 examples.
  
 vignette('MlmSoftRev')
  
  
  


 

   From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
 Of Iuri Gavronski
   Sent: Thursday, August 17, 2006 11:16 AM
   To: Doran, Harold
   Subject: Re: [R] Variance Components in R
   
   
   9500 records. It didn`t run in SPSS or SAS on Windows machines,
 so I am trying to convert the SPSS script to R to run in a RISC station
 at the university.
   
   
   On 8/17/06, Doran, Harold [EMAIL PROTECTED] wrote: 

   Iuri: 
   
   The lmer function is optimal for large data with crossed
 random effects.
   How large are your data?
   
-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf Of
 Iuri Gavronski
Sent: Thursday, August 17, 2006 11:08 AM
To: Spencer Graves
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] Variance Components in R
   
Thank you for your reply.
VARCOMP is available at SPSS advanced models, I'm not
 sure 
for how long it exists... I only work with SPSS for
 the last
4 years...
My model only has crossed random effects, what perhaps
 would
drive me to lmer().
However, as I have unbalanced data (why it is normally
 called 
'unbalanced design'? the data was not intended to be
unbalanced, only I could not get responses for all
 cells...),
I'm afraid that REML would take too much CPU, memory
 and time
to execute, and MINQUE would be faster and provide
 similar 
variance estimates (please, correct me if I'm wrong on
 that point).
I only found MINQUE on the maanova package, but as my
 study
is very far from genetics, I'm not sure I can use this
 package.
Any comment would be appreciated. 
Iuri
   
On 8/16/06, Spencer Graves [EMAIL PROTECTED]
 wrote:

   I used SPSS over 25 years ago, but I don't
 recall
ever fitting a
 variance components model with it.  Are all your
 random
effects nested?
 If they were, I would recommend you use 'lme' in the
 'nlme' package.
 However, if you have crossed random effects, I
 suggest you 
try 'lmer'
 associated with the 'lme4' package.

   For 'lmer', documentation is available in
 Douglas
Bates. Fitting
 linear mixed models in R. /R News/, 5(1):27-30, May
 2005 
 (www.r-project.org - newsletter).  I also recommend
 you try the
 vignette available with the 'mlmRev' package (see,
 e.g.,

 http://finzi.psych.upenn.edu/R/Rhelp02a/archive/81375.html).

Excellent documentation for both 'lme' (and
 indirectly for
 'lmer') is available in Pinheiro and Bates (2000)
Mixed-Effects Models
 in S and S-Plus (Springer).  I have personally
 recommended
this book
 so many times on this listserve that I just now got
 234 hits for
 RSiteSearch(graves pinheiro).  Please don't
 hesitate to pass this 
 recommendation to your university library.  This
 book is
the primary
 documentation for the 'nlme' package, which is part
 of the
standard R
 distribution.  A subdirectory
 ~library\nlme\scripts of your R 
 installation includes files named ch01.R,
 ch02.R, ...,
ch06.R,
 ch08.R, containing the R scripts described in the
 book.  These R
 script files make it much easier and more enjoyable
 to study that 
 book, because they make it much easier to try the
 commands
described
 in the book, one line at a time, testing
 

Re: [R] Fwd: Variance Components in R

2006-08-17 Thread Spencer Graves
Hi, Iuri: 

  How much RAM and how fast a microprocessor (and what version of 
Windows) do you have?  You might still try it in R under Windows.  The 
results might be comparable or dramatically better in R than in SPSS or 
SAS. 

  hope this helps.
  Spencer Graves

Iuri Gavronski wrote:
 9500 records. It didn`t run in SPSS or SAS on Windows machines, so I am
 trying to convert the SPSS script to R to run in a RISC station at the
 university.

 On 8/17/06, Doran, Harold [EMAIL PROTECTED] wrote:
   
 Iuri:

 The lmer function is optimal for large data with crossed random effects.
 How large are your data?

 
 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Iuri Gavronski
 Sent: Thursday, August 17, 2006 11:08 AM
 To: Spencer Graves
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] Variance Components in R

 Thank you for your reply.
 VARCOMP is available at SPSS advanced models, I'm not sure
 for how long it exists... I only work with SPSS for the last
 4 years...
 My model only has crossed random effects, what perhaps would
 drive me to lmer().
 However, as I have unbalanced data (why it is normally called
 'unbalanced design'? the data was not intended to be
 unbalanced, only I could not get responses for all cells...),
 I'm afraid that REML would take too much CPU, memory and time
 to execute, and MINQUE would be faster and provide similar
 variance estimates (please, correct me if I'm wrong on that point).
 I only found MINQUE on the maanova package, but as my study
 is very far from genetics, I'm not sure I can use this package.
 Any comment would be appreciated.
 Iuri

 On 8/16/06, Spencer Graves [EMAIL PROTECTED] wrote:
   
   I used SPSS over 25 years ago, but I don't recall
 
 ever fitting a
   
 variance components model with it.  Are all your random
 
 effects nested?
   
 If they were, I would recommend you use 'lme' in the 'nlme' package.
 However, if you have crossed random effects, I suggest you
 
 try 'lmer'
   
 associated with the 'lme4' package.

   For 'lmer', documentation is available in Douglas
 
 Bates. Fitting
   
 linear mixed models in R. /R News/, 5(1):27-30, May 2005
 (www.r-project.org - newsletter).  I also recommend you try the
 vignette available with the 'mlmRev' package (see, e.g.,
 http://finzi.psych.upenn.edu/R/Rhelp02a/archive/81375.html).

Excellent documentation for both 'lme' (and indirectly for
 'lmer') is available in Pinheiro and Bates (2000)
 
 Mixed-Effects Models
   
 in S and S-Plus (Springer).  I have personally recommended
 
 this book
   
 so many times on this listserve that I just now got 234 hits for
 RSiteSearch(graves pinheiro).  Please don't hesitate to pass this
 recommendation to your university library.  This book is
 
 the primary
   
 documentation for the 'nlme' package, which is part of the
 
 standard R
   
 distribution.  A subdirectory ~library\nlme\scripts of your R
 installation includes files named ch01.R, ch02.R, ...,
 
 ch06.R,
   
 ch08.R, containing the R scripts described in the book.  These R
 script files make it much easier and more enjoyable to study that
 book, because they make it much easier to try the commands
 
 described
   
 in the book, one line at a time, testing modifications to check you
 comprehension, etc.  In addition to avoiding problems with
 typographical errors, it also automatically overcomes a few
 
 minor but
   
 substantive changes in the notation between S-Plus and R.

   Also, the MINQUE method has been obsolete for over
 
 25 years.
   
 I recommend you use method = REML except for when you want to
 compare two nested models with different fixed effects;  in
 
 that case,
   
 you should use method = ML, as explained in Pinheiro and
 
 Bates (2000).
   
   Hope this helps.
   Spencer Graves

 Iuri Gavronski wrote:
 
 Hi,

 I'm trying to fit a model using variance components in R, but if
 very new on it, so I'm asking for your help.

 I have imported the SPSS database onto R, but I don't know how to
 convert the commands... the SPSS commands I'm trying to
   
 convert are:
   
 VARCOMP
RATING BY CHAIN SECTOR RESP ASPECT ITEM
/RANDOM = CHAIN SECTOR RESP ASPECT ITEM
/METHOD = MINQUE (1)
/DESIGN = CHAIN SECTOR RESP ASPECT ITEM
SECTOR*RESP SECTOR*ASPECT SECTOR*ITEM CHAIN*RESP
 CHAIN*ASPECT CHAIN*ITEM RESP*ASPECT RESP*ITEM
SECTOR*RESP*ASPECT SECTOR*RESP*ITEM
   
 CHAIN*RESP*ASPECT
   
/INTERCEPT = INCLUDE.

 VARCOMP
RATING BY CHAIN SECTOR RESP ASPECT ITEM
/RANDOM = CHAIN SECTOR RESP ASPECT ITEM
/METHOD = REML
/DESIGN = CHAIN SECTOR RESP ASPECT ITEM
SECTOR*RESP SECTOR*ASPECT SECTOR*ITEM CHAIN*RESP
 CHAIN*ASPECT CHAIN*ITEM RESP*ASPECT 

Re: [R] Fwd: Variance Components in R

2006-08-17 Thread Iuri Gavronski
We have tried on many machines, from my laptop to a dual core Intel
processor with 1GB of RAM.

On 8/17/06, Spencer Graves [EMAIL PROTECTED] wrote:

 Hi, Iuri:

   How much RAM and how fast a microprocessor (and what version of
 Windows) do you have?  You might still try it in R under Windows.  The
 results might be comparable or dramatically better in R than in SPSS or
 SAS.

   hope this helps.
   Spencer Graves

 Iuri Gavronski wrote:
  9500 records. It didn`t run in SPSS or SAS on Windows machines, so I am
  trying to convert the SPSS script to R to run in a RISC station at the
  university.
 
  On 8/17/06, Doran, Harold [EMAIL PROTECTED] wrote:
 
  Iuri:
 
  The lmer function is optimal for large data with crossed random
 effects.
  How large are your data?
 
 
  -Original Message-
  From: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED] On Behalf Of Iuri Gavronski
  Sent: Thursday, August 17, 2006 11:08 AM
  To: Spencer Graves
  Cc: r-help@stat.math.ethz.ch
  Subject: Re: [R] Variance Components in R
 
  Thank you for your reply.
  VARCOMP is available at SPSS advanced models, I'm not sure
  for how long it exists... I only work with SPSS for the last
  4 years...
  My model only has crossed random effects, what perhaps would
  drive me to lmer().
  However, as I have unbalanced data (why it is normally called
  'unbalanced design'? the data was not intended to be
  unbalanced, only I could not get responses for all cells...),
  I'm afraid that REML would take too much CPU, memory and time
  to execute, and MINQUE would be faster and provide similar
  variance estimates (please, correct me if I'm wrong on that point).
  I only found MINQUE on the maanova package, but as my study
  is very far from genetics, I'm not sure I can use this package.
  Any comment would be appreciated.
  Iuri
 
  On 8/16/06, Spencer Graves [EMAIL PROTECTED] wrote:
 
I used SPSS over 25 years ago, but I don't recall
 
  ever fitting a
 
  variance components model with it.  Are all your random
 
  effects nested?
 
  If they were, I would recommend you use 'lme' in the 'nlme' package.
  However, if you have crossed random effects, I suggest you
 
  try 'lmer'
 
  associated with the 'lme4' package.
 
For 'lmer', documentation is available in Douglas
 
  Bates. Fitting
 
  linear mixed models in R. /R News/, 5(1):27-30, May 2005
  (www.r-project.org - newsletter).  I also recommend you try the
  vignette available with the 'mlmRev' package (see, e.g.,
  http://finzi.psych.upenn.edu/R/Rhelp02a/archive/81375.html).
 
 Excellent documentation for both 'lme' (and indirectly for
  'lmer') is available in Pinheiro and Bates (2000)
 
  Mixed-Effects Models
 
  in S and S-Plus (Springer).  I have personally recommended
 
  this book
 
  so many times on this listserve that I just now got 234 hits for
  RSiteSearch(graves pinheiro).  Please don't hesitate to pass this
  recommendation to your university library.  This book is
 
  the primary
 
  documentation for the 'nlme' package, which is part of the
 
  standard R
 
  distribution.  A subdirectory ~library\nlme\scripts of your R
  installation includes files named ch01.R, ch02.R, ...,
 
  ch06.R,
 
  ch08.R, containing the R scripts described in the book.  These R
  script files make it much easier and more enjoyable to study that
  book, because they make it much easier to try the commands
 
  described
 
  in the book, one line at a time, testing modifications to check you
  comprehension, etc.  In addition to avoiding problems with
  typographical errors, it also automatically overcomes a few
 
  minor but
 
  substantive changes in the notation between S-Plus and R.
 
Also, the MINQUE method has been obsolete for over
 
  25 years.
 
  I recommend you use method = REML except for when you want to
  compare two nested models with different fixed effects;  in
 
  that case,
 
  you should use method = ML, as explained in Pinheiro and
 
  Bates (2000).
 
Hope this helps.
Spencer Graves
 
  Iuri Gavronski wrote:
 
  Hi,
 
  I'm trying to fit a model using variance components in R, but if
  very new on it, so I'm asking for your help.
 
  I have imported the SPSS database onto R, but I don't know how to
  convert the commands... the SPSS commands I'm trying to
 
  convert are:
 
  VARCOMP
 RATING BY CHAIN SECTOR RESP ASPECT ITEM
 /RANDOM = CHAIN SECTOR RESP ASPECT ITEM
 /METHOD = MINQUE (1)
 /DESIGN = CHAIN SECTOR RESP ASPECT ITEM
 SECTOR*RESP SECTOR*ASPECT SECTOR*ITEM CHAIN*RESP
  CHAIN*ASPECT CHAIN*ITEM RESP*ASPECT RESP*ITEM
 SECTOR*RESP*ASPECT SECTOR*RESP*ITEM
 
  CHAIN*RESP*ASPECT
 
 /INTERCEPT = INCLUDE.
 
  VARCOMP
 RATING BY CHAIN SECTOR RESP ASPECT ITEM
 /RANDOM = CHAIN SECTOR RESP ASPECT ITEM
 /METHOD = REML
 /DESIGN = CHAIN SECTOR RESP ASPECT ITEM
 SECTOR*RESP SECTOR*ASPECT SECTOR*ITEM CHAIN*RESP
  CHAIN*ASPECT CHAIN*ITEM 

Re: [R] Variance Components in R

2006-08-17 Thread Iuri Gavronski
I am trying to replicate Finn and Kayandé (1997) study on G-theory
application on Marketing. The idea is to have people evaluate some aspects
of service quality for chains on different economy sectors. Then, conduct a
G-study to identify the generalizability coefficient estimates for different
D-study designs.
I have persons rating 3 different items on 3 different aspects of service
quality on 3 chains on 3 sectors. It is normally assumed on G-studies that
the factors are random. So I have to specify a model to estimate the
variance components of CHAIN SECTOR RESP ASPECT ITEM, and the interaction of
SECTOR*RESP SECTOR*ASPECT SECTOR*ITEM CHAIN*RESP CHAIN*ASPECT CHAIN*ITEM
RESP*ASPECT RESP*ITEM SECTOR*RESP*ASPECT SECTOR*RESP*ITEM CHAIN*RESP*ASPECT.
'*' in VARCOMP means a crossed design.
Evaluating only the two dimensions interactions (x*y) ran in few minutes
with the full database. Including three interactions (x*y*z) didn't complete
the execution at all. I have the data and script sent to a professor of the
department of Statistics on my university and he could not run it on either
SPSS or SAS (we don't have SAS licenses here at the business school, only
SPSS). Nobody here at the business school has any experience with R, so I
don't have anyone to ask for help.
Ì am not sure if I have answered you question, but feel free to ask it
again, and I will try to restate the problem.

Best regards,

Iuri

On 8/17/06, Doran, Harold [EMAIL PROTECTED] wrote:

  This will (should) be a piece of cake for lmer. But, I don't speak SPSS.
 Can you write your model out as a linear model and give a brief description
 of the data and your problem?

 In addition to what Spencer noted as help below, you should also check out
 the vignette in the mlmRev package. This will give you many examples.

 vignette('MlmSoftRev')




  --
 *From:* [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] *On Behalf Of *Iuri
 Gavronski
 *Sent:* Thursday, August 17, 2006 11:16 AM
 *To:* Doran, Harold

 *Subject:* Re: [R] Variance Components in R

 9500 records. It didn`t run in SPSS or SAS on Windows machines, so I am
 trying to convert the SPSS script to R to run in a RISC station at the
 university.

 On 8/17/06, Doran, Harold [EMAIL PROTECTED] wrote:
 
  Iuri:
 
  The lmer function is optimal for large data with crossed random effects.
  How large are your data?
 
   -Original Message-
   From: [EMAIL PROTECTED]
   [mailto:[EMAIL PROTECTED] On Behalf Of Iuri Gavronski
   Sent: Thursday, August 17, 2006 11:08 AM
   To: Spencer Graves
   Cc: r-help@stat.math.ethz.ch
   Subject: Re: [R] Variance Components in R
  
   Thank you for your reply.
   VARCOMP is available at SPSS advanced models, I'm not sure
   for how long it exists... I only work with SPSS for the last
   4 years...
   My model only has crossed random effects, what perhaps would
   drive me to lmer().
   However, as I have unbalanced data (why it is normally called
   'unbalanced design'? the data was not intended to be
   unbalanced, only I could not get responses for all cells...),
   I'm afraid that REML would take too much CPU, memory and time
   to execute, and MINQUE would be faster and provide similar
   variance estimates (please, correct me if I'm wrong on that point).
   I only found MINQUE on the maanova package, but as my study
   is very far from genetics, I'm not sure I can use this package.
   Any comment would be appreciated.
   Iuri
  
   On 8/16/06, Spencer Graves [EMAIL PROTECTED] wrote:
   
  I used SPSS over 25 years ago, but I don't recall
   ever fitting a
variance components model with it.  Are all your random
   effects nested?
If they were, I would recommend you use 'lme' in the 'nlme' package.
However, if you have crossed random effects, I suggest you
   try 'lmer'
associated with the 'lme4' package.
   
  For 'lmer', documentation is available in Douglas
   Bates. Fitting
linear mixed models in R. /R News/, 5(1):27-30, May 2005
(www.r-project.org - newsletter).  I also recommend you try the
vignette available with the 'mlmRev' package (see, e.g.,
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/81375.html).
   
   Excellent documentation for both 'lme' (and indirectly for
'lmer') is available in Pinheiro and Bates (2000)
   Mixed-Effects Models
in S and S-Plus (Springer).  I have personally recommended
   this book
so many times on this listserve that I just now got 234 hits for
RSiteSearch(graves pinheiro).  Please don't hesitate to pass this
recommendation to your university library.  This book is
   the primary
documentation for the 'nlme' package, which is part of the
   standard R
distribution.  A subdirectory ~library\nlme\scripts of your R
installation includes files named ch01.R, ch02.R, ...,
   ch06.R,
ch08.R, containing the R scripts described in the book.  These R
script files make it much easier and more enjoyable to study 

Re: [R] nls convergence problem

2006-08-17 Thread Dieter Menne
Yours truly dieter.menne at menne-biomed.de writes:
...
 Recently, a colleague fitted gastric emptying
 curves using GraphPad, with 100% success, and
 nls failed for one third of  these.  When we
 checked GraphPads output more closely, some of
 the coefficients looked like 2.1 with a confidence
 interval in the range  -27128 ... 314141. Nobody
 forces you to look at these, though, when using
 GraphPad.


Since my comment has stirred a bit of an uproar, I should add
that this is not the fault of GraphPad, but that most non-linear
fitting programs, including those in the big SXXX, give the same
results. Harvey Motulsky from Graphpad/Prism informed me that
they were going to add special tests in the new versions. Their
pdf-manual on nonlinear fitting is worth a look anyway if
Bates/Watts is over your head.

And if anyone want to see sample data:

http://www.menne-biomed.de/gastempt/gastempt1.html

 I only wish nls were a little bit more polite in telling me what went wrong.

I stand corrected:

I only wish nls were less politically correct, but rather inform me
WHY it faltered.

Dieter

__
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] Fwd: Variance Components in R

2006-08-17 Thread Spencer Graves
  Burt Gunter just reminded me that the completion time could also 
be affected by the numbers of levels of each of the factors, especially 
random effects:  With N records, any variance components / mixed model 
software using MLE or REML will have to invert repeatedly an N x N 
matrix for the covariance structure of the random effects and noise.  If 
the software recognizes your design as having some simple structure, 
this can be quite fast;  otherwise, it could be a Herculean task.  In 
your case with N = 9500 records, just one copy of this covariance matrix 
could consume a substantial portion of 1GB RAM.  I compute 
8*9500*(9500-1)/2 = 361Mbytes. 

  However, any software that recognizes special structure in your 
design may be able to do the required computations without ever 
constructing a matrix this large.  I would say that it's still worth a 
try in R on your laptop or on the machine with 1GB RAM:  'lmer' might 
recognize special structure that neither of the other two do (and vice 
versa). 

  Hope this helps. 
  Spencer Graves

Iuri Gavronski wrote:
 We have tried on many machines, from my laptop to a dual core Intel 
 processor with 1GB of RAM.

 On 8/17/06, *Spencer Graves*  [EMAIL PROTECTED] 
 mailto:[EMAIL PROTECTED] wrote:

 Hi, Iuri:

   How much RAM and how fast a microprocessor (and what version of
 Windows) do you have?  You might still try it in R under Windows.  The
 results might be comparable or dramatically better in R than in
 SPSS or
 SAS.

   hope this helps.
   Spencer Graves

 Iuri Gavronski wrote:
  9500 records. It didn`t run in SPSS or SAS on Windows machines,
 so I am
  trying to convert the SPSS script to R to run in a RISC station
 at the
  university.
 
  On 8/17/06, Doran, Harold  [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED] wrote:
 
  Iuri:
 
  The lmer function is optimal for large data with crossed random
 effects.
  How large are your data?
 
 
  -Original Message-
  From: [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED]
  [mailto: [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED]] On Behalf Of Iuri Gavronski
  Sent: Thursday, August 17, 2006 11:08 AM
  To: Spencer Graves
  Cc: r-help@stat.math.ethz.ch mailto:r-help@stat.math.ethz.ch
  Subject: Re: [R] Variance Components in R
 
  Thank you for your reply.
  VARCOMP is available at SPSS advanced models, I'm not sure
  for how long it exists... I only work with SPSS for the last
  4 years...
  My model only has crossed random effects, what perhaps would
  drive me to lmer().
  However, as I have unbalanced data (why it is normally called
  'unbalanced design'? the data was not intended to be
  unbalanced, only I could not get responses for all cells...),
  I'm afraid that REML would take too much CPU, memory and time
  to execute, and MINQUE would be faster and provide similar
  variance estimates (please, correct me if I'm wrong on that
 point).
  I only found MINQUE on the maanova package, but as my study
  is very far from genetics, I'm not sure I can use this package.
  Any comment would be appreciated.
  Iuri
 
  On 8/16/06, Spencer Graves  [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED] wrote:
 
I used SPSS over 25 years ago, but I don't recall
 
  ever fitting a
 
  variance components model with it.  Are all your random
 
  effects nested?
 
  If they were, I would recommend you use 'lme' in the 'nlme'
 package.
  However, if you have crossed random effects, I suggest you
 
  try 'lmer'
 
  associated with the 'lme4' package.
 
For 'lmer', documentation is available in Douglas
 
  Bates. Fitting
 
  linear mixed models in R. /R News/, 5(1):27-30, May 2005
  (www.r-project.org http://www.r-project.org -
 newsletter).  I also recommend you try the
  vignette available with the 'mlmRev' package (see, e.g.,
  http://finzi.psych.upenn.edu/R/Rhelp02a/archive/81375.html
 http://finzi.psych.upenn.edu/R/Rhelp02a/archive/81375.html).
 
 Excellent documentation for both 'lme' (and indirectly for
  'lmer') is available in Pinheiro and Bates (2000)
 
  Mixed-Effects Models
 
  in S and S-Plus (Springer).  I have personally recommended
 
  this book
 
  so many times on this listserve that I just now got 234 hits for
  RSiteSearch(graves pinheiro).  Please don't hesitate to
 pass this
  recommendation to your university library.  This book is
 
  the primary
 
  documentation for the 'nlme' package, which is part of the
 
  standard R
 
  distribution.  A subdirectory ~library\nlme\scripts of your R
  installation includes files named ch01.R, ch02.R, ...,

[R] rbind-ing vectors inside lists

2006-08-17 Thread Domenico Vistocco
Dear helpeRs,

suppose I have two lists as follows:

a = list(1:5,5:9)
b = lapply(a,*,2)


I would like to rbind-ing the two lists, that is I would like to use 
something as rbind applied
component to component for the two list.

I have used the following solution:

fun.tile.wt = function(list1, list2)
{
 for(i in 1:length(list1))
 {
 list1[[i]]=rbind(list1[[i]],list2[[i]])
 }
 list1
}
fun.tile.wt(a,b)


Is it possible to directly obtain the result using the apply family 
(or something else)?

Any suggestions is appreciated.

Thanks in advance,
domenico vistocco 
[[alternative HTML version deleted]]


Chiacchiera con i tuoi amici in tempo reale! 
 http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com

__
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] rbind-ing vectors inside lists

2006-08-17 Thread Gabor Grothendieck
Try:

mapply(rbind, a, b, SIMPLIFY = FALSE)


On 8/17/06, Domenico Vistocco [EMAIL PROTECTED] wrote:
 Dear helpeRs,

 suppose I have two lists as follows:

 a = list(1:5,5:9)
 b = lapply(a,*,2)


 I would like to rbind-ing the two lists, that is I would like to use
 something as rbind applied
 component to component for the two list.

 I have used the following solution:

 fun.tile.wt = function(list1, list2)
 {
 for(i in 1:length(list1))
 {
 list1[[i]]=rbind(list1[[i]],list2[[i]])
 }
 list1
 }
 fun.tile.wt(a,b)


 Is it possible to directly obtain the result using the apply family
 (or something else)?

 Any suggestions is appreciated.

 Thanks in advance,
 domenico vistocco
[[alternative HTML version deleted]]


 Chiacchiera con i tuoi amici in tempo reale!
  http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com

 __
 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.


__
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.


[R] unlink disables help?

2006-08-17 Thread Kuhn, Max
I was hoping that someone could try to reproduce an error that I am
getting. The R Site Search keeps timing out on me, so apologies of this
has already come up.

I'm using 

 R.version
   _ 
platform   i386-pc-mingw32   
arch   i386  
os mingw32   
system i386, mingw32 
status   
major  2 
minor  3.1   
year   2006  
month  06
day01
svn rev38247 
language   R 
version.string Version 2.3.1 (2006-06-01)

When I use unlink as below, the help system is disabled:

 ?print
 testPath - tempdir()
 print(testPath)
[1] C:\\WINDOWS\\TEMP\\Rtmpo5Wnqb
 file.exists(testPath)
[1] TRUE
 unlink(testPath, recursive = TRUE)
 ?print
Error in int.unzip(file.path(path, zipname), topic, tmpd) : 
'destination' does not exist

I can produce the same error with Version 2.3.0 (2006-04-24) on Windows.

I haven't been able to reproduce this with directories that are created
using other means:

 ?print
 testPath - c:\\tmp\\unlinkTest
 dir.create(testPath)
 file.exists(testPath)
[1] TRUE
 unlink(testPath, recursive = TRUE)
 ?print


Thanks,

Max

--
LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}}

__
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] rbind-ing vectors inside lists

2006-08-17 Thread Richard M. Heiberger
## initial example
a = list(1:5, 5:9)
b = lapply(a,*,2)

library(abind)  ## you may need to download abind from CRAN
abind(data.frame(a), data.frame(b), along=.5)

## data.frames with column names
a = data.frame(first=1:5, second=5:9)
b = a^2
abind(a, b, along=.5, new.names=c(a,b))

__
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.


[R] R Site Search directly from Firefox's address bar

2006-08-17 Thread Adrian Dusa

Dear list,

For all those interested who use Firefox as the main browser, here is a quick 
way to make R related searches:

type about:config in the address bar
search for keyword.url
and modify it 
to 
http://finzi.psych.upenn.edu/cgi-bin/namazu.cgi?idxname=functionsidxname=docsidxname=Rhelp02aquery=;

From now on, every keyword(s) you type in the address bar will take you 
directly to the first page of hits at http://finzi.psych.upenn.edu

I found this very helpful.
Best,
Adrian

-- 
Adrian Dusa
Romanian Social Data Archive
1, Schitu Magureanu Bd
050025 Bucharest sector 5
Romania
Tel./Fax: +40 21 3126618 \
  +40 21 3120210 / int.101

__
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] unlink disables help?

2006-08-17 Thread Peter Dalgaard
Kuhn, Max [EMAIL PROTECTED] writes:

 I was hoping that someone could try to reproduce an error that I am
 getting. The R Site Search keeps timing out on me, so apologies of this
 has already come up.
 
 I'm using 
 
  R.version
never mind

 
 When I use unlink as below, the help system is disabled:
 
  ?print
  testPath - tempdir()
  print(testPath)
 [1] C:\\WINDOWS\\TEMP\\Rtmpo5Wnqb
  file.exists(testPath)
 [1] TRUE
  unlink(testPath, recursive = TRUE)
  ?print
 Error in int.unzip(file.path(path, zipname), topic, tmpd) : 
 'destination' does not exist
 
 I can produce the same error with Version 2.3.0 (2006-04-24) on Windows.

Read the documentation *carefully*:

Value:

 For 'tempfile' 

 For 'tempdir', the path of the per-session temporary directory.


And there is only one, and it is in there that the help system keeps
its stuff

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
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] day, month, year functions

2006-08-17 Thread Gabor Grothendieck
On 8/17/06, Martin Maechler [EMAIL PROTECTED] wrote:
  Gregor == Gregor Gorjanc [EMAIL PROTECTED]
  on Fri, 11 Aug 2006 00:27:27 + (UTC) writes:

Gregor Gabor Grothendieck ggrothendieck at gmail.com writes:

 Here are three ways:

 xx - as.Date(2006-01-05)

 # 1. use as.POSIXlt
 as.POSIXlt(xx)$mday
 as.POSIXlt(xx)$mon + 1
 as.POSIXlt(xx)$year + 1900

 # 2. use format
 as.numeric(format(xx, %d))
 as.numeric(format(xx, %m))
 as.numeric(format(xx, %Y))

 # 3. use month.day.year in chron package
 library(chron)
 month.day.year(unclass(xx))$day
 month.day.year(unclass(xx))$month
 month.day.year(unclass(xx))$year

Gregor Hi,

Gregor it would really be great if there would be

Gregor sec(), min(), hour() day(), month(), year()

Gregor generic functions that would work on all date classes. Where
Gregor applicable of course. I imagine that argument to get out integer
Gregor or character would alse be nice.

 I disagree pretty strongly:

 - We definitely don't want min() to return minutes instead of
  minimum !

 - Why pollute the namespace with 6 (well, actualy 5!) new
  function names, when  as.POSIXlt()
  *REALLY* is there exactly for this purpose ???

 I rather think the authors of each of the other old-fashioned
 date classes should provide as.POSIXlt() methods for their
 classes.

 Then, we'd have uniform interfaces, following's Gabor's # 1.
 above.

 Martin Maechler, ETH Zurich


There are two problems:

1. as.POSIXlt is not generic.  (This problem may not be too important
given that as.POSIXlt does handle Date and chron dates classes
already but in terms of handling all potential classes its a limitation.)

2. in the case of as.POSIXlt converting chron dates objects to
POSIXlt there is a time zone consideration, as shown below, where
today, August 17th in the Eastern Daylight Time zone, is displayed
as August 16th using as.POSIXlt unless we use tz = GMT

 library(chron)
 # today is August 17th.
 Sys.Date()
[1] 2006-08-17
 chron(unclass(Sys.Date()))
[1] 08/17/06
 Sys.time()
[1] 2006-08-17 14:28:19 Eastern Daylight Time
 as.POSIXlt(Sys.Date())
[1] 2006-08-17
 as.POSIXlt(chron(unclass(Sys.Date(
[1] 2006-08-16 20:00:00 Eastern Daylight Time
 as.POSIXlt(chron(unclass(Sys.Date())), tz = GMT)
[1] 2006-08-17 GMT
 R.version.string # Windows XP
[1] Version 2.3.1 Patched (2006-06-04 r38279)

__
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] R Site Search directly from Firefox's address bar

2006-08-17 Thread Peter Dalgaard
Adrian Dusa [EMAIL PROTECTED] writes:

 Dear list,
 
 For all those interested who use Firefox as the main browser, here is a quick 
 way to make R related searches:
 
 type about:config in the address bar
 search for keyword.url
 and modify it 
 to 
 http://finzi.psych.upenn.edu/cgi-bin/namazu.cgi?idxname=functionsidxname=docsidxname=Rhelp02aquery=;
 
 From now on, every keyword(s) you type in the address bar will take you 
 directly to the first page of hits at http://finzi.psych.upenn.edu
 
 I found this very helpful.

Breaks the feature that you get to www.r-project.org just by typing
r, though...

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
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.


[R] Boxplot Help: Re-ordering the x-axis

2006-08-17 Thread Pamela Allen
I am having a problem using boxlpot with my data.  I have my data arranged
in a data table, and two of my columns are mass and month.  I am trying
to plot the mass of my study animals by month, thus I would like to have it
in the order of January to December.  The problem is that R orders each
month in alphabetical order, and gives each month an integer value
corresponding to this (i.e. April is integer=1, August=2, September=12).  I
have tried many different ways to solve this but nothing is working.  If
anyone knows how to order the x-axis in boxplot, or alternatively, re-assign
integer values to each month that would be very helpful.  Thank you in
advance!  

Pamela Allen, MSc Candidate
University of British Columbia
Marine Mammal Research Unit, Fisheries Centre
Vancouver, B.C.  V6T 1Z4
 
[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R Site Search directly from Firefox's address bar

2006-08-17 Thread Adrian Dusa
On Thursday 17 August 2006 21:41, Peter Dalgaard wrote:
 [...]
 Breaks the feature that you get to www.r-project.org just by typing
 r, though...

Oh, this is very simple to fix. I created a bookmark named R with the above 
location and assigned it a keyword r.
Now, everytime I type r in the address bar it takes me to www.r-project.org
:)

-- 
Adrian Dusa
Romanian Social Data Archive
1, Schitu Magureanu Bd
050025 Bucharest sector 5
Romania
Tel./Fax: +40 21 3126618 \
  +40 21 3120210 / int.101

__
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] Boxplot Help: Re-ordering the x-axis

2006-08-17 Thread Marc Schwartz (via MN)
On Thu, 2006-08-17 at 11:46 -0700, Pamela Allen wrote:
 I am having a problem using boxlpot with my data.  I have my data arranged
 in a data table, and two of my columns are mass and month.  I am trying
 to plot the mass of my study animals by month, thus I would like to have it
 in the order of January to December.  The problem is that R orders each
 month in alphabetical order, and gives each month an integer value
 corresponding to this (i.e. April is integer=1, August=2, September=12).  I
 have tried many different ways to solve this but nothing is working.  If
 anyone knows how to order the x-axis in boxplot, or alternatively, re-assign
 integer values to each month that would be very helpful.  Thank you in
 advance!  

Note the following in the Details section of ?boxplot:

If multiple groups are supplied either as multiple arguments or via a
formula, parallel boxplots will be plotted, in the order of the
arguments or the order of the levels of the factor (see factor).


If you are using a formula approach, then something like the following:

month - factor(month, 
levels = c(January, February, 
..., 
   November, December)

boxplot(mass ~ month)


See ?factor


For future reference, using:

   RSiteSearch(boxplot order)

will search the r-help archive using the indicated key words, where you
will see that this has been covered previously.

HTH,

Marc Schwartz

__
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] Boxplot Help: Re-ordering the x-axis

2006-08-17 Thread Richard M. Heiberger
month.name
class(month.name)
character
tmp - data.frame(m=rep(month.name, 2), y=rnorm(24))
bwplot(y ~ m, data=tmp)

tmp - data.frame(m=ordered(rep(month.name, 2), levels=month.name), y=rnorm(24))
bwplot(y ~ m, data=tmp)

__
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.


[R] problem with cut(as.Date(2006-08-14), week)

2006-08-17 Thread Mikkel Grum
When I run cut.Date or cut.POSIXt with argument breaks
= weeks, the function gives the first day of that
week, unless the date is the first day of the week, in
which case it gives an error message as in:

 cut(as.Date(2006-08-16), week)
[1] 2006-08-14
Levels: 2006-08-14
 cut(as.Date(2006-08-14), week)
Error in 1:(1 + max(which(breaks  maxx))) : 
result would be too long a vector
In addition: Warning message:
no non-missing arguments to max; returning -Inf 
 sessionInfo()
Version 2.3.1 (2006-06-01) 
i386-pc-mingw32 

attached base packages:
[1] methods   stats graphics  grDevices
utils datasets 
[7] base 
 Sys.getlocale()
[1] LC_COLLATE=English_United
States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United
States.1252
 

Bug or feature?

Mikkel

__
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] NLME: Limitations of using identify to interact with scatterplots?

2006-08-17 Thread Paul Murrell
Hi

Take a look at panel.identify() (in the 'lattice' package).

I'm not sure if it will help you because I cannot run your example code.

Paul


Douglas Bates wrote:
 Most plotting functions in the nlme package use lattice graphics
 functions based on the grid package.  Identify will not work with
 lattice graphics.  I'm not sure if there is a replacement.
 
 On 8/17/06, Greg Distiller [EMAIL PROTECTED] wrote:
 I have a quick question regarding the use of identify to interact with
 points on a scatterplot. My question is essentially: can identify be used
 when one is plotting model objects to generate diagnostic plots?
 Specifically I am using NLME.
 For example, I am plotting the fitted values on the x axis vs a variable
 called log2game with the following code:

 plot(D2C29.nlme, log2game ~ fitted(.), abline=c(0,1))

 and then I have tried to use identify as follows:

 identify(D2C29.nlme$fitted[,2],Data2$log2game,row.names(Data2))

 (if I leave out the [,2] on the fitted attributes then I am told that x and
 y are not the same length and it appears that this is due to the fact that
 the fitted attribute has 2 columns.)

 but I get an error message that plot.new has not been called yet.

 I am not sure if this is because I am doing something wrong or if identify
 simply cannot be used in this context.

 Many thanks

 Greg

 __
 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.

 
 __
 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.

-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
[EMAIL PROTECTED]
http://www.stat.auckland.ac.nz/~paul/

__
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.


[R] Rgraphviz fails to load

2006-08-17 Thread Michael Kubovy
Dear r-helpers,

Can anyone suggest a remedy to the following failure of Rgraphviz to  
load?

  library(Rgraphviz)
Loading required package: graph
Loading required package: Ruuid
Error in dyn.load(x, as.logical(local), as.logical(now)) :
unable to load shared library '/Library/Frameworks/R.framework/ 
Resources/library/Rgraphviz/libs/ppc/Rgraphviz.so':
   dlopen(/Library/Frameworks/R.framework/Resources/library/Rgraphviz/ 
libs/ppc/Rgraphviz.so, 6): Library not loaded: /usr/local/lib/libpng. 
3.dylib
   Referenced from: /usr/local/lib/graphviz/libgvc.2.dylib
   Reason: image not found
Error: .onLoad failed in 'loadNamespace' for 'Rgraphviz'
Error: package/namespace load failed for 'Rgraphviz'

Version 2.3.1 (2006-06-01)
powerpc-apple-darwin8.6.0

attached base packages:
[1] utils methods   stats graphics  grDevices  
datasets  base

other attached packages:
  graph  RuuidJGR JavaGD  rJava   MASS 
lattice
   1.10.6   1.10.01.4-40.3-40.4-5 7.2-27.1   
0.13-10


_
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400Charlottesville, VA 22904-4400
Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
Office:B011+1-434-982-4729
Lab:B019+1-434-982-4751
Fax:+1-434-982-4766
WWW:http://www.people.virginia.edu/~mk9y/

__
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.


[R] Simulate p-value in lme4

2006-08-17 Thread Manuel Morales
Dear list,

This is more of a stats question than an R question per se. First, I
realize there has been a lot of discussion about the problems with
estimating P-values from F-ratios for mixed-effects models in lme4.
Using mcmcsamp() seems like a great alternative for evaluating the
significance of individual coefficients, but not for groups of
coefficients as might occur in an experimental design with 3 treatment
levels. I'm wondering if the simulation approach I use below to estimate
the P-value for a 3-level factor is appropriate, or if there are any
suggestions on how else to approach this problem. The model and data in
the example are from section 10.4 of MASS.

Thanks!
Manuel

# Load req. package (see functions to generate data at end of script)
library(lme4)
library(MASS)

# Full and reduced models - pred is a factor with 3 levels
result.full - lmer(y~pred+(1|subject), data=epil3, family=poisson)
result.base - lmer(y~1+(1|subject), data=epil3, family=poisson)

# Naive P-value from LR for significance of pred factor
anova(result.base,result.full)$Pr(Chisq)[[2]] # P-value
(test.stat - anova(result.base,result.full)$Chisq[[2]]) # Chisq-stat

# P-value from simulation. Note that in the simulation, I use the
# estimated random effects for each subject rather than generating a new
# distribution of means. I'm not sure if this is appropriate or not ...
intercept - fixef(result.base)
rand.effs - ranef(result.base)[[1]]
mu - exp(rep(intercept+rand.effs[[1]],2))

p.value - function(iter, stat) {
  chi.stat - vector()
  for(i in 1:iter) {
resp - rpois(length(mu), mu) # simulate values
sim.data - data.frame(y=resp,subject=epil3$subject,pred=epil3$pred)
result.f - lmer(y~pred+(1|subject), data=sim.data,
 family=poisson)
result.b - lmer(y~1+(1|subject), data=sim.data, family=poisson)
chi.stat[i] - anova(result.b,result.f)$Chisq[[2]]
  }
  val - sum(unlist(lapply(chi.stat, function(x) if(xstat) 1 else
 0)))/iter
  hist(chi.stat)
  return(val)
}

p.value(10,test.stat) # Increase to =1000 to get a reasonable P-value!

# Script to generate data, from section 10.4 of MASS
epil2 - epil[epil$period == 1, ]
epil2[period] - rep(0, 59); epil2[y] - epil2[base]
epil[time] - 1; epil2[time] - 4
epil2 - rbind(epil, epil2)
epil2$pred - unclass(epil2$trt) * (epil2$period  0)
epil2$subject - factor(epil2$subject)
epil3 - aggregate(epil2, list(epil2$subject, epil2$period  0),
   function(x) if(is.numeric(x)) sum(x) else x[1])
epil3$pred - factor(epil3$pred, labels = c(base, placebo, drug))

__
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] Variance Components in R

2006-08-17 Thread Doran, Harold
Iuri:
 
Here is an example of how a model would be specified using lmer using a couple 
of your factors:
 
fm - lmer(response.variable ~ chain*sector*resp 
+(chain*sector*resp|GroupingID), data)
 
This will give you a main effect for each factor and all possible interactions. 
However, do you have a grouping variable? I wonder if aov might be the better 
tool for your G-study? 
 
As a side note, I don't see that you have a factor for persons. Isn't this also 
a variance component of interest for your study?




From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Iuri 
Gavronski
Sent: Thursday, August 17, 2006 1:26 PM
To: Doran, Harold
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] Variance Components in R


I am trying to replicate Finn and Kayandé (1997) study on G-theory 
application on Marketing. The idea is to have people evaluate some aspects of 
service quality for chains on different economy sectors. Then, conduct a 
G-study to identify the generalizability coefficient estimates for different 
D-study designs. 
I have persons rating 3 different items on 3 different aspects of 
service quality on 3 chains on 3 sectors. It is normally assumed on G-studies 
that the factors are random. So I have to specify a model to estimate the 
variance components of CHAIN SECTOR RESP ASPECT ITEM, and the interaction of 
SECTOR*RESP SECTOR*ASPECT SECTOR*ITEM CHAIN*RESP CHAIN*ASPECT CHAIN*ITEM 
RESP*ASPECT RESP*ITEM SECTOR*RESP*ASPECT SECTOR*RESP*ITEM CHAIN*RESP*ASPECT. 
'*' in VARCOMP means a crossed design.
Evaluating only the two dimensions interactions (x*y) ran in few 
minutes with the full database. Including three interactions (x*y*z) didn't 
complete the execution at all. I have the data and script sent to a professor 
of the department of Statistics on my university and he could not run it on 
either SPSS or SAS (we don't have SAS licenses here at the business school, 
only SPSS). Nobody here at the business school has any experience with R, so I 
don't have anyone to ask for help. 
Ì am not sure if I have answered you question, but feel free to ask it 
again, and I will try to restate the problem.

Best regards,

Iuri


On 8/17/06, Doran, Harold [EMAIL PROTECTED] wrote: 

This will (should) be a piece of cake for lmer. But, I don't 
speak SPSS. Can you write your model out as a linear model and give a brief 
description of the data and your problem?
 
In addition to what Spencer noted as help below, you should 
also check out the vignette in the mlmRev package. This will give you many 
examples.
 
vignette('MlmSoftRev')
 
 
 




From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On 
Behalf Of Iuri Gavronski
Sent: Thursday, August 17, 2006 11:16 AM
To: Doran, Harold


Subject: Re: [R] Variance Components in R




9500 records. It didn`t run in SPSS or SAS on Windows machines, 
so I am trying to convert the SPSS script to R to run in a RISC station at the 
university.


On 8/17/06, Doran, Harold [EMAIL PROTECTED] wrote: 

Iuri: 

The lmer function is optimal for large data with 
crossed random effects.
How large are your data?

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Iuri Gavronski
 Sent: Thursday, August 17, 2006 11:08 AM
 To: Spencer Graves
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] Variance Components in R

 Thank you for your reply.
 VARCOMP is available at SPSS advanced models, I'm not 
sure 
 for how long it exists... I only work with SPSS for 
the last
 4 years...
 My model only has crossed random effects, what 
perhaps would
 drive me to lmer().
 However, as I have unbalanced data (why it is 
normally called 
 'unbalanced design'? the data was not intended to be
 unbalanced, only I could not get responses for all 
cells...),
 I'm afraid that REML would take too much CPU, memory 
and time
 to 

[R] getting sapply to skip columns with non-numeric data?

2006-08-17 Thread r user
getting s-apply to skip columns with non-numeric data?
I have a dataframe “x” of w columns.

Some columns are numeric, some are not.

I wish to create a function to calculate the mean and
standard deviation of each numeric column, and then
“bind” the column mean and standard deviation to the
bottom of the dataframe.

e.g. 

tempmean - apply(data.frame(x), 2, mean, na.rm = T)
xnew - rbind(x,tempmean)

I am running into one small problem…what is the best
way to have sapply “skip” the non-numeric data and
return NA’s?

__
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] R Site Search directly from Firefox's address bar

2006-08-17 Thread Charles Berry
Adrian Dusa dusa.adrian at gmail.com writes:

 
 On Thursday 17 August 2006 21:41, Peter Dalgaard wrote:
  [...]
  Breaks the feature that you get to www.r-project.org just by typing
  r, though...
 
 Oh, this is very simple to fix. I created a bookmark named R with the above 
 location and assigned it a keyword r.
 Now, everytime I type r in the address bar it takes me to www.r-project.org
 :)
 
 Or add a '%s' to your bookmark definition:
  
http://finzi.psych.upenn.edu/cgi-bin/namazu.cgi?idxname=functionsidxname=docsidxname=Rhelp02aquery=%s;

and assign it the keyword 'rsite'

then 'rsite search terms' will do the search

:-)

__
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] getting sapply to skip columns with non-numeric data?

2006-08-17 Thread Gabor Grothendieck
Use the first few rows of iris as test data and try this
where isnum is 1 for each numeric column and NA for
others.

irish - head(iris)
isnum - ifelse(sapply(iris, class) == numeric, 1, NA)
iris.data - data.matrix(iris)
rbind(iris, colMeans(iris.data) * isnum, sd(iris.data) * isnum)


On 8/17/06, r user [EMAIL PROTECTED] wrote:
 getting s-apply to skip columns with non-numeric data?
 I have a dataframe x of w columns.

 Some columns are numeric, some are not.

 I wish to create a function to calculate the mean and
 standard deviation of each numeric column, and then
 bind the column mean and standard deviation to the
 bottom of the dataframe.

 e.g.

 tempmean - apply(data.frame(x), 2, mean, na.rm = T)
 xnew - rbind(x,tempmean)

 I am running into one small problem…what is the best
 way to have sapply skip the non-numeric data and
 return NA's?

 __
 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.


__
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] getting sapply to skip columns with non-numeric data?

2006-08-17 Thread Liaw, Andy
There's something that either you have not thought of or neglected to tell
us:  If you have k variables in the data frame, you will need a data frame
of k variables and one row to be able to rbind() to the bottom of the
original one.  What are you going to put in place for non-numeric variables?

Perhaps this might help:

R dat - data.frame(f=factor(1:3), x=3:5, y=6:4)
R rbind(dat, as.data.frame(lapply(dat, function(x) if (!is.numeric(x)) NA
else mean(x
  f x y
1 1 3 6
2 2 4 5
3 3 5 4
11 NA 4 5

Andy 

From: r user
 
 getting s-apply to skip columns with non-numeric data?
 I have a dataframe x of w columns.
 
 Some columns are numeric, some are not.
 
 I wish to create a function to calculate the mean and 
 standard deviation of each numeric column, and then bind 
 the column mean and standard deviation to the bottom of the dataframe.
 
 e.g. 
 
 tempmean - apply(data.frame(x), 2, mean, na.rm = T) xnew - 
 rbind(x,tempmean)
 
 I am running into one small problem...what is the best way to 
 have sapply skip the non-numeric data and return NA's?
 
 __
 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.
 


__
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.


[R] DSC 2007

2006-08-17 Thread Paul Murrell
Hi

This is a second call for abstracts.
Please forward and circulate to other interested parties.
[apologies for any cross-posting]

DSC 2007, a conference on systems and environments for statistical
computing, will take place in Auckland, New Zealand on February 15  16,
2007.

We invite abstracts on the development of software systems and computing
environments for interactive statistics.  The workshop will focus on,
but is not limited to, open source statistical computing.

The deadline for submitting abstracts is 2006-10-15 (October 15th).
Please visit the conference web page at
http://www.stat.auckland.ac.nz/dsc-2007/
and send abstracts (one page) to [EMAIL PROTECTED]

Paul
(on behalf of the Organising Committee)
-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
[EMAIL PROTECTED]
http://www.stat.auckland.ac.nz/~paul/

___
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-announce

__
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.


[R] Font-path error when starting X11 device in Gentoo

2006-08-17 Thread Toby Muhlhofer
Dear R listers,

If I try to start the X11 device in Gentoo, I get the following 
complaint from R:

---
  X11()
Error in X11() : could not find any X11 fonts
Check that the Font Path is correct.
---

xset -q produces the following output:

---
Keyboard Control:
   auto repeat:  onkey click percent:  0LED mask:  0002
   auto repeat delay:  500repeat rate:  30
   auto repeating keys:  00ffdbbf
 fadfffdfffdfe5ef
 
 
   bell percent:  50bell pitch:  400bell duration:  100
Pointer Control:
   acceleration:  2/1threshold:  4
Screen Saver:
   prefer blanking:  yesallow exposures:  yes
   timeout:  0cycle:  0
Colors:
   default colormap:  0x20BlackPixel:  0WhitePixel:  16777215
Font Path:
 
/usr/share/fonts/misc/,/usr/share/fonts/TTF/,/usr/share/fonts/Type1/,/usr/share/fonts/75dpi/,/usr/share/fonts/100dpi/
Bug Mode: compatibility mode is disabled
DPMS (Energy Star):
   Standby: 3600Suspend: 3600Off: 7200
   DPMS is Enabled
   Monitor is On
File paths:
   Config file:  /etc/X11/xorg.conf
   Modules path: /usr/lib/xorg/modules
   Log file: /var/log/Xorg.0.log
---

Furthermore, no other graphics applications are complaining about not 
finding fonts.

By the way, this happens both with the Gentoo ebuilds (2.2.1 and 2.3.1) 
of R, as well as with the source tarball from the R website, compiled 
manually (with X support, of course).

Any suggestions?

Thanks,
Toby

__
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.


[R] Fitting Truncated Lognormal to a truncated data set (was: fitting truncated normal distribution)

2006-08-17 Thread xpRt.wannabe
Dear List,

I am trying to fit Truncated Lognormal to a data set that is
'truncated' from above a certain value, say, 0.01.  Below is what I
was able to come up with.  I would appreciate it if you could review
and make any necessary changes.

# This is modified off the code for 'dtnorm' of library(msm).
dtlnorm - function (n, mean = 0, sd = 1, lower = -Inf, upper = Inf)
{
   ret - numeric()
   if (length(n)  1)
   n - length(n)
   while (length(ret)  n) {
   y - rlnorm(n - length(ret), mean, sd)
   y - y[y = lower  y = upper]
   ret - c(ret, y)
   }
   stopifnot(length(ret) == n)
   ret
}

# This is modified off the code for 'rtnorm' of the library(msm).
rtlnorm - function (n, mean = 0, sd = 1, lower = -Inf, upper = Inf)
{
   ret - numeric()
   if (length(n)  1)
   n - length(n)
   while (length(ret)  n) {
   y - rlnorm(n - length(ret), mean, sd)
   y - y[y = lower  y = upper]
   ret - c(ret, y)
   }
   stopifnot(length(ret) == n)
   ret
}

x - rtlnorm(100, mean=-11.64857, sd = 3.422795, 0.01)

fitting truncated normal distribution on 8/16/2006.
dtlnorm0 - function(x, mean = 0, sd = 1)
{
dtlnorm(x, mean, sd, 0.01, Inf)
}

fitdistr(x, dtlnorm0, start = list(mean = -11, sd = 1))

Thank you.

platform i386-pc-mingw32
arch i386
os   mingw32
system   i386, mingw32
status
major2
minor2.1
year 2005
month12
day  20
svn rev  36812
language R

__
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] NLME: Limitations of using identify to interact with scatterplots?

2006-08-17 Thread Andrew Robinson
Many useful diagnostic plots can be recreated in the usual plot()
framework, with only a little coding effort. In this case, I would
imagine that

plot(dframe$log2game, fitted(D2C29.nlme))
abline(0,1)

should get pretty close, if the name of the dataframe containing the
variable is 'dframe'.

Andrew

On Thu, Aug 17, 2006 at 08:55:41AM -0500, Douglas Bates wrote:
 Most plotting functions in the nlme package use lattice graphics
 functions based on the grid package.  Identify will not work with
 lattice graphics.  I'm not sure if there is a replacement.
 
 On 8/17/06, Greg Distiller [EMAIL PROTECTED] wrote:
  I have a quick question regarding the use of identify to interact with
  points on a scatterplot. My question is essentially: can identify be used
  when one is plotting model objects to generate diagnostic plots?
  Specifically I am using NLME.
  For example, I am plotting the fitted values on the x axis vs a variable
  called log2game with the following code:
 
  plot(D2C29.nlme, log2game ~ fitted(.), abline=c(0,1))
 
  and then I have tried to use identify as follows:
 
  identify(D2C29.nlme$fitted[,2],Data2$log2game,row.names(Data2))
 
  (if I leave out the [,2] on the fitted attributes then I am told that x and
  y are not the same length and it appears that this is due to the fact that
  the fitted attribute has 2 columns.)
 
  but I get an error message that plot.new has not been called yet.
 
  I am not sure if this is because I am doing something wrong or if identify
  simply cannot be used in this context.
 
  Many thanks
 
  Greg
 
  __
  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.
 
 
 __
 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.

-- 
Andrew Robinson  
Department of Mathematics and StatisticsTel: +61-3-8344-9763
University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599
Email: [EMAIL PROTECTED] http://www.ms.unimelb.edu.au

__
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.


[R] Lattice package par.settings/trellis.par.settings questions

2006-08-17 Thread Debarchana Ghosh
Hi All,

I'm trying to modify some of the default graphic parameters in a 
conditional histogram. While I was able to change the default grey 
background to white, I couldn't change the axis.font or the xlab font.

I used the following code:

/histogram(~V751|V013+V025, finalbase, xlab=Heard of HIV/AIDS 
(No/Yes), col=c(cyan,magenta), par.settings=list(background=white))

/The arguments for example  like /axis.font=2/, or /cex=2/ are not 
working in the /par.settings(). /I also tried to read the manual of 
/trellis.par.settings()/ but didn't understand how to use it and where 
exactly to put it.

Any help with this will be appreciated.

Thanks,
Debarchana.

-- 
Debarchana Ghosh
Research Assistant
Department of Geography
University of Minnesota
PH: 8143607580
email to: [EMAIL PROTECTED]
www.tc.umn.edu/~ghos0033

__
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] Lattice package par.settings/trellis.par.settings questions

2006-08-17 Thread Gabor Grothendieck
The parameter names are axis.text$font and axis.text$cex .
Try issuing the command:
  trellis.par.get()
to get a complete list.

Here is an example:

histogram(1:10, par.settings = list(axis.text = list(font = 2, cex = 0.5)))


On 8/17/06, Debarchana Ghosh [EMAIL PROTECTED] wrote:
 Hi All,

 I'm trying to modify some of the default graphic parameters in a
 conditional histogram. While I was able to change the default grey
 background to white, I couldn't change the axis.font or the xlab font.

 I used the following code:

 /histogram(~V751|V013+V025, finalbase, xlab=Heard of HIV/AIDS
 (No/Yes), col=c(cyan,magenta), par.settings=list(background=white))

 /The arguments for example  like /axis.font=2/, or /cex=2/ are not
 working in the /par.settings(). /I also tried to read the manual of
 /trellis.par.settings()/ but didn't understand how to use it and where
 exactly to put it.

 Any help with this will be appreciated.

 Thanks,
 Debarchana.

 --
 Debarchana Ghosh
 Research Assistant
 Department of Geography
 University of Minnesota
 PH: 8143607580
 email to: [EMAIL PROTECTED]
 www.tc.umn.edu/~ghos0033

 __
 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.


__
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] Lattice package par.settings/trellis.par.settings questions

2006-08-17 Thread Anupam Tyagi
Please read about lattice.par.settings, and not trellis.par.settings. Trellis is
in S/S-plus. Anupam.

__
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.