Re: [R] LME correlation structures: user defined

2005-07-01 Thread Steve Roberts
Hi,

I noticed your old posts whilst tidying up my mailbox. I am struggling 
trying to understand the code to define new structures - part of the real 
work is hidden away in C code and I don't speak C very well. Have 
either of you successfully implemented any alternative structures? (At 
one stage I ws interested in trying Toeplitz forms, and now have a 
need for compound symmetry forms where the rho depends on a 
factor.) Have you anything beyond the source that might help? - for 
example a more richly commented example, or notes on what the C 
(and R)  functions actually do.

Regards,

Steve.




Date sent:  Wed, 23 Mar 2005 10:56:46 +1100
To: "Michael Jerosch-Herold" <[EMAIL PROTECTED]>, 
R-help@stat.math.ethz.ch
From:   Simon Blomberg <[EMAIL PROTECTED]>
Subject:Re: [R] LME correlation structures: user defined
Copies to:  
> >Let me modify my question about user-defined covariance structures
> >for LME models: Can somebody tell me how I can see the code for the
> >definition of the correlation structures that come with the NLME
> >package. Specifically I like to see the code for the functions coef,
> >corMatrix, and intialize for any of the pre-defined correlation
> >structures, and use this as a template to define a new correlation
> >structure. So how do I see e.g. the code for the method initialize
> >for the correlation structure corExp or corARMA?
> 
> I'm interested in this too. Go to CRAN and download the source code
> for the nlme package. ungzip and untar it. Got to the R subdirectory.
> Inside that is a file called corStruct.R with all the method
> definitions for the built-in corStruct classes. Reading those should
> help.
> 
> Cheers,
> 
> Simon.
> 
> 
> >
> >thank you in advance!
> >
> >Michael Jerosch-Herold
> >
> >PS: Oh, and if somebody could still send me example code for a user
> >defined correlation structure I would much appreciate it, as my
> >previous requests for help have not yielded any response.
> >
> >__
> >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
> 
> 
> -- 
> Simon Blomberg, B.Sc.(Hons.), Ph.D, M.App.Stat.
> Visiting Fellow
> School of Botany & Zoology
> The Australian National University
> Canberra ACT 0200
> Australia
> 
> T: +61 2 6125 8057  email: [EMAIL PROTECTED]
> F: +61 2 6125 5573
> 
> CRICOS Provider # 00120C
> 
> __
> 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


  Dr Steve Roberts 
  [EMAIL PROTECTED]

Senior Lecturer in Medical Statistics,
CMMCH NHS Trust and University of Manchester Biostatistics Group,
0161 275 5192/5764 / 0161 276 5785

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


[R] lme/gls heteroscedastic correlation structure

2005-06-15 Thread Steve Roberts
Greetings,

We want to fit lme/gls models with a compound symmetry variance 
structure, but where the ICC takes different values across different 
groups of clusters. (Specifically a two arm clustrered trial with different 
ICC in each arm) Equivalent models can be fitted with heteroscedastic 
variance functions, but these have positivity constraints which we want 
to avoid and we would prefer to use the correlation structure directly. Is 
there a way to do this? Writing a new variance structure seems rather 
non-trivial - but maybe I haven't tried hard enough.. 

Any ideas?

Steve.

  Dr Steve Roberts 
  [EMAIL PROTECTED]

Senior Lecturer in Medical Statistics,
CMMCH NHS Trust and University of Manchester Biostatistics Group,
0161 275 5192/5764 / 0161 276 5785

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


Re: [R] R2.1.0: Bug in list.files

2005-05-12 Thread Steve Roberts
Yes I missed the NEWS entry - or rather didn't realise its significance. 
So the "bug" was in the previous version and my old code which worked 
but shouldn't have.

Thanks for the replies - rapid and to the point as usual.

Steve.


Date sent:  Thu, 12 May 2005 10:45:03 +0200
From:   Uwe Ligges <[EMAIL PROTECTED]>
Organization:   Fachbereich Statistik, Universitaet Dortmund
To: [EMAIL PROTECTED]
Copies to:  R-help@stat.math.ethz.ch
Subject:Re: [R] R2.1.0: Bug in list.files

> Steve Roberts wrote:
> 
> > R2.0.1 (MS Windows)
> > 
> > 
> >>list.files(myloc,"*.zip",full=T)
> > 
> > [1] "P:/SARsoftware/Rlibraries/gnlm_0.1.zip"
> > [2] "P:/SARsoftware/Rlibraries/lms2_0.2.zip"
> > 
> > 
> > R2.1.0:
> > 
> > 
> >>list.files(myloc,"*.zip",full=T)
> > 
> > Error in list.files(path, pattern, all.files, full.names, recursive)
> > : 
> > invalid 'pattern' regular expression
>  >
> > Bug? or have I missed something
> 
> You missed to read the NEWS that tells you:
> 
>  o   The regular expression code is now based on that in glibc
>  2.3.3. It has stricter conformance to POSIX, so metachars such as
>  { } + * may need to be escaped where before they did not (but
>  could have been).
> 
> 
> Probably you want
> 
>   list.files(pattern = "\\.zip$", full.names = TRUE)
> 
> Uwe Ligges
> 
> 
> > Steve.
> >   Dr Steve Roberts 
> >   [EMAIL PROTECTED]
> > 
> > Senior Lecturer in Medical Statistics,
> > CMMCH NHS Trust and University of Manchester Biostatistics Group,
> > 0161 275 5192/5764 / 0161 276 5785
> > 
> > __
> > 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
> 


  Dr Steve Roberts 
  [EMAIL PROTECTED]

Senior Lecturer in Medical Statistics,
CMMCH NHS Trust and University of Manchester Biostatistics Group,
0161 275 5192/5764 / 0161 276 5785

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


[R] R2.1.0: Bug in list.files

2005-05-12 Thread Steve Roberts
R2.0.1 (MS Windows)

> list.files(myloc,"*.zip",full=T)
[1] "P:/SARsoftware/Rlibraries/gnlm_0.1.zip"
[2] "P:/SARsoftware/Rlibraries/lms2_0.2.zip"


R2.1.0:

> list.files(myloc,"*.zip",full=T)
Error in list.files(path, pattern, all.files, full.names, recursive) : 
invalid 'pattern' regular expression

Bug? or have I missed something

Steve.
  Dr Steve Roberts 
  [EMAIL PROTECTED]

Senior Lecturer in Medical Statistics,
CMMCH NHS Trust and University of Manchester Biostatistics Group,
0161 275 5192/5764 / 0161 276 5785

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


[R] lme RE variance computation

2004-09-21 Thread Steve Roberts
As I understand it lme (in R v1.9.x) estimates random effect variances 
on a log scale, constraining them to be positive. Whilst this seems 
sensible, it does lead to apparently biased estimates if the variance is 
actually  zero - which makes our simulation results look strange. Whilst 
we need to think a bit deeper about it - I still haven't got my head 
around what a negative variance could mean - does anyone know a 
way to take away the contraint and allowing zero or negative 
variances?

Steve.  Dr Steve Roberts 
  [EMAIL PROTECTED]

Senior Lecturer in Medical Statistics,
CMMCH NHS Trust and University of Manchester Biostatistics Group,
0161 275 5192 / 0161 276 5785

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


Re: [R] Help with plotmath

2004-06-10 Thread Steve Roberts
No that isn't it I'm afraid - my expression is pasted together from 
various bits and pieces and is at some stage a string variable. I 
needed parse as Brian pointed out

Thanks anyway,

Steve.

From:   "Petr Pikal" <[EMAIL PROTECTED]>
To:     "Steve Roberts" <[EMAIL PROTECTED]>
Date sent:  Thu, 10 Jun 2004 13:44:21 +0200
Subject:Re: [R] Help with plotmath
Copies to:  [EMAIL PROTECTED]
Priority:   normal

> Hi
> 
> On 10 Jun 2004 at 12:28, Steve Roberts wrote:
> 
> > There must be a simple answer. I want to plot an expression, 
> > where the expression is held in a string variable. The "obvious"
> > solution along the lines of
> > 
> > ex<-"x^2"
> > plot( c(0,1), c(0,1), main=as.expression(ex) )
> 
> Plotmath example led me to
> 
> ex<-expression(x^2)
> plot( c(0,1), c(0,1), main=(ex) )
> 
> hope it is what you want.
> 
> Cheers
> Petr
> 
> 
> > 
> > gives me the a title x^2 - ie doesn't treat it like an expression. I
> > suspect I don't understand expressions properly. For the real problem
> > I do need to have my expression string in a variable as it is
> > data-dependent. 
> > 
> > Can someone tell me the magic words?
> > 
> > Steve
> >   Dr Steve Roberts 
> >   [EMAIL PROTECTED]
> > 
> > Senior Lecturer in Medical Statistics,
> > CMMCH NHS Trust and University of Manchester Biostatistics Group, 0161
> > 275 5192 / 0161 276 5785
> > 
> > __________
> > [EMAIL PROTECTED] mailing list
> > https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
> > http://www.R-project.org/posting-guide.html
> 
> Petr Pikal
> [EMAIL PROTECTED]
> 
> 


  Dr Steve Roberts 
  [EMAIL PROTECTED]

Senior Lecturer in Medical Statistics,
CMMCH NHS Trust and University of Manchester Biostatistics Group,
0161 275 5192 / 0161 276 5785

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


[R] Help with plotmath

2004-06-10 Thread Steve Roberts
There must be a simple answer. I want to plot an expression, 
where the expression is held in a string variable. The "obvious" 
solution along the lines of

ex<-"x^2"
plot( c(0,1), c(0,1), main=as.expression(ex) )

gives me the a title x^2 - ie doesn't treat it like an expression. I 
suspect I don't understand expressions properly. For the real 
problem I do need to have my expression string in a variable as it is 
data-dependent. 

Can someone tell me the magic words?

Steve
  Dr Steve Roberts 
  [EMAIL PROTECTED]

Senior Lecturer in Medical Statistics,
CMMCH NHS Trust and University of Manchester Biostatistics Group,
0161 275 5192 / 0161 276 5785

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


[R] 2 lme questions

2004-04-05 Thread Steve Roberts
Greetings,

1) Is there a nice way of extracting the variance estimates from an lme fit? They 
don't seem to be part of the lme object.

2) In a series of simulations, I am finding that with ML fitting one of my random 
effect variances is sometimes being estimated as essentially zero with massive CI 
instead of the finite value it should have, whilst using REML I get the expected 
value. I guess it is a numerical/optimisation problem but don't know enough about the 
lme fitting algorithm to know which tollerance/scale parameter to mess about with. Any 
suggestions where to start? 

Thanks,

Steve.

[[alternative HTML version deleted]]

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


[R] DLLs and the Floating Point Control Word.

2004-02-23 Thread Steve Roberts
Greetings. 

One for the developers I guess...  I am having problems in using a 
(non-recommended) Fortran compiler (Salford ftn95 Windoze), and 
the crashes do seem to be associated with the ftn95-dervived DLL 
changing the Floating Point Control Word. The compiler people are 
suggesting (and I paraphrase!) that if R minds what the FPCW is it 
is up to R to make sure it is the value it wants and R should 
check/reset on returning from the DLL call. There seems to me to 
be some logic in this position - if only to make life easier for those 
of us who don't really know what a FPCW is! Having to add 
unintelligable code to reset the FPCW at the end of each fortran 
routine is inelegant. It probably isn't as easy as it sounds  - I guess 
there are multi-platform issues? Is this a sensible suggestion to 
add to the wish list?

Keep up the good work

Steve.
  Dr Steve Roberts 
  [EMAIL PROTECTED]

Senior Lecturer in Medical Statistics,
CMMCH NHS Trust and University of Manchester Biostatistics Group,
0161 275 5192 / 0161 276 5785

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


[R] RGui (Windows) crashes after use of a Salford Fortran DLL

2004-02-11 Thread Steve Roberts
Anybody out there successfully using the Salford Fortran compilers 
with R? 

I have created a DLL using the Salford FTN95 compiler and it works 
in as far I can dyn.load it, run the routines and get the  right 
answers back. Unfortunately subsequently, sometime later, the 
Rgui crashes (access violation I think from the DrWatson log). The 
crashes depend on whether or not I paste the code as one big 
chunk, or as little chunks, and sometimes I can do a few things 
before it crashes and other times not - but if I do exactly the same 
things the crashes are reproducible. The crashes are sometimes in 
the DLL and sometimes in pure R code. R1.7.1 and 1.8.1 seem to 
behave identically. Windows 2000 Pro.

I do get the dyn.load warning about the DLL changing the FPU 
control word.

Does this ring any bells with anyone?

Steve.

  Dr Steve Roberts 
  [EMAIL PROTECTED]

Senior Lecturer in Medical Statistics,
CMMCH NHS Trust and University of Manchester Biostatistics Group,
0161 275 5192 / 0161 276 5785

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


[R] Bug in cor.test - Spearman

2003-11-07 Thread Steve Roberts
Greetings.

There seems to be a problem with the P-value computation in the 
cor.test with method="spearman". In R1.8.0  (MS Windows) I 
seem to be getting intermittently nonsense P-values, but the rho's 
are OK. I can get this reproducibly with the toy example attached 
where the first use is OK and subsequent calls with the same data 
give nonsense. (I have also seen the problem without the warning 
about duplicated values.) The toy example behaves correctly under 
1.7.1.

Steve.

---Script---
x<-1:100
y<-rep(c(2,3,4,5),25)
cor.test(x,y,m="p")
cor.test(x,y,m="s")
cor.test(x,y,m="s")
cor.test(x,y,m="k")

---Output--
R : Copyright 2003, The R Development Core Team
Version 1.8.0  (2003-10-08)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for a HTML browser interface to help.
Type 'q()' to quit R.

> x<-1:100
> y<-rep(c(2,3,4,5),25)
> cor.test(x,y,m="p")

Pearson's product-moment correlation

data:  x and y 
t = 0.3837, df = 98, p-value = 0.702
alternative hypothesis: true correlation is not equal to 0 
95 percent confidence interval:
 -0.1588952  0.2333745 
sample estimates:
   cor 
0.03873177 

> cor.test(x,y,m="s")

Spearman's rank correlation rho

data:  x and y 
S = 160195, p-value = 0.7015
alternative hypothesis: true rho is not equal to 0 
sample estimates:
   rho 
0.03873177 

Warning message: 
p-values may be incorrect due to ties in: cor.test.default(x, y, m = 
"s") 
> cor.test(x,y,m="s")

Spearman's rank correlation rho

data:  x and y 
S = 160195, p-value = < 2.2e-16
alternative hypothesis: true rho is not equal to 0 
sample estimates:
   rho 
0.03873177 

Warning message: 
p-values may be incorrect due to ties in: cor.test.default(x, y, m = 
"s") 
> cor.test(x,y,m="k")

Kendall's rank correlation tau

data:  x and y 
z = 0.5132, p-value = 0.6078
alternative hypothesis: true tau is not equal to 0 
sample estimates:
   tau 
0.03481553 

> 

  Dr Steve Roberts 
  [EMAIL PROTECTED]

Senior Lecturer in Medical Statistics,
CMMCH NHS Trust and University of Manchester Biostatistics Group,
0161 275 5192 / 0161 276 5785

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


[R] What a wonderful list (was Strange and disturbing bug)

2003-03-18 Thread Steve Roberts
What a wonderful set of people you are! - I 
solved by own problem, deleted the message and 
got 3 replies before I realised I'd hit "send" 
rather then "delete". 

Steve.
 
  Dr Steve Roberts 
  [EMAIL PROTECTED]

Senior Lecturer in Medical Statistics,
CMMCH NHS Trust and University of Manchester Biostatistics Group,
0161 275 5192 / 0161 276 5785

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


[R] Strange and disturbing bug

2003-03-18 Thread Steve Roberts
How about this one? If I set a variable in a data.frame with a two-
part name including a dot (say y.pair), and if the variable with the 
name of the first part (y) doesn't but I ask for it's value I get the 
value of the two-part name. Ie set fred$x.pair and print the value of 
fred$x it gives me the value I set to fred$x.pair. Weird and 
somewhat disturbing!
Maybe an example makes it clearer:


  Dr Steve Roberts 
  [EMAIL PROTECTED]

Senior Lecturer in Medical Statistics,
CMMCH NHS Trust and University of Manchester Biostatistics Group,
0161 275 5192 / 0161 276 5785

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


[R] Profile on optim/nlm

2003-01-23 Thread Steve Roberts
Greetings,

Before I reinvent the wheel has anyone done a profile function for a 
fit using optim (or nlm)?  (like the buggy profile.ms in S+) . It 
seems a bit tricky as the function to be minimised has to have 
arguments corresponding to the variables being fitted - which is one 
less than the function provided to optim()... I guess you can create 
another function on the fly somehow.

Cheers,

Steve.
Dr Steve Roberts 
[EMAIL PROTECTED]

Biostatistics Group,
School of Epidemiology and Health Sciences, 
2nd Floor,Stopford Building,
University of Manchester.   
M13 9PT.
Tel: 0161 275 5192 FAX: 0161 275 5205

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