Re: [R] Tools For Preparing Data For Analysis

2007-06-10 Thread Chris Evans
(Ted Harding) sent the following  at 10/06/2007 09:28:

... much snipped ...

> (As is implicit in many comments in Robert's blog, and indeed also
> from many postings to this list over time and undoubtedly well
> known to many of us in practice, a lot of the problems with data
> files arise at the data gathering and entry stages, where people
> can behave as if stuffing unpaired socks and unattributed underwear
> randomly into a drawer, and then banging it shut).

And they look surprised when pointing a statistician at the chest of
drawers doesn't result in a cut price display worthy of Figleaf (or
Victoria's Secret I think for those of you in N.America) and get them
their degree, doctorate, latest publication ...

Ah me, how wonderfully, wonderfully ... sadly, accurate!

Thanks Ted, great thread and I'm impressed with EpiData that I've
discovered through this. I'd still like something that is even more
integrated with R but maybe some day, if EpiData go fully open source as
I think they are doing ("A full conversion plan to secure this and
convert the software to open-source has been made (See complete
description of license and principles)." at http://www.epidata.dk/ but
the link to http://www.epidata.dk/about.htm doesn't exactly clarify this
I don't think.  But I can hope.)

Thanks, yet again, to everyone who creates and contributes to the R
system and this list: wonderful!

C


-- 
Chris Evans <[EMAIL PROTECTED]> Skype: chris-psyctc
Professor of Psychotherapy, Nottingham University;
Consultant Psychiatrist in Psychotherapy, Notts PDD network;
Research Programmes Director, Nottinghamshire NHS Trust;
*If I am writing from one of those roles, it will be clear. Otherwise*
*my views are my own and not representative of those institutions*

__
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] Tools For Preparing Data For Analysis

2007-06-08 Thread Chris Evans

Martin Henry H. Stevens sent the following  at 08/06/2007 15:11:
> Is there an example available of this sort of problematic data that  
> requires this kind of data screening and filtering? For many of us,  
> this issue would be nice to learn about, and deal with within R. If a  
> package could be created, that would be optimal for some of us. I  
> would like to learn a tad more, if it were not too much effort for  
> someone else to point me in the right direction?
> Cheers,
> Hank
> On Jun 8, 2007, at 8:47 AM, Douglas Bates wrote:
> 
>> On 6/7/07, Robert Wilkins <[EMAIL PROTECTED]> wrote:
>>> As noted on the R-project web site itself ( www.r-project.org ->

... rest snipped ...

OK, I can't resist that invitation.  I think there are many kinds of
problematic data.  I handle some nasty textish things in perl (and I
loved the purgatory quote) and I'm afraid I do some things in Excel and
some cleaning I can handle in R, but I never enter data directly into R.

However, one very common scenario I have faceda all my working life is
psych data from questionnaires or interviews in low budget work, mostly
student research or routine entry of therapists' data.  Typically you
have an identifier, a date, some demographics and then a lot of item
data.  There's little money (usual zero) involved for data entry and
cleaning but I've produced a lot of good(ish) papers out of this sort of
very low budget work over the last 20 years.  (Right at the other end of
a financial spectrum from the FDA/validated s'ware thread but this is
about validation again!)

The problem I often face is that people are lousy data entry machines
(well, actually, they vary ... enormously) and if they mess up the data
entry we all know how horrible this can be.

SPSS (boo hiss) used to have an excellent "module", actually a
standalone PC/Windoze program, that allowed you to define variables so
they had allowed values and it would refuse to accept out of range or
out of acceptable entries, it also allowed you to create checking rules
and rules that would, in the light of earlier entries, set later values
and not ask about them.  In a rudimentary way you could also lay things
out on the screen so that it paginated where the q'aire or paper data
record did etc.  The final nice touch was that you could define some
variables as invariant and then set the thing so an independent data
entry person could re-enter the other data (i.e. pick up q'aire, see if
ID fits the one showing on screen, if so, enter the rest of the data).
It would bleep and not move on if you entered a value other than that
entered by the first person and you had to confirm that one of you was
right.

That saved me wasted weeks I'm sure on analysing data that turned out to
be awful and I'd love to see someone build something to replace that.

Currently I tend to use (boo hiss) Excel for this as everyone I work
with seems to have it (and not all can install open office and anyway I
haven't had time to learn that properly yet either ...) and I set up
spreadsheets with validation rules set.  That doesn't get the branching
rules and checks (e.g. if male, skip questions about periods, PMT and
pregnancies), or at least, with my poor Excel skills it doesn't.  I just
skip a column to indicate page breaks in the q'aire, and I get, when I
can, two people to enter the data separately and then use R to compare
the two spreadsheets having yanked them into data frames.

I would really, really love someone to develop (and perhaps replace) the
rather buggy edit() and fix() routines (seem to hang on big data frames
in Rcmdr which is what I'm trying to get students onto) with something
that did some or all of what SPSS/DE used to do for me or I bodge now in
Excel.  If any generous coding whiz were willing to do this, I'll try to
alpha and beta test and write help etc.

There _may_ be good open source things out there that do what I need but
something that really integrated into R would be another huge step
forward in being able to phase out SPSS in my work settings and phase in R.

Very best all,

Chris



-- 
Chris Evans <[EMAIL PROTECTED]> Skype: chris-psyctc
Professor of Psychotherapy, Nottingham University;
Consultant Psychiatrist in Psychotherapy, Notts PDD network;
Research Programmes Director, Nottinghamshire NHS Trust;
*If I am writing from one of those roles, it will be clear. Otherwise*
*my views are my own and not representative of those institutions*

__
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] Oddities upgrading from 2.4.1 to 2.5.0

2007-05-13 Thread Chris Evans
I'm working on Windoze XP and have for some time installed R in D:\R and
 upgraded my packages after installing the new version of R with a bit
of code I think I got from the list:
ip <- installed.packages(lib.loc = "d:\\R\\R-2.4.1\\library")
ip <- ip[ip[,1]!="base" ,1]
install.packages(ip)

This time around that's produced some warning grumbles:
Warning messages:
1: packages 'dynamicGraph', 'ggplot', 'grid', 'Qtoolbox', 'ref',
'splines', 'stats4', 'tapiR', 'tcltk', 'tools' are not available
2: dependencies 'Design', 'graph', 'RBGL' are not available

Sure enough, those in warning 1 were all in the 2.4.1 library directory
tree and those in warning 2 weren't.  Now I'm trying to work out how
these failures have happened.

I think some of this could be because of a problem with the mirrors
(though I've tried both UK(London) and Switzerland(Zurich)).  I have
seen the posting saying that there are problems.  I also think some
could be because I may have installed some packages under 2.4.1 which
didn't come from CRAN but I didn't keep careful records stupidly.

Anyway, looking at http://cran.r-project.org/ packages I think that:
'dynamicGraph', 'ggplot', 'ref', 'stats4' and 'Design' should all be
there for me to install with install.packages() but they're definitely
not at UK(London) or Switzerland(Zurich).

Searching a bit I can see that Qtoolbox was a non-CRAN package I
installed directly.

However, I still seem to have created some warnings here that searching
the R site search isn't answering for me.

Two questions/suggestions:
1) is there a list somewhere of packages/libraries that were once in R
but aren't now?
2) is there a way of checking for missing dependencies that will
identify both what's missing (clearly something like this is producing
warning 2 following my call of "install.packages(ip)") but might also
produce a list of the origins of the dependencies?

Sorry if these are trivial issues.

TIA,

Chris


-- 
Chris Evans <[EMAIL PROTECTED]> Skype: chris-psyctc
Professor of Psychotherapy, Nottingham University;
Consultant Psychiatrist in Psychotherapy, Notts PDD network;
Research Programmes Director, Nottinghamshire NHS Trust;
Hon. SL Institute of Psychiatry, Hon. Con., Tavistock & Portman Trust
*If I am writing from one of those roles, it will be clear. Otherwise*
*my views are my own and not representative of those institutions*

__
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] Making TIFF images with rtiff

2007-01-12 Thread Chris Evans
Prof Brian Ripley sent the following  at 12/01/2007 08:07:
> Let us be clear that TIFF is not a format, it is a collection of formats 
... snip ...

> [I don't recall anyone ever writing to thank us for the
> PNG or JPEG or bitmap drivers, and lack of appreciation does play a part.]

... rest snipped ...

I hope I'm not going to turn out to be one a deluge of people now who
hit the list with this but, I think you have a real point there.  I
sometimes wince at the tartness of some responses on this list but I owe
you and many other people a completely unredeemable debt both for R
itself including all its drivers, libraries, extraordinary portability,
etc., etc. _AND_ for the fantastic quality of the advice that is given
away daily here.

If it's any consolation, I've started offering workshops to conferences
in my own area to introduce novices away from SPSS and other packages (I
loved SAS for a long time) and onto R.  Trouble is, if I succeed,
that'll probably only increase the rate of feature requests and
questions here.

Perhaps the sheer unredeemable nature of the debt to you all is part of
what makes us quiet.

Cheers all,

Chris

P.S. as ever, really helpful information re TIFFs confirming things I
utterly failed to convince a printers and a subeditor about last year,
fortunately the editor was a friend and we ended up getting the paper
accepted with PS graphics as files!


-- 
Chris Evans <[EMAIL PROTECTED]> Skype: chris-psyctc
Professor of Psychotherapy, Nottingham University;
Consultant Psychiatrist in Psychotherapy, Notts PDD network;
Research Programmes Director, Nottinghamshire NHS Trust;
Hon. SL Institute of Psychiatry, Hon. Con., Tavistock & Portman Trust
*If I am writing from one of those roles, it will be clear. Otherwise*
*my views are my own and not representative of those institutions*

__
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] Finding points with equal probability between normal distributions

2006-08-07 Thread Chris Evans
Eleni Rapsomaniki sent the following  at 07/08/2006 11:35:
> Dear mailing list, 
> 
> For two normal distributions, e.g:
> 
> r1 =rnorm(20,5.2,2.1)
> r2 =rnorm(20,4.2,1.1)
> plot(density(r2), col="blue")
> lines(density(r1), col="red")
> 
> Is there a way in R to compute/estimate the point(s) x where the density of 
> the
> two distributions cross (ie where x has equal probability of belonging to
> either of the two distributions)?

I worry about showing my statistical incompetence or incomprehension but
isn't what you need Jacobson et al.'s criterion C for clinical change?
I.e. the point at which the misclassification rates in two Normal
distributions, one with a higher mean than the other, match.

It's at (sd1*mean2 + sd2*mean1)/(sd1 + sd2)

So for Eleni's example I think that comes out at 4.544 and if I use:
> r1b <- rnorm(200,5.2,2.1)
> r2b <- rnorm(200,4.2,1.1)
> plot(density(r2b), col="blue")
> plot(density(r1b), col="red")
> plot(density(r2b), col="blue")
> lines(density(r1b), col="red")
> cscc <- 4.544
> abline(v=cscc)

It happened to work out beautifully:

> sum(r1b > cscc)
[1] 126
> sum(r2b < cscc)
[1] 126

of course, set a different seed (I broke the posting rules and didn't
set one, yes,  I know) you won't get such a nice result every time and
with n=20 in each group you'll get much more wobble.

Or am I missing something.  The original paper, which got reliable
change wrong, was:

Jacobson, N. S., Follette, W. C. & Revenstorf, D. (1984) Psychotherapy
outcome research: methods for reporting variability and evaluating
clinical significance. Behavior Therapy, 15, 336-352.

There's a summary most people cite at:
Jacobson, N. S. & Truax, P. (1991) Clinical significance: a statistical
approach to defining meaningful change in psychotherapy research.
Journal of Consulting and Clinical Psychology, 59, 12-19.

and shameless self-promotion here, I tried to summarise it:
Evans, C., Margison, F. & Barkham, M. (1998) The contribution of
reliable and clinically significant change methods to evidence-based
mental health. Evidence Based Mental Health, 1, 70-72.

I hadn't twigged that what the criterion gives is balanced
missclassification when I wrote that.  I've played with some simulations
and it's not as vulnerable to non-Gaussian distributions as I'd expected
but someone can probably point to published work, simulation or
analytic, on that.

Cheers all,

Chris

__
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] Power of a single sample binomial test

2006-07-30 Thread Chris Evans
The only references to this I can find searching the archives are to a
student who asked in relation to his course work on a stats course.
Promise I'm not doing that!

I have a situation in which we want to test proportions against an
expected proportion, binom.test() is great.  I'd like to do some post
hoc power tests (the x and n were beyond our control in the survey as
all we could set was an overall n.max where n < n.max, n is between  1
and 44).

I would love to work out our power to have detected a proportions
different from the expected (.307).  I've run two-tailed binomial tests
as we were interested in both high and low.  We can not unreasonably
confine to the directional prediction of observed x/n << .307, say <.15
if that makes the maths easier.  I can't see functions in R that will do
this for me.  The only book I seem to have to hand that addresses this is:
Kraemer, H. C. & Thiemann, S. (1988) How many subjects?  Statistical
power analysis in research. Newbury Park California, Sage Publications, Inc.
which I appreciate is ageing but I assume still correct.  The problem I
have is that I can use R to get Kraemer's upper case delta (p.77) and
look up in their "Master table" but I'd love a more flexible function
that would  say solve for power where p1, n, p0 and alpha are given.  I
think I ought to be able to work out how their master table was
calculated and work from that but I'm finding the mathematics a bit
opaque for my ageing brain.  Their model is clearly one-tailed.  I'm not
sure how one works a two-tailed power.

A search around for web calculators etc. turns up all manner of things,
some probably good, some dead etc.  I'd hugely appreciate if someone
here could share anything they may have in R or point me to R solutions
I may have missed.

TIA,

Chris

-- 
Chris Evans <[EMAIL PROTECTED]>
Professor of Psychotherapy, Nottingham University;
Consultant Psychiatrist in Psychotherapy, Rampton Hospital;
Research Programmes Director, Nottinghamshire NHS Trust;
Hon. SL Institute of Psychiatry, Hon. Con., Tavistock & Portman Trust
**If I am writing from one of those roles, it will be clear. Otherwise**

**my views are my own and not representative of those institutions**

__
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] Plotting league tables/ caterpillar plots

2006-07-24 Thread Chris Evans
Eik Vettorazzi sent the following  at 24/07/2006 13:04:
> Dear list,
> I was wondering if there is a function to plot league tables, sometimes  
> also known as "caterpillar plots"?
> A league table is conceptually very similar to a box plot. One difference  
> is that the inter-quartile ranges are not shown. If there isn't such a  
> function a first attempt for a "selfmade" plot would be to tell boxplot  
> not to plot boxes (sounds silly isn't it?). I've tried the option  
> "boxwex=0" but the result is unsatisfactory.
> 
> An example for a league table can be found in Marshall, Spiegelhalter  
> [1998], Reliability of league tables of in vitro fertilisation clinics,  
> BMJ1998;316:1701-1705, you may find it at http://bmj.bmjjournals.com


Interesting, never heard the term "caterpillar plot" but I like that.  I
also call related things "biplane plots": the body is the parameter and
the wings (not really biplanes at all are they) are the 95% CI for the
parameter.  However, these caterpillar plots are rather like forest
plots or "trees plots" (I argue that you can see both the wood and the
trees!)

I tend to plot them rotated by 90 degrees and without such good
labelling as in the Spiegelhalter paper, but this code may help you.
The "traffic lights" in this superimpose overall quartiles which is used
in some colleagues' way of looking at league tables.  I've used similar
plots for proportions, means, correlations and even alpha reliability
parameters, it's fairly easy to substitute different parameters and
their CIs.  I prefer to use a more exact estimator of the CI of the
median than the one that, if I remember rightly, is the default in the
boxplot which is, I think a much quicker but less robust estimator of
the CI for each sample.

I'd appreciate gentle constructive criticism of my coding, I know I'm a
much better psychotherapist than a programmer!

C

-- 
Chris Evans <[EMAIL PROTECTED]>
Professor of Psychotherapy, Nottingham University;
Consultant Psychiatrist in Psychotherapy, Rampton Hospital;
Research Programmes Director, Nottinghamshire NHS Trust;
Hon. SL Institute of Psychiatry, Hon. Con., Tavistock & Portman Trust
**If I am writing from one of those roles, it will be clear. Otherwise**

**my views are my own and not representative of those institutions**
## user controlled initialising
title.txt <- paste("")
dependent <- E1SESSPL
indeped <- DBSITE
### special temporary addition for planned number of sessions
dependent[dependent==0] <- NA
missing.crit <- 50 # if the percentage of non-missing values for each level of 
the factor falls below this, colour changes
lights.on <- 0
colour.not.in.final <- 1

# legend.pos <- "bottomright" # options are "topleft" or "bottomright"
# legend.pos <- "topleft" # options are "topleft" or "bottomright"
legend.pos <- "topright" # options are "topleft","topright" or "bottomright"
sort.ord.flag <- "median" # options are "site","size","median"
#sort.ord.flag <- "size" # options are "site","size","median"
#sort.ord.flag <- "site" # options are "site","size","median"


## get the values
#xlow <- min(indeped)
#xhigh <- max(indeped)
tmp.dat1 <- cbind(dependent,indeped)
tmp.dat2 <- na.omit(tmp.dat1)
tmp.val.dep <- tmp.dat2[,1]
tmp.val.indep <- tmp.dat2[,2]
tmp.n <- table(tmp.val.indep)
site.names <- as.numeric(names(tmp.n))
xlen <- length(site.names)
xlow <- 1
xhigh <- xlen
print(xlen)
## OK deal with, and count, missings
print(tmp.n)
print(sum(tmp.n))
grand.n <- length(indeped)
usable.n <- length(tmp.val.dep)
n.missing <- grand.n - usable.n
perc.missing <- round(100*round(n.missing/grand.n,2),2)
grand.n.site <- table(indeped)
miss.triggered <- 0

#ord.site <- order(as.numeric(names(tmp.n)))

## set up storage
lwr <- rep(0,xlen)
skip.site <- lwr
site.median <- lwr
upr <- lwr
n.site <- lwr
perc.site <- lwr
prop <- lwr
n.sig.low <- 0
n.sig.high <- 0

## need to find limits
yhigh <- max(tmp.val.dep)
ylow  <- min(tmp.val.dep)
#yhigh <- 4
#ylow <- 0

## now use it
ref.median <- median(tmp.val.dep)
overall.max <- round(max(tmp.val.dep),2)
overall.min <- round(min(tmp.val.dep),2)
for (i in 1:xlen) {
tmpval.site <- site.names[i]
tmp.site.dat <- tmp.val.dep[tmp.val.indep==tmpval.site]
n.site[i] <- length(tmp.site.dat)
   perc.site[i] <- 100*n.site[i]/grand.n.site[i]
if (n.site[i] <= 5) {
prop[i] <- -1   # impossible prop < 0 useful for 
sort order and to omit these
 

Re: [R] Re-binning histogram data

2006-06-09 Thread Chris Evans
François Pinard sent the following  at 09/06/2006 00:53:
> [Berton Gunter]
> 
>> I would argue that histograms are outdated relics and that density  
>> plots (whatever your favorite flavor is) should **always** be used 
>> instead these days.
> 
> When a now retired researcher paid us a visit, I showed him a density 
> plot produced by R over some data he did work a lot, before he left.
> I, too, find them rather sexy, and I wanted to impress him with some of 
> the pleasures of R, especially knowing he has been a dedicated user of 
> SAS in his times.  Yet, this old and wise man _immediately_ caught that 
> the density curve was leaking a tiny bit through the extrema.
> 
> Not a big deal of course -- and he did like what he saw.  Nevertheless, 

... rest snipped ...

I did like Francois's post very much and confess I'm not very familiar
with density plots and use histograms a lot still.  However, I'm not a
statistician, though like to think I'm not a complete Luddite.

Rather naive question: doesn't this depend a bit on whether you see
yourself as describing the sample or describing the (inferred)
population.  It's intrigued me, much though I think the developing
graphical methods of data exploration are wonderful, that I think that
distinction between sample and population is not made as clearly for
graphical methods as perhaps it would be if the presentation were
textual.  Perhaps that's because it's often implicitly pretty clear, for
example, boxplots and histograms, with inevitable problems, describing
samples, some density plots at least, implicitly describing populations.

I know there's an argument that only the inferences (and their CIs)
about the population are statistics and the rest is accountancy but I am
not happy with that idea!

I'd be interested to hear others' views even if we are rather OTT (Off
The Topic, not Over The Top) here.  Perhaps I'm completely wrong?

Thanks to all for their posts, as ever, I'm learning much.

Chris

-- 
Chris Evans <[EMAIL PROTECTED]>
Hon. Professor of Psychotherapy, Nottingham University;
Consultant Psychiatrist in Psychotherapy, Rampton Hospital;
Research Programmes Director, Nottinghamshire NHS Trust;
Hon. SL Institute of Psychiatry, Hon. Con., Tavistock & Portman Trust
**If I am writing from one of those roles, it will be clear. Otherwise**

**my views are my own and not representative of those institutions**

__
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] Significance test, Cronbach's Alpha

2006-06-05 Thread Chris Evans
Jonathan Baron sent the following  at 05/06/2006 12:05:

... some snipped ...

> It is rare to see anyone report a test for alpha because it is
> usually used descriptively.  If it isn't .7 or higher, people get 
> upset, yet even .5 would be wildly significant in most cases.
> 
> Jon

Feldt did a lot of good work on ANOVA models of alpha, well summarised
in his paper with Salih.  Here are some functions.  Please don't
ridicule my R style, I'm a psychotherapist first, researcher second, and
R enthusiast third.  Amused advice on how to write better code warmly
received.

I'm sure that jackknifing or bootstrapping would give much more
distributionally robust CIs and p values but, as Jon's point above makes
so simply, the real problem is that people don't think through what
they're looking for from an alpha.  I find there are situations in which
I'm genuinely interested in the null: is there some evidence of
covariance here?; and other situations where I want a high alpha because
I'm postulating that we have a useful measure, in the latter case, all
these totemistic values that are "acceptable", "excellent" etc. are
often misleading and a CI around the observed alpha and some exploration
of the factor structure, EFA or CFA, or IRT model explorations, will be
far more important than exactly what alpha you got.

Oops   not quite sure where I should have put the starter on that!

I'll go back to enjoying the fact that I think this is the first time
I've posted something that might be useful to someone!

Very best all:



Chris

feldt1.return <- function(obs.a, n, k, ci = 0.95, null.a = 0)
{
if(obs.a > null.a)
f <- (1 - obs.a)/(1 - null.a)
else f <- (1 - null.a)/(1 - obs.a)  
  # allows for testing against a higher null
n.den <- (n - 1) * (k - 1)
n.num <- n - 1
null.p <- pf(f, n.num, n.den)   
  # set the upper and lower p values for the desired C.I.
p1 <- (1 - ci)/2
p2 <- ci + p1   # corresponding F values
f1 <- qf(p1, n.num, n.den)
f2 <- qf(p2, n.num, n.den)  # confidence interval
lwr <- 1 - (1 - obs.a) * f2
upr <- 1 - (1 - obs.a) * f1
cat(round(lwr,2), "to",round(upr,2),"\n")
interval <- list(lwr,upr)
return(interval)
}

feldt1.lwr <- function(obs.a, n, k, ci = 0.95, null.a = 0)
{
if(obs.a > null.a)
f <- (1 - obs.a)/(1 - null.a)
else f <- (1 - null.a)/(1 - obs.a)  
 # allows for testing against a higher null
n.den <- (n - 1) * (k - 1)
n.num <- n - 1
null.p <- pf(f, n.num, n.den)   
 # set the upper and lower p values for the desired C.I.
p1 <- (1 - ci)/2
p2 <- ci + p1   # corresponding F values
f1 <- qf(p1, n.num, n.den)
f2 <- qf(p2, n.num, n.den)  # confidence interval
lwr <- 1 - (1 - obs.a) * f2
return(lwr)
}

feldt1.upr <- function(obs.a, n, k, ci = 0.95, null.a = 0)
{
if(obs.a > null.a)
f <- (1 - obs.a)/(1 - null.a)
else f <- (1 - null.a)/(1 - obs.a)  
  # allows for testing against a higher null
n.den <- (n - 1) * (k - 1)
n.num <- n - 1
null.p <- pf(f, n.num, n.den)   
  # set the upper and lower p values for the desired C.I.
p1 <- (1 - ci)/2
    p2 <- ci + p1   # corresponding F values
f1 <- qf(p1, n.num, n.den)
f2 <- qf(p2, n.num, n.den)  # confidence interval
upr <- 1 - (1 - obs.a) * f1
return(upr)
}



-- 
Chris Evans <[EMAIL PROTECTED]>
Hon. Professor of Psychotherapy, Nottingham University;
Consultant Psychiatrist in Psychotherapy, Rampton Hospital;
Research Programmes Director, Nottinghamshire NHS Trust;
Hon. SL Institute of Psychiatry, Hon. Con., Tavistock & Portman Trust
**If I am writing from one of those roles, it will be clear. Otherwise**

**my views are my own and not representative of those institutions**

__
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] lme4: Error in getResponseFormula(form) : "Form" must be a two sided formula

2006-02-06 Thread Chris Evans
I'm sure I'm being stupid so flame away...

R2.2.1 on Windoze (boohoo) latest updates of packages.

I'm exploring a dataset (land) with three variables looking at an
narrowly unbalanced two group (GROUP) ANCOVA of a randomised
controlled trial analysing endpoint score (SFQ.LOCF.ENDPOINT) entering
the baseline score (SFQ.BASELINE) as covariate and the following work
fine:

> res.same <- lm(SFQ.LOCF.ENDPOINT ~ SFQ.BASELINE + GROUP,land)
> res.diff <- lm(SFQ.LOCF.ENDPOINT ~ SFQ.BASELINE + GROUP + 
> SFQ.BASELINE*GROUP,land)
> anova(res.same,res.diff)

I try:

> lmList(SFQ.LOCF.ENDPOINT ~ SFQ.BASELINE | GROUP, land)
Call:
Error in getResponseFormula(form) : "Form" must be a two sided formula

I'm puzzled.  That looks like a two sided formula very like the one in
the help for lme4 (which had been loaded) and the data look OK:

> table(land$SFQ.LOCF.ENDPOINT)
 3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 23
 1  1  2  4  8  5 16  9  7 14 18  7 16  9  6  8  4  6  2  3 
> table(land$SFQ.BASELINE)
 3  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 1  1  3  3  4 11  7  7 10 12  9 16 14  9  8  7  8  6  1  1 
> table(land$GROUP)
 1  2
87 89

Advice accepted gratefully and flames ruefully!

Chris

-- 
Chris Evans <[EMAIL PROTECTED]>
Consultant Psychiatrist in Psychotherapy, Rampton Hospital; 
Research Programmes Director, Nottinghamshire NHS Trust, 
Hon. Professor of Psychotherapy, Nottingham University,
Hon. SL Institute of Psychiatry
*** My views are my own and not representative of those institutions ***

__
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] R Graph Gallery : categorization of the graphs

2005-06-07 Thread Chris Evans
On 6 Jun 2005 at 17:48, Sander Oom wrote:
... much snipped ...
> The whole point of a gallery is to show something to the user before
> the user knows what he is looking for. The R help functions currently
> available are hopeless when you have a picture of a graph in your head
> without knowing the required commands.
... much snipped ...

Belief that good graphics are often as important or more important 
than inferential tests or even CIs was one of the reasons I've moved 
over the last 15 years from SPSS (still use it a bit 'cos most 
colleagues do) through SAS (much better, much better graphics) to S+ 
(same but more so) to R (same and FLOSS!)

The demo graphics and the gallery are wonderful visual arguments for 
R and also great resources to help us learn.  Categories that I think 
might be useful sometimes might be: 
describes one variable where that is:
dichotomous, categorical (n(categories) > 2), polytomous 
(short),
polytomous (many levels), or continuous (might allow 
something on
superimposing different referential distributions
describes relationship between two variables where:
both are dichotomous or polytomous
one is ditto, other is continuous (box & violin etc: very 
useful to
see good e.g.s of how to get most appropriate boxplots 
as it's 
always possible to get good ones but not always obvious)
(pointer to back-to-back histogram in Hmisc here)
both are continuous (with and without jitter and weighting 
blobs)
describe relationships between more than two variables...

However, the gallery idea is a very powerful one and being able to 
scroll through and drill down is a useful trick that M$ have, I 
grudgingly admit, used well so could we mimic their galleries from 
Excel as someone has suggested and perhaps mimic the drop down 
graphics picker in S+ (I no longer have access).

It's not much help but someone could put up the drop down list for 
newbies coming from SPSS ... ooh, just opened up my copy (11.0.1) and 
realised there's a gallery there with the following:
bar, line, area, pie, high-low, pareto, control, boxplots, error bar, 
scatter, histogram, normal P-P, normal Q-Q, sequence, 
autocorrelations, cross-correlations & spectral.  Never knew that the 
was there!  The drop down list below that has essentially the same 
list but with the last three under a sub-heading of "time series" and 
ROC curves added.

I wonder if someone hosted a wiki for a while at least it would get 
people contributing code for examples for some of these?  The results 
could transfer to the wonderful graphics gallery as they accumulated. 
 My skills aren't that hot but I'd throw in a few things happily and 
I'm sure a reward would be hearing of better ways to do things both 
in terms of coding and in terms of better displays/graphics to use.

Cheers all,

C
-- 
Chris Evans <[EMAIL PROTECTED]>
Consultant Psychiatrist in Psychotherapy, Rampton Hospital; 
Research Programmes Director, Nottinghamshire NHS Trust, 
Hon. SL Institute of Psychiatry
*** My views are my own and not representative of those institutions 
***

__
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] A long digression on packages

2005-06-06 Thread Chris Evans
On 6 Jun 2005 at 8:38, Jonathan Baron wrote:

> So use my search engine and unclick all the options except for
> "functions"?  Do I need a different term?
No, I'm being an idiot (as I suspected!) and had looked through your 
particular search interface and jumped to the big CRAN one.  Replying 
this to R-help list for public helping of humble porridge and in case 
anyone else is making same mistake.  Thanks for a great search 
facility!
 
> BTW, there is a package called ltm for IRT, but my search is not
> picking it up.  I think there is a problem!  (It may be fixed by
> the time you read this.)
Yup: ltm has got some of what I want but not all yet!!

All power to you on your search interface and thanks again.

C
-- 
Chris Evans <[EMAIL PROTECTED]>
Consultant Psychiatrist in Psychotherapy, Rampton Hospital; 
Research Programmes Director, Nottinghamshire NHS Trust, 
Hon. SL Institute of Psychiatry
*** My views are my own and not representative of those institutions 
***

__
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] A long digression on packages

2005-06-06 Thread Chris Evans
On 6 Jun 2005 at 7:02, Jonathan Baron wrote:

> I haven't followed this thread, but the web interface may exist.
> (Perhaps "help.search()" does something that Namazu doesn't do,
> but I don't think so.)  See my .sig below.
> 
> This is where you get if you click on "Search" in the R home
> page.
Not quite: that's wonderful and I use it a lot but it throws up much 
more from r-project than just the search of the current release 
packages would in help.search() so it can give you much more than you 
need ... if there are tuning parameters one can add that will do the 
necessary, and I'm sure there are, then I'd love to see then and 
ideally see another search box that applied them for us! 

But thanks Jonathan!

Chris
-- 
Chris Evans <[EMAIL PROTECTED]>
Consultant Psychiatrist in Psychotherapy, Rampton Hospital; 
Research Programmes Director, Nottinghamshire NHS Trust, 
Hon. SL Institute of Psychiatry
*** My views are my own and not representative of those institutions 
***

__
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] A long digression on packages

2005-06-06 Thread Chris Evans
On 5 Jun 2005 at 18:44, Jari Oksanen wrote:

> There are diverse opinions about netiquette. One of the most basic, in
> my opinion, is this: if someone posts starts a discussion in a certain
> forum, you shall not divert it to another forum where it may be hidden
> by most readers, perhaps even by the originator of the thread.

With the greatest of respect for Duncan and the R-devel list, I think 
Jari has a point here.  This is one of the most important issues I've 
seen raised on this list (R-help) in recent months and I think it may 
be a structural problem for the development of R, in common with that 
of much FLOSS s'ware, that there's a separation of users and authors 
that needs thought.  There are no perfect answers but too big a 
separation and projects go "techno" and it's hard for those of us who 
can't code C and who are mere "users" to help those outstanding 
people on whom we depend hear what we need: sometimes they are so 
clever, so specialised in their knowledge, or simply in the realm of 
genius not the ordinary, that they can't see our problem.  I have 
slowly come to respect that a pretty brusque style from our 
authorities is the only way to prevent this list being a madhouse but 
I think that Jim's point may fall into that class that is worth some 
duplicate bandwidth here.

I know I've found the problem Jim highlights very confusing and 
unhelpful at times.  Views, which I didn't know, seem helpful but not 
a real solution to the key problem: they may tangentially help by 
ensuring that if your needs fit into a view, it becomes more likely 
that you'll install the packages you need and a local search may tell 
you what you need.  I've taken the inefficient route which suits me 
of installing just about every package to make it less likely I'll 
miss something of use to me. That means my search for "kappa" and 
"Cohen" (with ignore.case=FALSE) turns up at least three 
implementations of aspects of Cohen's kappa.

It may already exist, but a web interface that did a help.search over 
all the packages in the current release version would be great.  (If 
it does exist, sorry, but I'm no dunce and use R nearly every day and 
try to read much of r-help every day and don't know it, which may say 
something!)

I think there may be a need for some R improvement and automated 
updating of what I think is Frank Harrell's function finder:
http://biostat.mc.vanderbilt.edu/s/finder/finder.html
Though I'm not absolutely sure how fitting your works into something 
like that could be imposed on developers!

Another thing that might help would be for a system by which ordinary 
users would volunteer to pair up with developers for packages and try 
to suggest adaptations of the help and such like that might make the 
packages more user friendly.  I wouldn't want to do that for the 
whole of a huge and vital package like MASS or Hmisc (or base or 
stats!) but I'm up for pairing with a developer on a smaller package 
if anyone thinks that would be helpful.

Thoughts for what they're worth.  Thanks a million to all developers 
... asbestos suit on!

Chris
-- 
Chris Evans <[EMAIL PROTECTED]>
Consultant Psychiatrist in Psychotherapy, Rampton Hospital; 
Research Programmes Director, Nottinghamshire NHS Trust, 
Hon. SL Institute of Psychiatry
*** My views are my own and not representative of those institutions 
***

__
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] Seeking friend for life (not)

2005-05-15 Thread Chris Evans
I'll take a risk following Uwe's wonderful response to that advert.  
I'm looking for someone, perhaps particularly a stats student, who 
might want to do a piece of work with me on using R to present and 
analyse routine data that psychotherapists might submit on a cgi-bin 
interface and perhaps cross-referencing that against some largish 
referential data to which I have access.

Like Uwe, I require that the student bring beauty, brains, money, 
infinite tolerance ... no, seriously.  If this might be of any 
possible link up with yourself or a student of yours, read on, 
otherwise reread Uwe's post or just hit the delete button!

The situation is that I have co-developed a "copyleft" self-report 
measure that adult, tabloid literate clients in psychological 
therapies can complete readily that gives reasonable indication of 
their state say at referral, assessment, start of therapy, during 
therapy, end of therapy, follow-up etc.  It's part of a system we 
call CORE (Clinical Outcomes in Routine Evaluation).  How it is used 
is up to practitioners as our aim is to persuade therapists that such 
data can be of use to them, not just to researchers.  There is a 
linked therapist completed assessment form and end of therapy form 
which provides a therapist rating of initial and final state but, 
much more importantly, provides information that contextualises the 
self-report data.

A company in whom I have no financial interest have written a 
wonderful PC based program that takes data and analyses it (CORE-PC, 
see http://coreims.co.uk/ for information on that and the system of 
measures).  However, I am interested in putting something on the www 
using a cgi-bin interface to R to allow therapists not yet convinced 
of the value of CORE-PC to overcome their alienation from routine 
data analysis. 

I am a psychotherapist and psychotherapy researcher first but my 
stats is competent and I've pretty much fixed on R for all my stats 
work now (bye SPSS et al.!) and love it.  However, to use R to do 
this well clearly means getting my head around RZope/RSOAP or 
Rstatserver or something like that as just using CGIwithR, though 
brilliant, is slow and inefficient.

I have discussed this with our local university (Nottingham) who are 
R supportive but have no cgi-bin expertise so I'm asking more widely 
now.  Our/my history is of getting good papers out and we have good 
ones on uses of the system in submission and in press as well as as a 
sample list below.  Unless I do most of the work I'm very unconcerned 
about where my name comes in co-authorship as I'm not under RAE 
pressures, just my own and NHS pressures to move this initiative on.  
Hence it may be a good link up for people.  I currently have 
legitimate access to anonymised datasets from a few thosand in 
specific (multi-practitioner) services to massive (c40k) datasets 
from wider collections and there are many angles to look at within a 
general EDA/visualising approach to help therapy practitioners 
overcome their phobias and lack of numeracy.

Do get in touch directly if you think this may be of some interest.

Very best,

Chris

Sample publications, happy to send snail mail copies:

Barkham, M., Evans, C., Margison, F., et al (1998) The rationale for 
developing and implementing core outcome batteries for routine use in 
service settings and psychotherapy outcome research. Journal of 
Mental Health, 7, 35-47.
Barkham, M., Margison, F., Leach, C., et al (2001) Service profiling 
and outcomes benchmarking using the CORE-OM: toward practice-based 
evidence in the psychological therapies. Journal of Consulting and 
Clinical Psychology, 69, 184-196.
Evans, C., Connell, J., Barkham, M., et al (2002) Towards a 
standardised brief outcome measure: psychometric properties and 
utility of the CORE-OM. British Journal of Psychiatry, 180, 51-60.
 (2003) Practice-Based Evidence: benchmarking NHS primary care 
counselling services at national and local levels. Clinical 
Psychology & Psychotherapy, 10, 374-388.
Evans, C., Mellor-Clark, J., Margison, F., et al (2000) CORE: 
Clinical Outcomes in Routine Evaluation. Journal of Mental Health, 9, 
247-255.
Margison, F. R., Barkham, M., Evans, C., et al (2000) Measurement and 
psychotherapy: Evidence-based practice and practice-based evidence. 
British Journal of Psychiatry, 177, 123-130.
Mellor-Clark, J., Connell, J., Barkham, M., et al (2001) Counselling 
outcomes in primary health care: a CORE system data profile. European 
journal of psychotherapy, counselling and health, 4, 65-86.
-- 
Chris Evans <[EMAIL PROTECTED]>
Consultant Psychiatrist in Psychotherapy, Rampton Hospital; 
Research Programmes Director, Nottinghamshire NHS Trust, 
Hon. SL Institute of Psychiatry
*** My views are my own and not representative of those institutions 
***

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.

Re: [R] working with CGIwithR [2 answers]

2005-05-10 Thread Chris Evans
On 8 May 2005 at 19:45, Chris Evans wrote:

> Do people have advice on debugging R programs running after CGIwithR
> inputting of data from forms?  
... rest of my original post snipped, I'm replying to my own post for 
the archives! ...

I had two kind responses, one shrewd one from Tom Short noting that 
you can have problems with error messages in angle brackets if you're 
looking at HTML sink output.  Noted but that wasn't the problem.  He 
and David Firth, who tells me there's a new version, 0.70, of 
CGIwithR uploaded to CRAN which helps 2.1.0 compatibility, both tell 
me I'll have to use ssh and hack things on the server from there.  
True indeed and I think one message is that you have to be prepared 
to work out how to get your data into the program directly if 
bypassing form input.  I've debugged things now and the program runs.

Now some more questions separately for healthy archiving!

Thanks all,

Chris
-- 
Chris Evans <[EMAIL PROTECTED]>
Consultant Psychiatrist in Psychotherapy, Rampton Hospital; 
Research Programmes Director, Nottinghamshire NHS Trust, 
Hon. SL Institute of Psychiatry
*** My views are my own and not representative of those institutions 
***

__
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] working with CGIwithR

2005-05-08 Thread Chris Evans
Short question: 
Do people have advice on debugging R programs running after CGIwithR 
inputting of data from forms?  Is there a way of setting up fast 
local versions if your local machine has to be a windoze (2k) machine 
(R 2.1.0) and your server is a Debian, ssh shell only set up running 
R 1.8.0?  Are there simple guides to ways of not having to invoke R 
each time you submit data from a form?  No complaints here about R or 
CGIwithR: both brilliant.  I just need some help partly because my 
hardware resources are slow.

TIA, Chris

Long question for those with time and wanting more detail:

I'm not a statistician though I've spent a lot of the last thirty 
years of my life working with statisticians and doing my own stats 
part time.  I've worked from roll my own in dBaseII, through BMDP, 
loads of SPSS, SAS & SAS/IML, S+ and now, over the last two to three 
years, from S+ to R and loving it.  However, at times I really hit 
the limits of my amateur skills.  and this is one of them!

I've put together some scripts to deal with Jacobson et al.'s ideas 
of "reliable change and clinically significant" change.  They work 
fine on R 2.10 on my Win2K box and can output to ascii & a windows 
graphics plot or to HTML and jpg using R2HTML.  Now I'm trying to 
transfer them to my www server which runs Debian stable and R 1.8.0 
and I'm using CGIwithR to get the input from people.  

All probably fine but the of course I struggled with some aspects of 
getting the data entry flexible and now something is simply not 
working as I pass the data to the main bits of the program that I've 
worked out for local use.  I'm sure the problem will turn out to be 
some trivial incorrect class or the like that's afflicting one of the 
parameters or bits of data.  I won't (yet) waste time here with 
detail but I'd love advice on ways to get more debugging information 
and on speeding things up as my server is slow, the only one I can 
currently afford, and each invocation of the script takes minutes to 
turn around and even with:
  zz <-file("Rmess.all",open="wt")
  sink(zz,type=c("output","message"))
I'm not trapping any error messages, the program just appears to skp 
entering a function I've written and continue on with nary an apology 
or gentle complaint about my stupidity!  Most unlike R!

Thanks to anyone with suggestions!

Chris



-- 
Chris Evans <[EMAIL PROTECTED]>
Consultant Psychiatrist in Psychotherapy, Rampton Hospital; 
Research Programmes Director, Nottinghamshire NHS Trust, 
Hon. SL Institute of Psychiatry
*** My views are my own and not representative of those institutions 
***

__
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] (Fwd) Re: your membership of the AFT Email list

2005-04-28 Thread Chris Evans
Totally understood.  If you remain "on vacation" (we wish eh?!) and 
get further messages like that from the list s'ware, just accept my 
standing apologies and delete them.

Very welcome re letter!

Very best,

Chris

--- Forwarded message follows ---
Send reply to:  "Alana O'C" <[EMAIL PROTECTED]>
From:   "Alana O'C" <[EMAIL PROTECTED]>
To: "Chris Evans" <[EMAIL PROTECTED]>
Subject:Re: your membership of the AFT Email list
Date sent:  Thu, 28 Apr 2005 22:26:01 +1000

thanks, I'm not actually on vacation but just don't have time to read
all my emails at the moment! ps. thanks for OK'ing my "letter to the
editor" in the most recent edition of the Australian and New Zealand
Journal of Family Therapy (adapted from a post originally sent to 
this
list, and on which I have been quite silent ever since, due to time
constraints!)

Alana O'Callaghan
Meridian Youth and Family Services
Anglicare Victoria
7 Shipley St.
Box Hill  VIC  3182
Ph: +61-3-9890-6322
0413-543-049


- Original Message - 
From: "Chris Evans" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, April 28, 2005 7:05 AM
Subject: your membership of the AFT Email list


> You are receiving this message from a program I run monthly to check
> the AFT (Association for Family Therapy and Systemic Practice) Email
> list membership list.  This Email address is on the list but marked
> as on vacation.  If your address has been marked as on vacation so
> that you can post to the list from this address but won't receive
> duplicate messages (presumably because you are on the list at
> another address as well) then just ignore this message.
>
> Otherwise you may be receiving this because you have been on
> vacation and may want to unset that and start receiving messages
> again, or you may have been placed on vacation by the list software
> because this Email address failed repeatedly but not fatally (which
> can happen for many reasons, e.g. your inbox being too full).
>
> If you do want to unset vacation and restart receiving messages from
> the list, send a message to: [EMAIL PROTECTED] saying "unset
> vacation" (without the quotation marks) in the subject line.
>
> If you actually want this address removed from the list, send a
> message to the same address saying "unsubscribe" (again, without the
> quotation marks).
>
> If this is all baffling to you, and you have never heard of the AFT
> Email list but think that you might want to be on it, then something
> very odd is going on but you might want to look at
> http://www.psyctc.org/aft/ to see if  you want to unset vacation or
> else leave the list.
>
> Any other questions or concerns, contact me, the list 
> "owner"/administrator
> at [EMAIL PROTECTED]
>
> If Email to me there doesn't work, try [EMAIL PROTECTED] or
> you can contact me by snail mail c.o.:
>   Rampton Hospital, Retford, Notts. DN22 0PD, Britain
>
> Best wishes,
>
>
> Chris (AFT Email list "owner"/administrator) 

--- End of forwarded message - 
Chris Evans <[EMAIL PROTECTED]>
Consultant Psychiatrist in Psychotherapy, Rampton Hospital; 
Research Programmes Director, Nottinghamshire NHS Trust, 
Hon. SL Institute of Psychiatry
*** My views are my own and not representative of those institutions 
***

__
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] How to transform the date format as "20050425"

2005-04-25 Thread Chris Evans
Ooops, ditch my clumsy suggestion. Shows what I'm learning from being 
on r-help!  Thanks Marc and everyone else!

Chris

On 25 Apr 2005 at 15:32, Marc Schwartz wrote:

> On Mon, 2005-04-25 at 15:18 -0500, Yong Wang wrote:
> > Dear R user,
> > if the dates are in format as "20050425" i.e., Apr. 25 2004"
> > can you suggest an easy way to transfom it to standard form
> > as "2005-04-25" or "2004Apr25" or "2005/04/25" or any other
> > format which is R recognizable?
> > if there is no easy way to do that, can you let me know what
> > is the function in R performing similiar function as the "string"
> > function in C or some other more basic language, so I can loop
> > through all dates to make the desired change. thank you regards
> 
> If you are just formatting the Date (ie. no time component) then look
> at ?as.Date, which has a format argument:
> 
> > as.Date("20050425", "%Y%M%d")
> [1] "2005-04-25"
> 
> Using the format argument, you then return a standard Date class
> object for use in R. The format argument varies as required for your
> data format.
> 
> On the output side, there is the format() function, which has a method
> for Dates, that you can then use to convert the Date class object into
> a character vector:
> 
> > MyDate <- as.Date("20050425", "%Y%M%d")
> > MyDate
> [1] "2005-04-25"
> 
> 
> > format(MyDate, "%B %d %Y")
> [1] "April 25 2005"
> 
> Also see ?strftime for details on date format strings.
> 
> 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

-- 
Chris Evans <[EMAIL PROTECTED]>
Consultant Psychiatrist in Psychotherapy, Rampton Hospital; 
Research Programmes Director, Nottinghamshire NHS Trust, 
Hon. SL Institute of Psychiatry
*** My views are my own and not representative of those institutions 
***

__
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] How to transform the date format as "20050425"

2005-04-25 Thread Chris Evans
On 25 Apr 2005 at 15:18, Yong Wang wrote:

> Dear R user,
> if the dates are in format as "20050425" i.e., Apr. 25 2004"
> can you suggest an easy way to transfom it to standard form
> as "2005-04-25" or "2004Apr25" or "2005/04/25" or any other
> format which is R recognizable?
> if there is no easy way to do that, can you let me know what
> is the function in R performing similiar function as the "string"
> function in C or some other more basic language, so I can loop through
> all dates to make the desired change. thank you regards
> 
If the format really is always like that you can use this:
require(date) # gives you date handling
x <- as.character(20050425)
date <- 
mdy.date(as.numeric(substr(x,5,6)),as.numeric(substr(x,7,8)),\ 
as.numeric(substr(x,1,4)))

(You'll have to remove the line wrapping there, the "\" is where I 
put a break in!)

Good luck!

Chris

-- 
Chris Evans <[EMAIL PROTECTED]>
Consultant Psychiatrist in Psychotherapy, Rampton Hospital; 
Research Programmes Director, Nottinghamshire NHS Trust, 
Hon. SL Institute of Psychiatry
*** My views are my own and not representative of those institutions 
***

__
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] controlling the x axis of boxplots

2005-04-19 Thread Chris Evans
v 2.0.1 (sh old!) on Win2k

I think I know the answer to this but I can hope ...

I have data for continuous variables (measures of residents) by a 
categorical variable in range (1,22), the units in which they live.  

I want to plot these data with a pair of boxplots one above another 
with same x-axis (1,22) using par(mfrow=c(2,1)) and then plotting 
first for the women then for the men.  My problem is that some units 
have only men, some have only women, and some have both.  I'd like 
both plots to have the same x axis and the notched, varwidth boxplots 
to locate themselves with some gaps so that the units are in the same 
place on the x axis on each plot.

I think that I can't do this with boxplot or bxp as both work out the 
x axis from the work that boxplot has done on the data.  Although 
there also seem to be useful extensions or alternative boxplots in 
other packages, I can't see one that does what I want and I think 
that rolling my own from bxp is really beyond my skills.

Am I right that it doesn't exist in the CRAN packages?  If not, 
apologies and point me where I should look?  If I am right (boo hoo!) 
I don't suppose anyone has written this or is feeling like 
demonstrating their personal genius with R coding?!!!  If they were, 
I don't think I'd be the only one to end up owing them a great deal 
of gratitude!

Thanks as ever to all who have made and continue to make R what it 
is: brilliant!

Chris


-- 
Chris Evans <[EMAIL PROTECTED]>
Consultant Psychiatrist in Psychotherapy, Rampton Hospital; 
Research Programmes Director, Nottinghamshire NHS Trust, 
Hon. SL Institute of Psychiatry
*** My views are my own and not representative of those institutions 
***

__
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[2]: [R] Where has the Debian respository gone?

2004-11-18 Thread Chris Evans
Hello Dirk,

Thursday, November 18, 2004, 3:18:40 PM, you wrote:

DE> On Thu, Nov 18, 2004 at 08:52:38AM +, stats wrote:
>> I'm a bit puzzled.  I had
>> deb http://cran.r-project.org/bin/linux/debian woody main
>> in /etc/apt/sources.list and had hoped, perhaps rather unwisely, that
>> this would look after the transition from 1.8.0 on my internet server (Debian
>> stable) where it serves up some cgi-bin work.  (Most of my R work is
>> on a Win2k machine, much though I'd like to go Debian all the way,
>> that isn't possible for my main job in near future.)
>> 
>> Is there an easy way of upgrading R on a Debian stable machine?  I
>> don't want to move off stable as the security side of that server is
>> too important.  I also don't really want to compile it myself if I can
>> avoid that, the server is pretty old iron and that might back up all
>> the Email stuff it does.
>> 
>> Advice anyone?

DE> More than advice, we need a volunteer to "backport" the current R package(s)
DE> for Debian to the Debian stable distribution. As I said, testing and
DE> unstable are taken care of (and yes, testing is still lagging because of the
DE> now much more formal interdependence of packages; R 2.0.* will appears once
DE> all dependent packages are available on all architectures)

I'm sure this is in itself proof that I'm not the person to do it but
can you say a bit more about what's involved Dirk?  I run a pretty low
powered Debian stable server on i386 hardware (an athlon if I remember
rightly) with pretty much the standard packages, GCC, perl etc. and I'm
not completely stupid.  However, debugging compiler and make complaints
is really not my area of competence and I do wonder about the likely load
on the machine and on my time.

In the not too distant future this machine should be replaced with a
much more powerful one and a somewhat more powerful backup machine so
hardware may not be a long term problem.

Any chance I can be useful?  Could I team up with someone who really
knows what s/he is doing but doesn't use Debian stable and work this
together?

Let me know, I'd love to put something very direct back into the R project.

Chris

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


[R] simple repeated measures model: dumb user baffled!

2004-04-28 Thread Chris Evans
I am in the process of transferring from an old version of S+ to using
R having used a variety of other packages in the past.  I'm hugely
impressed with R but it has an excellent but depressing habit of exposing
that I'm not a professional statistician and has done so again.

Someone has run a nice little repeated measures design on my advice,
students randomised to four orders of a condition that can be N or E:
four orders used: NEEN, NENE, ENEN, ENNE, ten students in each block.  I've inherited
the data (in SPSS but I can deal with that!) with variables like:
ID GENDER ORDER C1 C2 C3 C4 RESP1 RESP2 RESP3 RESP4 ...

ORDER is the order as a/b/c/d; C1:C4 has the N or E for each occasion, and
RESP1:RESP4 the response variables.  (There are a number of these but
looking at each separately is justifiable theoretically).

I've had a look around the R help and some S+ books I've got and I
realise I'm seriously out of my depth and my repeated measures ANOVA
knowledge is rusty and very different from the way that more modern
statistics handles such designs.

Can anyone point me to an idiot's guide to the syntax that would help
me test:
a) that there is a change (probably a fall in RESPn) over the four
repeats (probable through a practice effect)
b) whether that shows any sign of higher than linear change
c) whether on top of that, there are N/E differences.

I realise that this is probably trivially easy but I'm staring at all
sorts of wonderful things in Venables & Ripley (S+ 2nd ed.) and in Chambers & Hastie
(S, 1st ed.) but nothing is quite near enough to what I need to help
me overcome my limitations!

TIA,

Chris

__
[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] Moving to 1.8.1: can you transfer your package list?

2004-03-19 Thread Chris Evans
I prefer to use R on a linux box and ultimately need things to end up 
there to serve things up using David Firth's excellent CGIwithR and 
apache, but one step at a time and I've installed 1.8.1 under win2k.  
Another question that I'm sure is simple: is there a simple way to 
find the list of installed libraries I had in my 1.7.1 installation 
and use that to drive install.packages?

I've done it with a rather ugly bit of copy and paste using library() 
in the 1.7.1 installation and then using install.packages("xxx") on 
each of the package names from the first column of the output from 
library().  How should I have done it more elegantly gurus?

TIA,

Chris
PSYCTC: Psychotherapy, Psychology, Psychiatry, Counselling
   and Therapeutic Communities; practice, research, 
   teaching and consultancy.
Chris Evans & Jo-anne Carlyle
http://psyctc.org/ Email: [EMAIL PROTECTED]

__
[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] 1.8.1 on Debian stable

2004-03-19 Thread Chris Evans
This has probably been addressed here, but I can't find it if it has, 
and it may be up on the R project homepage or the CRAN pages, but if 
so 

... so sorry if this has been answered before: question is, can I 
upgrade to 1.8.1 under Debian stable (a.k.a. "Woody")?  The deb 
packages in the CRAN archive are clearly for 1.8.0 and those in the 
"unstable" distro for Debian are 1.8.1.  Therefore I assume there are 
dependency problems to solve that didn't make it worth making 1.8.1 
available for Woody and if the package maintainers don't want to try, 
I certainly won't attempt it.  But I am sorry as this seems to mean 
that I can't get the ROC package in Bioconductor for my machine.

(No: too many security reasons why I don't want to go to "unstable" 
on the machine in question.)

Thanks in advance for any advice, pointers or clarifications.

Chris
PSYCTC: Psychotherapy, Psychology, Psychiatry, Counselling
   and Therapeutic Communities; practice, research, 
   teaching and consultancy.
Chris Evans & Jo-anne Carlyle
http://psyctc.org/ Email: [EMAIL PROTECTED]

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


Re: [R] Clinical significance as a package? [Scanned by NHC]

2004-02-11 Thread Chris Evans
On 11 Feb 2004 at 10:15, Alistair Campbell wrote:

> But, to my question. Does anyone know if there is a package developed
> for evaluating clinical significance using Jacobson and Truax's, or
> variations thereof, procedures?

Not exactly but you might want to look at:
   http://www.psyctc.org/stats/R/CSC1.html
which works using R and CGIwithR and shows some of the logic of CSC.

I'd be very interested to help with doing something and know a bit 
about the issues and have proselytised for the idea a bit:
Evans, C., Margison, F. & Barkham, M. (1998) The contribution of 
reliable and clinically significant change methods to evidence-based 
mental health. Evidence Based Mental Health, 1, 70-72.

Chris

-- 
Chris Evans <[EMAIL PROTECTED]>
Consultant Psychiatrist in Psychotherapy, Rampton Hospital; 
Forensic Research Programme Director, Nottinghamshire NHS Trust, 
Research Consultant, Tavistock & Portman NHS Trust; 
Hon. SL Institute of Psychiatry
*** My views are my own and not representative 
of those institutions ***

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


Re: [R] Rcgi

2003-08-14 Thread Chris Evans
On 30 Jul 2003 at 19:01, Chris Evans wrote:

> I am keen to look at Rcgi as I want to put up some simple bits of R to
> do prescribed tasks on HTML form input.  Rweb is overkill and
> worryingly flexible for what I want and it sounds as if Rcgi is more
> what I need.  However, I can't get any of the URLs I've found for it
> to work over the last few days.  
> 
> Does anyone have a recent copy they could Email me or a working URL
> for it?

Replying to myself to have this documented in the list archives.  I 
had found the pointer to RCGI from the R-FAQ:
http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html#R%20Web%20Interfaces

However, http://stats.mth.uea.ac.uk/Rcgi/ remains offline and Email 
to Mark J. Ray bounces and I see that someone was asking if the 
project was dead back in 2001 so I guess it should be removed from 
the FAQ and I've Emailed Kurt Hornik to suggest that he changes that 
section of the FAQ to remove Rcgi and add the excellent CGIwithR 
package which does just what I want.  Thanks to David Firth for 
writing it and to both he and Adelchi Azzalini for pointing it out to 
me ... and to everyone on the R enterprise for this wonderful tool.

Trivial, less impressive than Adelchi Azzalini's example:
http://tango.stat.unipd.it/SN/sn-fit.html
but I am underway with the sorts of things I wanted to do:
   http://www.psyctc.org/stats/R/binconf1.html
   http://www.psyctc.org/stats/R/binconf2.html

One afterthought: does anyone have any ideas about how to secure 
GGIwithR to prevent some idiot simply hitting repeatedly with a small 
script to get a DoS on any server running it?  I suspect there may be 
throtting settings I can use in Apache or even calls to the system 
inside R to check how many instances of it are running ... but I 
suspect that others are cleverer than I am at this sort of thing .... 
or just less paranoid?!

Chris
-- 
Chris Evans <[EMAIL PROTECTED]>
Consultant Psychiatrist in Psychotherapy, Rampton Hospital; 
Forensic Research Programme Director, Nottinghamshire NHS Trust, 
Research Consultant, Tavistock & Portman NHS Trust; 
Hon. SL Institute of Psychiatry
*** My views are my own and not representative 
of those institutions ***

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


[R] Rcgi

2003-07-30 Thread Chris Evans
I am keen to look at Rcgi as I want to put up some simple bits of R 
to do prescribed tasks on HTML form input.  Rweb is overkill and 
worryingly flexible for what I want and it sounds as if Rcgi is more 
what I need.  However, I can't get any of the URLs I've found for it 
to work over the last few days.  

Does anyone have a recent copy they could Email me or a working URL 
for it?

TIA,

Chris

PSYCTC: Psychotherapy, Psychology, Psychiatry, Counselling
   and Therapeutic Communities; practice, research, 
   teaching and consultancy.
Chris Evans & Jo-anne Carlyle
http://psyctc.org/ Email: [EMAIL PROTECTED]

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