Re: [R] Contrasts for MANOVA

2003-12-20 Thread Prof Brian Ripley
On Fri, 19 Dec 2003, Andy Bunn wrote:

 A colleague asked me if R can do contrasts for MANOVA. SAS will using
 PROC GLM with CONTRAST but can R? I assured her that R can do everything
 but make coffee. If this is trivial then I apologize in advance.

Depends what you mean: I don't believe that SAS command does what I 
understand by manova, at least as its main purpose.

Both lm() and aov() handle multiple responses.

aov() in R is really set up to consider terms, but its summary method can 
split terms (via its `split' argument).

What summary.manova does which the other aov methods does not is to
compute multivariate test statistics for each term.  If your colleague
wants both the splitting allowed in summary.aov and the multivariate test
statistics of summary.manova then that is not currently supported. What I
would do there is to is ensure each of the contrasts I wanted had a
separate term in the model, and then use summary(manova(...)).

As ever, an example of what you want would help, as I have been guessing 
rather.

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

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


Re: [R] Error running LDA

2003-12-20 Thread Prof Brian Ripley
As it says, some of your variables appear not to vary, which means LDA is 
not appropriate.  LDA assumes a common multivariate normal distribution 
for the variation of each group about the group centre, and that cannot 
generate data like yours.

On Fri, 19 Dec 2003, Yun-Fang Juan wrote:

 oh sorry
 here is the error.
 Please advice.
 
 thanks,
 
 Yun-Fang
 
  lda1 - lda(retention ~ . , data=RetentionDF40[1:1,]);
 Error in lda.default(x, grouping, ...) : variable(s)  11  14  24  29  30  31
 32  33  34  35  41  43  44  47  48  49  50  51  54  55  56  57  58  59  60
 61  65  66  67  68  70  71  72  74  78  82  85  87  88  89  91  92  93 101
 102 103 107 108 109 111 112 117 122 124 125 127 148 151 153 155 156 162 170
 173 176 181 182 183 184 186 189 190 192 193 194 196 200 209 212 213 214 215
 216 218 220 222 223 224 228 230 231 234 235 236 237 appear to be constant
 within groups
 
 - Original Message -
 From: Marc R. Feldesman [EMAIL PROTECTED]
 To: Yun-Fang Juan [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Sent: Friday, December 19, 2003 6:38 PM
 Subject: Re: [R] Error running LDA
 
 
  At 06:13 PM 12/19/2003, Yun-Fang Juan wrote:
   Hi,
   I try to run the linear discriminant analysis using the following
 command
   but got an error like the following.
   lda1 - lda(retention ~ . , data=RetentionDF40[1:1,]);
   
 
  What error did you get?  Did you read the help file for lda?  What version
  of R and what version of VR are you using?  What platform?
 
 
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 
 

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

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


Re: [R] draft of posting guide

2003-12-20 Thread Peter Dalgaard
Tony Plate [EMAIL PROTECTED] writes:

 h3Common posting mistakes/h3
 
 Doing any of the following may result in you getting a
 response that you may find rude or insulting.  (However,
 such a response may be justified in the eyes of some because
 you have wasted people's time or unjustly insulted people's
 work.)
 
 * Not doing your homework before posting a question.
 
 * Asking R-help to do your classroom homework for you
   (remember that many of the subscribers of R-help are
   university professors and can recognize homework questions
   with great speed and accuracy)
 
 * Claiming that something is a bug when in fact the software
   is working as intended and documented, just not in the way
   you first expected.
 
 * Claiming that some commonly used function is not behaving
   in what you think is a sensible manner (it's far more
   productive and polite to just ask why it behaves the way
   it does if you think it is odd -- but only after reading
   all the relevant documentation!)

* Threatening not to use the software if you cannot get your question
  answered. Even when intended as a statement of fact, it tends to
  create negative attitudes.

-- 
   O__   Peter Dalgaard Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics 2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907

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


RE: [R] draft of posting guide

2003-12-20 Thread Gabor Grothendieck


Thanks for your effort.  Here are some comments.

1. The guidelines seem only to cover people
_asking_ questions.  What about those answering?

2. I think bug needs to be taken in the broader
sense of a problem.  Such problems are not limited
to discrepancies between documentation and
implementation.  The real serious problems are
design problems and may not represent such
deviations at all.  If the behavior is unexpected
it may very well be a problem even if its not a
bug in the narrow sense.

3. Rude answers are never warranted.

4. Its too long and there are too many rules.  

5. The tone should be friendlier -- more helpful
and inviting.  Words like lazy should be
eliminated.  Although R is not a commercial
enterprise and its users are not customers in the
usual sense, its users should still be treated
with respect and encouraged rather than
admonished.  A customer oriented attitude will
be appreciated and encourage more participation.
The purpose of this should not be so
much to tell posters what they can do and not do
but to help them elicit useful responses and
to help responders provide userful answers.

6. Points should be numbered so they can be
referred to.  Each one should have an address so
that one can refer to them individually like this:
http://www.r-project.org/...whatever.../etiquette.html#3.1

7. I personally find the statistics questions
interesting and would not like to see guidelines
about not posting statistical problems.

8. Where documents are referred to, provide a URL.
Where R is being referred to point that out.  For
example, help.search is an R command.  This may be
obvious to some but it might not be obvious to
someone just coming to R.

9. It might be worthwhile to point out that the
following google search works:   
   whatever site:r-project.org

The real problem with the lists is not the
posters.  The real problems are:

- rude answers

- insufficient discussion about the direction and
  design and, in general, higher level issues.  If
  you compare this to ruby, python, perl and lua
  there are all sorts of interesting proposals and
  discussions on this on their lists with little
  counterpart on R's.

 Date: Fri, 19 Dec 2003 22:55:53 -0700 
 From: Tony Plate [EMAIL PROTECTED]
 To: [EMAIL PROTECTED] 
 Subject: [R] draft of posting guide 
 
  
  
 Here is a first draft of a guide for posters to r-help and
 r-devel. Suggestions on how to improve any aspect of it are
 most welcome. Suggestions on ways to make it more concise
 are especially welcome. Comments on which parts you like
 or don't like are welcome. Rather than clutter up R-help with
 lots of small corrections etc, please send them to me, and I
 will try to incorporate and summarize appropriately.
 
 I've left out most HTML formatting (except for headings) to
 make it readable -- I'll insert that later (to conform with
 the style on the other pages at r-project.org.) I've placed
 ??? in places where feedback is specifically needed.
 
 h2Posting Guide: How to ask good questions that prompt useful
 answers/h2
 
 * Remember that R is free software, constructed and
 maintained by volunteers. They have various reasons for
 contributing to R, but often have limited time. Remember
 that no one owes you anything, and if you rude or
 disrespectful in your questions, you are likely to either
 be ignored or have the sentiment returned to you.
 
 * The R mailing lists are primarily intended for questions
 and discussion about the R software. However, sometimes
 questions about statistical methodology are posted. [???
 are these discouraged/tolerated/... ???] People are far
 less likely to respond to these types of questions than to
 questions about the R software. Depending on how much the
 post shows thought and background research, responses may
 merely (and sometimes brusquely) suggest that you should
 be seeking statistical consulting advice elsewhere.
 Sometimes, if the question is well-asked AND of interest
 to someone on the list, you may get an informative,
 up-to-date answer.
 
 * Don't expect R-help to teach you basic statistics. That's
 what statistics textbooks and statistics classes are for.
 
 * If you have a question about R that you want answered,
 don't be lazy. Do your homework first. If it is clear
 that you have done your homework, your are far more likely
 to get an informative response. The type of homework that
 needs to be done depends on the type of question --
 details are in the following paragraphs.
 
 * Make it easy for people to answer your question: be clear
 and concise, remove unnecessary details, and, if they
 might be useful, provide brief examples.
 
 * A much more detailed (and highly recommended) essay on how
 to ask questions on mailing lists about software is Eric
 Raymond's How To Ask Questions The Smart Way
 http://www.catb.org/~esr/faqs/smart-questions.html. (Note
 that catb.org has no association with the R project and
 will not respond to questions concerning R.)
 
 

[R] sound library

2003-12-20 Thread [EMAIL PROTECTED]
I'm collaborating with and electronic musician to experiment on the production of 
music from number sequences. As I'm an R user I started playing around with the sound 
library and I found it very useful. However there are several things I do not 
understand (I'm not an expert in acustic nor audio signal treatment).

The first thing I'd like to understand is: let s be a normalized sample and suppose it 
generates a waveform with non audible frequencies. Then if I play it trough the 
function play (I'm using an R-window version) I won't hear anything. Then I play: 
play(1*s) and I can hear something. What is happening to the audio sample? 

I saved as wave files both s and 1*s and then with my musician friend we looked at 
the waveforms we got.
They are totally different from each other and we couldn't fidure out which 
transformation of s generated the 1*s waveform.

Can anyone explain what is going on?

Thanks in advance

Giovanna Jona Lasinio

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


Re: [R] sound library

2003-12-20 Thread Uwe Ligges
[EMAIL PROTECTED] wrote:

I'm collaborating with and electronic musician to experiment on the production of music from number sequences. As I'm an R user I started playing around with the sound library and I found it very useful. However there are several things I do not understand (I'm not an expert in acustic nor audio signal treatment).

The first thing I'd like to understand is: let s be a normalized sample and suppose it generates a waveform with non audible frequencies. Then if I play it trough the function play (I'm using an R-window version) I won't hear anything. Then I play: play(1*s) and I can hear something. What is happening to the audio sample? 
Looks like it is not checked whether the generated sound, i.e. a wave 
file, is valid. Using 16 bit resolution, you cannot have more than 2^16 
integers, but 1*s contains invalid integers for the wave representation.


I saved as wave files both s and 1*s and then with my musician friend we looked at 
the waveforms we got.
They are totally different from each other and we couldn't fidure out which 
transformation of s generated the 1*s waveform.
Since you are writing invalid values to the file, those are interpreted 
in the wrong way and you might get something different.


Can anyone explain what is going on?
Two more comments:
sound as is does not pass Rcmd check on Windows (because Media Player 
is not available on the system I do compile on, etc.) and has some more 
deficiencies. It's only available as a Windows binary on CRAN because of 
my personal interest in the package.
The author of the package, Matthias Heymann, has been informed, but he 
is not going to fix the bugs in the near future, unfortunately.

I am planing to write a package for the analysis of music (including 
loading / playing / saving wave files) next year myself.

Uwe Ligges



Thanks in advance

Giovanna Jona Lasinio

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


Re: [R] for loop over dataframe without indices

2003-12-20 Thread Gabor Grothendieck



I think I've found a problem with the by approach.  Compare:

data(iris)
by( iris, row.names(iris), function(x)x )[1:5,]

to

iris[1:5,]

It seems by has reordered the rows.

 
Date: Fri, 19 Dec 2003 21:31:50 -0500 (EST) 
From: Gabor Grothendieck [EMAIL PROTECTED]
To: [EMAIL PROTECTED] 
Cc: [EMAIL PROTECTED] 
Subject: Re: [R] for loop over dataframe without indices 

 
 


Thomas, Thanks for your response. Its is quite nifty. 

Pursuing your solutions,
I think the objective should be to reproduce the output from 
t.data.frame defined as below (note that I posted a proposal
to change t.data.frame to r-devel before I received your reply):

t.data.frame - function( df ) { 
ll - NULL
for( i in 1:nrow(df) ) ll - append( ll, list(df[i,]) )
ll 
}

Using the first 3 rows from the iris data set as our data frame,
run the following which shows that your by solution works provided
we nullify out the attributes afterwards. The do.call solution
does not appear to work, as required, since it turns the data 
frame into a matrix.

data(iris)
df - iris[1:3,]

# Consider:

id - function(x)x

# t.data.frame solution
zt - t(df)

# by solution is good but it adds some junk attributes 
zby - by( df, row.names(df), id )
identical(zt,zby) # FALSE

# nullifying these attributes seems to do it
zby2 - zby
attributes(zby2) - NULL
identical(zt,zby2) # TRUE

# do.call doesn't work right since it appears to turn the result into a matrix
str( do.call(mapply, list(id,df) ) ) # note matrix output


Here is the result of pasting the above into R 1.8.1 on Windows 2000:

 data(iris)
 df - iris[1:3,]
 
 # Consider:
 
 id - function(x)x
 
 # t.data.frame solution
 zt - t(df)
 
 # by solution is good but it adds some junk attributes 
 zby - by( df, row.names(df), id )
 identical(zt,zby)
[1] FALSE
 
 # nullifying these attributes seems to do it
 zby2 - zby
 attributes(zby2) - NULL
 identical(zt,zby2)
[1] TRUE
 
 # do.call doesn't work right since it appears to turn the result into a matrix
 str( do.call(mapply, list(id,df) ) )
num [1:3, 1:5] 5.1 4.9 4.7 3.5 3 3.2 1.4 1.4 1.3 0.2 ...
- attr(*, dimnames)=List of 2
..$ : NULL
..$ : NULL
 


Based on your solution I think the proposal should be changed
to:

t.data.frame - function(df) {
z - by( df, row.names(df), function(x)x )
attributes(z) - NULL
z
}


---

Date: Fri, 19 Dec 2003 10:03:55 -0800 (PST) 
From: Thomas Lumley [EMAIL PROTECTED]
To: Gabor Grothendieck [EMAIL PROTECTED] 
Cc: [EMAIL PROTECTED] 
Subject: Re: [R] for loop over dataframe without indices 



On Fri, 19 Dec 2003, Gabor Grothendieck wrote:

 What I now realize is that the thing that is oddly
 missing in R is that you can't do an apply over
 the rows of a dataframe (at least not without having
 it coerced to an array and the elements coerced to
 possibly different types). The documentation does
 point this out. Its not a bug but its an omission
 that seems deserving of being addressed.


Since mapply() applies a function to each 'row' of a list of vectors, ou
can achieve this effect with
do.call(mapply, list(FUN,data.frame))
and also as a degenerate case of by():
by(data.frame, row.names(data.frame), FUN)

These should probably be documented under apply()


-thomas

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

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


Re: [R] C++: Appending Values onto an R-Vector.

2003-12-20 Thread Jim Java
[Jim Java]
Hi folks. I posted this question a few days ago, but maybe it got
lost because of the code I included with it. I'm having a problem
using the SET_LENGTH() macro in an R extension I'm writing in C++.
In a function within the extension I use SET_LENGTH() to resize R
vectors so as to allow the concatenation of single values onto the
vectors -- it's a push back function to append values onto the
end of a vector. However, when I use this function to push back a
large number of values one at a time, Rgui.exe (I'm working with R
1.8.1 in Windows XP) crashes from an Access Violation; if, however,
I pre-allocate space (is the space actually pre-allocated?) for the
vector (say with NEW_INTEGER(n) rather than NEW_INTEGER(0)) and
insert values into the allocated slots, the code works fine. If
you'd like to see some test code, I've already posted it here:

https://www.stat.math.ethz.ch/pipermail/r-help/2003-December/041871.html

Here's my question, then: Is SET_LENGTH() the appropriate way to
create space for tacking values onto the end of an R-vector in C++,
or should I be trying to tack them on in some other way?

[Brian Ripley]
You UNPROTECT before calling lengthgets, and that is I think part
of your problem.  You need to use REPROTECT...

[Jim Java]
This problem is solved, so I want to post a follow-up for reference
in the archives. My thanks to Prof. Ripley for helping me out: the
problem was indeed in using UNPROTECT before lengthgets() rather than
using REPROTECT afterwards. My revised test code is listed below, also
for reference.

CPP Code
  SEXP R_SimplePushBackTest(SEXP args)
  {
SEXP arg1, arg2, int_vect;

PROTECT(arg1 = AS_INTEGER(CADR(args)));
int n_reps = INTEGER_POINTER(arg1)[0];
PROTECT(arg2 = AS_LOGICAL(CADDR(args)));
bool full_alloc = (LOGICAL_POINTER(arg2)[0] ? true : false);
PROTECT_INDEX int_vect_pindex;
if (full_alloc)
  PROTECT_WITH_INDEX(int_vect = NEW_INTEGER(n_reps), int_vect_pindex);
else
  PROTECT_WITH_INDEX(int_vect = NEW_INTEGER(0), int_vect_pindex);

for (int i = 0; i  n_reps; ++i) {
  Rprintf(  ** Iteration %d:\n, i + 1);
  if (full_alloc)
INTEGER_POINTER(int_vect)[i] = i;
  else {
// This works now! --
SET_LENGTH(int_vect, GET_LENGTH(int_vect) + 1);
REPROTECT(int_vect, int_vect_pindex);
INTEGER_POINTER(int_vect)[GET_LENGTH(int_vect) - 1] = i;
  }
}

SEXP out, names, cls;

PROTECT(out = NEW_LIST(1));
SET_VECTOR_ELT(out, 0, int_vect);

PROTECT(names = NEW_CHARACTER(1));
SET_STRING_ELT(names, 0, COPY_TO_USER_STRING(integer.vector));
SET_NAMES(out, names);

PROTECT(cls = NEW_CHARACTER(1));
SET_STRING_ELT(cls, 0, COPY_TO_USER_STRING(pushback));
classgets(out, cls);

UNPROTECT(6);
return out;
  }
/CPP Code

R Code
  nreps=5
  allocate=FALSE
  sink(pushback_test.txt)
  test.pushback=.External(R_SimplePushBackTest, as.integer(nreps), 
as.logical(allocate))
  print(test.pushback)
  sink()
/R Code

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


Re: [R] Different scales for keys in lattice levelplots

2003-12-20 Thread Deepayan Sarkar
On Friday 19 December 2003 14:23, Waichler, Scott R wrote:
 Can anyone tell me how to obtain a custom scale for
 the colorkey in each levelplot of a lattice?  I am using
 lattice and levelplot to plot z = f(x, y) for multiple z
 variables.  x and y values are the same across plots, but
 units for z are different and therefore I need to create
 a custom scale for each plot's key.  It follows that I need
 to place each plot's key inside that plot's box.  Should I
 use filled.contour() and gridBase instead?

I'm not sure I understand your question. Are you using different calls to 
levelplot() for the different z variables ? What's wrong with the default 
colorkey for each such plot ? 

In any case, the arguments controlling colorkey are described in the help page 
for levelplot. Another way to control the scales (to be same across different 
calls to levelplot, say) is via the 'at' argument to levelplot (this can be 
used in a manner similar to what might have been expected from a 'zlim' 
argument, had one been available).

Hope that helps,

Deepayan

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


Re: [R] weighted regression

2003-12-20 Thread [EMAIL PROTECTED]
Paul
Thanks for your quick response.  Yes I have
x and y backward.  Thomas Blackwell pointed that out to
me. Oops.  And yes I will be considering more than 3 points
for any regression.  This little data set was first presented by
a math wizard in a MathCAD forum explaining the mathematics
behind weighted regression.  When I tried Statistica on the data set
I  found that their definition of weights was a replication counter NOT in
the spirit of 1/var.
It put me into a blue funk ... I hate it when my state-of-the-art tools turn
out to be a sham.
I then turned to R and all appears to be mathemagically working well.
As I walk the dogs I'm thinking (amittedly confusedly) on how prediction and
confidence
intervals could be generated around a weighted regression line.  My thoughts
range from purloining concepts from kriging, or bootstapping ... in each
case
I come to the conclusion that this is more complex topic than I thought
Oh well...it keeps me interested in talking to smart people like you.
Have a Merry Christmas
REX
- Original Message -
From: Paul E. Johnson [EMAIL PROTECTED]
To: [EMAIL PROTECTED] [EMAIL PROTECTED]
Sent: Friday, December 19, 2003 2:43 PM
Subject: Re: [R] weighted regression



 I keep new user tips at http://www.ku.edu/~pauljohn/R/Rtips.html

 I have some observations on your example:

 1. You have y and x backward in your lm code

 2. You get rid of the intercept by lm(y~x-1) but it is not generally
 advisable.  it will bias the slope parameter if your assumption is wrong.

 3. You are right that Weighted Least Squares can be accomplished by
 weights in lm.  Please read the description of weight in ?lm

 weights: an optional vector of weights to be used in the fitting
   process. If specified, weighted least squares is used with
   weights 'weights' (that is, minimizing 'sum(w*e^2)');
   otherwise ordinary least squares is used.

 If you understand WLS, then you will see how to enter the variable w.

 4. I hope you aren't really doing regression with 3 observations.

 pj


 [EMAIL PROTECTED] wrote:

 To all
 
 I have some simple questions pertaining to weights used in regression.
 If the variability of the dependent variable (y) is a function of the
magnitude of predictor
 variable (x), can the use of weights give an appropriate answer to the
regression parameters
 and the std errors?
 
 Assume that y at x=1 and 6 has a standard deviation of 0.1 and at x=11 it
is 0.4
 Then according to a web page on weighted regression for a calibration
curve at
 http://member.nifty.ne.jp/mniwa/rev006.htm, I should use 1/(std^2) for
each weight.
 
 i.e. for x=1 and 6, w = 100 and x=11, w = 6.25
 
 In R the run is:
 
 
 
 y-c(1,6,11)
 x-c(6.7,6.7,6.6)
 w-c(100,100,6.25)
 reg -lm(x~y, weight=w)
 summary(reg)
 
 
 
 Call:
 lm(formula = x ~ y, weights = w)
 
 Residuals:
123
 -0.04762  0.09524 -0.19048
 
 Coefficients:
  Estimate Std. Error t value Pr(|t|)
 (Intercept)  6.707619   0.025431 263.762  0.00241 **
 y   -0.002857   0.005471  -0.522  0.69361
 ---
 Signif. codes:  0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
 
 Residual standard error: 0.2182 on 1 degrees of freedom
 Multiple R-Squared: 0.2143, Adjusted R-squared: -0.5714
 F-statistic: 0.2727 on 1 and 1 DF,  p-value: 0.6936
 
 Am I using the weight method correctly?
 And if so does the Estimated Std. Error for the Intercept and slope make
sense?
 
 On another note.  How does one do a regression with the origin fixed at
0?
 
 Merry Christmas
 
 REX
 
 
 
 
 
  [[alternative HTML version deleted]]
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help
 
 


 --
 Paul E. Johnson   email: [EMAIL PROTECTED]
 Dept. of Political Sciencehttp://lark.cc.ukans.edu/~pauljohn
 University of Kansas  Office: (785) 864-9086
 Lawrence, Kansas 66045FAX: (785) 864-5700


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


[R] error bars around a point

2003-12-20 Thread [EMAIL PROTECTED]
Andy
Thank you.  Downloaded Hmisc using the Packages
button in the RGUI for Windows.  My hat's off to the programmers...
the system of downloading and installing a package works like a champ.
I then tried your code and it too works great.

I've added your suggested http://cran.r-project.org/search.html
to my Favorites list.  Very helpful.
Merry Christmas
REX

Message: 36
Date: Fri, 19 Dec 2003 17:31:52 -0700
From: Andy Bunn [EMAIL PROTECTED]
Subject: RE: [R] error bars around a point 
To: '[EMAIL PROTECTED]' [EMAIL PROTECTED],
[EMAIL PROTECTED]
Message-ID: [EMAIL PROTECTED]
Content-Type: text/plain; charset=us-ascii

See errbar in Hmisc. I found this with:

help.search(error bar)

And it's in the html help too. And on the r site:
http://cran.r-project.org/search.html
http://www.google.com/search?q=error+bardomains=r-project.orgsitesearc
h=r-project.org

# Example
require(Hmisc)
set.seed(1)
x - 1:10
y - x + rnorm(10)
delta - runif(10)
errbar( x, y, y + delta, y - delta )

HTH, Andy



[[alternative HTML version deleted]]

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


[R] Huynh-Feldt correction

2003-12-20 Thread Wolfgang Pauli
Dear All,

I tried to help myself by searching in newsgroups etc. I found a test for
epsilon in a newsgroup (see attachement). I wrote a little skript to update
the summary.anova if epsilon  0.75.
Although I doublechecked my statistic book for the formula, the result is
always the half of the epsilon calculated by SPSS. It is really strange. If I
multiply espilon by two, I get the right results...

regards,

WP

#begin -

correctSummary - function(sum,eps) {
# eps is the epsilon-value returned by function hf
# sum is the summary.aov object in which the Huynh-Fldt correction has to be
down
len - length(sum)
newSum - sum
for (i in 2: len) {
newSum[[i]][[1]][4,] - newSum[[i]][[1]][2,]
newSum[[i]][[1]][3,] - newSum[[i]][[1]][2,]
newSum[[i]][[1]][2,] - newSum[[i]][[1]][1,]
rownames(newSum[[i]][[1]]) - c(rownames(newSum[[i]][[1]][1,]),
Huynh-Feldt, rownames(newSum[[i]][[1]][2,]), Huynh-Feldt)
newSum[[i]][[1]][2,][1] - newSum[[i]][[1]][2,][1]*epsilon*2
newSum[[i]][[1]][4,][1] - newSum[[i]][[1]][4,][1]*epsilon*2
newSum[[i]][[1]][2,][3] - newSum[[i]][[1]][2,][2]/newSum[[i]][[1]][2,][1]
newSum[[i]][[1]][4,][3] - newSum[[i]][[1]][4,][2]/newSum[[i]][[1]][4,][1]
newSum[[i]][[1]][2,][4] - newSum[[i]][[1]][2,][3]/newSum[[i]][[1]][4,][3]

newSum[[i]][[1]][2,][5] - pf(as.numeric(newSum[[i]][[1]][2,][4]),
as.numeric(newSum[[i]][[1]][2,][1]), as.numeric(newSum[[i]][[1]][4,][1]),
lower.tail = FALSE)
}
newSum

}

hf - function(m){
# m is a matrix with subjects as rows and conditions as columns
# note that checking for worst case scenarios F correction first
 might # be a good idea using J/(J-1) as the df correction factor
n- length(m[,1])
J-length(m[1,])
X-cov(m)
r- length(X[,1])
D-0
for (i in 1: r) D- D+ X[i,i]
D-D/r
SPm- mean(X)
SPm2- sum(X^2)
SSrm-0
for (i in 1: r) SSrm- SSrm + mean(X[i,])^2
epsilon - (1/(J-1))*((J^2*(D-SPm)^2)/(SPm2 - 2*J*SSrm + J^2*SPm^2))
epsilon
}


# 

On Thursday December 18 2003 12:00, Wolfgang Pauli wrote:
 Dear R-helpers,

 Does anybody know, whether there is an option to tell aov/anova, or do
 something similar, to get a Huynh-Feldt correction of dfs in the aov/anova
 function?

 Thanks in advance!

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

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


[R] Software/algorithms for competing risks analysis

2003-12-20 Thread Ravi Varadhan
Dear R group:

I am compiling a list of available algorithms/macros/software for 
performing the following types of competing risks analyses:
(1) cumulative (crude) incidence regression
(2) Gray's K-sample log-rank test for cmulative incidence
(3) multi-state models
(4) dependent competing risks modeling with (a) copulas, (b) Robin's 
Inverse probability of censoring weighted (IPCW) estimator, (c) frailty

I would really appreciate any pointers/references to 
algorithms/software in other environments such as SAS/STATA/SPSS, as 
well as in R.

Thanks very much,
Ravi.

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


[R] Sweave/LaTeX Problem with EPS PDF

2003-12-20 Thread Harold Doran
Dear List:
 
I am unsure if my problem is with Sweave or LaTeX. Anyhow, I am using the MikTeX 
distribution and TexnicCenter. 
 
I can easily create Sweave files and all goes well until I try to incorporate 
graphics. I use the same code as found in the examples found in the users manual. 
 
In R, the graphics I want are created as Sweave is creating the .tex file. When I 
examine the .tex file created by Sweave, it includes the includegraphics{} statement 
needed. 
 
When I run LaTeX on the .tex file, everything works except that the graphics I want 
are not displayed. 
 
However, when I examine the pdf or eps files created, there is nothing there. When I 
view the EPS using Ghostview, the file is empty, but there appears to be a bounding 
box surrounding nothing. When I open the pdf graphic, there is nothing there either. I 
have tried creating both dvis and pdf files. Again, text works perfectly, but graphics 
do not work.
 
Does anyone have any suggestions?
 
Many thanks,
 
Harold

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


[R] varFixed

2003-12-20 Thread Harold Doran
Dear List:
 
Earlier this week I posted a question and received no response, and I continue to 
struggle with my model. My original question is pasted below.
 
I am using lme and want to fix the variance of the within group residual at 1 
(e~n(0,1). I think the varFixed function should be used to accomplish this, but I am 
struggling to figure out how to do this.
 
Can anyone offer suggestions on how this might be accomplished? 
 
Thanks, I would appreciate any suggestions.
 
Harold
 
 
Dear List:

I am trying to figure out how to incorporate measurement error in an longitudinal 
educational data set using lme to create a true score model. As a by-product of the 
procedures used to scale educational tests, one can obtain a person-specific 
measurement error associated with each score, or a conditional standard error. For 
example, a score of 200 would have measurement error specific to that score that would 
be different than, say, a score of 250.

I have been rather successful in figuring out how to rescale the necessary components 
to create this true score model. This simply requires that the response variable, 
the intercept, and any other variables in the design matrix be multiplied by the 
reciprocal of the standard error of measurement for the associated score. There may be 
a better way to do this, but I manually create a vector of 1s for all observations and 
multiply this vector by 1/sem. This is the new intercept. I also multiply any other 
predictors in the design matrix by the same value.

In the R code, I remove the intercept included by default (-1) and include the newly 
created intercept (which is no longer a constant) as well as the new response variable 
and rescaled predictors.

However, I am confused regarding the within-group error term. Fitting this model 
requires that the variance be fixed at 1:  e ~ n(0,1).

Is it possible to constrain the variance for this model as such?

I would appreciate any comments or suggestions regarding this model.

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


Re: [R] Sweave/LaTeX Problem with EPS PDF

2003-12-20 Thread Jason Turner
Harold Doran wrote:
[... Sweave use...]
However, when I examine the pdf or eps files created, there 
is nothing there. When I view the EPS using Ghostview, the file
 is empty, but there appears to be a bounding box surrounding
 nothing. When I open the pdf graphic, there is nothing there
 either. I have tried creating both dvis and pdf files. Again,
 text works perfectly, but graphics do not work.
Are they lattice graphics?  They need to be wrapped in a print() 
statement, like

print(xyplot(...))

Without that, they don't produce output to eps or pdf.

Cheers

Jason
--
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
[EMAIL PROTECTED]
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help