Re: [R] t.test() with missing values

2007-09-14 Thread Birgit Lemcke
Thanks for your answer.

First I will show you both vectors:

Mal66
   [1]   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
[28]   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
[55]   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   
6.0   NA  4.0  6.0  9.0  0.5  6.0  6.0   NA   NA   NA   NA  5.0   NA   
3.0
[82] 10.0  6.0   NA  5.0  7.0   NA   NA   NA  6.0  4.0  8.0  5.0
NA   NA   NA   NA  3.0  2.0  0.8   NA  7.0   NA  6.0   NA   NA  5.0   NA
[109]  2.0  3.5   NA  7.0  6.0  5.0  4.0   NA   NA   NA   NA   NA
NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
[136]   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
[163]   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
[190]   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
[217]   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
[244]   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
[271]   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
[298]   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
[325]   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA   NA
 > Fem66
   [1] 5.0  NA 4.5 6.0 0.8  NA 7.0 4.5  NA  NA  NA  NA 5.0  NA 6.0   
NA 5.0  NA 5.0 8.0  NA  NA  NA 8.0  NA 8.0 5.0  NA  NA  NA  NA 8.0   
NA 1.0
[35]  NA  NA  NA  NA  NA  NA 5.0  NA 4.0 8.0  NA 6.0 6.0 4.5 3.5  NA   
NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA
[69]  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA   
NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA
[103]  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA   
NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA   
NA  NA
[137]  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA   
NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA   
NA  NA
[171]  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA   
NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA   
NA  NA
[205]  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA   
NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA   
NA  NA
[239]  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA   
NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA   
NA  NA
[273]  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA   
NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA   
NA  NA
[307]  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA   
NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA  NA   
NA  NA
[341]  NA  NA  NA  NA  NA  NA  NA  NA

I tried this (complete.cases(Fem66, Mal66)) and you are right, it  
gives me back:

(complete.cases(Fem66, Mal66))
   [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  
FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[23] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  
FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[45] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  
FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[67] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  
FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[89] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  
FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[111] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  
FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[133] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  
FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[155] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  
FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[177] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  
FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[199] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  
FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
[221] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE  
FALS

[R] replace NA value with 0

2007-09-14 Thread Alfredo Alessandrini
Hi,

how can I replace NA value with 0:

1991 217  119 103 109 137 202 283 240 146  NA
1992 270  174 149 144 166 239 278 237 275  NA
1993 146  111 104  89  98 131 153 148 175  NA
1994 177  123 146 124 121 200 266 191 240 106
1995 145   98  95  89  95 130 183 161 164 129
1996 145   98  89  90  93 138 158 131 161 161

1991 217  119 103 109 137 202 283 240 146  0
1992 270  174 149 144 166 239 278 237 275  0
1993 146  111 104  89  98 131 153 148 175  0
1994 177  123 146 124 121 200 266 191 240 106
1995 145   98  95  89  95 130 183 161 164 129
1996 145   98  89  90  93 138 158 131 161 161


Best wishes,

Alfredo

[[alternative HTML version deleted]]

__
R-help@r-project.org 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] t.test() with missing values

2007-09-14 Thread Peter Dalgaard
Birgit Lemcke wrote:
> Thanks for your answer.
>
> First I will show you both vectors:
>   [...]
>
> I tried this (complete.cases(Fem66, Mal66)) and you are right, it
> gives me back:
>
> (complete.cases(Fem66, Mal66))
>   [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
> FALSE FALSE FALSE
[]
> I thought the t.test is a comparison of means and why can I not use it
> if I have a lot of missing values. Is the reason that I use the paired
> option?
> What is different in the calculation using paired?
>
> Ah ja this seems to be the case:
>
> T66<-t.test(Mal66, Fem66, alternative= "two.sided")
> > T66
>
>
> Welch Two Sample t-test
>
> data:  Mal66 and Fem66
> t = -0.4881, df = 49.229, p-value = 0.6277
> alternative hypothesis: true difference in means is not equal to 0
> 95 percent confidence interval:
> -1.4637045  0.8915906
> sample estimates:
> mean of x mean of y
> 5.096552  5.382609
>
> I use the paired option because may plants (male and female) belong to
> the same species (and because may boss said that I have to use paired
> in this case)
Don't do what your boss says, do what is right! (It might of course be
the same thing). So pair #1 is one species, pair #2 another species, up
to 331 different species?

> So what can I do now to solve my problem?
>
> Do you think I should not use paired=TRUE?
You *can* only use it when you have pairs, and you must do it then, to
correct for intra-pair correlation. The drawback is that it looks only
at complete pairs, throwing away all the singlets. It is possible to
recover the information from the singlets , basically by combining a
paired test for the pairs and an unpaired one for the singlets. (Someone
must have written this down, but I'm afraid I don't have a nice reference).

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

__
R-help@r-project.org 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] replace NA value with 0

2007-09-14 Thread Gabor Csardi
x[ is.na(x) ] <- 0

should work in most cases i think.

Gabor

On Fri, Sep 14, 2007 at 10:08:19AM +0200, Alfredo Alessandrini wrote:
> Hi,
> 
> how can I replace NA value with 0:
> 
> 1991 217  119 103 109 137 202 283 240 146  NA
> 1992 270  174 149 144 166 239 278 237 275  NA
> 1993 146  111 104  89  98 131 153 148 175  NA
> 1994 177  123 146 124 121 200 266 191 240 106
> 1995 145   98  95  89  95 130 183 161 164 129
> 1996 145   98  89  90  93 138 158 131 161 161
> 
> 1991 217  119 103 109 137 202 283 240 146  0
> 1992 270  174 149 144 166 239 278 237 275  0
> 1993 146  111 104  89  98 131 153 148 175  0
> 1994 177  123 146 124 121 200 266 191 240 106
> 1995 145   98  95  89  95 130 183 161 164 129
> 1996 145   98  89  90  93 138 158 131 161 161
> 
> 
> Best wishes,
> 
> Alfredo
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org 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.

-- 
Csardi Gabor <[EMAIL PROTECTED]>MTA RMKI, ELTE TTK

__
R-help@r-project.org 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] Sweave: tables vs matrices

2007-09-14 Thread Robin Hankin
Hello everyone


I am preparing a document using Sweave in which I want my matrices
to appear as tables.  I am running into problems because as my
Rnw files stand, I have to  change table entries twice, once for
the matrix and once for the typeset table.

I have lots of material like the following.  How can I arrange
my Rnw file so that  I only have to change one set of figures
when my numbers change?

One reason I prefer tables here is that the NA entries
appear as "-" in the table, but as "NA" in the Schunk.
Is there a way to make the Schunk  typeset NAs
as minuses?



\begin{table}
\centering
\begin{tabular}{||c|}\hline
\multicolumn{4}{|c|}{brand}&\\ \hline
A&B&C&D&total\\ \hline
2   & 3  &  4   & 1& 10   \\
0   & 5   & 7   & -& 12   \\
3   & 7   & -   & 4& 14   \\
2   & -   & -   & 2&  4\\ \hline
7&15&11&7&40\\ \hline
\end{tabular}
\caption{snipped caption}
\end{table}


<<>>=
jj <- matrix(c(2,  3,  4, 1,
0,  5,  7, NA,
3,  7, NA, 4,
2, NA, NA, 2
),byrow=TRUE,nrow=4)
jj <- rbind(jj,apply(jj,2,sum,na.rm=TRUE))
jj <- cbind(jj,apply(jj,1,sum,na.rm=TRUE))
jj
@








--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743

__
R-help@r-project.org 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] Sweave: tables vs matrices

2007-09-14 Thread Gavin Simpson
On Fri, 2007-09-14 at 09:34 +0100, Robin Hankin wrote:
> Hello everyone
> 
> 
> I am preparing a document using Sweave in which I want my matrices
> to appear as tables.  I am running into problems because as my
> Rnw files stand, I have to  change table entries twice, once for
> the matrix and once for the typeset table.
> 
> I have lots of material like the following.  How can I arrange
> my Rnw file so that  I only have to change one set of figures
> when my numbers change?
> 
> One reason I prefer tables here is that the NA entries
> appear as "-" in the table, but as "NA" in the Schunk.
> Is there a way to make the Schunk  typeset NAs
> as minuses?

See ?print.default and its argument na.print:

> print.default(jj, na.print = "-")
 [,1] [,2] [,3] [,4] [,5]
[1,]2341   10
[2,]057-   12
[3,]37-4   14
[4,]2--24
[5,]7   15   117   40

Is that what you meant? It still prints the [1,] bits...

HTH

G

> 
> 
> 
> \begin{table}
> \centering
> \begin{tabular}{||c|}\hline
> \multicolumn{4}{|c|}{brand}&\\ \hline
> A&B&C&D&total\\ \hline
> 2   & 3  &  4   & 1& 10   \\
> 0   & 5   & 7   & -& 12   \\
> 3   & 7   & -   & 4& 14   \\
> 2   & -   & -   & 2&  4\\ \hline
> 7&15&11&7&40\\ \hline
> \end{tabular}
> \caption{snipped caption}
> \end{table}
> 
> 
> <<>>=
> jj <- matrix(c(2,  3,  4, 1,
> 0,  5,  7, NA,
> 3,  7, NA, 4,
> 2, NA, NA, 2
> ),byrow=TRUE,nrow=4)
> jj <- rbind(jj,apply(jj,2,sum,na.rm=TRUE))
> jj <- cbind(jj,apply(jj,1,sum,na.rm=TRUE))
> jj
> @
> 
> 
> 
> 
> 
> 
> 
> 
> --
> Robin Hankin
> Uncertainty Analyst
> National Oceanography Centre, Southampton
> European Way, Southampton SO14 3ZH, UK
>   tel  023-8059-7743
> 
> __
> R-help@r-project.org 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.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
R-help@r-project.org 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] statistics - hypothesis testing question

2007-09-14 Thread Pfaff, Bernhard Dr.
Hello Mark,

in addition and complementing the already provided answers to your
question. You want to consider the J-test, too. For an outline and the
pitfalls of this test, see:

http://citeseer.ist.psu.edu/cache/papers/cs/24954/http:zSzzSzwww.econ.qu
eensu.cazSzfacultyzSzdavidsonzSzbj4-noam.pdf/bootstrap-j-tests-of.pdf


Best,
Bernhard 

>
>I estimate two competing simple regression models, A and B 
>where the LHS
>is the same in both cases but the predictor is different (
>I handle the intercept issue based on other postings I have seen ). I
>estimate the two models on a weekly basis over 24 weeks. 
>So, I end up with 24 RSquaredAs and 24 RsquaredBs, so essentally 2 time
>series of Rsquareds. This doesn't have to be necessarily 
>thought of as a
>time series problem but, is there a usual way, given the Rsquared data,
>to test 
>
>H0 : Rsquared B = Rsquared A versus H1 : Rsquared B > Rsquared A 
>
>so that I can map the 24 R squared numbers into 1 statistic. Maybe
>that's somehow equivalent to just running 2 big regressions over the
>whole 24 weeks and then calculating a statistic from those based on
>those regressions ?
>
>I broke things up into 24 weeks because I was thinking that the
>stability of the performance difference of the two models could be 
>examined over time. Essentially these are simple time series 
>regressions
>X_t = B*X_t-1 + epsilon so I always need to consider
>whether any type of behavior is stable.  But now I am thinking 
>that,  if
>I just want one overall number,  then maybe I should be considering all
>the data simultaneously ? 
>
>In a nutshell,  I am looking for any suggestions on the best 
>way to test
>whether Model B is better than Model A where
>
>Model A :  X_t = Beta*X_t-1 + epsilon
>
>Model B :  X_t = Betastar*Xstar_t-1 + epsilonstar
>
>
>Thanks fo your help.
>
>
>This is not an offer (or solicitation of an offer) to 
>buy/se...{{dropped}}
>
>__
>R-help@r-project.org 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.
>
*
Confidentiality Note: The information contained in this mess...{{dropped}}

__
R-help@r-project.org 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] t.test() with missing values

2007-09-14 Thread Birgit Lemcke

Am 14.09.2007 um 10:26 schrieb Peter Dalgaard:

> Birgit Lemcke wrote:
>> Thanks for your answer.
>>
>> First I will show you both vectors:
>>   [...]
>>
>> I tried this (complete.cases(Fem66, Mal66)) and you are right, it
>> gives me back:
>>
>> (complete.cases(Fem66, Mal66))
>>   [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
>> FALSE FALSE FALSE
> []
>> I thought the t.test is a comparison of means and why can I not  
>> use it
>> if I have a lot of missing values. Is the reason that I use the  
>> paired
>> option?
>> What is different in the calculation using paired?
>>
>> Ah ja this seems to be the case:
>>
>> T66<-t.test(Mal66, Fem66, alternative= "two.sided")
>>> T66
>>
>>
>> Welch Two Sample t-test
>>
>> data:  Mal66 and Fem66
>> t = -0.4881, df = 49.229, p-value = 0.6277
>> alternative hypothesis: true difference in means is not equal to 0
>> 95 percent confidence interval:
>> -1.4637045  0.8915906
>> sample estimates:
>> mean of x mean of y
>> 5.096552  5.382609
>>
>> I use the paired option because may plants (male and female)  
>> belong to
>> the same species (and because may boss said that I have to use paired
>> in this case)
> Don't do what your boss says, do what is right! (It might of course be
> the same thing). So pair #1 is one species, pair #2 another  
> species, up
> to 331 different species?
>
348 species. The rest is correct.
>> So what can I do now to solve my problem?
>>
>> Do you think I should not use paired=TRUE?
> You *can* only use it when you have pairs, and you must do it then, to
> correct for intra-pair correlation. The drawback is that it looks only
> at complete pairs, throwing away all the singlets. It is possible to
> recover the information from the singlets , basically by combining a
> paired test for the pairs and an unpaired one for the singlets.  
> (Someone
> must have written this down, but I'm afraid I don't have a nice  
> reference).

Anyway, thanks a lot and I will try to find it or perhaps somebody  
else in the mailing list knows anything about it.
>
> -- 
>O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
>   c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
>  (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45)  
> 35327918
> ~~ - ([EMAIL PROTECTED])  FAX: (+45)  
> 35327907
>
>

Birgit Lemcke
Institut für Systematische Botanik
Zollikerstrasse 107
CH-8008 Zürich
Switzerland
Ph: +41 (0)44 634 8351
[EMAIL PROTECTED]






[[alternative HTML version deleted]]

__
R-help@r-project.org 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] replace NA value with 0

2007-09-14 Thread S Ellison


>>> Gabor Csardi <[EMAIL PROTECTED]> 14/09/2007 09:27:03 >>>
>x[ is.na(x) ] <- 0
>
>should work in most cases i think.

... only you probably shouldn't be doing that at all. Words like 'bias' spring 
to mind...

Woudn't it be better to accept the NA's and find methods that handle them as 
genuinely missing. R is usually quite good at that.

On Fri, Sep 14, 2007 at 10:08:19AM +0200, Alfredo Alessandrini wrote:
> Hi,
> 
> how can I replace NA value with 0:


***
This email and any attachments are confidential. Any use, co...{{dropped}}

__
R-help@r-project.org 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] replace NA value with 0

2007-09-14 Thread Gabor Csardi
On Fri, Sep 14, 2007 at 09:46:57AM +0100, S Ellison wrote:
> 
> 
> >>> Gabor Csardi <[EMAIL PROTECTED]> 14/09/2007 09:27:03 >>>
> >x[ is.na(x) ] <- 0
> >
> >should work in most cases i think.
> 
> ... only you probably shouldn't be doing that at all. Words like 'bias' 
> spring to mind...
> 
> Woudn't it be better to accept the NA's and find methods that handle them as 
> genuinely missing. R is usually quite good at that.

Although in some cases the proper handling of NA values is to treat 
them az zeros 

I like this list because if you ask a question, 
they don't only solve it immediately (in five different ways), but they
persuade you that what you're trying to do is actually 
incorrect/stupid/uninteresting or your problem just makes no sense at all.
:)

Gabor

> On Fri, Sep 14, 2007 at 10:08:19AM +0200, Alfredo Alessandrini wrote:
> > Hi,
> > 
> > how can I replace NA value with 0:
> 
> 
> ***
> This email and any attachments are confidential. Any use, co...{{dropped}}
> 
> __
> R-help@r-project.org 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.

-- 
Csardi Gabor <[EMAIL PROTECTED]>MTA RMKI, ELTE TTK

__
R-help@r-project.org 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] replace NA value with 0

2007-09-14 Thread S Ellison


>>On Fri, Sep 14, 2007 at 09:46:57AM +0100, S Ellison wrote:
>> 
>>... only you probably shouldn't be doing that at all. Words like 'bias' 
>>spring to mind...
>> 
>> Woudn't it be better to accept the NA's and find methods that handle them as 
>> genuinely missing. 
>> R is usually quite good at that.

And Gabor Csardi <[EMAIL PROTECTED]> replied 

>Although in some cases the proper handling of NA values is to treat 
>them az zeros 
Yup. And sometimes not...

>I like this list because if you ask a question, 
>they don't only solve it immediately (in five different ways), but they
>persuade you that what you're trying to do is actually 
>incorrect/stupid/uninteresting or your problem just makes no sense at all.
>:)

Being a chemist, I have to confess that I can't always tell that what I'm about 
to attempt is barking, trivial, uninteresting or better done a completely 
different way; myself, I'd rather be warned too often than left to dig my own 
pit and fall into it ... 

On NA's vs zero, I usually have the reverse problem in my corner of the world; 
folk will often call nondetects 'missing', which is also often a silly thing to 
do; nondetect means 'I looked and it was too low to see' but NA means 'I didn't 
look'. All that leaves me a bit nervous about replacing NA with 0 and vice 
versa ... hence the knee-jerk. Apologies if I'm teaching egg-sucking to an 
expert. 

S

***
This email and any attachments are confidential. Any use, co...{{dropped}}

__
R-help@r-project.org 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] replace NA value with 0

2007-09-14 Thread Gabor Csardi
On Fri, Sep 14, 2007 at 10:22:36AM +0100, S Ellison wrote:
[...]
> knee-jerk. Apologies if I'm teaching egg-sucking to an expert.  

No apologies please. As i said I _like_ it. Thanks :)

G

> S
> 
> ***
> This email and any attachments are confidential. Any use, ...{{dropped}}

__
R-help@r-project.org 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] t.test() with missing values

2007-09-14 Thread S Ellison


>>> Peter Dalgaard <[EMAIL PROTECTED]> 14/09/2007 09:26:16 >>>
>> So what can I do now to solve my problem?
>>
>> Do you think I should not use paired=TRUE?
>You *can* only use it when you have pairs, and you must do it then, to
>correct for intra-pair correlation. The drawback is that it looks only
>at complete pairs, throwing away all the singlets. It is possible to
>recover the information from the singlets , basically by combining a
>paired test for the pairs and an unpaired one for the singlets. (Someone
>must have written this down, but I'm afraid I don't have a nice reference).

Question: Could you achieve this kind of outcome with lme? stack the two 
groups, mark the observations y by subject (ie the pair ID) and group 
(treatment, presumably), and do something like

anova(lme(y~group, data=d, random=~1|subj, na.action=na.omit))

Or is that just disguising one of those nasty unbalanced 2-way anova problems?

***
This email and any attachments are confidential. Any use, co...{{dropped}}

__
R-help@r-project.org 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] Multiple R sessions, Mac version

2007-09-14 Thread James Reilly


On 14/9/07 3:00 AM, David Afshartous wrote:
> I've just switched to running R 2.5.1 on a Mac 0S X 10.4.1 platform.  I
> can't seem to find how to run simultaneous R sessions.  Didn't see anything
> in the archives on this or under the R file menu.

I've switched to Mac OS X recently too (10.4.10). While running 
simultaneous R sessions under X11 or from the terminal works for me out 
of the box, the only way I've found to run simultaneous Aqua sessions is 
to make extra copies of R.app and run those.

James
-- 
James Reilly
Department of Statistics, University of Auckland
Private Bag 92019, Auckland, New Zealand

__
R-help@r-project.org 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] Logistic regression

2007-09-14 Thread Wayne.W.Jones

Google search "Logistic Regression using R"

There are loads of good links here. Basically you use a generalized linear 
model.

Look up ?glm

Regards

Wayne

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of martin pareja
Sent: 13 September 2007 16:33
To: r-help@r-project.org
Subject: [R] Logistic regression


Hello
I am trying to get the estimated value of logit(p), along with its
standard error/conf interval from a logistic regression model (for the
overall sample, and for individual treatment levels), where p is the
proportion of "successes". I am having difficulty in finding how to
tell R to give this information.
Would anybody be able to help with this?

Thanks
Martin Pareja

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org 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] t.test() with missing values

2007-09-14 Thread Peter Dalgaard
S Ellison wrote:
>   
 Peter Dalgaard <[EMAIL PROTECTED]> 14/09/2007 09:26:16 >>>
 
>>> So what can I do now to solve my problem?
>>>
>>> Do you think I should not use paired=TRUE?
>>>   
>> You *can* only use it when you have pairs, and you must do it then, to
>> correct for intra-pair correlation. The drawback is that it looks only
>> at complete pairs, throwing away all the singlets. It is possible to
>> recover the information from the singlets , basically by combining a
>> paired test for the pairs and an unpaired one for the singlets. (Someone
>> must have written this down, but I'm afraid I don't have a nice reference).
>> 
>
> Question: Could you achieve this kind of outcome with lme? stack the two 
> groups, mark the observations y by subject (ie the pair ID) and group 
> (treatment, presumably), and do something like
>
> anova(lme(y~group, data=d, random=~1|subj, na.action=na.omit))
>
> Or is that just disguising one of those nasty unbalanced 2-way anova problems?
>   
Yes, but

I don't think lme() will do better than what you can do by hand: Get two
independent estimates of mu1-mu2 (one estimate from the pairs and one
from the singlets), compute a weighted average using the s.e.'s and test
that against zero (possibly after testing them for equality for good
measure). This is easy if you use a plug-in approach: first assume that
the s.e. are known, then plug in their empirical value. The tricky bit
is to calculate the DF in the style of Welch's test.

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

__
R-help@r-project.org 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] Sweave: tables vs matrices

2007-09-14 Thread Robin Hankin
Hi Gavin

thanks for that. . . it does 99% of what I wanted.
I'd forgotten about the na.print argument.

It's considerably nicer than my other solution
which converted to character, then jj[is.na(jj)] <- "-"
then noquote(jj).

But  sometimes I just need nice LaTeX tables
and I can't think of a way to arrange things
so that: (i) I have only one set of numbers to maintain,
and (ii) an NA appears as a "-" in the LaTeX table.

best wishes

rksh

On 14 Sep 2007, at 09:52, Gavin Simpson wrote:

> On Fri, 2007-09-14 at 09:34 +0100, Robin Hankin wrote:
>> Hello everyone
>>
>>
>> I am preparing a document using Sweave in which I want my matrices
>> to appear as tables.  I am running into problems because as my
>> Rnw files stand, I have to  change table entries twice, once for
>> the matrix and once for the typeset table.
>>
>> I have lots of material like the following.  How can I arrange
>> my Rnw file so that  I only have to change one set of figures
>> when my numbers change?
>>
>> One reason I prefer tables here is that the NA entries
>> appear as "-" in the table, but as "NA" in the Schunk.
>> Is there a way to make the Schunk  typeset NAs
>> as minuses?
>
> See ?print.default and its argument na.print:
>
>> print.default(jj, na.print = "-")
>  [,1] [,2] [,3] [,4] [,5]
> [1,]2341   10
> [2,]057-   12
> [3,]37-4   14
> [4,]2--24
> [5,]7   15   117   40
>
> Is that what you meant? It still prints the [1,] bits...
>
> HTH
>
> G
>
>>
>>
>>
>> \begin{table}
>> \centering
>> \begin{tabular}{||c|}\hline
>> \multicolumn{4}{|c|}{brand}&\\ \hline
>> A&B&C&D&total\\ \hline
>> 2   & 3  &  4   & 1& 10   \\
>> 0   & 5   & 7   & -& 12   \\
>> 3   & 7   & -   & 4& 14   \\
>> 2   & -   & -   & 2&  4\\ \hline
>> 7&15&11&7&40\\ \hline
>> \end{tabular}
>> \caption{snipped caption}
>> \end{table}
>>
>>
>> <<>>=
>> jj <- matrix(c(2,  3,  4, 1,
>> 0,  5,  7, NA,
>> 3,  7, NA, 4,
>> 2, NA, NA, 2
>> ),byrow=TRUE,nrow=4)
>> jj <- rbind(jj,apply(jj,2,sum,na.rm=TRUE))
>> jj <- cbind(jj,apply(jj,1,sum,na.rm=TRUE))
>> jj
>> @
>>
>>
>>
>

--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743

__
R-help@r-project.org 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] Sweave: tables vs matrices

2007-09-14 Thread Gavin Simpson
On Fri, 2007-09-14 at 11:24 +0100, Robin Hankin wrote:
> Hi Gavin
> 
> thanks for that. . . it does 99% of what I wanted.
> I'd forgotten about the na.print argument.
> 
> It's considerably nicer than my other solution
> which converted to character, then jj[is.na(jj)] <- "-"
> then noquote(jj).
> 
> But  sometimes I just need nice LaTeX tables
> and I can't think of a way to arrange things
> so that: (i) I have only one set of numbers to maintain,
> and (ii) an NA appears as a "-" in the LaTeX table.

Ok, then the xtable package and function is your answer. You can use
this within Sweave but I think you need to set the output to latex in
the Sweave chunk?

Is this closer to what you want?

> print.xtable(xtable(jj), NA.string = "-")
% latex table generated in R 2.5.1 by xtable 1.4-6 package
% Fri Sep 14 11:43:34 2007
\begin{table}[ht]
\begin{center}
\begin{tabular}{rr}
  \hline
 & 1 & 2 & 3 & 4 & 5 \\
  \hline
1 & 2.00 & 3.00 & 4.00 & 1.00 & 10.00 \\
  2 & 0.00 & 5.00 & 7.00 & $-$ & 12.00 \\
  3 & 3.00 & 7.00 & $-$ & 4.00 & 14.00 \\
  4 & 2.00 & $-$ & $-$ & 2.00 & 4.00 \\
  5 & 7.00 & 15.00 & 11.00 & 7.00 & 40.00 \\
   \hline
\end{tabular}
\end{center}
\end{table}

HTH

G

> 
> best wishes
> 
> rksh
> 
> On 14 Sep 2007, at 09:52, Gavin Simpson wrote:
> 
> > On Fri, 2007-09-14 at 09:34 +0100, Robin Hankin wrote:
> >> Hello everyone
> >>
> >>
> >> I am preparing a document using Sweave in which I want my matrices
> >> to appear as tables.  I am running into problems because as my
> >> Rnw files stand, I have to  change table entries twice, once for
> >> the matrix and once for the typeset table.
> >>
> >> I have lots of material like the following.  How can I arrange
> >> my Rnw file so that  I only have to change one set of figures
> >> when my numbers change?
> >>
> >> One reason I prefer tables here is that the NA entries
> >> appear as "-" in the table, but as "NA" in the Schunk.
> >> Is there a way to make the Schunk  typeset NAs
> >> as minuses?
> >
> > See ?print.default and its argument na.print:
> >
> >> print.default(jj, na.print = "-")
> >  [,1] [,2] [,3] [,4] [,5]
> > [1,]2341   10
> > [2,]057-   12
> > [3,]37-4   14
> > [4,]2--24
> > [5,]7   15   117   40
> >
> > Is that what you meant? It still prints the [1,] bits...
> >
> > HTH
> >
> > G
> >
> >>
> >>
> >>
> >> \begin{table}
> >> \centering
> >> \begin{tabular}{||c|}\hline
> >> \multicolumn{4}{|c|}{brand}&\\ \hline
> >> A&B&C&D&total\\ \hline
> >> 2   & 3  &  4   & 1& 10   \\
> >> 0   & 5   & 7   & -& 12   \\
> >> 3   & 7   & -   & 4& 14   \\
> >> 2   & -   & -   & 2&  4\\ \hline
> >> 7&15&11&7&40\\ \hline
> >> \end{tabular}
> >> \caption{snipped caption}
> >> \end{table}
> >>
> >>
> >> <<>>=
> >> jj <- matrix(c(2,  3,  4, 1,
> >> 0,  5,  7, NA,
> >> 3,  7, NA, 4,
> >> 2, NA, NA, 2
> >> ),byrow=TRUE,nrow=4)
> >> jj <- rbind(jj,apply(jj,2,sum,na.rm=TRUE))
> >> jj <- cbind(jj,apply(jj,1,sum,na.rm=TRUE))
> >> jj
> >> @
> >>
> >>
> >>
> >
> 
> --
> Robin Hankin
> Uncertainty Analyst
> National Oceanography Centre, Southampton
> European Way, Southampton SO14 3ZH, UK
>   tel  023-8059-7743
> 
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

__
R-help@r-project.org 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] How to remove index from list after split?

2007-09-14 Thread Rick DeShon
In the following example, how can I drop the group index from the list after
I perform a split?
n <- 3
nn   <- 10
g <- factor(round(n * runif(n * nn)))
x <- rnorm(n * nn) + sqrt(as.numeric(g))
df<- data.frame(g,x)
df.s <- split(df,g)

Thanks!

Rick DeShon

[[alternative HTML version deleted]]

__
R-help@r-project.org 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] segfault in download.file

2007-09-14 Thread max . e . brown
Hello,

I was trying to use get.hist.quote in tseries, and got a segfault:

-8<---

> library(tseries)
Loading required package: quadprog
Loading required package: zoo

'tseries' version: 0.10-6

'tseries' is a package for time series analysis and computational
finance.

See 'library(help="tseries")' for details.

> get.hist.quote("^spx")
trying URL 
'http://chart.yahoo.com/table.csv?s=^spx&a=0&b=02&c=1991&d=8&e=13&f=2007&g=d&q=q&y=0&z=^spx&x=.csv'

 *** caught segfault ***
address 0x5f4d4550, cause 'memory not mapped'

Traceback:
 1: download.file(url, destfile, method = method, quiet = quiet)
 2: get.hist.quote("^spx")

Possible actions:
1: abort (with core dump)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection: 1
aborting ...
Segmentation fault

--

This appears to be reproducible.

My R version is
platform   powerpc-apple-darwin8.6.0 
arch   powerpc   
os darwin8.6.0   
system powerpc, darwin8.6.0  
status   
major  2 
minor  3.1   
year   2006  
month  06
day01
svn rev38247 
language   R 
version.string Version 2.3.1 (2006-06-01)

Is this a known issue?

Thanks,

Max

PS:
I can't seem to get useful info out of the dumped core:

Core was generated by 
`/Library/Frameworks/R.framework/Resources/bin/exec/ppc/R'.
#0  0x90003568 in ?? ()
(gdb) bt
#0  0x90003568 in ?? ()

I guess I would need a version of R with debugging symbols in there?

__
R-help@r-project.org 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] How to remove index from list after split?

2007-09-14 Thread Vladimir Eremeev

Did not completely understand what is a 'group index', 
but to remove any element from a list or a matrix, or a vector or a data
frame you could use the negative index.

For example, 

> df.s[-c(1:3)]
$`3`
   gx
1  3 3.916503
12 3 1.435718
24 3 2.252151

> df.s[-c(1:3)][[1]][-1]
  x
1  3.916503
12 1.435718
24 2.252151

You can also assign the results to a variable (the same or the other one)
> df.s<-df.s[-c(1:3)][[1]][-1]
> df.s
  x
1  3.916503
12 1.435718
24 2.252151



Rick DeShon wrote:
> 
> In the following example, how can I drop the group index from the list
> after
> I perform a split?
> n <- 3
> nn   <- 10
> g <- factor(round(n * runif(n * nn)))
> x <- rnorm(n * nn) + sqrt(as.numeric(g))
> df<- data.frame(g,x)
> df.s <- split(df,g)
> 

-- 
View this message in context: 
http://www.nabble.com/How-to-remove-index-from-list-after-split--tf4441712.html#a12673118
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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] t.test() with missing values

2007-09-14 Thread Birgit Lemcke

Am 14.09.2007 um 12:05 schrieb Peter Dalgaard:

> S Ellison wrote:
>>
> Peter Dalgaard <[EMAIL PROTECTED]> 14/09/2007 09:26:16 >>>
>
 So what can I do now to solve my problem?

 Do you think I should not use paired=TRUE?

>>> You *can* only use it when you have pairs, and you must do it  
>>> then, to
>>> correct for intra-pair correlation. The drawback is that it looks  
>>> only
>>> at complete pairs, throwing away all the singlets. It is possible to
>>> recover the information from the singlets , basically by combining a
>>> paired test for the pairs and an unpaired one for the singlets.  
>>> (Someone
>>> must have written this down, but I'm afraid I don't have a nice  
>>> reference).
>>>
>>
>> Question: Could you achieve this kind of outcome with lme? stack  
>> the two groups, mark the observations y by subject (ie the pair  
>> ID) and group (treatment, presumably), and do something like
>>
>> anova(lme(y~group, data=d, random=~1|subj, na.action=na.omit))
>>
>> Or is that just disguising one of those nasty unbalanced 2-way  
>> anova problems?
>>
> Yes, but
>
> I don't think lme() will do better than what you can do by hand:  
> Get two
> independent estimates of mu1-mu2 (one estimate from the pairs and one
> from the singlets), compute a weighted average using the s.e.'s and  
> test
> that against zero (possibly after testing them for equality for good
> measure). This is easy if you use a plug-in approach: first assume  
> that
> the s.e. are known, then plug in their empirical value. The tricky bit
> is to calculate the DF in the style of Welch's test.

I apologise but I really can not follow your 
explanations. I am  R  
and Stastistics Beginner.

What do you mean with mu1-mu2 and what are s.e.´s?

Once again thank you for your help.

Birgit




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

Birgit Lemcke
Institut für Systematische Botanik
Zollikerstrasse 107
CH-8008 Zürich
Switzerland
Ph: +41 (0)44 634 8351
[EMAIL PROTECTED]






[[alternative HTML version deleted]]

__
R-help@r-project.org 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] segfault in download.file

2007-09-14 Thread Vladimir Eremeev

I tried the same operations, and got

trying URL
'http://chart.yahoo.com/table.csv?s=^spx&a=0&b=02&c=1991&d=8&e=13&f=2007&g=d&q=q&y=0&z=^spx&x=.csv'
Error in download.file(url, destfile, method = method, quiet = quiet) : 
cannot open URL
'http://chart.yahoo.com/table.csv?s=^spx&a=0&b=02&c=1991&d=8&e=13&f=2007&g=d&q=q&y=0&z=^spx&x=.csv'
In addition: Warning message:
cannot open: HTTP status was '404 Not Found' in: download.file(url,
destfile, method = method, quiet = quiet) 

Probably, you should upgrade R and the package.


max.e.brown wrote:
> 
> Hello,
> 
> I was trying to use get.hist.quote in tseries, and got a segfault:
> 
> -8<---
> 
>> library(tseries)
> Loading required package: quadprog
> Loading required package: zoo
> 
> 'tseries' version: 0.10-6
> 
> 'tseries' is a package for time series analysis and computational
> finance.
> 
> See 'library(help="tseries")' for details.
> 
>> get.hist.quote("^spx")
> trying URL
> 'http://chart.yahoo.com/table.csv?s=^spx&a=0&b=02&c=1991&d=8&e=13&f=2007&g=d&q=q&y=0&z=^spx&x=.csv'
> 
>  *** caught segfault ***
> address 0x5f4d4550, cause 'memory not mapped'
> 
> Traceback:
>  1: download.file(url, destfile, method = method, quiet = quiet)
>  2: get.hist.quote("^spx")
> 
> Possible actions:
> 1: abort (with core dump)
> 2: normal R exit
> 3: exit R without saving workspace
> 4: exit R saving workspace
> Selection: 1
> aborting ...
> Segmentation fault
> 
> --
> 
> This appears to be reproducible.
> 
> My R version is
> platform   powerpc-apple-darwin8.6.0 
> arch   powerpc   
> os darwin8.6.0   
> system powerpc, darwin8.6.0  
> status   
> major  2 
> minor  3.1   
> year   2006  
> month  06
> day01
> svn rev38247 
> language   R 
> version.string Version 2.3.1 (2006-06-01)
> 
> Is this a known issue?
> 
> Thanks,
> 
> Max
> 
> PS:
> I can't seem to get useful info out of the dumped core:
> 
> Core was generated by
> `/Library/Frameworks/R.framework/Resources/bin/exec/ppc/R'.
> #0  0x90003568 in ?? ()
> (gdb) bt
> #0  0x90003568 in ?? ()
> 
> I guess I would need a version of R with debugging symbols in there?
> 
> 

-- 
View this message in context: 
http://www.nabble.com/segfault-in-download.file-tf4441735.html#a12672985
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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] quantiles and dataframe

2007-09-14 Thread Anders Bjørgesæter
Hi

I have a dataframe, RQ, like this:

AB1B2B3
1NA11212
2NA123   123
3NA32413
43 21535
54 1233
67 1 335
74 NA3535
84 NANA
9NANANA
105NANA
124NANA
152NANA
173NA1
631NA1
75NA   NANA
100   NA   NANA
123   NA   NANA
155   NA   NANA
166   NA   NANA
177   NA   NANA

I want to extract min, max, 5% and 95% from A based on the range of the Bs.

Using this:

s1<-A[min(which(!is.na(B1))):max(which(!is.na(B1)))]
q1<-quantile(s1,probs=c(0,5,95,100,NA)/100)

I manage to get this by changing the B1 manually for each B

B1B2B3
4.01.00 1.00(min)
63.0   6.00 63.00   (max)
4.54.5  1.65(5%)
40.0   6.00 63.00   (95%)

I tried to use apply like this: s1<-apply(RQ,2,function(x) 
{A[min(which(!is.na(RQ[,2:4]))):max(which(!is.na(RQ[,2:4])))] })

to get the range of each B but that doesn't work.

Also as you see, s1 includes the A where the B's are NA, e.g. for B1 I 
get the 9 at row 9 (4,5,6,7,8,9,10,12,15,17,63) and not 
(4,5,6,7,8,10,12,15,17,63), which I would prefer.

BUT the main question is how can I extract min, max etc. from each B in 
dataframe RQ without using a loop?

Any help is greatly appreciated!

Best Regards
Anders

__
R-help@r-project.org 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] write.csv / string extraction and field limits

2007-09-14 Thread kwaj

I worked it out. It wasn't actually the write.csv command - it was the fact
that I wasn't putting "as.is" in the read.csv that was corrupting the
process


Xavier Abulker wrote:
> 
> This example works fine:
> 
> test<-matrix(c(1,2,'VOICIUNPETITTES',3),ncol=2,nrow=2)
> write.csv(test,file='C:/xavier/test.csv')
> 
> 
> Could you provide the same small example when it doesn't work?
> 
> 
> 
> kwaj wrote:
>> 
>> Hello, 
>> 
>> I have a peculiar problem which I am hoping I can get help on. 
>> 
>> I am using the write.csv command to write a matrix structure to a file,
>> which I later read in excel. The command works quite well for most
>> strings and numerical values in the matrix structure. 
>> 
>> However, I have found that when a field in the matrix contains a string
>> of long length, when the matrix is finally written the file - the field
>> shows up as "NA". I am assuming write.csv has a limit on the field size?
>> Maybe 16 characters?
>> 
>> Assuming the above is correct - I tried to extract a portion of the
>> string using the 'substring' command and enter the extracted portion into
>> the field before using the write.csv command. However I find, that when a
>> string is extracted, the output from write.csv generates a NA in the file
>> output. 
>> 
>> My questions are:
>> 
>> 1) Does write.csv have a limit on the size of strings in the matrix
>> fields? Is there anyway to place large strings in the field?
>> 
>> 2) Is there anyway to make the substring command or an alternative but
>> similar command, compatible with write.csv? I have tried
>> 'as.character(substring(phrase, min, max)' and that does not seem to work
>> 
>> cheers
>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/write.csv---string-extraction-and-field-limits-tf4395535.html#a12673415
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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] t.test() with missing values

2007-09-14 Thread Peter Dalgaard
Birgit Lemcke wrote:
>
> Am 14.09.2007 um 12:05 schrieb Peter Dalgaard:
>
>> S Ellison wrote:
>>>
>> Peter Dalgaard <[EMAIL PROTECTED]> 14/09/2007 09:26:16 >>>
>>
> So what can I do now to solve my problem?
>
> Do you think I should not use paired=TRUE?
>
 You *can* only use it when you have pairs, and you must do it then, to
 correct for intra-pair correlation. The drawback is that it looks only
 at complete pairs, throwing away all the singlets. It is possible to
 recover the information from the singlets , basically by combining a
 paired test for the pairs and an unpaired one for the singlets.
 (Someone
 must have written this down, but I'm afraid I don't have a nice
 reference).

>>>
>>> Question: Could you achieve this kind of outcome with lme? stack the
>>> two groups, mark the observations y by subject (ie the pair ID) and
>>> group (treatment, presumably), and do something like
>>>
>>> anova(lme(y~group, data=d, random=~1|subj, na.action=na.omit))
>>>
>>> Or is that just disguising one of those nasty unbalanced 2-way anova
>>> problems?
>>>
>> Yes, but
>>
>> I don't think lme() will do better than what you can do by hand: Get two
>> independent estimates of mu1-mu2 (one estimate from the pairs and one
>> from the singlets), compute a weighted average using the s.e.'s and test
>> that against zero (possibly after testing them for equality for good
>> measure). This is easy if you use a plug-in approach: first assume that
>> the s.e. are known, then plug in their empirical value. The tricky bit
>> is to calculate the DF in the style of Welch's test.
>
> I apologise but I really can not follow your explanations.
> I am  R and Stastistics Beginner.
>
> What do you mean with mu1-mu2 and what are s.e.´s?
>
That was a reply to S. Ellison. If you don't understand it, don't worry;
you'll probably need to read a book chapter or more about weighted
analyses to get up to speed for that. 

mu1, mu2 : (theoretical) mean for group 1, 2
s.e.: standard error
> Once again thank you for your help.
>
> Birgit
>
>
>
>
>>
>> --   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
>>   c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
>>  (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45)
>> 35327918
>> ~~ - ([EMAIL PROTECTED])  FAX: (+45)
>> 35327907
>>
>>
>
> Birgit Lemcke
> Institut für Systematische Botanik
> Zollikerstrasse 107
> CH-8008 Zürich
> Switzerland
> Ph: +41 (0)44 634 8351
> [EMAIL PROTECTED]
>
>
>
>
>
>


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

__
R-help@r-project.org 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] How to remove index from list after split?

2007-09-14 Thread Wayne.W.Jones
Not sure what you mean by "group index" but try: 

lapply(df.s,function(l){l$x})
or something like: 

do.call("rbind",df.s) 

to convert the result into a data.frame. 

Regards

Wayne



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Rick DeShon
Sent: 14 September 2007 11:50
To: [EMAIL PROTECTED]
Subject: [R] How to remove index from list after split?


In the following example, how can I drop the group index from the list after
I perform a split?
n <- 3
nn   <- 10
g <- factor(round(n * runif(n * nn)))
x <- rnorm(n * nn) + sqrt(as.numeric(g))
df<- data.frame(g,x)
df.s <- split(df,g)

Thanks!

Rick DeShon

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org 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] covariates in nlmer function

2007-09-14 Thread Kari Ruohonen
I am trying to explore nlmer by running some nlme examples from Pinheiro
& Bates (2000). I do not seem to find information how to specify fixed
effects covariates to nlmer models. Specifically, I tried to run the
"Carbon Dioxide Uptake" example from p. 368 onwards in the PB200 book.
The model without fixed effects covariates runs well but how to tell
nlmer to include Type and Treatment similar to the nlme model on p. 374
in the PB2000 book? Or is this something that has not been implemented
yet?

regards,
Kari Ruohonen

__
R-help@r-project.org 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] t.test() with missing values

2007-09-14 Thread Petr PIKAL
Hi

[EMAIL PROTECTED] napsal dne 14.09.2007 13:50:58:

> Birgit Lemcke wrote:
> >
> > Am 14.09.2007 um 12:05 schrieb Peter Dalgaard:
> >
> >> S Ellison wrote:
> >>>
> >> Peter Dalgaard <[EMAIL PROTECTED]> 14/09/2007 09:26:16 >>>
> >>





> >>>
> >> Yes, but
> >>
> >> I don't think lme() will do better than what you can do by hand: Get 
two
> >> independent estimates of mu1-mu2 (one estimate from the pairs and one
> >> from the singlets), compute a weighted average using the s.e.'s and 
test
> >> that against zero (possibly after testing them for equality for good
> >> measure). This is easy if you use a plug-in approach: first assume 
that
> >> the s.e. are known, then plug in their empirical value. The tricky 
bit
> >> is to calculate the DF in the style of Welch's test.
> >
> > I apologise but I really can not follow your explanations.
> > I am  R and Stastistics Beginner.
> >
> > What do you mean with mu1-mu2 and what are s.e.´s?
> >
> That was a reply to S. Ellison. If you don't understand it, don't worry;
> you'll probably need to read a book chapter or more about weighted
> analyses to get up to speed for that. 
> 
> mu1, mu2 : (theoretical) mean for group 1, 2
> s.e.: standard error

But as Birgit actually does not have any paired values, according to the 
data she had sent, she can not do paired t.test at all. The only way is to 
compare averages from each vector by non paired t.test or to get some new 
values for which she have counterparts. 

Regards
Petr



> > Once again thank you for your help.
> >
> > Birgit
> >
> > 
> >
> > 
> >>
> >> --   O__   Peter Dalgaard Øster Farimagsgade 5, 
Entr.B
> >>   c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
> >>  (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45)
> >> 35327918
> >> ~~ - ([EMAIL PROTECTED])  FAX: (+45)
> >> 35327907
> >>
> >>
> >
> > Birgit Lemcke
> > Institut für Systematische Botanik
> > Zollikerstrasse 107
> > CH-8008 Zürich
> > Switzerland
> > Ph: +41 (0)44 634 8351
> > [EMAIL PROTECTED]
> >
> >
> >
> >
> >
> >
> 
> 
> -- 
>O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
>   c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
>  (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 
35327918
> ~~ - ([EMAIL PROTECTED])  FAX: (+45) 
35327907
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org 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] quantiles and dataframe

2007-09-14 Thread Gabor Grothendieck
Try this:

sapply(RQ[-1], quantile, probs = c(0, .05, .95, 1), na.rm = TRUE)



On 9/14/07, Anders Bjørgesæter <[EMAIL PROTECTED]> wrote:
> Hi
>
> I have a dataframe, RQ, like this:
>
> AB1B2B3
> 1NA11212
> 2NA123   123
> 3NA32413
> 43 21535
> 54 1233
> 67 1 335
> 74 NA3535
> 84 NANA
> 9NANANA
> 105NANA
> 124NANA
> 152NANA
> 173NA1
> 631NA1
> 75NA   NANA
> 100   NA   NANA
> 123   NA   NANA
> 155   NA   NANA
> 166   NA   NANA
> 177   NA   NANA
>
> I want to extract min, max, 5% and 95% from A based on the range of the Bs.
>
> Using this:
>
> s1<-A[min(which(!is.na(B1))):max(which(!is.na(B1)))]
> q1<-quantile(s1,probs=c(0,5,95,100,NA)/100)
>
> I manage to get this by changing the B1 manually for each B
>
> B1B2B3
> 4.01.00 1.00(min)
> 63.0   6.00 63.00   (max)
> 4.54.5  1.65(5%)
> 40.0   6.00 63.00   (95%)
>
> I tried to use apply like this: s1<-apply(RQ,2,function(x)
> {A[min(which(!is.na(RQ[,2:4]))):max(which(!is.na(RQ[,2:4])))] })
>
> to get the range of each B but that doesn't work.
>
> Also as you see, s1 includes the A where the B's are NA, e.g. for B1 I
> get the 9 at row 9 (4,5,6,7,8,9,10,12,15,17,63) and not
> (4,5,6,7,8,10,12,15,17,63), which I would prefer.
>
> BUT the main question is how can I extract min, max etc. from each B in
> dataframe RQ without using a loop?
>
> Any help is greatly appreciated!
>
> Best Regards
> Anders
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org 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] t.test() with missing values

2007-09-14 Thread Peter Dalgaard
Petr PIKAL wrote:
> Hi
>
> [EMAIL PROTECTED] napsal dne 14.09.2007 13:50:58:
>
>   
>> Birgit Lemcke wrote:
>> 
>>> Am 14.09.2007 um 12:05 schrieb Peter Dalgaard:
>>>
>>>   
 S Ellison wrote:
 
 Peter Dalgaard <[EMAIL PROTECTED]> 14/09/2007 09:26:16 >>>

 
>
>
> 
>
>
>   
 Yes, but

 I don't think lme() will do better than what you can do by hand: Get 
 
> two
>   
 independent estimates of mu1-mu2 (one estimate from the pairs and one
 from the singlets), compute a weighted average using the s.e.'s and 
 
> test
>   
 that against zero (possibly after testing them for equality for good
 measure). This is easy if you use a plug-in approach: first assume 
 
> that
>   
 the s.e. are known, then plug in their empirical value. The tricky 
 
> bit
>   
 is to calculate the DF in the style of Welch's test.
 
>>> I apologise but I really can not follow your explanations.
>>> I am  R and Stastistics Beginner.
>>>
>>> What do you mean with mu1-mu2 and what are s.e.´s?
>>>
>>>   
>> That was a reply to S. Ellison. If you don't understand it, don't worry;
>> you'll probably need to read a book chapter or more about weighted
>> analyses to get up to speed for that. 
>>
>> mu1, mu2 : (theoretical) mean for group 1, 2
>> s.e.: standard error
>> 
>
> But as Birgit actually does not have any paired values, according to the 
> data she had sent, she can not do paired t.test at all. The only way is to 
> compare averages from each vector by non paired t.test or to get some new 
> values for which she have counterparts. 
>   
True, for that particular set of data. I did make that point in my first
reply (tried to, anyways), but I didn't repeat it the second time.

If you look back, you'll see that Birgit was also doing

TTest75<-t.test(Fem75, Mal75, alternative= "two.sided", paired= TRUE)

and presumably there are several similar sets of data. This "works" in the 
sense that it produces a test, but one could get the suspicion that it is only 
using a small subset of available data if the dropout rate is approaching that 
of Fem66/Mal66. Hence the discussion of the general case.

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


 
>>> Birgit Lemcke
>>> Institut für Systematische Botanik
>>> Zollikerstrasse 107
>>> CH-8008 Zürich
>>> Switzerland
>>> Ph: +41 (0)44 634 8351
>>> [EMAIL PROTECTED]
>>>
>>>
>>>
>>>
>>>
>>>
>>>   
>> -- 
>>O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
>>   c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
>>  (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 
>> 
> 35327918
>   
>> ~~ - ([EMAIL PROTECTED])  FAX: (+45) 
>> 
> 35327907
>   
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide 
>> 
> http://www.R-project.org/posting-guide.html
>   
>> and provide commented, minimal, self-contained, reproducible code.
>> 
>
> __
> R-help@r-project.org 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.
>   


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

__
R-help@r-project.org 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] replace NA value with 0

2007-09-14 Thread S Ellison


>>> Ted Harding <[EMAIL PROTECTED]> 14/09/2007 10:59:47 >>>
>On the contrary! It adds to our "collective wisdom".
>
>We all have to suck eggs, and usually can successfully perform the act.

Ted,

Thanks for the kind remarks.

But we'll have to get off the egg topic, or we'll all end up as acknowledged 
expert suckers

Steve E

***
This email and any attachments are confidential. Any use, co...{{dropped}}

__
R-help@r-project.org 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] quantiles and dataframe

2007-09-14 Thread jim holtman
I think this does what you want:

> RQ
 A B1  B2   B3
11 NA 112   12
22 NA 123  123
33 NA 324   13
44  3  21  535
55  4  12   33
66  7   1  335
77  4  NA 3535
88  4  NA   NA
99 NA  NA   NA
10  10  5  NA   NA
11  12  4  NA   NA
12  15  2  NA   NA
13  17  3  NA1
14  63  1  NA1
15  75 NA  NA   NA
16 100 NA  NA   NA
17 123 NA  NA   NA
18 155 NA  NA   NA
19 166 NA  NA   NA
20 177 NA  NA   NA
> x <- lapply(RQ[-1], function(.col){
+ quantile(RQ[!is.na(.col), 1], probs=c(0, 0.05, 0.95, 1))
+ })
> do.call('cbind', x)
B1   B2   B3
0%4.00 1.00  1.0
5%4.45 1.25  1.4
95%  42.30 5.75 44.6
100% 63.00 6.00 63.0


On 9/14/07, Anders Bjørgesæter <[EMAIL PROTECTED]> wrote:
> Hi
>
> I have a dataframe, RQ, like this:
>
> AB1B2B3
> 1NA11212
> 2NA123   123
> 3NA32413
> 43 21535
> 54 1233
> 67 1 335
> 74 NA3535
> 84 NANA
> 9NANANA
> 105NANA
> 124NANA
> 152NANA
> 173NA1
> 631NA1
> 75NA   NANA
> 100   NA   NANA
> 123   NA   NANA
> 155   NA   NANA
> 166   NA   NANA
> 177   NA   NANA
>
> I want to extract min, max, 5% and 95% from A based on the range of the Bs.
>
> Using this:
>
> s1<-A[min(which(!is.na(B1))):max(which(!is.na(B1)))]
> q1<-quantile(s1,probs=c(0,5,95,100,NA)/100)
>
> I manage to get this by changing the B1 manually for each B
>
> B1B2B3
> 4.01.00 1.00(min)
> 63.0   6.00 63.00   (max)
> 4.54.5  1.65(5%)
> 40.0   6.00 63.00   (95%)
>
> I tried to use apply like this: s1<-apply(RQ,2,function(x)
> {A[min(which(!is.na(RQ[,2:4]))):max(which(!is.na(RQ[,2:4])))] })
>
> to get the range of each B but that doesn't work.
>
> Also as you see, s1 includes the A where the B's are NA, e.g. for B1 I
> get the 9 at row 9 (4,5,6,7,8,9,10,12,15,17,63) and not
> (4,5,6,7,8,10,12,15,17,63), which I would prefer.
>
> BUT the main question is how can I extract min, max etc. from each B in
> dataframe RQ without using a loop?
>
> Any help is greatly appreciated!
>
> Best Regards
> Anders
>
> __
> R-help@r-project.org 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.
>


-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

__
R-help@r-project.org 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] building with atlas version of blas and lapack

2007-09-14 Thread K Vanw
On 9/12/07, Uwe Ligges <[EMAIL PROTECTED]> wrote:
>
> Flags should be
>--with-blas="-L/usr/local/atlas/lib -lf77blas -latlas"

That worked. Thanks.

__
R-help@r-project.org 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] quantiles and dataframe

2007-09-14 Thread Gabor Grothendieck
Sorry, try this instead.  It creates a data frame of 3 columns in which
each column equals RQ[,1] except it has NAs where the columns of RQ[-1]
has NAs.  Perform the quantile operation on that.

sapply(sign(RQ[-1]) * RQ[,1], quantile, probs = c(0, .05, .95, 1), na.rm = TRUE)


On 9/14/07, Gabor Grothendieck <[EMAIL PROTECTED]> wrote:
> Try this:
>
> sapply(RQ[-1], quantile, probs = c(0, .05, .95, 1), na.rm = TRUE)
>
>
>
> On 9/14/07, Anders Bjørgesæter <[EMAIL PROTECTED]> wrote:
> > Hi
> >
> > I have a dataframe, RQ, like this:
> >
> > AB1B2B3
> > 1NA11212
> > 2NA123   123
> > 3NA32413
> > 43 21535
> > 54 1233
> > 67 1 335
> > 74 NA3535
> > 84 NANA
> > 9NANANA
> > 105NANA
> > 124NANA
> > 152NANA
> > 173NA1
> > 631NA1
> > 75NA   NANA
> > 100   NA   NANA
> > 123   NA   NANA
> > 155   NA   NANA
> > 166   NA   NANA
> > 177   NA   NANA
> >
> > I want to extract min, max, 5% and 95% from A based on the range of the Bs.
> >
> > Using this:
> >
> > s1<-A[min(which(!is.na(B1))):max(which(!is.na(B1)))]
> > q1<-quantile(s1,probs=c(0,5,95,100,NA)/100)
> >
> > I manage to get this by changing the B1 manually for each B
> >
> > B1B2B3
> > 4.01.00 1.00(min)
> > 63.0   6.00 63.00   (max)
> > 4.54.5  1.65(5%)
> > 40.0   6.00 63.00   (95%)
> >
> > I tried to use apply like this: s1<-apply(RQ,2,function(x)
> > {A[min(which(!is.na(RQ[,2:4]))):max(which(!is.na(RQ[,2:4])))] })
> >
> > to get the range of each B but that doesn't work.
> >
> > Also as you see, s1 includes the A where the B's are NA, e.g. for B1 I
> > get the 9 at row 9 (4,5,6,7,8,9,10,12,15,17,63) and not
> > (4,5,6,7,8,10,12,15,17,63), which I would prefer.
> >
> > BUT the main question is how can I extract min, max etc. from each B in
> > dataframe RQ without using a loop?
> >
> > Any help is greatly appreciated!
> >
> > Best Regards
> > Anders
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
>

__
R-help@r-project.org 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] Logistic regression

2007-09-14 Thread David Barron
You might want to look at the lrm function in the Design package as an
alternative to the standard tools.

On 9/14/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Google search "Logistic Regression using R"
>
> There are loads of good links here. Basically you use a generalized linear 
> model.
>
> Look up ?glm
>
> Regards
>
> Wayne
>
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of martin pareja
> Sent: 13 September 2007 16:33
> To: r-help@r-project.org
> Subject: [R] Logistic regression
>
>
> Hello
> I am trying to get the estimated value of logit(p), along with its
> standard error/conf interval from a logistic regression model (for the
> overall sample, and for individual treatment levels), where p is the
> proportion of "successes". I am having difficulty in finding how to
> tell R to give this information.
> Would anybody be able to help with this?
>
> Thanks
> Martin Pareja
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
> __
> R-help@r-project.org 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.
>


-- 
=
David Barron
Said Business School
University of Oxford
Park End Street
Oxford OX1 1HP

__
R-help@r-project.org 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] t.test() with missing values

2007-09-14 Thread Birgit Lemcke

Am 14.09.2007 um 14:12 schrieb Petr PIKAL:

> Hi
>
> [EMAIL PROTECTED] napsal dne 14.09.2007 13:50:58:
>
>> Birgit Lemcke wrote:
>>>
>>> Am 14.09.2007 um 12:05 schrieb Peter Dalgaard:
>>>
 S Ellison wrote:
>
 Peter Dalgaard <[EMAIL PROTECTED]> 14/09/2007  
 09:26:16 >>>

>
>
> 
>
>
>
 Yes, but

 I don't think lme() will do better than what you can do by hand:  
 Get
> two
 independent estimates of mu1-mu2 (one estimate from the pairs  
 and one
 from the singlets), compute a weighted average using the s.e.'s and
> test
 that against zero (possibly after testing them for equality for  
 good
 measure). This is easy if you use a plug-in approach: first assume
> that
 the s.e. are known, then plug in their empirical value. The tricky
> bit
 is to calculate the DF in the style of Welch's test.
>>>
>>> I apologise but I really can not follow your  
>>> explanations.
>>> I am  R and Stastistics Beginner.
>>>
>>> What do you mean with mu1-mu2 and what are s.e.´s?
>>>
>> That was a reply to S. Ellison. If you don't understand it, don't  
>> worry;
>> you'll probably need to read a book chapter or more about weighted
>> analyses to get up to speed for that.
>>
>> mu1, mu2 : (theoretical) mean for group 1, 2
>> s.e.: standard error
>
> But as Birgit actually does not have any paired values, according  
> to the
> data she had sent, she can not do paired t.test at all. The only  
> way is to
> compare averages from each vector by non paired t.test or to get  
> some new
> values for which she have counterparts.
>
> Regards
> Petr
>   
That is what I found out some hours ago. I thought about this problem  
and in my opinion it makes no sense to test the both vectors for  
significant differences, because I can not use another method for  
this vectors than for the other 24 vectors to test. To get new values  
is also not possible. And so I decided  that I will not test this two  
vectors for significance because of too many missing values.

But I thank you all
for your efforts to help me.

Greetings

Birgit
>
>
>>> Once again thank you for your help.
>>>
>>> Birgit
>>>
>>>
>>>
>>>

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


>>>
>>> Birgit Lemcke
>>> Institut für Systematische Botanik
>>> Zollikerstrasse 107
>>> CH-8008 Zürich
>>> Switzerland
>>> Ph: +41 (0)44 634 8351
>>> [EMAIL PROTECTED]
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>> -- 
>>O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
>>   c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
>>  (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45)
> 35327918
>> ~~ - ([EMAIL PROTECTED])  FAX: (+45)
> 35327907
>>
>> __
>> R-help@r-project.org 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.
>

Birgit Lemcke
Institut für Systematische Botanik
Zollikerstrasse 107
CH-8008 Zürich
Switzerland
Ph: +41 (0)44 634 8351
[EMAIL PROTECTED]






[[alternative HTML version deleted]]

__
R-help@r-project.org 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] t.test() with missing values

2007-09-14 Thread Birgit Lemcke

Am 14.09.2007 um 14:27 schrieb Peter Dalgaard:

> Petr PIKAL wrote:
>> Hi
>>
>> [EMAIL PROTECTED] napsal dne 14.09.2007 13:50:58:
>>
>>
>>> Birgit Lemcke wrote:
>>>
 Am 14.09.2007 um 12:05 schrieb Peter Dalgaard:


> S Ellison wrote:
>
> Peter Dalgaard <[EMAIL PROTECTED]> 14/09/2007  
> 09:26:16 >>>
>
>
>>
>>
>> 
>>
>>
>>
> Yes, but
>
> I don't think lme() will do better than what you can do by  
> hand: Get
>
>> two
>>
> independent estimates of mu1-mu2 (one estimate from the pairs  
> and one
> from the singlets), compute a weighted average using the s.e.'s  
> and
>
>> test
>>
> that against zero (possibly after testing them for equality for  
> good
> measure). This is easy if you use a plug-in approach: first assume
>
>> that
>>
> the s.e. are known, then plug in their empirical value. The tricky
>
>> bit
>>
> is to calculate the DF in the style of Welch's test.
>
 I apologise but I really can not follow your  
 explanations.
 I am  R and Stastistics Beginner.

 What do you mean with mu1-mu2 and what are s.e.´s?


>>> That was a reply to S. Ellison. If you don't understand it, don't  
>>> worry;
>>> you'll probably need to read a book chapter or more about weighted
>>> analyses to get up to speed for that.
>>>
>>> mu1, mu2 : (theoretical) mean for group 1, 2
>>> s.e.: standard error
>>>
>>
>> But as Birgit actually does not have any paired values, according  
>> to the
>> data she had sent, she can not do paired t.test at all. The only  
>> way is to
>> compare averages from each vector by non paired t.test or to get  
>> some new
>> values for which she have counterparts.
>>
> True, for that particular set of data. I did make that point in my  
> first
> reply (tried to, anyways), but I didn't repeat it the second time.
>
> If you look back, you'll see that Birgit was also doing
>
> TTest75<-t.test(Fem75, Mal75, alternative= "two.sided", paired= TRUE)
>
> and presumably there are several similar sets of data. This "works"  
> in the sense that it produces a test, but one could get the  
> suspicion that it is only using a small subset of available data if  
> the dropout rate is approaching that of Fem66/Mal66. Hence the  
> discussion of the general case.

In my case the other vectors contain  about 10 or 15 missing values.  
So as I understand this will only a little reduce the accuracy of my  
tests. But for the future and for people like me that are not yet so  
familiar with R, it would be fine to have a function for example for  
a T-Test, that is able to use all the data inspite of missing values  
in pairs. If there is already a function that is doing that, I  
apologise, but I haven´t found one.

But now as we would say in Germany: I will be quiet when adults are  
talking.

Kind regards

Birgit


>
>> Regards
>> Petr
>>
>>
>>
>>
 Once again thank you for your help.

 Birgit





> --   O__   Peter Dalgaard Øster Farimagsgade 5, 
>
>> Entr.B
>>
>   c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
>  (*) \(*) -- University of Copenhagen   Denmark  Ph:   
> (+45)
> 35327918
> ~~ - ([EMAIL PROTECTED])  FAX:  
> (+45)
> 35327907
>
>
>
 Birgit Lemcke
 Institut für Systematische Botanik
 Zollikerstrasse 107
 CH-8008 Zürich
 Switzerland
 Ph: +41 (0)44 634 8351
 [EMAIL PROTECTED]







>>> -- 
>>>O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
>>>   c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
>>>  (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45)
>>>
>> 35327918
>>
>>> ~~ - ([EMAIL PROTECTED])  FAX: (+45)
>>>
>> 35327907
>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>>
>> http://www.R-project.org/posting-guide.html
>>
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>> __
>> R-help@r-project.org 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.
>>
>
>
> -- 
>O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
>   c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
>  (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45)  
> 35327918
> ~~ - ([EMAIL PROTECTED])  FAX: (+45)  
> 35327907
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/m

Re: [R] t.test() with missing values

2007-09-14 Thread Petr PIKAL
> Petr PIKAL wrote:
> > Hi
> >
> > [EMAIL PROTECTED] napsal dne 14.09.2007 13:50:58:
> >
> > 
> >> Birgit Lemcke wrote:
> >> 
> >>> Am 14.09.2007 um 12:05 schrieb Peter Dalgaard:
> >>>
> >>> 
>  S Ellison wrote:
>  
>  Peter Dalgaard <[EMAIL PROTECTED]> 14/09/2007 09:26:16 
>>>
> 
>  
> >
> >
> > 
> >
> >
> > 
>  Yes, but
> 
>  I don't think lme() will do better than what you can do by hand: 
Get 
>  
> > two
> > 
>  independent estimates of mu1-mu2 (one estimate from the pairs and 
one
>  from the singlets), compute a weighted average using the s.e.'s and 

>  
> > test
> > 
>  that against zero (possibly after testing them for equality for 
good
>  measure). This is easy if you use a plug-in approach: first assume 
>  
> > that
> > 
>  the s.e. are known, then plug in their empirical value. The tricky 
>  
> > bit
> > 
>  is to calculate the DF in the style of Welch's test.
>  
> >>> I apologise but I really can not follow your 
explanations.
> >>> I am  R and Stastistics Beginner.
> >>>
> >>> What do you mean with mu1-mu2 and what are s.e.´s?
> >>>
> >>> 
> >> That was a reply to S. Ellison. If you don't understand it, don't 
worry;
> >> you'll probably need to read a book chapter or more about weighted
> >> analyses to get up to speed for that. 
> >>
> >> mu1, mu2 : (theoretical) mean for group 1, 2
> >> s.e.: standard error
> >> 
> >
> > But as Birgit actually does not have any paired values, according to 
the 
> > data she had sent, she can not do paired t.test at all. The only way 
is to 
> > compare averages from each vector by non paired t.test or to get some 
new 
> > values for which she have counterparts. 
> > 
> True, for that particular set of data. I did make that point in my first
> reply (tried to, anyways), but I didn't repeat it the second time.
> 
> If you look back, you'll see that Birgit was also doing
> 
> TTest75<-t.test(Fem75, Mal75, alternative= "two.sided", paired= TRUE)
> 
> and presumably there are several similar sets of data. This "works" in 
the 
> sense that it produces a test, but one could get the suspicion that it 
is only
> using a small subset of available data if the dropout rate is 
approaching that
> of Fem66/Mal66. Hence the discussion of the general case.

I see, sorry I did not noticed before. But everything depends on which 
hypotheses she wants to test. She told us about 334 different plant 
species (male and female) and if she wants to test if male and female is 
different she does not have many other options. 

Petr

> 
> > Regards
> > Petr
> >
> >
> >
> > 
> >>> Once again thank you for your help.
> >>>
> >>> Birgit
> >>>
> >>>
> >>>
> >>>
> >>> 
>  --   O__   Peter Dalgaard Øster Farimagsgade 5, 
>  
> > Entr.B
> > 
>    c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
>   (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45)
>  35327918
>  ~~ - ([EMAIL PROTECTED])  FAX: (+45)
>  35327907
> 
> 
>  
> >>> Birgit Lemcke
> >>> Institut für Systematische Botanik
> >>> Zollikerstrasse 107
> >>> CH-8008 Zürich
> >>> Switzerland
> >>> Ph: +41 (0)44 634 8351
> >>> [EMAIL PROTECTED]
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> 
> >> -- 
> >>O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
> >>   c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
> >>  (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 
> >> 
> > 35327918
> > 
> >> ~~ - ([EMAIL PROTECTED])  FAX: (+45) 
> >> 
> > 35327907
> > 
> >> __
> >> R-help@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide 
> >> 
> > http://www.R-project.org/posting-guide.html
> > 
> >> and provide commented, minimal, self-contained, reproducible code.
> >> 
> >
> > __
> > R-help@r-project.org 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.
> > 
> 
> 
> -- 
>O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
>   c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
>  (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 
35327918
> ~~ - ([EMAIL PROTECTED])  FAX: (+45) 
35327907
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
ht

Re: [R] t.test() with missing values

2007-09-14 Thread Birgit Lemcke

Am 14.09.2007 um 15:54 schrieb Petr PIKAL:

>> Petr PIKAL wrote:
>>> Hi
>>>
>>> [EMAIL PROTECTED] napsal dne 14.09.2007 13:50:58:
>>>
>>>
 Birgit Lemcke wrote:

> Am 14.09.2007 um 12:05 schrieb Peter Dalgaard:
>
>
>> S Ellison wrote:
>>
>> Peter Dalgaard <[EMAIL PROTECTED]> 14/09/2007 09:26:16

>>
>>
>>>
>>>
>>> 
>>>
>>>
>>>
>> Yes, but
>>
>> I don't think lme() will do better than what you can do by hand:
> Get
>>
>>> two
>>>
>> independent estimates of mu1-mu2 (one estimate from the pairs and
> one
>> from the singlets), compute a weighted average using the  
>> s.e.'s and
>
>>
>>> test
>>>
>> that against zero (possibly after testing them for equality for
> good
>> measure). This is easy if you use a plug-in approach: first  
>> assume
>>
>>> that
>>>
>> the s.e. are known, then plug in their empirical value. The  
>> tricky
>>
>>> bit
>>>
>> is to calculate the DF in the style of Welch's test.
>>
> I apologise but I really can not follow your
> explanations.
> I am  R and Stastistics Beginner.
>
> What do you mean with mu1-mu2 and what are s.e.´s?
>
>
 That was a reply to S. Ellison. If you don't understand it, don't
> worry;
 you'll probably need to read a book chapter or more about weighted
 analyses to get up to speed for that.

 mu1, mu2 : (theoretical) mean for group 1, 2
 s.e.: standard error

>>>
>>> But as Birgit actually does not have any paired values, according to
> the
>>> data she had sent, she can not do paired t.test at all. The only way
> is to
>>> compare averages from each vector by non paired t.test or to get  
>>> some
> new
>>> values for which she have counterparts.
>>>
>> True, for that particular set of data. I did make that point in my  
>> first
>> reply (tried to, anyways), but I didn't repeat it the second time.
>>
>> If you look back, you'll see that Birgit was also doing
>>
>> TTest75<-t.test(Fem75, Mal75, alternative= "two.sided", paired= TRUE)
>>
>> and presumably there are several similar sets of data. This  
>> "works" in
> the
>> sense that it produces a test, but one could get the suspicion  
>> that it
> is only
>> using a small subset of available data if the dropout rate is
> approaching that
>> of Fem66/Mal66. Hence the discussion of the general case.
>
> I see, sorry I did not noticed before. But everything depends on which
> hypotheses she wants to test. She told us about 334 different plant

348

> species (male and female) and if she wants to test if male and  
> female is
> different

yes

> she does not have many other options.
>
> Petr
>
>>
>>> Regards
>>> Petr
>>>
>>>
>>>
>>>
> Once again thank you for your help.
>
> Birgit
>
>
>
>
>
>> --   O__   Peter Dalgaard Øster Farimagsgade 5, 
>>
>>> Entr.B
>>>
>>   c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
>>  (*) \(*) -- University of Copenhagen   Denmark  Ph:   
>> (+45)
>> 35327918
>> ~~ - ([EMAIL PROTECTED])  FAX:  
>> (+45)
>> 35327907
>>
>>
>>
> Birgit Lemcke
> Institut für Systematische Botanik
> Zollikerstrasse 107
> CH-8008 Zürich
> Switzerland
> Ph: +41 (0)44 634 8351
> [EMAIL PROTECTED]
>
>
>
>
>
>
>
 -- 
O__   Peter Dalgaard Øster Farimagsgade 5,  
 Entr.B
   c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
  (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45)

>>> 35327918
>>>
 ~~ - ([EMAIL PROTECTED])  FAX: (+45)

>>> 35327907
>>>
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide

>>> http://www.R-project.org/posting-guide.html
>>>
 and provide commented, minimal, self-contained, reproducible code.

>>>
>>> __
>>> R-help@r-project.org 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.
>>>
>>
>>
>> -- 
>>O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
>>   c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
>>  (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45)
> 35327918
>> ~~ - ([EMAIL PROTECTED])  FAX: (+45)
> 35327907
>>
>> __
>> R-help@r-project.org 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 comm

[R] add a row...

2007-09-14 Thread Alfredo Alessandrini
Hi,

If I've a dataframe like this:

a <- data.frame(a=c(14,21,14,4), b=c(21,45,23,11))

print(a)

   a  b
1 14 21
2 21 45
3 14 23
4  4 11

I can delete the first row with:

b = a[-(1),]

print (b)

   a  b
2 21 45
3 14 23
4  4 11

Now, can I add to dataframe b the row that I've deleded?

print (b)

   a  b
1 14 21
2 21 45
3 14 23
4  4 11



Best Wishes,

Alfredo

[[alternative HTML version deleted]]

__
R-help@r-project.org 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] Comparing regression models

2007-09-14 Thread darteta001

Dear list,

I am interested in comparing two linear regression models to see if 
including one extra variable improves the model significantly. I have 
read that one possibility is doing an F test on the goodness-of-fit 
values for both models, and another option that is comparing the 
residuals of both models using a paired test. I also know about the 
anova() function that compares results for two models but am not sure 
what it actually does compare. Can you give me any suggestions?

Does the same hold if the models were logistic instead of linear? I 
have read that the Akaike´s AIC is also a valid option. 

Thanks in advance for your comments

David

__
R-help@r-project.org 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] add a row...

2007-09-14 Thread Christoph Heibl
Use rbind:

d <- c(14,21)
b <- rbind(d, b)

CH



On 14.09.2007, at 16:15, Alfredo Alessandrini wrote:

> Hi,
>
> If I've a dataframe like this:
>
> a <- data.frame(a=c(14,21,14,4), b=c(21,45,23,11))
>
> print(a)
>
>a  b
> 1 14 21
> 2 21 45
> 3 14 23
> 4  4 11
>
> I can delete the first row with:
>
> b = a[-(1),]
>
> print (b)
>
>a  b
> 2 21 45
> 3 14 23
> 4  4 11
>
> Now, can I add to dataframe b the row that I've deleded?
>
> print (b)
>
>a  b
> 1 14 21
> 2 21 45
> 3 14 23
> 4  4 11
>
>
>
> Best Wishes,
>
> Alfredo
>
>   [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting- 
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org 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] Comparing regression models

2007-09-14 Thread Wayne.W.Jones


I would suggest doing an F-test.A descrition is given here: 
http://www.graphpad.com/curvefit/2_models__1_dataset.htm. 
The method is valid becasue one of your models is a subset of another. 

Correct use of the anova function does indeed perform this test. 
For example: 

data(airquality)
lm1<-lm(Ozone~.,airquality) # full model
lm2<-lm(Ozone~Solar.R+Wind +Month+Day,airquality) # reduced model
anova(lm2,lm1)




-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
[EMAIL PROTECTED]
Sent: 14 September 2007 15:49
To: r-help@r-project.org
Subject: [R] Comparing regression models



Dear list,

I am interested in comparing two linear regression models to see if 
including one extra variable improves the model significantly. I have 
read that one possibility is doing an F test on the goodness-of-fit 
values for both models, and another option that is comparing the 
residuals of both models using a paired test. I also know about the 
anova() function that compares results for two models but am not sure 
what it actually does compare. Can you give me any suggestions?

Does the same hold if the models were logistic instead of linear? I 
have read that the Akaike´s AIC is also a valid option. 

Thanks in advance for your comments

David

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org 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] Print to file

2007-09-14 Thread Alessandra Marmo
Hello list I'M new
I need help about print to file
How i can Print more table in a file (in append)
using xtable and print functions?
 
 Tanks
 
 Alessandra

__
R-help@r-project.org 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] replace NA value with 0

2007-09-14 Thread Ted Harding
On 14-Sep-07 09:22:36, S Ellison wrote:
> Being a chemist, I have to confess that I can't always tell
> that what I'm about to attempt is barking, trivial, uninteresting
> or better done a completely different way; myself, I'd rather be
> warned too often than left to dig my own pit and fall into it ... 
> 
> On NA's vs zero, I usually have the reverse problem in my corner
> of the world; folk will often call nondetects 'missing', which is
> also often a silly thing to do; nondetect means 'I looked and it
> was too low to see' but NA means 'I didn't look'. All that leaves
> me a bit nervous about replacing NA with 0 and vice versa ... hence
> the knee-jerk. Apologies if I'm teaching egg-sucking to an expert. 
> 
> S

On the contrary! It adds to our "collective wisdom".

We all have to suck eggs, and usually can successfully perform the act.
But it is useful to learn about people's experiences of when it is wise
to spit out the result.

Thanks, and best wishes,
Ted.


E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
Fax-to-email: +44 (0)870 094 0861
Date: 14-Sep-07   Time: 10:59:42
-- XFMail --

__
R-help@r-project.org 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] ISIN numbers into Bloomberg tickers

2007-09-14 Thread Shubha Vishwanath Karanth
Hi R,

 

Can I convert ISIN numbers into Bloomberg tickers in the RBloomberg
package?

 

BR, Shubha


[[alternative HTML version deleted]]

__
R-help@r-project.org 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] replace NA value with 0

2007-09-14 Thread Greg Snow

 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Gabor Csardi
> Sent: Friday, September 14, 2007 2:56 AM
> To: S Ellison
> Cc: [EMAIL PROTECTED]
> Subject: Re: [R] replace NA value with 0

I nominate the following paragraph for the fortunes package

> I like this list because if you ask a question, they don't 
> only solve it immediately (in five different ways), but they 
> persuade you that what you're trying to do is actually 
> incorrect/stupid/uninteresting or your problem just makes no 
> sense at all.
> :)
> 
> Gabor

__
R-help@r-project.org 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] Yahoo data feed in R / Corporate Actions

2007-09-14 Thread kwaj

Is there anyway to import data from Yahoo into R and to have it adjusted for
share splits / dividend payouts (corporate actions)? I can currently import
data into R but the price series is not adjusted
-- 
View this message in context: 
http://www.nabble.com/Yahoo-data-feed-in-R---Corporate-Actions-tf4441979.html#a12673581
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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] x-axis order

2007-09-14 Thread Gustaf Rydevik
Hi all,

I have a time series which contain data collected weekly from week 26
to week 25 the following year. How do I plot this data, so that the
x-axis is displaying the week numbers, ordered as in the data?

Thanks in advance,

Gustaf
---
x<-c(26:52,1:25)
y<-rnorm(52)+1:52
plot(x,y)   ## How do I get the x axis to be ordered by the current
ordering of x?



-- 
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
skype:gustaf_rydevik

__
R-help@r-project.org 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] Row-Echelon Form

2007-09-14 Thread Peter Danenberg
> I append the function below, along with some other simple
> linear-algebra functions.

I never thanked you, by the way, John; have you considered incurring
the overhead of producing a formal R package?

Otherwise, it's worth its SLOC in gold.

__
R-help@r-project.org 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] replace NA value with 0

2007-09-14 Thread John Kane
Seconded.
--- Greg Snow <[EMAIL PROTECTED]> wrote:

> 
>  
> 
> > -Original Message-
> > From: [EMAIL PROTECTED] 
> > [mailto:[EMAIL PROTECTED] On Behalf Of
> Gabor Csardi
> > Sent: Friday, September 14, 2007 2:56 AM
> > To: S Ellison
> > Cc: [EMAIL PROTECTED]
> > Subject: Re: [R] replace NA value with 0
> 
> I nominate the following paragraph for the fortunes
> package
> 
> > I like this list because if you ask a question,
> they don't 
> > only solve it immediately (in five different
> ways), but they 
> > persuade you that what you're trying to do is
> actually 
> > incorrect/stupid/uninteresting or your problem
> just makes no 
> > sense at all.
> > :)
> > 
> > Gabor
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
>

__
R-help@r-project.org 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] R2 in mixed model

2007-09-14 Thread Angelo Colombo
Hello.
I have some basic question for you!.
Has calculating R2 sense in mixed model? I think no! But i don't why!

Thank in advance for your help
Angelo

__
R-help@r-project.org 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] 行=政=工=作=统=筹=管=理S

2007-09-14 Thread Nuafl
0 

===
如-果-您-不-希-望-再-收-到-我-们-的-邮-件,请-直-接-回-复-推-定-信-箱 { tuidingyi@sohu.com }
===
  
   ��行=政=工=作=统=筹=管=理=高=级=研=修=班  
  

  2007年9月21-22日 上 海 园 林 格 兰 云 天 大 酒 店
  2007年9月29-30日 深.圳.新.大.洲.酒.店
  2007年10月24-25日  苏 州 新 世 纪 大 酒 店
  2007年10月27-28日北 京 新 兴 宾 馆
 
===
 
 举w办w单w位: 希*格*玛*管*理*培*训*网   www.~gmp~.com

 适w合w对w象: 行.政.总.监,行.政.经.理,办.公.室.主.任,经.理.助.理、总.经.理.秘.书;

 学w习w费w用:  2500元/人 (包`含`教`材`费、听`课`费、中`餐、课`间`茶`点) ;
 
 深w圳w电w话:  (0755)82121728   82121381   

 上w海w电w话: (021)51028491
 
 北w京w电w$话: (010)51669582 

 报w名w邮w箱: [EMAIL PROTECTED]
===
 
【课-程-介-绍】
 在行政工作中没有受到过系统训练,无法从战略性全方位角度认知行政管理工作;在所从事的行政管理工作中感觉缺乏理论支持;
 感觉工作中总是被动行事,不能主动掌握工作节奏;想给公司节省费用,但却不知从何处下手,如何节省;行使对外界社会的管
 理职能时没有感觉到有很多事物的“黑洞”要提防;对行政工作的各项标准不清楚;在公司的职位地位不理想,缺乏战略性思考
 工作;要干的事情太多,社会资源也有很多,但不知如何利用社会资源;想系统学习,提高行政管理技能,但没有合适的传授经
 验课程,空有理论知识;对于如何管理公司的系统性整体行政事务心中没底。
 ● 课程目标
 系统地学习行政管理的统筹管理知识;识别各种行政管理中的容易出现的管理黑洞;掌握行政管理中的各种技巧,提升行政管理技能;
 ● 课程特色
 实操性强,讲师以自己国际500强的大型公司工作经验结合管理理论讲授,及现场与学员的互动引导,使学员能够感悟到自己工作中应
 该预防的漏洞,并对行政管理工作更加得心应手。
===
 
【学-习-内-容】:
 一、现代企业中行政管理的定位
 1、现代企业运行模型 
 2、行政管理工作的绩效价值
 3、行政管理人员的素质特点 
 4、行政管理制度的框架结构
 演练:工作漏洞究竟出在哪里?

 二、行政主管的自我管理
 1、职业规范要点与评估标准 
 2、人际关系处理的准则与该注意的”陷井”
 3、职业优势保持的要点
 演练:如何说服你的上司

 三、行政部门的内部管理
 1、前台文员管理 
 2、秘书(领导秘书)管理
 3、行政工作人员管理 
 4、司机、保安、清洁工管理
 5、行政事务性工作的内部分工 
 6、强化行政工作执行机制
 7、呈现突出行政工作业绩
 演练:整合资源-分工协作-达成目标

 四、经验积累与知识创新管理
 1、公文处理与管理 
 2、会议成果的提炼与分享
 3、工作创新管理与应用 

 五、行政统筹管理关键事物控制
 1. 集团电话管理 
 2. 集团的复印机管理
 3. 集团的车辆管理不同方式 
 4. 食堂管理的外包流程
 5. 员工的应急安全保障 
 6. 办公室布局管理
 7. 办公室搬家管理 
 8. 与物业的关系要点 
 9. 对施工方的管理要点 
 10. 公司驻在地的社区关系
 11. 公共关系管理 
 12. 危机处理 

 六、行政统筹必备的沟通技巧
 1、施展人际影响解决管理冲突 
 2、感召他人的4大热键
 3、表扬、批评5步法 
 4、令人心服口服的方法
 演练:为何费力不讨好!?

 七、会议组织与活动管理
 1、成功会议的准备工作:会前、会中、会后 
 2、如何主持会议与公司活动
 3、高效率会议的实用工具 

 八、接待工作与职业礼仪
 1、接待工作中的十大禁忌论 
 2、行政人员的着装、仪表、语言
 3、使用电话、手机、E-mail的礼仪规范 
 4、宴请、参观、旅游的礼仪规范

 九、行政管理人员的职业规划
 1、行政管理职业的职场阶梯 
 2、职业生涯规划中的五个一工程
 3、从优秀到卓越,从技术到艺术
 毕业演练:八分钟设计职场八年!
===
 
【授 课 讲 师】
刘大海 老师 欧亚人力资源发展联盟中国区首席咨询师,亚洲咨询培训与发展协会秘书长,中国企管网资深顾问。2001年开始专职
从事于培训与咨询工作,以访问学者身份多次出访过法国、德国、瑞士等国知名大学和大型企业,在企业中高层经理人领导素质提升、
企业行政体系构建及通用管理领域等方面拥有领先的视角和丰厚的实践经验。其授课特色是从国内企业所面临的实际问题出发,通过
各种典型案例的讲解和分析,以及模拟现实环境的操作演练,系统提升企业解决问题的能力和实施操作水平。指导过的企业有 :安利
(中国)、百度、海尔集团、美的集团、联想集团、深发展、东风日产、上海比亚迪、深圳移动、广州移动、中山移动、中科智担保
集团、航天科工集团、广东核电集团、华侨城物业、长城物业、北京信威通讯、厦门名姿集团、深圳人保财险、深圳天虹商场、深圳
市经纬科技有限公司、中国人才热线、西部人力资源市场、泰昂电子、超华电子、梁子时装等百余家中外企业。
===
   
※※★★培 �� 回 �� 表 (此表�}�u有效)★★★※※

  TO:希*格*��*培*��*�W  深+圳+传+真: (0755)82121869  

上+海+传+真:(021)51028491转分机2

北+京+传+真:(010)51669582转分机2


  好的!我确认参加希.格.玛.培.训.网.举办的“行~工~作~统~筹~管~理~高~级~研~修~班”课程,请填妥盖章后传真至
主办单位,您将收到我们的确认函回执及会议地点路线图。

 单~位~名~称:

 培~训~联~系~人:___联~系~电~话:___联~系~传~真:___

 移~动~电~话:___电~子~邮~箱:

 参~加~人~数:___人 ��费~用~总~计:元

 参 ~会~人:___职 ~务:___手 ~机:

 参~ 会~ 人:___职 ~务:___手~ 机::

 参~ 会~ 人:___职 ~务:___手 ~机::

 付~款~方~式:(请选择打钩 ) □1、现 金  □2、电 汇  □3、转 帐 

 培~训~地~点:(请选择打钩 ) □1、上 海□1、深 圳   □2、苏 州□3、北 京


9
041

__
R-help@r-project.org 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] Yahoo data feed in R / Corporate Actions

2007-09-14 Thread davidr
This came up last week on r-sig-finance:
https://stat.ethz.ch/pipermail/r-sig-finance/2007q3/001686.html


David L. Reiner
Rho Trading Securities, LLC
550 W. Jackson Blvd #1000
Chicago, IL 60661-5704
 
312-244-4610 direct
312-244-4500 main
312-244-4501 fax
 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of kwaj
Sent: Friday, September 14, 2007 6:41 AM
To: [EMAIL PROTECTED]
Subject: [R] Yahoo data feed in R / Corporate Actions


Is there anyway to import data from Yahoo into R and to have it adjusted
for
share splits / dividend payouts (corporate actions)? I can currently
import
data into R but the price series is not adjusted
-- 
View this message in context:
http://www.nabble.com/Yahoo-data-feed-in-R---Corporate-Actions-tf4441979
.html#a12673581
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org 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] Print to file

2007-09-14 Thread mel
Alessandra Marmo a écrit :
> Hello list I'M new
> I need help about print to file
> How i can Print more table in a file (in append)
> using xtable and print functions?

?write.table

__
R-help@r-project.org 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] Collapsing data frame; aggregate() or better function?

2007-09-14 Thread Tobin, Jared
Thanks for the quick reply Jim.

I haven't had any success when I whittle down 'by' list even further
though.  I believe I'm using the right command, but now it's just a
matter of clear memory issues.

> test <- aggregate(lf1.turbot[,17:217], list(lf1.turbot$vessel,
lf1.turbot$trip, lf1.turbot$set), sum)
Error: cannot allocate vector of size 237.4 Mb In addition: Warning
messages:
1: Reached total allocation of 734Mb: see help(memory.size)
2: Reached total allocation of 734Mb: see help(memory.size)
3: Reached total allocation of 734Mb: see help(memory.size)
4: Reached total allocation of 734Mb: see help(memory.size) 

A fellow kindly emailed me directly and suggested trying Wickham's
'reshape' package, but again when using the melt() function in that
package I run into memory problems.  A colleague suggested I 'create
factors using as.factor() and feed this directly into the appropriate
apply function', but I've had no success with this when using tapply().

Any suggestions as to a less memory-intensive procedure would be greatly
appreciated.

Thanks,

--

jared tobin, student research assistant
fisheries and oceans canada
[EMAIL PROTECTED]

-Original Message-
From: jim holtman [mailto:[EMAIL PROTECTED] 
Sent: Thursday, September 13, 2007 6:49 PM
To: Tobin, Jared
Cc: [EMAIL PROTECTED]
Subject: Re: [R] Collapsing data frame; aggregate() or better function?

The second argument for aggregate is supposed to be a list, so try
(notice the missing comma before "1:8"):

test <- aggregate(lf1.turbot[,c(11, 12, 17:217)], lf1.turbot[1:8],sum)


On 9/13/07, Tobin, Jared <[EMAIL PROTECTED]> wrote:
> Hello r-help,
>
> I am trying to collapse or aggregate 'some' of a data frame.  A very 
> simplified version of my data frame looks like:
>
> > tester
>  trip set num sex lfs1 lfs2
> 1  313  15   5   M23
> 2  313  15   3   F12
> 3  313  17   1   M01
> 4  313  17   2   F11
> 5  313  17   1   U10
>
> And I want to omit sex from the picture and just get an addition of 
> num, lfs1, and lfs2 for each unique trip/set combination.  Using 
> aggregate() works fine here,
>
> > test <- aggregate(tester[,c(3,5:6)], tester[,1:2], sum) test
>  trip set num lfs1 lfs2
> 1  313  15   835
> 2  313  17   422
>
> But I'm having trouble getting the same function to work on my actual 
> data frame which is considerably larger.
>
> > dim(lf1.turbot)
> [1] 16468   217
> > test <- aggregate(lf1.turbot[,c(11, 12, 17:217)], lf1.turbot[,1:8],
> sum)
> Error in vector("list", prod(extent)) : vector size specified is too 
> large In addition: Warning messages:
> 1: NAs produced by integer overflow in: ngroup * (as.integer(index) -
> one)
> 2: NAs produced by integer overflow in: group + ngroup *
> (as.integer(index) - one)
> 3: NAs produced by integer overflow in: ngroup * nlevels(index)
>
> I'm guessing that either aggregate() can't handle a data frame of this

> size OR that there is an issue with 'omitting' more than one variable 
> (in the same way I've omitted sex in the above example).  Can anyone 
> clarify and/or recommend any relatively simple alternative procedure 
> to accomplish this?
>
> I plan on trying variants of by() and tapply() tomorrow morning, but 
> I'm about to head home for the day.
>
> Thanks,
>
> --
>
> jared tobin, student research assistant fisheries and oceans canada 
> [EMAIL PROTECTED]
>
> __
> R-help@r-project.org 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.
>


--
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

__
R-help@r-project.org 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] ISIN numbers into Bloomberg tickers

2007-09-14 Thread davidr
You can try

> blpGetData(conn, "US912828HA15 Govt", 
c("ticker", "cpn", "maturity", "market_sector_des"), retval="raw")

and paste together the parts.

HTH,

David L. Reiner
Rho Trading Securities, LLC


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Shubha Vishwanath Karanth
Sent: Friday, September 14, 2007 8:42 AM
To: [EMAIL PROTECTED]
Subject: [R] ISIN numbers into Bloomberg tickers

Hi R,

 

Can I convert ISIN numbers into Bloomberg tickers in the RBloomberg
package?

 

BR, Shubha


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org 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] Bootstrapping / stats question (not R)

2007-09-14 Thread Pedro Mardones
Dear all;

I'm looking for some advice regarding the following idea:

Let's say that I have a sample of y-values randomly taken from a
population and I want to compute the mean of y and its confidence
intervals but without assuming any particular distribution (I'm
assuming that the mean of this sample is a good indicator of the mean
of the population of y's). As far as I know we can use a nonparametric
bootstrap analysis approach to do something like this.

Now, let's say that instead of having to measure "y", I can measure
"x" because is easier. Moreover I have a model that relates y and x,
so I can predict the "y" giving the set of observed x. At the end of
the day I will have yhat=(y1-hat,...,yn-hat)' which is the vector of
predicted y-values.

Here the is question: Does it make any sense to try to calculate the
mean of the predicted "y's" and its CI by using a bootstrap analysis?
Am I violating any assumptions for that kind of analysis? (maybe the
independence of the samples?)

Sorry if this is a dumb question but I would like to have a different opinion

Thanks in advance

PM

__
R-help@r-project.org 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] Intercept in lm and in library(car): Anova

2007-09-14 Thread Stefan Th. Gries
Hi

I have two questions regarding the meaning of intercept outputs of lm.

Question 1: In data set 1 (a fully-balanced design), the line with
(Intercept) contains the overall mean, and the estimates contain the
differences from the overall mean (matching those from model.tables).
But in data set 2, the line with the intercept does not correspond to
the overall mean and the estimates don't correspond to the differences
outputted by model.tables. What does the output contain here?

#
rm(list=ls(all=TRUE))
options(contrasts=c("contr.sum", "contr.poly"))

# data set 1
Y1<-c(43, 23, 88, 45, 2, 68, 39, 41, 55, 64, 91, 9, 90, 37, 88, 41)
M1<-factor(c("k", "g", "k", "g", "k", "k", "g", "g", "g", "g", "k",
"k", "g", "g", "k", "k"))
N1<-factor(c("k", "g", "g", "k", "k", "g", "k", "g", "k", "g", "g",
"k", "g", "k", "g", "k"))

# linear model 1
model1<-lm(Y1~M1*N1); summary(model1)
model.tables(aov(Y1~M1*N1), "means")
model.tables(aov(Y1~M1*N1))

# data set 2
Y2<-c(34, 16, 46, 5, 2, 78, 31, 39, 25, 64, 45, 92, 65, 91, 60, 12,
33, 40, 72, 61, 49, 59)
M2<-factor(c(rep("a", 10), rep("b", 12)))
N2<-factor(c(rep("d", 4), rep("e", 6), rep("d", 8), rep("e", 4)))

# linear model 2
model2<-lm(Y2~M2*N2); summary(model2)
model.tables(aov(Y2~M2*N2), "means")
model.tables(aov(Y2~M2*N2))
#


Question 2: what does the line with (Intercept) mean that the
following lines produce?

#
library(car)
Anova(model, type=c("III"))
#

Any help would be much appreciated. Thx,
STG

__
R-help@r-project.org 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] x-axis order

2007-09-14 Thread jim holtman
This should do what you want.

x<-c(26:52,1:25)
y<-rnorm(52)+1:52

plot(seq_along(x), y, xaxt='n')
axis(1, at=seq_along(x), labels=x)



On 9/14/07, Gustaf Rydevik <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I have a time series which contain data collected weekly from week 26
> to week 25 the following year. How do I plot this data, so that the
> x-axis is displaying the week numbers, ordered as in the data?
>
> Thanks in advance,
>
> Gustaf
> ---
> x<-c(26:52,1:25)
> y<-rnorm(52)+1:52
> plot(x,y)   ## How do I get the x axis to be ordered by the current
> ordering of x?
>
>
>
> --
> Gustaf Rydevik, M.Sci.
> tel: +46(0)703 051 451
> address:Essingetorget 40,112 66 Stockholm, SE
> skype:gustaf_rydevik
>
> __
> R-help@r-project.org 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.
>


-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

__
R-help@r-project.org 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] Intercept in lm and in library(car): Anova

2007-09-14 Thread John Fox
Dear Stefan,

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Stefan Th. Gries
> Sent: Friday, September 14, 2007 2:09 PM
> To: [EMAIL PROTECTED]
> Subject: [R] Intercept in lm and in library(car): Anova
> 
> Hi
> 
> I have two questions regarding the meaning of intercept outputs of lm.
> 
> Question 1: In data set 1 (a fully-balanced design), the line with
> (Intercept) contains the overall mean, and the estimates 
> contain the differences from the overall mean (matching those 
> from model.tables).
> But in data set 2, the line with the intercept does not 
> correspond to the overall mean and the estimates don't 
> correspond to the differences outputted by model.tables. What 
> does the output contain here?

In both datasets, the intercept is the "grand mean", which in a two-way
ANOVA (parametrized with sum-to-zero contrasts) is the mean of the cell
means. In the first case, because the data are balanced, the mean of the
cell means corresponds to the mean of Y1. In the second case, where there
are unequal cell counts, the mean of the cell means is different from the
mean of Y2 (but equal to the estimated intercept):

> mean(tapply(Y2, list(M2, N2), mean))
[1] 45.02083

The line in the output from Anova() in the package for the intercept tests
the null hypothesis that the intercept parameter is different from 0, which
rarely would be of interest.

I hope this helps,
 John

> 
> #
> rm(list=ls(all=TRUE))
> options(contrasts=c("contr.sum", "contr.poly"))
> 
> # data set 1
> Y1<-c(43, 23, 88, 45, 2, 68, 39, 41, 55, 64, 91, 9, 90, 37, 
> 88, 41) M1<-factor(c("k", "g", "k", "g", "k", "k", "g", "g", 
> "g", "g", "k", "k", "g", "g", "k", "k")) N1<-factor(c("k", 
> "g", "g", "k", "k", "g", "k", "g", "k", "g", "g", "k", "g", 
> "k", "g", "k"))
> 
> # linear model 1
> model1<-lm(Y1~M1*N1); summary(model1)
> model.tables(aov(Y1~M1*N1), "means")
> model.tables(aov(Y1~M1*N1))
> 
> # data set 2
> Y2<-c(34, 16, 46, 5, 2, 78, 31, 39, 25, 64, 45, 92, 65, 91, 
> 60, 12, 33, 40, 72, 61, 49, 59) M2<-factor(c(rep("a", 10), 
> rep("b", 12))) N2<-factor(c(rep("d", 4), rep("e", 6), 
> rep("d", 8), rep("e", 4)))
> 
> # linear model 2
> model2<-lm(Y2~M2*N2); summary(model2)
> model.tables(aov(Y2~M2*N2), "means")
> model.tables(aov(Y2~M2*N2))
> #
> 
> 
> Question 2: what does the line with (Intercept) mean that the 
> following lines produce?
> 
> #
> library(car)
> Anova(model, type=c("III"))
> #
> 
> Any help would be much appreciated. Thx, STG
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org 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] Cross Compiling

2007-09-14 Thread Scott Hyde
Hello All,

I have a Linux computer and do all of my work from it.  However, I
teach also, which means that many of my students use windows.   Hence,
I need to create packages that work under windows as well as Linux.  I
have tried to follow the directions at

http://cran.r-project.org/doc/contrib/cross-build.pdf

which is the document "Building Microsoft Windows Versions of R and R
packages under Intel Linux".  This has been very helpful.  However,
the file R_Tcl.zip is no longer available, so I cannot compile R for
Windows using the "make R" command as described in the document.  Is
it necessary to have the Tcl sources in there?  If it is, how should
the directions be modified to enable the complete compilation of R?

None of my code contains C, Fortran, or any other language.  It is
just plain R code.  I would think that this would be easier to convert
over.  Is it?  I tried the following and it seems to work, but I'd
like to know if it is safe.

1.  Build package with "pre-compiled binary package" option "R CMD
build --binary pkgname"
2. convert the resulting tar.gz file to a zip archive.
3. Install it on a windows machine.

This process successfully works when I install it on a windows
machine, but I have no idea how safe it is.

-- 
*
Scott K. Hyde
Assistant Professor of Statistics and Mathematics
School of Computing
Brigham Young University -- Hawaii

__
R-help@r-project.org 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] Row-Echelon Form

2007-09-14 Thread John Fox
Dear Peter,

I don't have sufficient confidence in the numerical methods that I employed
in these functions to contribute them to CRAN as a package. I'm glad that
you found them useful, however.

Regards,
 John


John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox 
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Peter Danenberg
> Sent: Thursday, September 13, 2007 5:40 PM
> To: r-help@r-project.org
> Subject: Re: [R] Row-Echelon Form
> 
> > I append the function below, along with some other simple 
> > linear-algebra functions.
> 
> I never thanked you, by the way, John; have you considered 
> incurring the overhead of producing a formal R package?
> 
> Otherwise, it's worth its SLOC in gold.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org 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] Collapsing data frame; aggregate() or better function?

2007-09-14 Thread jim holtman
Here is a way that I have used when the data get big.  The 'trick' is
to create the key (in your case concatenating columns 1:8) and then
creating a list of indices (row numbers) of the dataframe that
correspond to the grouping (using split).  The you have the lapply
operate on the list of indices and index into the data to perform the
operations.

I created some test data of your size and here was the result:

> row <- 16468
> col <- 217
> x <- matrix(sample(1:4, row * col, TRUE), row, col)
> x.df <- as.data.frame(x)
> # create the indices by concatenating the fields
> y <- do.call('paste', x.df[1:8])
> z <- split(seq(nrow(x.df)), y)  # create a list of the indices
> system.time({
+ ans <- lapply(z, function(.rows){
+ colSums(x.df[.rows, c(11,12,17:217)])
+ })
+ })
   user  system elapsed
 147.571.15  197.42
>
> # combine back into a dataframe
> ans <- do.call('rbind', ans)
> ans[1:10, 1:7]
V11 V12 V17 V18 V19 V20 V21
1 1 1 1 1 1 2 1   1   4   2   2   2   3   3
1 1 1 1 1 1 2 3   4   4   4   2   1   2   2
1 1 1 1 1 1 3 1   1   3   2   2   1   3   2
1 1 1 1 1 1 4 2   1   1   2   4   4   4   2
1 1 1 1 1 1 4 3   1   4   4   3   3   2   4
1 1 1 1 1 2 4 1   2   3   2   1   3   4   1
1 1 1 1 1 2 4 2   2   2   4   3   4   4   3
1 1 1 1 1 2 4 4   2   4   4   3   2   2   3
1 1 1 1 1 3 4 1   3   3   4   4   1   2   1
1 1 1 1 1 3 4 3   1   3   4   3   1   3   2
>

Printed out the first couple of rows.  The row labels are the
concatented values.

On 9/14/07, Tobin, Jared <[EMAIL PROTECTED]> wrote:
> Thanks for the quick reply Jim.
>
> I haven't had any success when I whittle down 'by' list even further
> though.  I believe I'm using the right command, but now it's just a
> matter of clear memory issues.
>
> > test <- aggregate(lf1.turbot[,17:217], list(lf1.turbot$vessel,
> lf1.turbot$trip, lf1.turbot$set), sum)
> Error: cannot allocate vector of size 237.4 Mb In addition: Warning
> messages:
> 1: Reached total allocation of 734Mb: see help(memory.size)
> 2: Reached total allocation of 734Mb: see help(memory.size)
> 3: Reached total allocation of 734Mb: see help(memory.size)
> 4: Reached total allocation of 734Mb: see help(memory.size)
>
> A fellow kindly emailed me directly and suggested trying Wickham's
> 'reshape' package, but again when using the melt() function in that
> package I run into memory problems.  A colleague suggested I 'create
> factors using as.factor() and feed this directly into the appropriate
> apply function', but I've had no success with this when using tapply().
>
> Any suggestions as to a less memory-intensive procedure would be greatly
> appreciated.
>
> Thanks,
>
> --
>
> jared tobin, student research assistant
> fisheries and oceans canada
> [EMAIL PROTECTED]
>
> -Original Message-
> From: jim holtman [mailto:[EMAIL PROTECTED]
> Sent: Thursday, September 13, 2007 6:49 PM
> To: Tobin, Jared
> Cc: [EMAIL PROTECTED]
> Subject: Re: [R] Collapsing data frame; aggregate() or better function?
>
> The second argument for aggregate is supposed to be a list, so try
> (notice the missing comma before "1:8"):
>
> test <- aggregate(lf1.turbot[,c(11, 12, 17:217)], lf1.turbot[1:8],sum)
>
>
> On 9/13/07, Tobin, Jared <[EMAIL PROTECTED]> wrote:
> > Hello r-help,
> >
> > I am trying to collapse or aggregate 'some' of a data frame.  A very
> > simplified version of my data frame looks like:
> >
> > > tester
> >  trip set num sex lfs1 lfs2
> > 1  313  15   5   M23
> > 2  313  15   3   F12
> > 3  313  17   1   M01
> > 4  313  17   2   F11
> > 5  313  17   1   U10
> >
> > And I want to omit sex from the picture and just get an addition of
> > num, lfs1, and lfs2 for each unique trip/set combination.  Using
> > aggregate() works fine here,
> >
> > > test <- aggregate(tester[,c(3,5:6)], tester[,1:2], sum) test
> >  trip set num lfs1 lfs2
> > 1  313  15   835
> > 2  313  17   422
> >
> > But I'm having trouble getting the same function to work on my actual
> > data frame which is considerably larger.
> >
> > > dim(lf1.turbot)
> > [1] 16468   217
> > > test <- aggregate(lf1.turbot[,c(11, 12, 17:217)], lf1.turbot[,1:8],
> > sum)
> > Error in vector("list", prod(extent)) : vector size specified is too
> > large In addition: Warning messages:
> > 1: NAs produced by integer overflow in: ngroup * (as.integer(index) -
> > one)
> > 2: NAs produced by integer overflow in: group + ngroup *
> > (as.integer(index) - one)
> > 3: NAs produced by integer overflow in: ngroup * nlevels(index)
> >
> > I'm guessing that either aggregate() can't handle a data frame of this
>
> > size OR that there is an issue with 'omitting' more than one variable
> > (in the same way I've omitted sex in the above example).  Can anyone
> > clarify and/or recommend any relatively simple alternative procedure
> > to accomplish this?
> >
> > I plan on trying variants of by() and tapply() tomorrow morning, but
> > I'm about to head home for the day.
> >
> > Thanks,
> >

Re: [R] Cross Compiling

2007-09-14 Thread Douglas Bates
An alternative to cross-compiling when you have a source package is to
use the Win-builder facility at win-builder.R-project.org

Thanks to Uwe for providing this facility.  I find it much, much
easier than trying to cross-compile or to set up a Windows computer
for compiling R packages.

On 9/14/07, Scott Hyde <[EMAIL PROTECTED]> wrote:
> Hello All,
>
> I have a Linux computer and do all of my work from it.  However, I
> teach also, which means that many of my students use windows.   Hence,
> I need to create packages that work under windows as well as Linux.  I
> have tried to follow the directions at
>
> http://cran.r-project.org/doc/contrib/cross-build.pdf
>
> which is the document "Building Microsoft Windows Versions of R and R
> packages under Intel Linux".  This has been very helpful.  However,
> the file R_Tcl.zip is no longer available, so I cannot compile R for
> Windows using the "make R" command as described in the document.  Is
> it necessary to have the Tcl sources in there?  If it is, how should
> the directions be modified to enable the complete compilation of R?
>
> None of my code contains C, Fortran, or any other language.  It is
> just plain R code.  I would think that this would be easier to convert
> over.  Is it?  I tried the following and it seems to work, but I'd
> like to know if it is safe.
>
> 1.  Build package with "pre-compiled binary package" option "R CMD
> build --binary pkgname"
> 2. convert the resulting tar.gz file to a zip archive.
> 3. Install it on a windows machine.
>
> This process successfully works when I install it on a windows
> machine, but I have no idea how safe it is.
>
> --
> *
> Scott K. Hyde
> Assistant Professor of Statistics and Mathematics
> School of Computing
> Brigham Young University -- Hawaii
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

__
R-help@r-project.org 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] add boxplot to histogram

2007-09-14 Thread Haiyong Xu
Hi there,

I am wondering if it is possible to add a small boxplot in a  
histogram, just like the legend.

Thanks.
Haiyong

__
R-help@r-project.org 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] unbalanced effects in aov

2007-09-14 Thread Brooke LaFlamme
Hi, I have been having some trouble using aov to do an anova, probably because 
I'm not understanding how to use this function correctly. For some reason it 
always tells me that "Estimated effects may be unbalanced", though I'm not sure 
what this means. Is the formula I am using written incorrectly? Below is the 
code I am using along with the data: 

> my.data
 response species sex line replicate plate
1   -7.092854e-03   1   11 1 1
2   -8.663481e-04   1   21 1 1
3   -5.797276e-03   1   12 1 1
4   -2.598078e-03   1   22 1 1
57.832551e-04   2   11 1 1
61.61e-03   2   21 1 1
7   -8.972490e-04   2   12 1 1
8   -2.834589e-03   2   22 1 1
95.655464e-04   3   11 1 1
10   7.371403e-03   3   21 1 1
11   3.160040e-03   3   12 1 1
12  -4.110653e-03   1   12 2 2
13  -2.262314e-03   1   22 2 2
14  -3.259483e-03   1   13 1 2
15  -5.671712e-03   1   23 1 2
16  -3.636077e-03   2   12 2 2
17  -3.904864e-03   2   22 2 2
18   1.025440e-03   2   13 1 2
19  -3.789292e-03   2   23 1 2
20   3.396270e-03   3   12 2 2
21   8.807778e-03   3   22 2 2
22   5.456604e-03   3   23 1 2
23  -1.134216e-02   1   13 2 3
24  -7.725740e-03   1   23 2 3
25  -1.589719e-03   1   14 1 3
26   4.574659e-04   1   24 1 3
27  -2.899983e-03   2   13 2 3
28  -4.310185e-03   2   23 2 3
29  -3.200475e-05   2   14 1 3
30   3.166308e-03   3   13 2 3
31   5.697712e-03   3   23 2 3
32   6.058486e-03   3   14 1 3
33   6.941016e-03   3   24 1 3
34  -2.794982e-03   1   14 2 4
35  -4.416711e-03   1   15 1 4
36  -4.062832e-03   1   25 1 4
37   1.763941e-03   2   14 2 4
38  -2.928930e-03   2   24 2 4
39  -2.869975e-03   2   25 1 4
40   6.949621e-03   3   14 2 4
41   5.766447e-03   3   24 2 4
42   2.510278e-03   3   15 1 4
43   5.507496e-03   3   25 1 4
44  -1.197325e-02   1   25 2 5
45  -6.556955e-03   1   16 1 5
46   3.622169e-04   2   15 2 5
47  -1.288784e-03   2   25 2 5
48  -2.863541e-03   2   16 1 5
49  -7.082933e-03   2   26 1 5
50   3.813700e-03   3   15 2 5
51   9.593295e-03   3   25 2 5
52   9.881930e-03   3   26 1 5
53  -1.081725e-02   1   16 2 6
54  -8.870041e-03   1   26 2 6
55  -5.305931e-04   1   27 1 6
56   2.835570e-03   2   16 2 6
57   4.541555e-03   2   26 2 6
58  -5.909101e-03   2   17 1 6
59  -2.768342e-03   2   27 1 6
60   8.835976e-03   3   16 2 6
61   1.234038e-02   3   26 2 6
62   2.015527e-03   3   17 1 6
63   6.485565e-03   3   27 1 6
64  -8.372922e-03   1   17 2 7
65  -9.439749e-03   1   27 2 7
66  -3.782672e-03   1   18 1 7
67  -2.576470e-03   1   28 1 7
68   2.878789e-03   2   17 2 7
69  -9.458139e-04   2   27 2 7
70  -3.993852e-03   2   28 1 7
71   5.997718e-03   3   17 2 7
72  -9.595505e-05   3   18 1 7
73   8.167411e-03   3   28 1 7
74  -1.181158e-02   1   18 2 8
75  -1.072585e-02   1   28 2 8
76  -2.856532e-03   1   19 1 8
77  -4.944013e-03   1   29 1 8
78   2.558783e-03   2   18 2 8
79   3.393314e-03   2   28 2 8
80  -4.466758e-03   2   19 1 8
81  -5.667622e-03   2   29 1 8
82   7.491253e-03   3   28 2 8
83   4.380724e-03   3   19 1 8
84   2.827233e-03   3   29 1 8
85  -7.433928e-03   1   29 2 9
86  -9.177664e-03   1   1   10 1 9
87  -6.040020e-04   1   2   10 1 9
88   1.394224e-03   2   19 2 9
89  -7.455449e-04   2   1   10 1 9
90  -2.251806e-03   2   2   10 

Re: [R] covariates in nlmer function

2007-09-14 Thread Douglas Bates
On 9/14/07, Kari Ruohonen <[EMAIL PROTECTED]> wrote:
> I am trying to explore nlmer by running some nlme examples from Pinheiro
> & Bates (2000). I do not seem to find information how to specify fixed
> effects covariates to nlmer models. Specifically, I tried to run the
> "Carbon Dioxide Uptake" example from p. 368 onwards in the PB200 book.
> The model without fixed effects covariates runs well but how to tell
> nlmer to include Type and Treatment similar to the nlme model on p. 374
> in the PB2000 book? Or is this something that has not been implemented
> yet?

To tell you the truth, I'm not sure.

I have been preparing classes and attending so many oral exams
recently that I can't remember exactly what capabilities are available
in nlmer right now.  I'll reply more definitively next week when I get
a chance to catch my breath a bit.

__
R-help@r-project.org 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] Comparing regression models

2007-09-14 Thread Lucke, Joseph F
The classic way to test for better fit with an additional variable is to use 
the anova() function.  The model must have the suspect variable listed last 
into your model.  The anova() function will give you the correct sequential 
decomposition of your model effects and their conditional (F or t) tests.  
Check a regression text for the details.  (You should have done this already.)

I have never heard of comparing residuals using the t-test.  It makes no sense 
because the residuals have mean zero under either model.

The AIC is also valid, but my reading between your lines would indicate the 
anova test would be better.

JFL

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
Sent: Friday, September 14, 2007 9:49 AM
To: r-help@r-project.org
Subject: [R] Comparing regression models


Dear list,

I am interested in comparing two linear regression models to see if including 
one extra variable improves the model significantly. I have read that one 
possibility is doing an F test on the goodness-of-fit values for both models, 
and another option that is comparing the residuals of both models using a 
paired test. I also know about the
anova() function that compares results for two models but am not sure what it 
actually does compare. Can you give me any suggestions?

Does the same hold if the models were logistic instead of linear? I have read 
that the Akaike´s AIC is also a valid option. 

Thanks in advance for your comments

David

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org 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] add boxplot to histogram

2007-09-14 Thread Henrique Dallazuanna
Like this:

 x <- rnorm(100)
 hist(x)
 op <- par(fig=c(.02,.5,.5,.98), new=TRUE)
 boxplot(x)


-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

On 14/09/2007, Haiyong Xu <[EMAIL PROTECTED]> wrote:
>
> Hi there,
>
> I am wondering if it is possible to add a small boxplot in a
> histogram, just like the legend.
>
> Thanks.
> Haiyong
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

__
R-help@r-project.org 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] Copying row names

2007-09-14 Thread kwaj

I have been trying to copy the row names of one matrix to another matrix but
having difficulty. The original matrix contains a row name which I would
like to replicate in the new matrix. I use the following approach?
The two matrices have identical dimensions.

rN <- row.names(origMatrix)
row.names(newMatrix) <- rN

However the new matrix does not take on the labels. 

I have also tried, 

row.names(newMatrix) <- as.character(rN)

Any ideas?


-- 
View this message in context: 
http://www.nabble.com/Copying-row-names-tf4445280.html#a12683702
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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] Copying row names

2007-09-14 Thread Paul Smith
On 9/14/07, kwaj <[EMAIL PROTECTED]> wrote:
> I have been trying to copy the row names of one matrix to another matrix but
> having difficulty. The original matrix contains a row name which I would
> like to replicate in the new matrix. I use the following approach?
> The two matrices have identical dimensions.
>
> rN <- row.names(origMatrix)
> row.names(newMatrix) <- rN
>
> However the new matrix does not take on the labels.
>
> I have also tried,
>
> row.names(newMatrix) <- as.character(rN)
>
> Any ideas?

Use 'rownames' instead of 'row.names':

> a <- matrix(1:9,,3)
> rownames(a) <- c("x","y","z")
> b <- matrix(1:9,,3)
> names.of.a <- rownames(a)
> rownames(b) <- names.of.a
> a
  [,1] [,2] [,3]
x147
y258
z369
> b
  [,1] [,2] [,3]
x147
y258
z369
>

Paul

__
R-help@r-project.org 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] xyplot question

2007-09-14 Thread Raymond Balise
I am tring to do an xyplot where I want to plot 5 dots in each pane of
the trellice and the dots need to have lines (whiskers) extending up
and down at each point(plus a 45 degree reference line).  The data
frame is set up with the variables x y lcl and ucl (where the lcl and
ucl are the limits on the lines I want).  The code below gives me the
points but I cant figure out the lines limited by the lcl and ucl
variable.


library(lattice)
library(grid)

with(fig2,
  xyplot(y ~ x |  group * Method,
  xlab = "",
  xlim = c(-5, 1),
  ylab = "",
  ylim = c(-5, 1),
  col = "black",
  groups = group,
  aspect = 1,

  panel = function(x, y, ...) {
 panel.superpose(x, y, ...)
 panel.abline(0, 1)
 },
 )
)

The not trellice version of the first image I need in the xyplot can
be done like this:

with(sub1,
plot(y~x,
  xlim = c(-5,1),
  ylim = c(-5,1)
  )
)
abline (0, 1)
lines(rep(sub1$x[1],2), c(sub1$lcl[1], sub1$ucl[5]))
lines(rep(sub1$x[2],2), c(sub1$lcl[2], sub1$ucl[5]))
lines(rep(sub1$x[3],2), c(sub1$lcl[3], sub1$ucl[5]))
lines(rep(sub1$x[4],2), c(sub1$lcl[4], sub1$ucl[5]))
lines(rep(sub1$x[5],2), c(sub1$lcl[5], sub1$ucl[5]))

How can i tell it to use the lcl and ucl values to draw the whiskers I
need above and below the points?

__
R-help@r-project.org 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] xyplot question

2007-09-14 Thread hadley wickham
Hi Raymond,

It isn't lattice, but this is fairly easy to do with ggplot2:

install.packages("ggplot2")
library(ggplot2)

qplot(x, y, facets = group ~ Method) +
geom_linerange(aes(min = lcl, max=ucl)) +
geom_abline()

See more at http://had.co.nz/ggplot2

Hadley

On 9/14/07, Raymond Balise <[EMAIL PROTECTED]> wrote:
> I am tring to do an xyplot where I want to plot 5 dots in each pane of
> the trellice and the dots need to have lines (whiskers) extending up
> and down at each point(plus a 45 degree reference line).  The data
> frame is set up with the variables x y lcl and ucl (where the lcl and
> ucl are the limits on the lines I want).  The code below gives me the
> points but I cant figure out the lines limited by the lcl and ucl
> variable.
>
>
> library(lattice)
> library(grid)
>
> with(fig2,
>   xyplot(y ~ x |  group * Method,
>   xlab = "",
>   xlim = c(-5, 1),
>   ylab = "",
>   ylim = c(-5, 1),
>   col = "black",
>   groups = group,
>   aspect = 1,
>
>   panel = function(x, y, ...) {
>  panel.superpose(x, y, ...)
>  panel.abline(0, 1)
>  },
>  )
> )
>
> The not trellice version of the first image I need in the xyplot can
> be done like this:
>
> with(sub1,
> plot(y~x,
>   xlim = c(-5,1),
>   ylim = c(-5,1)
>   )
> )
> abline (0, 1)
> lines(rep(sub1$x[1],2), c(sub1$lcl[1], sub1$ucl[5]))
> lines(rep(sub1$x[2],2), c(sub1$lcl[2], sub1$ucl[5]))
> lines(rep(sub1$x[3],2), c(sub1$lcl[3], sub1$ucl[5]))
> lines(rep(sub1$x[4],2), c(sub1$lcl[4], sub1$ucl[5]))
> lines(rep(sub1$x[5],2), c(sub1$lcl[5], sub1$ucl[5]))
>
> How can i tell it to use the lcl and ucl values to draw the whiskers I
> need above and below the points?
>
> __
> R-help@r-project.org 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.
>


-- 
http://had.co.nz/

__
R-help@r-project.org 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] question on layout and image.plot

2007-09-14 Thread Ranjan Maitra
Dear colleagues,

I have struggled for the past couple of days with the following layout of 
plots. First, for something that finally works (and I understand it also, or so 
I think!):

A B x 

where A and B are 4x4 matrices of images, x is the common legend for A and B.

The following does what I want (note that the images are nonsensical 
realizations from N(0, 1) in this rendering so that it is possible for people 
to try it out):



library(fields)


mat <- matrix(1:16, ncol = 4, nrow = 4, by = T)
mat2 <- cbind(mat, rep(17, nrow(mat)), mat + 17, rep(34, nrow(mat)),
rep(35, nrow(mat)))
layout(mat2, heights = rep(8, 4), widths = c(rep(8, 4), 1, rep(8,
4), 3, 1), respect = F)   

par(mar = c(0, 0, 0, 0))

for (i in 1:16) image(matrix(rnorm(64^2), ncol = 64), col =
 tim.colors(64), axes = F)

frame()

for (i in 1:16) image(matrix(rnorm(64^2), ncol = 64), col =
 tim.colors(64), axes = F)

par(oma = c(0, 0, 0, 4))
par(mar = c(0, 0, 0, 0))

image.plot( zlim = c(-3, 3) , cex = 0.7, lwd = 0.5, legend.only=TRUE,
legend.width = 15, legend.shrink = 0.75)






The above works. But now, I want something that is of the format:

A x B x

where A and B are 4x4 matrices of images, x are the corresponding legends for A 
and B.

So, I tried the following:


library(fields)


mat <- matrix(1:16, ncol = 4, nrow = 4, by = T)
mat2 <- cbind(mat, rep(17, nrow(mat)), rep(18, nrow(mat)), mat + 18,
rep(35, nrow(mat)), rep(36, nrow(mat)))

layout(mat2, heights = rep(8, 4), widths = c(rep(8, 4), 3, 1, rep(8,
4), 3, 1), respect = F)   

par(mar = c(0, 0, 0, 0))

for (i in 1:16) image(matrix(rnorm(64^2), ncol = 64), col =
 tim.colors(64), axes = F)

par(oma = c(0, 0, 0, 4))
par(mar = c(0, 0, 0, 0))

image.plot( zlim = c(-3, 3) , cex = 0.7, lwd = 0.5, legend.only=TRUE,
legend.width = 15, legend.shrink = 0.75)

frame()

for (i in 1:16) image(matrix(rnorm(64^2), ncol = 64), col =
 tim.colors(64), axes = F)

par(oma = c(0, 0, 0, 4))
par(mar = c(0, 0, 0, 0))

image.plot( zlim = c(-3, 3) , cex = 0.7, lwd = 0.5, legend.only=TRUE,
legend.width = 15, legend.shrink = 0.75)




And everything goes haywire from the application of image.plot onwards. Indeed, 
if I replace the first image.plot call with frame(), everything goes through 
but of course, I do not get the first legend. So, I wonder what am I doing 
wrong? Also how should I fix this? Note that submitting the figures separately 
is not an option for me (stupid journal rules:-()

Can someone please suggest what I should do here? 

Many thanks and best wishes,
Ranjan

__
R-help@r-project.org 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] lme for repeated measurements over time

2007-09-14 Thread Armin Goralczyk
Hi list

I am just beginning to understand the complexities of linear mixed
effects models. Maybe someone can give advise concerning the following
problem:

I have two groups of surgical patients in which repeated laboratory
measurements were taken over time after surgery. I decided that lme
would be the best model to fit the data.
I already fitted the model

lme(logratio ~ gr*I(pod-10) + I(pod^2-10) + I(pod^3-10), data=xyz,
random = ~ pod|subj)

where gr = two groups; pod = postoperative day; subj = patient;
logratio = log of value at day pod/preoperative value: log(post/pre)

but these questions remain:

1. Is lme the best model to fit the data? Other suggestions?

2. Since the ratio had no gaussian distribution I took the log which
seems to have a normal distribution. Is this OK?

3. I shifted the intercept to pod 10 because at this point the
difference of the intercept is significant different whereas the
difference at 0 is not significant. Can I do this?

4. Inspection of the data showed that a polynomial regression would be
a better fit for the data. I tried several polynomial regressions up
to pod^5. The above model had the lowest AIC, BIC and logLik. When I
use Anova to compare the models there I get the warning message:
"Fitted objects with different fixed effects. REML comparisons are not
meaningful."
What can I use instead to compare the models?

5. For random I used only pod and not pod^x. Is this correct?

6. Omitting the group factor from pod^2 and pod^3 the model had a
slightly better fit. Can I do this?

7. Can I assume that the data is heteroskedastic? How do I apply the
'weights' in the above model?

I am sorry if some questions may sound weird but I am just beginning
to understand this (for me) rather complex concept. Thanks for any
help.
-- 
Armin Goralczyk, M.D.
Dept. of General Surgery
University of Göttingen
Göttingen, Germany
http://www.chirurgie-goettingen.de
__
R-help@r-project.org 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] xyplot question

2007-09-14 Thread Deepayan Sarkar
On 9/14/07, Raymond Balise <[EMAIL PROTECTED]> wrote:
> I am tring to do an xyplot where I want to plot 5 dots in each pane of
> the trellice and the dots need to have lines (whiskers) extending up
> and down at each point(plus a 45 degree reference line).  The data
> frame is set up with the variables x y lcl and ucl (where the lcl and
> ucl are the limits on the lines I want).  The code below gives me the
> points but I cant figure out the lines limited by the lcl and ucl
> variable.

demo("intervals", package = "lattice")

should get you most of the way. The source should be easier to read from

https://svn.r-project.org/R-packages/trunk/lattice/demo/intervals.R

You can ignore most of it; you just need prepanel.ci, panel.ci, and
the xyplot() call at the end.

-Deepayan

__
R-help@r-project.org 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] locate word in vector

2007-09-14 Thread kevinchang

Hey All,


I am wondering if there is a built-in function allowing us to locate a
particular word in a character vector.

ex: vector a

a
[1] "superman"  "xamn"  "spiderman" "superman"  "superman"  "xman" 
[7] "spiderman"

Is there any built-in function that can show "superman" are the first,
fourth and fifith element in "a"? Please help me out. Thanks. 


-- 
View this message in context: 
http://www.nabble.com/locate-word-in-vector-tf4445881.html#a12685567
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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] locate word in vector

2007-09-14 Thread jim holtman
Is this what you want:

> x <- c("superman" , "xamn" , "spiderman", "superman" , "superman" , 
> "xman",
+ "spiderman" )
> which(x == "superman")
[1] 1 4 5
>


On 9/14/07, kevinchang <[EMAIL PROTECTED]> wrote:
>
> Hey All,
>
>
> I am wondering if there is a built-in function allowing us to locate a
> particular word in a character vector.
>
> ex: vector a
>
> a
> [1] "superman"  "xamn"  "spiderman" "superman"  "superman"  "xman"
> [7] "spiderman"
>
> Is there any built-in function that can show "superman" are the first,
> fourth and fifith element in "a"? Please help me out. Thanks.
>
>
> --
> View this message in context: 
> http://www.nabble.com/locate-word-in-vector-tf4445881.html#a12685567
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org 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.
>


-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

__
R-help@r-project.org 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] locate word in vector

2007-09-14 Thread Chuck Cleland
kevinchang wrote:
> Hey All,
> 
> 
> I am wondering if there is a built-in function allowing us to locate a
> particular word in a character vector.
> 
> ex: vector a
> 
> a
> [1] "superman"  "xamn"  "spiderman" "superman"  "superman"  "xman" 
> [7] "spiderman"
> 
> Is there any built-in function that can show "superman" are the first,
> fourth and fifith element in "a"? Please help me out. Thanks. 

a <- c("superman", "xamn", "spiderman", "superman",
   "superman", "xman", "spiderman")

grep("^superman$", a)
[1] 1 4 5

?grep

OR

which(a %in% "superman")
[1] 1 4 5

?which
?is.element

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

__
R-help@r-project.org 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.