Re: [R] defining color sequence in image()

2006-12-26 Thread talepanda
one solution is:

img1-matrix(1:5)
img2-matrix(2:5)
col-1:5 # col-c(green,yellow,...)
image(img1,col=col[sort(unique(img1))])
image(img2,col=col[sort(unique(img2))])

On 12/26/06, Milton Cezar Ribeiro [EMAIL PROTECTED] wrote:
 Dear All,

   How can I define a color sequence for each image value? I have several
 images with values varying from 1 to 5, and I would like to assing a fixed
 color for each value (green for 1, yellow for 2...). I used somethink like:

image(img,col=c(green,yellow,...))

   but unfortunately whem I have absent values, the color that I defined for
 each values change.

   Thanks a lot,

   Miltinho
   Brazil

   PS : Merry Christmas!!!

  __


   [[alternative HTML version deleted]]

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


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


Re: [R] extend summary.lm for hccm?

2006-12-26 Thread Achim Zeileis
On Sun, 24 Dec 2006, John Fox wrote:

 If I remember Freedman's recent paper correctly, he argues that sandwich
 variance estimator, though problematic in general, is not problematic in the
 case that White described -- an otherwise correctly specified linear model
 with heteroscedasticity estimated by least-squares.

More generally, sandwich-type estimators are valid (i.e., estimate
the right quantity, although not necessarily precisely, as Frank pointed
out) in situations where the estimating functions are correctly specified
but remaining aspets of the likelihood (not captured in the estimating
functions) are potentially not.

In linear models, it is easy to see what this means: the mean function has
to be correctly specified (i.e., the errors have zero mean) but the
correlation structure of the errors (i.e., their (co-)variances) might
differ from the usual assumptions. In GLMs, in particular logistic
regression, it is much more difficult to see against which types of
misspecification sandwich-based inference is robust.

Freedman's paper stresses the point that many model misspecifications also
imply misspecified estimating functions (and in his example this is rather
obvious) so that consequently the sandwich-type estimators estimate the
wrong quantity.

Best wishes,
Z

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


[R] HOW TO: vectorize an iterative process.

2006-12-26 Thread Geoffrey Zhu
SGkgRXZlcnlvbmUsDQogDQpJIGFtIHN0dWNrIHdpdGggYSBzaW1wbGUgcHJvYmxlbS4gU3Vw
cG9zZSBJIGhhdmUgYSB2ZWN0b3IgeCwgYW5kIEkgd2FudCB0byBjYWxjdWxhdGUgeVtpXT14
W2krMV0teFtpXSwgaXQgaXMgdmVyeSBlYXN5LiBJIGp1c3QgbmVlZCB0byB3cml0ZSB5PC14
WzI6bGVuZ3RoKHgpXS14WzE6bGVuZ3RoKHgpLTFdLiANCiANCk5vdyBpZiBJIGtub3cgeSwg
YW5kIHdhbnQgdG8ga25vdyB0aGUgdmVjdG9yIHggZGVmaW5lZCBieSB4W2ldPXhbaS0xXSt5
W2ktMV0gZm9yIGFsbCBpLCBob3cgY2FuIEkgZG8gdGhpcyB3aXRob3V0IGEgbG9vcD8gDQog
DQpUaGFua3MsDQpHZW9mZnJleQ0KIA0KDQpfX19fX19fX19fX19fX19fX19fX19fX19fX19f
X19fX19fX19fX19fX19fX19fX19fX19fX19fCgoKVGhlIGluZm9ybWF0aW9uIGluIHRoaXMg
ZW1haWwgb3IgaW4gYW55IGZpbGUgYXR0YWNoZWQgaGVyZXRvIGlzCmludGVuZGVkIG9ubHkg
Zm9yIHRoZSBwZXJzb25hbCBhbmQgY29uZmlkZW50aWFsIHVzZSBvZiB0aGUgaW5kaXZpZHVh
bApvciBlbnRpdHkgdG8gd2hpY2ggaXQgaXMgYWRkcmVzc2VkIGFuZCBtYXkgY29udGFpbiBp
bmZvcm1hdGlvbiB0aGF0IGlzCnByb3ByaWV0YXJ5IGFuZCBjb25maWRlbnRpYWwuIElmIHlv
dSBhcmUgbm90IHRoZSBpbnRlbmRlZCByZWNpcGllbnQgb2YKdGhpcyBtZXNzYWdlIHlvdSBh
cmUgaGVyZWJ5IG5vdGlmaWVkIHRoYXQgYW55IHJldmlldywgZGlzc2VtaW5hdGlvbiwKZGlz
dHJpYnV0aW9uIG9yIGNvcHlpbmcgb2YgdGhpcyBtZXNzYWdlIGlzIHN0cmljdGx5IHByb2hp
Yml0ZWQuIFRoaXMgY29tbXVuaWNhdGlvbiBpcyBmb3IgaW5mb3JtYXRpb24gcHVycG9zZXMg
b25seSBhbmQgc2hvdWxkIG5vdCBiZSByZWdhcmRlZCBhcyBhbiBvZmZlciB0byBzZWxsIG9y
IGFzIGEgc29saWNpdGF0aW9uIG9mIGFuIG9mZmVyIHRvIGJ1eSBhbnkgZmluYW5jaWFsIHBy
b2R1Y3QuIEVtYWlsIHRyYW5zbWlzc2lvbiBjYW5ub3QgYmUgZ3VhcmFudGVlZCB0byBiZSBz
ZWN1cmUgb3IgZXJyb3ItZnJlZS4NCg==

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


[R] writing to S-PLUS .dat file

2006-12-26 Thread Sebastian Michalski
Dear Users,
I am new to R. I use write() to write my data in .txt format. I'd like 
to write to a disc any kind of data in a .dat S-PLUS format.
Please help.
SM

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


Re: [R] sequential row selection in dataframe

2006-12-26 Thread Michael Kubovy
On Dec 26, 2006, at 12:07 AM, Pedro Mardones wrote:

 I'm wondering if there is any 'efficient' approach for selecting a
 sample of 'every nth rows'  from a dataframe. For example, let's use
 the dataframe GAGurine in MASS library:

 length(GAGurine[,1])
 [1] 314

 # select an 75% of the dataset, i.e. = 236 rows, every 2 rows starting
 from row 1
 test-GAGurine[seq(1,314,2),]
 length(test[,1])
 [1] 157

 # so, I still need another 79 rows, one way could be:
 test2-GAGurine[-seq(1,314,2),]
 length(test2[,1])
 [1] 157
 test3-test2[seq(1,157,2),]

 # and then
 final-rbind(test2,test3)
 length(final[,1])
 [1] 236

 Does anyone have a better idea to get the same results but without
 creating different datasets like test2 and test3?

A probabilistic approach:

len - length(GAGurine[,1])
GAGu - GAGurine[sample(1:len, round(.75 * len)), ] # 236 rows

A deterministic one:

nr - 1 #or 2
GAGu2 - GAGurine[-seq(nr, len, 4),] # drop every 4th, giving 235 rows
nr - 3 # or 4
will give 236 rows.
_
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400Charlottesville, VA 22904-4400
Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
Office:B011+1-434-982-4729
Lab:B019+1-434-982-4751
Fax:+1-434-982-4766
WWW:http://www.people.virginia.edu/~mk9y/

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


[R] vectorizing an iterative process.

2006-12-26 Thread Geoffrey Zhu
Hi Everyone,
 
I am stuck with a simple problem. Suppose I have a vector x, and I want
to calculate y[i]=3Dx[i+1]-x[i], it is very easy. I just need to write
y-x[2:length(x)]-x[1:length(x)-1]. 
 
Now if I know y, and want to know the vector x defined by
x[i]=3Dx[i-1]+y[i-1] for all i, how can I do this without a loop? 
 
Thanks,
Geoffrey

PS. Sorry if you see a duplicate message. The previous one was in a
weird format that most people would not be able to read.

___=0A=
=0A=
=0A=
The information in this email or in any file attached hereto is=0A=
intended only for the personal and confidential use of the individual=0A=
or entity to which it is addressed and may contain information that is=0A=
proprietary and confidential. If you are not the intended recipient of=0A=
this message you are hereby notified that any review, dissemination,=0A=
distribution or copying of this message is strictly prohibited. This communi=
cation is for information purposes only and should not be regarded as an off=
er to sell or as a solicitation of an offer to buy any financial product. Em=
ail transmission cannot be guaranteed to be secure or error-free.

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


Re: [R] vectorizing an iterative process.

2006-12-26 Thread Richard M. Heiberger
 x[i]=3Dx[i-1]+y[i-1] for all i, how can I do this without a loop? 

It looks like
   x - cumsum(y)

What does 3D mean?

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


Re: [R] vectorizing an iterative process.

2006-12-26 Thread Geoffrey Zhu
Hi Richard,

3D is automatically generated by the mailing list software, probably
because I had ] followed by =3D without a space in the original post. 

What I meant was to calculate x[i] =3D x[i-1] + y[i-1] 

For example, if X - 1:10

Then I want the vector Y to be 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, or
in other words Y[i] =3D y[i-1] + x[i]. 

Yes, cumsum does the trick for this. This is what I need. Thanks.

Just curious, do you know how to calculate the more generic x[i] - f(
x[i-1], y[i-1] )?

Thanks,
Geoffrey



-Original Message-
From: Richard M. Heiberger [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, December 26, 2006 9:56 AM
To: Geoffrey Zhu; r-help@stat.math.ethz.ch
Subject: Re: [R] vectorizing an iterative process.

 x[i]=3D3Dx[i-1]+y[i-1] for all i, how can I do this without a loop? 

It looks like
   x - cumsum(y)

What does 3D mean?



___=0A=
=0A=
=0A=
The information in this email or in any file attached hereto is=0A=
intended only for the personal and confidential use of the individual=0A=
or entity to which it is addressed and may contain information that is=0A=
proprietary and confidential. If you are not the intended recipient of=0A=
this message you are hereby notified that any review, dissemination,=0A=
distribution or copying of this message is strictly prohibited. This communi=
cation is for information purposes only and should not be regarded as an off=
er to sell or as a solicitation of an offer to buy any financial product. Em=
ail transmission cannot be guaranteed to be secure or error-free.

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


Re: [R] vectorizing an iterative process.

2006-12-26 Thread hadley wickham
  x[i]=3Dx[i-1]+y[i-1] for all i, how can I do this without a loop?

 It looks like
x - cumsum(y)

 What does 3D mean?

The =3D is probably an encoding error - it should just be =.

In general to vectorise an iterative problem, you will need to solve
the recurrence relation
(http://en.wikipedia.org/wiki/Recurrence_relation), although I think
it's pretty tricky in general, and there's no guarantee that the
vectorised/non-recursive form will be more efficient.

Hadley

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


Re: [R] vectorizing an iterative process.

2006-12-26 Thread Geoffrey Zhu
I meant  x[i] - x[i-1] + y[i-1] and Y[i] - y[i-1] + x[i] below.

The mailing list software just keep adding 3D's. Sorry. 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Geoffrey Zhu
Sent: Tuesday, December 26, 2006 10:03 AM
To: Richard M. Heiberger; r-help@stat.math.ethz.ch
Subject: Re: [R] vectorizing an iterative process.

Hi Richard,

3D is automatically generated by the mailing list software, probably
because I had ] followed by =3D3D without a space in the original post. 

What I meant was to calculate x[i] =3D3D x[i-1] + y[i-1] 

For example, if X - 1:10

Then I want the vector Y to be 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, or
in other words Y[i] =3D3D y[i-1] + x[i]. 

Yes, cumsum does the trick for this. This is what I need. Thanks.

Just curious, do you know how to calculate the more generic x[i] - f(
x[i-1], y[i-1] )?

Thanks,
Geoffrey



-Original Message-
From: Richard M. Heiberger [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 26, 2006 9:56 AM
To: Geoffrey Zhu; r-help@stat.math.ethz.ch
Subject: Re: [R] vectorizing an iterative process.

 x[i]=3D3D3Dx[i-1]+y[i-1] for all i, how can I do this without a loop? 

It looks like
   x - cumsum(y)

What does 3D mean?



___=3D0A=3D
=3D0A=3D
=3D0A=3D
The information in this email or in any file attached hereto is=3D0A=3D
intended only for the personal and confidential use of the
individual=3D0A=3D or entity to which it is addressed and may contain
information that is=3D0A=3D proprietary and confidential. If you are not the
intended recipient of=3D0A=3D this message you are hereby notified that any
review, dissemination,=3D0A=3D distribution or copying of this message is
strictly prohibited. This communi=3D cation is for information purposes
only and should not be regarded as an off=3D er to sell or as a
solicitation of an offer to buy any financial product. Em=3D ail
transmission cannot be guaranteed to be secure or error-free.

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



___=0A=
=0A=
=0A=
The information in this email or in any file attached hereto is=0A=
intended only for the personal and confidential use of the individual=0A=
or entity to which it is addressed and may contain information that is=0A=
proprietary and confidential. If you are not the intended recipient of=0A=
this message you are hereby notified that any review, dissemination,=0A=
distribution or copying of this message is strictly prohibited. This communi=
cation is for information purposes only and should not be regarded as an off=
er to sell or as a solicitation of an offer to buy any financial product. Em=
ail transmission cannot be guaranteed to be secure or error-free.

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


Re: [R] vectorizing an iterative process.

2006-12-26 Thread Christos Hatzis
In your case, the recurrence relationship for x can be solved easily:
Notice that 

sum{i=1,n}(x[i]-x[i-1]) = x[n] - x[0] 

and therefore

x[n] = x[0] + sum{i=1,n}(y[i-1] for n=1, N, with the appropriate initial
condition for i=0, (x[0],y[0]).

Thus cumsum on y will give you a direct answer.

-Christos

Christos Hatzis, Ph.D.
Nuvera Biosciences, Inc.
400 West Cummings Park
Suite 5350
Woburn, MA 01801
Tel: 781-938-3830
www.nuverabio.com
 
  

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Geoffrey Zhu
Sent: Tuesday, December 26, 2006 11:06 AM
To: r-help@stat.math.ethz.ch
Subject: Re: [R] vectorizing an iterative process.

I meant  x[i] - x[i-1] + y[i-1] and Y[i] - y[i-1] + x[i] below.

The mailing list software just keep adding 3D's. Sorry. 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Geoffrey Zhu
Sent: Tuesday, December 26, 2006 10:03 AM
To: Richard M. Heiberger; r-help@stat.math.ethz.ch
Subject: Re: [R] vectorizing an iterative process.

Hi Richard,

3D is automatically generated by the mailing list software, probably because
I had ] followed by =3D3D without a space in the original post. 

What I meant was to calculate x[i] =3D3D x[i-1] + y[i-1] 

For example, if X - 1:10

Then I want the vector Y to be 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, or in
other words Y[i] =3D3D y[i-1] + x[i]. 

Yes, cumsum does the trick for this. This is what I need. Thanks.

Just curious, do you know how to calculate the more generic x[i] - f(
x[i-1], y[i-1] )?

Thanks,
Geoffrey



-Original Message-
From: Richard M. Heiberger [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 26, 2006 9:56 AM
To: Geoffrey Zhu; r-help@stat.math.ethz.ch
Subject: Re: [R] vectorizing an iterative process.

 x[i]=3D3D3Dx[i-1]+y[i-1] for all i, how can I do this without a loop? 

It looks like
   x - cumsum(y)

What does 3D mean?



___=3D0A=3D
=3D0A=3D
=3D0A=3D
The information in this email or in any file attached hereto is=3D0A=3D
intended only for the personal and confidential use of the
individual=3D0A=3D or entity to which it is addressed and may contain
information that is=3D0A=3D proprietary and confidential. If you are not the
intended recipient of=3D0A=3D this message you are hereby notified that any
review, dissemination,=3D0A=3D distribution or copying of this message is
strictly prohibited. This communi=3D cation is for information purposes only
and should not be regarded as an off=3D er to sell or as a solicitation of
an offer to buy any financial product. Em=3D ail transmission cannot be
guaranteed to be secure or error-free.

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



___=0A=
=0A=
=0A=
The information in this email or in any file attached hereto is=0A= intended
only for the personal and confidential use of the individual=0A= or entity
to which it is addressed and may contain information that is=0A= proprietary
and confidential. If you are not the intended recipient of=0A= this message
you are hereby notified that any review, dissemination,=0A= distribution or
copying of this message is strictly prohibited. This communi= cation is for
information purposes only and should not be regarded as an off= er to sell
or as a solicitation of an offer to buy any financial product. Em= ail
transmission cannot be guaranteed to be secure or error-free.

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

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


Re: [R] Problem to generate training data set and test data set

2006-12-26 Thread Charles C. Berry

What you describe is called stratified sampling. It was discusssed last 
month (and other times) on this list:

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

Using

RSiteSearch(stratified sampling)

will produce many hits to relevant articles and packages.



On Mon, 25 Dec 2006, Aimin Yan wrote:

 I have a full data set like this:

aa basaas bms   ams bcuacu omega   y
 1 ALA   0 127.71   0 69.99   0 -0.2498560  79.91470 outward
 2 PRO   0  68.55   0 55.44   0 -0.0949008  76.60380 outward
 3 ALA   0  52.72   0 47.82   0 -0.0396550  52.19970 outward
 4 PHE   0  22.62   0 31.21   0  0.1270330 169.52500  inward
 5 SER   0  71.32   0 52.84   0 -0.1312380   7.47528 outward
 6 VAL   0  12.92   0 22.40   0  0.1728390 149.09400  inward
 ..


 aa have 19 levels, and there are different number of observation for each
 levels.
 I want to pick 75% of observations of each levels randomly to generate a
 training set,
 and 25% of observation of each levels to generate a testing set.

 Does anyone know to do this?

 Thanks

 Aimin Yan

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


Charles C. Berry(858) 534-2098
  Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]   UC San Diego
http://biostat.ucsd.edu/~cberry/ La Jolla, San Diego 92093-0717

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


Re: [R] vectorizing an iterative process.

2006-12-26 Thread Geoffrey Zhu
Yes, this solves my problem. Thanks for your help.

-Original Message-
From: Christos Hatzis [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, December 26, 2006 10:58 AM
To: Geoffrey Zhu; r-help@stat.math.ethz.ch
Subject: RE: [R] vectorizing an iterative process.

In your case, the recurrence relationship for x can be solved easily:
Notice that 

sum{i=3D1,n}(x[i]-x[i-1]) =3D x[n] - x[0] 

and therefore

x[n] =3D x[0] + sum{i=3D1,n}(y[i-1] for n=3D1, N, with the appropriate initi=
al
condition for i=3D0, (x[0],y[0]).

Thus cumsum on y will give you a direct answer.

-Christos

Christos Hatzis, Ph.D.
Nuvera Biosciences, Inc.
400 West Cummings Park
Suite 5350
Woburn, MA 01801
Tel: 781-938-3830
www.nuverabio.com
 
  

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Geoffrey Zhu
Sent: Tuesday, December 26, 2006 11:06 AM
To: r-help@stat.math.ethz.ch
Subject: Re: [R] vectorizing an iterative process.

I meant  x[i] - x[i-1] + y[i-1] and Y[i] - y[i-1] + x[i] below.

The mailing list software just keep adding 3D's. Sorry. 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Geoffrey Zhu
Sent: Tuesday, December 26, 2006 10:03 AM
To: Richard M. Heiberger; r-help@stat.math.ethz.ch
Subject: Re: [R] vectorizing an iterative process.

Hi Richard,

3D is automatically generated by the mailing list software, probably
because I had ] followed by =3D3D3D without a space in the original post. 

What I meant was to calculate x[i] =3D3D3D x[i-1] + y[i-1] 

For example, if X - 1:10

Then I want the vector Y to be 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, or
in other words Y[i] =3D3D3D y[i-1] + x[i]. 

Yes, cumsum does the trick for this. This is what I need. Thanks.

Just curious, do you know how to calculate the more generic x[i] - f(
x[i-1], y[i-1] )?

Thanks,
Geoffrey



-Original Message-
From: Richard M. Heiberger [mailto:[EMAIL PROTECTED]
Sent: Tuesday, December 26, 2006 9:56 AM
To: Geoffrey Zhu; r-help@stat.math.ethz.ch
Subject: Re: [R] vectorizing an iterative process.

 x[i]=3D3D3D3Dx[i-1]+y[i-1] for all i, how can I do this without a loop? 

It looks like
   x - cumsum(y)

What does 3D mean?



___=3D3D0A=3D3D
=3D3D0A=3D3D
=3D3D0A=3D3D
The information in this email or in any file attached hereto is=3D3D0A=3D3D
intended only for the personal and confidential use of the
individual=3D3D0A=3D3D or entity to which it is addressed and may contain
information that is=3D3D0A=3D3D proprietary and confidential. If you are not
the intended recipient of=3D3D0A=3D3D this message you are hereby notified
that any review, dissemination,=3D3D0A=3D3D distribution or copying of this
message is strictly prohibited. This communi=3D3D cation is for
information purposes only and should not be regarded as an off=3D3D er to
sell or as a solicitation of an offer to buy any financial product.
Em=3D3D ail transmission cannot be guaranteed to be secure or error-free.

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



___=3D0A=3D
=3D0A=3D
=3D0A=3D
The information in this email or in any file attached hereto is=3D0A=3D
intended only for the personal and confidential use of the
individual=3D0A=3D or entity to which it is addressed and may contain
information that is=3D0A=3D proprietary and confidential. If you are not the
intended recipient of=3D0A=3D this message you are hereby notified that any
review, dissemination,=3D0A=3D distribution or copying of this message is
strictly prohibited. This communi=3D cation is for information purposes
only and should not be regarded as an off=3D er to sell or as a
solicitation of an offer to buy any financial product. Em=3D ail
transmission cannot be guaranteed to be secure or error-free.

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






___=0A=
=0A=
=0A=
The information in this email or in any file attached hereto is=0A=
intended only for the personal and confidential use of the individual=0A=
or entity to which it is addressed and may contain information that is=0A=
proprietary and confidential. If you are not the intended recipient of=0A=
this message you are hereby notified that any review, dissemination,=0A=
distribution or copying of this message is strictly prohibited. This communi=
cation is for information purposes only and should not be regarded as an off=
er to sell or as a solicitation of an offer to buy any 

[R] Rating competitors

2006-12-26 Thread Jeff Newmiller
I am looking for hints on how to estimate ratings for competitors
in an ongoing pairwise competition using R... my particular area of
interest being the game of Go, but the idea of identifying ratings
(on a continuous scale) rather than relative rankings seems easily
generalized to other competitions so I thought someone might be
studying something related already.

I presume the rating of a competitor would be best modeled as a random
variate on the rating scale, and an encounter between two
competitors would be represented by a binary result.  Logistic regression
seems promising, but I am at a loss how to represent the model since
the pairings are arbitrary and not necessarily repeated often.

I have read about some approaches to estimating ratings for Go,
but they seem to involve optimization using assumed distributions
rather than model fitting which characterizes analysis in R.

Does any of this sound familiar? Suggestions for reading, anyone?

-- 
---
Jeff NewmillerThe .   .  Go Live...
DCN:[EMAIL PROTECTED]Basics: ##.#.   ##.#.  Live Go...
   Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k

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


Re: [R] vectorizing an iterative process.

2006-12-26 Thread Peter Dalgaard
Geoffrey Zhu wrote:
 I meant  x[i] - x[i-1] + y[i-1] and Y[i] - y[i-1] + x[i] below.

 The mailing list software just keep adding 3D's. Sorry. 
   
Rather, I suspect that *your* mailer is sending in Quoted-Printable, 
without setting the appropriate headers. Take a look at

 http://mail.python.org/pipermail/mailman-users/2003-December/033425.html

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Geoffrey Zhu
 Sent: Tuesday, December 26, 2006 10:03 AM
 To: Richard M. Heiberger; r-help@stat.math.ethz.ch
 Subject: Re: [R] vectorizing an iterative process.

 Hi Richard,

 3D is automatically generated by the mailing list software, probably
 because I had ] followed by =3D3D without a space in the original post. 

 What I meant was to calculate x[i] =3D3D x[i-1] + y[i-1] 

 For example, if X - 1:10

 Then I want the vector Y to be 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, or
 in other words Y[i] =3D3D y[i-1] + x[i]. 

 Yes, cumsum does the trick for this. This is what I need. Thanks.

 Just curious, do you know how to calculate the more generic x[i] - f(
 x[i-1], y[i-1] )?

 Thanks,
 Geoffrey



 -Original Message-
 From: Richard M. Heiberger [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, December 26, 2006 9:56 AM
 To: Geoffrey Zhu; r-help@stat.math.ethz.ch
 Subject: Re: [R] vectorizing an iterative process.

   
 x[i]=3D3D3Dx[i-1]+y[i-1] for all i, how can I do this without a loop? 
 

 It looks like
x - cumsum(y)

 What does 3D mean?



 ___=3D0A=3D
 =3D0A=3D
 =3D0A=3D
 The information in this email or in any file attached hereto is=3D0A=3D
 intended only for the personal and confidential use of the
 individual=3D0A=3D or entity to which it is addressed and may contain
 information that is=3D0A=3D proprietary and confidential. If you are not the
 intended recipient of=3D0A=3D this message you are hereby notified that any
 review, dissemination,=3D0A=3D distribution or copying of this message is
 strictly prohibited. This communi=3D cation is for information purposes
 only and should not be regarded as an off=3D er to sell or as a
 solicitation of an offer to buy any financial product. Em=3D ail
 transmission cannot be guaranteed to be secure or error-free.

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



 ___=0A=
 =0A=
 =0A=
 The information in this email or in any file attached hereto is=0A=
 intended only for the personal and confidential use of the individual=0A=
 or entity to which it is addressed and may contain information that is=0A=
 proprietary and confidential. If you are not the intended recipient of=0A=
 this message you are hereby notified that any review, dissemination,=0A=
 distribution or copying of this message is strictly prohibited. This communi=
 cation is for information purposes only and should not be regarded as an off=
 er to sell or as a solicitation of an offer to buy any financial product. Em=
 ail transmission cannot be guaranteed to be secure or error-free.

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


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


Re: [R] Rating competitors

2006-12-26 Thread Spencer Graves
  Have you considered Bradley-Terry models?   RSiteSearch(bradley, 
functions) just returned 31 hits for me. 

  Hope this helps. 
  Spencer Graves

Jeff Newmiller wrote:
 I am looking for hints on how to estimate ratings for competitors
 in an ongoing pairwise competition using R... my particular area of
 interest being the game of Go, but the idea of identifying ratings
 (on a continuous scale) rather than relative rankings seems easily
 generalized to other competitions so I thought someone might be
 studying something related already.

 I presume the rating of a competitor would be best modeled as a random
 variate on the rating scale, and an encounter between two
 competitors would be represented by a binary result.  Logistic regression
 seems promising, but I am at a loss how to represent the model since
 the pairings are arbitrary and not necessarily repeated often.

 I have read about some approaches to estimating ratings for Go,
 but they seem to involve optimization using assumed distributions
 rather than model fitting which characterizes analysis in R.

 Does any of this sound familiar? Suggestions for reading, anyone?



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


Re: [R] Rating competitors

2006-12-26 Thread Charles C. Berry


There is a substantial literature on 'statistics in sports' and pairwise 
comparisons are of obvious interest. Here is a starting point:

http://www.amstat.org/sections/sis/

You might browse the newsletters posted there.

You might enjoy:

Bridging Different Eras in Sports by Scott M. Berry, Patrick D. Larkey, C. 
Shane Reese; Journal of the American Statistical Association, Vol. 94, 
1999

or

Baseball's All-Time Best Hitters: How Statistics Can Level the Playing 
Field by Michael J. Schell

http://press.princeton.edu/titles/6550.html


On Tue, 26 Dec 2006, Jeff Newmiller wrote:

 I am looking for hints on how to estimate ratings for competitors
 in an ongoing pairwise competition using R... my particular area of
 interest being the game of Go, but the idea of identifying ratings
 (on a continuous scale) rather than relative rankings seems easily
 generalized to other competitions so I thought someone might be
 studying something related already.

 I presume the rating of a competitor would be best modeled as a random
 variate on the rating scale, and an encounter between two
 competitors would be represented by a binary result.  Logistic regression
 seems promising, but I am at a loss how to represent the model since
 the pairings are arbitrary and not necessarily repeated often.

 I have read about some approaches to estimating ratings for Go,
 but they seem to involve optimization using assumed distributions
 rather than model fitting which characterizes analysis in R.

 Does any of this sound familiar? Suggestions for reading, anyone?

 -- 
 ---
 Jeff NewmillerThe .   .  Go Live...
 DCN:[EMAIL PROTECTED]Basics: ##.#.   ##.#.  Live Go...
   Live:   OO#.. Dead: OO#..  Playing
 Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
 /Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k

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


Charles C. Berry(858) 534-2098
  Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]   UC San Diego
http://biostat.ucsd.edu/~cberry/ La Jolla, San Diego 92093-0717

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


[R] slightly inconsistent behavior

2006-12-26 Thread ivo welch
dear R experts:

This is just a minor, minor nuisance, but I thought I would point it out:

 dataset - read.table(file=pipe(cmdline), header =T,
+   na.strings=c(NaN, C,I,M, E), sep=,,
as.is=T, nrows=);
Error: cannot allocate vector of size 781249 Kb

If I extend nrows by a few more 9's, the error goes away.  Similarly,
if I use much fewer observations, the error goes away.

regards,

/iaw

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


Re: [R] Rating competitors

2006-12-26 Thread Michael Kubovy
I would start with elimination-by-aspects models:
?eba
I would read the Tversky 1972 paper (cited on the help page for the  
eba() function), which is brilliant.

Jeff Newmiller wrote:

 I am looking for hints on how to estimate ratings for competitors
 in an ongoing pairwise competition using R... my particular area of
 interest being the game of Go, but the idea of identifying ratings
 (on a continuous scale) rather than relative rankings seems easily
 generalized to other competitions so I thought someone might be
 studying something related already.

 I presume the rating of a competitor would be best modeled as a random
 variate on the rating scale, and an encounter between two
 competitors would be represented by a binary result.  Logistic  
 regression
 seems promising, but I am at a loss how to represent the model since
 the pairings are arbitrary and not necessarily repeated often.
_
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400Charlottesville, VA 22904-4400
Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
Office:B011+1-434-982-4729
Lab:B019+1-434-982-4751
Fax:+1-434-982-4766
WWW:http://www.people.virginia.edu/~mk9y/

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


Re: [R] Rating competitors

2006-12-26 Thread Greg Snow
One approach that is already coded in R is the Bradley-Terry model
(found in the BradleyTerry package of all places).

This could be a good place to start if you want something quick, others
have given you references if you want more detail and/or control. 


-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jeff Newmiller
Sent: Tuesday, December 26, 2006 10:54 AM
To: r-help@stat.math.ethz.ch
Subject: [R] Rating competitors

I am looking for hints on how to estimate ratings for competitors in an
ongoing pairwise competition using R... my particular area of interest
being the game of Go, but the idea of identifying ratings (on a
continuous scale) rather than relative rankings seems easily generalized
to other competitions so I thought someone might be studying something
related already.

I presume the rating of a competitor would be best modeled as a random
variate on the rating scale, and an encounter between two competitors
would be represented by a binary result.  Logistic regression seems
promising, but I am at a loss how to represent the model since the
pairings are arbitrary and not necessarily repeated often.

I have read about some approaches to estimating ratings for Go, but they
seem to involve optimization using assumed distributions rather than
model fitting which characterizes analysis in R.

Does any of this sound familiar? Suggestions for reading, anyone?

--

---
Jeff NewmillerThe .   .  Go
Live...
DCN:[EMAIL PROTECTED]Basics: ##.#.   ##.#.  Live
Go...
   Live:   OO#.. Dead: OO#..
Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.
rocks...1k

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

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


[R] McNemar test in R SPSS

2006-12-26 Thread Bob Green
Hello,

I am hoping someone can clarify why I might obtain a quite different value 
in R  SPSS  for a McNemar test I ran.

Firstly, here is the R syntax  output


R OUTPUT

  mctest - as.table(matrix(c(128,29,331,430),
+ ncol =2, dimnames = list(group=c(preMHT,postMHT),
+ assault=c(yes,no

  mctest
   assault
group   yes  no
   preMHT  128 331
   postMHT  29 430

   mcnemar.test(mctest,correct=F)

 McNemar's Chi-squared test

data:  mctest
McNemar's chi-squared = 253.3444, df = 1, p-value  2.2e-16


SPSS OUTPUT

The same data was inputted in SPSS. Regarding the first table SPSS 
generated - it lists the number of cases in each combination of categories. 
The diagonal contains the number of cases with the same response on both 
variables, while the off diagonal contains cases that have different 
responses on the 2 variables. The overall chisquare value is much lower 
than the value obtained using R, though still significant.


pre02  post02

pre02   post02

 0   1
0   311 20
1   119 9


Test Statistics(b)

  pre02  post02

N   459
Chi-Square(a)   69.094
Asymp. Sig. .000

a  Continuity Corrected
b  McNemar Test


Any assistance is much appreciated,

Bob Green

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


Re: [R] McNemar test in R SPSS

2006-12-26 Thread Peter Dalgaard
Bob Green wrote:
 Hello,

 I am hoping someone can clarify why I might obtain a quite different value 
 in R  SPSS  for a McNemar test I ran.

 Firstly, here is the R syntax  output


 R OUTPUT

   mctest - as.table(matrix(c(128,29,331,430),
 + ncol =2, dimnames = list(group=c(preMHT,postMHT),
 + assault=c(yes,no

   mctest
assault
 group   yes  no
preMHT  128 331
postMHT  29 430

mcnemar.test(mctest,correct=F)

  McNemar's Chi-squared test

 data:  mctest
 McNemar's chi-squared = 253.3444, df = 1, p-value  2.2e-16


 SPSS OUTPUT

 The same data was inputted in SPSS. Regarding the first table SPSS 
 generated - it lists the number of cases in each combination of categories. 
 The diagonal contains the number of cases with the same response on both 
 variables, while the off diagonal contains cases that have different 
 responses on the 2 variables. The overall chisquare value is much lower 
 than the value obtained using R, though still significant.


 pre02  post02

 pre02   post02

  0   1
 0   311 20
 1   119 9


 Test Statistics(b)

   pre02  post02

 N   459
 Chi-Square(a)   69.094
 Asymp. Sig. .000

 a  Continuity Corrected
 b  McNemar Test


 Any assistance is much appreciated,
   
Well, you can't expect R to give the correct result if you feed it the 
wrong matrix, can you?

 d - read.table(stdin())

0:  0   1

1: 0   311 20

2: 1   119 9

3: 

 d

   X0 X1

0 311 20

1 119  9

 mcnemar.test(as.matrix(d),correct=F)

McNemar's Chi-squared test

data:  as.matrix(d) 

McNemar's chi-squared = 70.5108, df = 1, p-value  2.2e-16

 mcnemar.test(as.matrix(d),correct=T)

McNemar's Chi-squared test with continuity correction

data:  as.matrix(d) 

McNemar's chi-squared = 69.0935, df = 1, p-value  2.2e-16



 Bob Green

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


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


Re: [R] extend summary.lm for hccm?

2006-12-26 Thread Charles C. Berry
On Mon, 25 Dec 2006, Achim Zeileis wrote:

 On Sun, 24 Dec 2006, John Fox wrote:

 If I remember Freedman's recent paper correctly, he argues that sandwich
 variance estimator, though problematic in general, is not problematic in the
 case that White described -- an otherwise correctly specified linear model
 with heteroscedasticity estimated by least-squares.

 More generally, sandwich-type estimators are valid (i.e., estimate
 the right quantity, although not necessarily precisely, as Frank pointed
 out) in situations where the estimating functions are correctly specified
 but remaining aspets of the likelihood (not captured in the estimating
 functions) are potentially not.

Not exactly. The asymptotic properites are good, but in samples of 
moderate size the properties (including both biasedness and variance) can 
be surprisingly bad. And if you are trying to calculate a p-value, getting 
a too-small variance estimate gives you spuriously small p-values. FWIW, 
I've seen a case in which the nominal size of a test based on the sandwich 
estimator was several orders of magnitude smaller than a test with correct 
nominal size.

There is a modest literature on this. Some refs:

Background Papers:

Drum M, McCullagh P. Comment. Statistical Science 1993; 8:300-301.

Freedman DA. On the So-Called Huber Sandwich Estimator and Robust
Standard Errors. The American Statistician, Volume 60, Number 4, 
November 2006, pp. 299-302(4)

-

Some Proposed Corrections:

Fay MP and Graubard BI. Small-Sample Adjustments for
Walt-Type Tests Using Sandwich Estimators. Biometrics 2001; 57:
1198-1206.

Guo X, Pan W, Connett JE, Hannan PJ and French SA.  Small-sample
performance of the robust score test and its modifications in
generalized estimating equations Statistics in Medicine 2005;
24:3479-3495

Mancl LA and DeRouen TA, A Covariance Estimator for GEE with Improved
Small-Sample Properties. Biometrics 2001; 57:126-134.

Morel JG, Bokossa MC, and Neerchal NK.  Small Sample Correction for
the Variance of GEE Estimators Biometrical Journal 2003; 45(4):
395-409.

Pan W and Wall MM. Small-sample adjustments in using the
sandwich variance estimator in generalized estimating
equations. Statistics in Medicine  2002; 21:1429-1441.


HTH,

Chuck


 In linear models, it is easy to see what this means: the mean function has
 to be correctly specified (i.e., the errors have zero mean) but the
 correlation structure of the errors (i.e., their (co-)variances) might
 differ from the usual assumptions. In GLMs, in particular logistic
 regression, it is much more difficult to see against which types of
 misspecification sandwich-based inference is robust.

 Freedman's paper stresses the point that many model misspecifications also
 imply misspecified estimating functions (and in his example this is rather
 obvious) so that consequently the sandwich-type estimators estimate the
 wrong quantity.

 Best wishes,
 Z

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


Charles C. Berry(858) 534-2098
  Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]   UC San Diego
http://biostat.ucsd.edu/~cberry/ La Jolla, San Diego 92093-0717

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


Re: [R] McNemar test in R SPSS

2006-12-26 Thread Bob Green
Peter,

Thanks for your reply. To perform the analysis in R, I used the table 
format suggested in the book by Everitt  Hothorn, whereas in SPSS the 
analysis was performed directly from the 2 variables, rather than using 
count data.

There is still something I don't understand  - I tried to replicate the 
syntax from your e-mail but my computer just kept waiting - what am I still 
doing wrong?


  mctest - as.table(matrix(c(128,29,331,430), ncol =2, dimnames = 
list(group=c(preMHT,postMHT), assault=c(yes,no
  d - read.table(stdin())
0: mcnemar.test(as.matrix(d),correct=F)
1:

Thanks again

Bob


At 10:52 PM 26/12/2006 +0100, Peter Dalgaard wrote:
Bob Green wrote:
Hello,

I am hoping someone can clarify why I might obtain a quite different 
value in R  SPSS  for a McNemar test I ran.

Firstly, here is the R syntax  output


R OUTPUT

   mctest - as.table(matrix(c(128,29,331,430),
+ ncol =2, dimnames = list(group=c(preMHT,postMHT),
+ assault=c(yes,no

   mctest
assault
group   yes  no
preMHT  128 331
postMHT  29 430

mcnemar.test(mctest,correct=F)

  McNemar's Chi-squared test

data:  mctest
McNemar's chi-squared = 253.3444, df = 1, p-value  2.2e-16


SPSS OUTPUT

The same data was inputted in SPSS. Regarding the first table SPSS 
generated - it lists the number of cases in each combination of 
categories. The diagonal contains the number of cases with the same 
response on both variables, while the off diagonal contains cases that 
have different responses on the 2 variables. The overall chisquare value 
is much lower than the value obtained using R, though still significant.


pre02  post02

pre02   post02

  0   1
0   311 20
1   119 9


Test Statistics(b)

   pre02  post02

N   459
Chi-Square(a)   69.094
Asymp. Sig. .000

a  Continuity Corrected
b  McNemar Test


Any assistance is much appreciated,

Well, you can't expect R to give the correct result if you feed it the 
wrong matrix, can you?

d - read.table(stdin())

0:  0   1

1: 0   311 20

2: 1   119 9

3:
d

   X0 X1

0 311 20

1 119  9

mcnemar.test(as.matrix(d),correct=F)

McNemar's Chi-squared test

data:  as.matrix(d)
McNemar's chi-squared = 70.5108, df = 1, p-value  2.2e-16

mcnemar.test(as.matrix(d),correct=T)

McNemar's Chi-squared test with continuity correction

data:  as.matrix(d)
McNemar's chi-squared = 69.0935, df = 1, p-value  2.2e-16



Bob Green

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


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


Re: [R] McNemar test in R SPSS

2006-12-26 Thread Peter Dalgaard
Bob Green wrote:
 Peter,

 Thanks for your reply. To perform the analysis in R, I used the table 
 format suggested in the book by Everitt  Hothorn, whereas in SPSS the 
 analysis was performed directly from the 2 variables, rather than using 
 count data.
   
You still need the right table.

matrix(c(128,29,331,430), ncol =2,)

consists of the two marginal tables, which has strictly less information than 
the crosstabulation of pre and post values. I expect every text on the McNemar 
test makes this point, and I'd be highly surprised if EH really suggested that 
you should use the table that you did.

 There is still something I don't understand  - I tried to replicate the 
 syntax from your e-mail but my computer just kept waiting - what am I still 
 doing wrong?
   
You need to give it the data when it starts with the 0:-style prompt, 
end with a blank line, as shown. It's just a device for cutting and 
pasting your table. I might as well have used

d - matrix(c(311,119,20,9), ncol=2)

Or, with the raw data to hand

d - table(preMHT, postMHT)



   mctest - as.table(matrix(c(128,29,331,430), ncol =2, dimnames = 
 list(group=c(preMHT,postMHT), assault=c(yes,no
   d - read.table(stdin())
 0: mcnemar.test(as.matrix(d),correct=F)
 1:

 Thanks again

 Bob


 At 10:52 PM 26/12/2006 +0100, Peter Dalgaard wrote:
   
 Bob Green wrote:
 
 Hello,

 I am hoping someone can clarify why I might obtain a quite different 
 value in R  SPSS  for a McNemar test I ran.

 Firstly, here is the R syntax  output


 R OUTPUT

   mctest - as.table(matrix(c(128,29,331,430),
 + ncol =2, dimnames = list(group=c(preMHT,postMHT),
 + assault=c(yes,no

   mctest
assault
 group   yes  no
preMHT  128 331
postMHT  29 430

mcnemar.test(mctest,correct=F)

  McNemar's Chi-squared test

 data:  mctest
 McNemar's chi-squared = 253.3444, df = 1, p-value  2.2e-16


 SPSS OUTPUT

 The same data was inputted in SPSS. Regarding the first table SPSS 
 generated - it lists the number of cases in each combination of 
 categories. The diagonal contains the number of cases with the same 
 response on both variables, while the off diagonal contains cases that 
 have different responses on the 2 variables. The overall chisquare value 
 is much lower than the value obtained using R, though still significant.


 pre02  post02

 pre02   post02

  0   1
 0   311 20
 1   119 9


 Test Statistics(b)

   pre02  post02

 N   459
 Chi-Square(a)   69.094
 Asymp. Sig. .000

 a  Continuity Corrected
 b  McNemar Test


 Any assistance is much appreciated,

   
 Well, you can't expect R to give the correct result if you feed it the 
 wrong matrix, can you?

 
 d - read.table(stdin())
   
 0:  0   1

 1: 0   311 20

 2: 1   119 9

 3:
 
 d
   
   X0 X1

 0 311 20

 1 119  9

 
 mcnemar.test(as.matrix(d),correct=F)
   
McNemar's Chi-squared test

 data:  as.matrix(d)
 McNemar's chi-squared = 70.5108, df = 1, p-value  2.2e-16

 
 mcnemar.test(as.matrix(d),correct=T)
   
McNemar's Chi-squared test with continuity correction

 data:  as.matrix(d)
 McNemar's chi-squared = 69.0935, df = 1, p-value  2.2e-16



 
 Bob Green

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

   

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


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


[R] xyplot line colors

2006-12-26 Thread Osman Al-Radi
Hello,

I have a longitudinal data with about 30 subjects. I used xyplot() to plot
the longitudinal data. One problem is that xyplot() recycles the color of
auto.key so that every 7th subject has the same color (symbol if setps() was
used). Is there a way so that every subject will have a unique color or
symbol?

Thanks

Osman

-- 
Osman O. Al-Radi, MD, MSc, FRCSC
Fellow, Cardiovascular Surgery
The Hospital for Sick Children
University of Toronto, Canada

[[alternative HTML version deleted]]

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


Re: [R] xyplot line colors

2006-12-26 Thread Gabor Grothendieck
Set the colors yourself using the par.settings= argument of xyplot or
trellis.par.set.  See ?xyplot and ?trellis.par.set for more info.

If you follow the instructions on the last line of every post to r-help you
will get more detailed answers.

On 12/26/06, Osman Al-Radi [EMAIL PROTECTED] wrote:
 Hello,

 I have a longitudinal data with about 30 subjects. I used xyplot() to plot
 the longitudinal data. One problem is that xyplot() recycles the color of
 auto.key so that every 7th subject has the same color (symbol if setps() was
 used). Is there a way so that every subject will have a unique color or
 symbol?

 Thanks

 Osman

 --
 Osman O. Al-Radi, MD, MSc, FRCSC
 Fellow, Cardiovascular Surgery
 The Hospital for Sick Children
 University of Toronto, Canada

[[alternative HTML version deleted]]

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


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


Re: [R] Bayesian data mining

2006-12-26 Thread David Farrar
Frank,
   
  You might want to use a package that is associated with some textbook that 
can give you guidance and examples.  A lot of people would do this with 
WinBUGS, which is usually run separately although it has some kind of R 
interface.  I'm sure there are lots of nice texts about that package.  
   
  You might have a look at the bayesm package.  For that, you can find lots of 
examples in a text on Bayes in marketing (Rossi et al.) 
   
  David Farrar
  New River Analytic
  540-818-7373
   
  
Frank Grex [EMAIL PROTECTED] wrote:
  Hi, I need a help to know whether I can perform the following in R:
I have a set of observations (Ns) and each observation is drawn from a 
poisson distribution with an unkown mean, lambda. The set of lambdas in 
their turn are drawn from a common prior distribution which is supposed to 
be a a mixture of two gamma distributions.
Is there a way to determine the poisson means in R, given the Ns and the 
probabilities?
And how can one determine the two alphas and the two betas of the gamma 
mixtures? I am assuming there will be an MLE somewhere.
This is to help me understand and apply William DuMouchel concept of 
datamining especially in his article: Bayesian data mining in large 
frequency tables. Thanks

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


[[alternative HTML version deleted]]

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


[R] plotting time series with zoo pckg

2006-12-26 Thread ahmad ajakh
Hi all,

I am using the zoo package to plot time series. I have a problem with 
formatting the axes.
my zoo object (z) looks like the following.

c1  
1992-01-10 21 
1992-01-17 34 
1992-01-24 33  
1992-01-31 41 
1992-02-07 39 
1992-02-14 38 
1992-02-21 37
1992-02-28 28 
1992-03-06 33 
1992-03-13 40  

plot.zoo(z) produces a plot with the labels on the x-axis that I cannot control.
I want a an xtick every 10 data points with corresponding date labels.
I have tried different combination of axis command without success
any idea?
Thanks

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


Re: [R] plotting time series with zoo pckg

2006-12-26 Thread Gabor Grothendieck
Try this:


# test data
library(zoo)
z - structure(c(21, 34, 33, 41, 39, 38, 37, 28, 33, 40),
 index = structure(c(8044, 8051, 8058, 8065, 8072, 8079, 8086,
 8093, 8100, 8107), class = Date), class = zoo)
z

# plot without X axis
plot(z, xaxt = n)

# unlabelled tick at each point
axis(1, time(z), lab = FALSE)

# labelled tick every third point
dd - time(z)[seq(1, length(z), 3)]
axis(1, dd, as.character(dd), cex.axis = 0.7, tcl = -0.7)



On 12/26/06, ahmad ajakh [EMAIL PROTECTED] wrote:
 Hi all,

 I am using the zoo package to plot time series. I have a problem with 
 formatting the axes.
 my zoo object (z) looks like the following.

c1
 1992-01-10 21
 1992-01-17 34
 1992-01-24 33
 1992-01-31 41
 1992-02-07 39
 1992-02-14 38
 1992-02-21 37
 1992-02-28 28
 1992-03-06 33
 1992-03-13 40

 plot.zoo(z) produces a plot with the labels on the x-axis that I cannot 
 control.
 I want a an xtick every 10 data points with corresponding date labels.
 I have tried different combination of axis command without success
 any idea?
 Thanks

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


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


Re: [R] plotting time series with zoo pckg

2006-12-26 Thread ahmad ajakh
Dear Gabor,
Thank you for your quick reply.
This solution works for my univariate zoo class time series. I first tried
it for a timeseries with 4 columns of data, it did not plot the labels nor the
ticks, I tried it on a one dim timeseries (one column zoo class data as the 
example 
in the question) and it worked!  is there something that I am missing?
Thanks again.
AA.


- Original Message 
From: Gabor Grothendieck [EMAIL PROTECTED]
To: ahmad ajakh [EMAIL PROTECTED]
Cc: r-help@stat.math.ethz.ch
Sent: Tuesday, December 26, 2006 8:31:07 PM
Subject: Re: [R] plotting time series with zoo pckg

Try this:


# test data
library(zoo)
z - structure(c(21, 34, 33, 41, 39, 38, 37, 28, 33, 40),
 index = structure(c(8044, 8051, 8058, 8065, 8072, 8079, 8086,
 8093, 8100, 8107), class = Date), class = zoo)
z

# plot without X axis
plot(z, xaxt = n)

# unlabelled tick at each point
axis(1, time(z), lab = FALSE)

# labelled tick every third point
dd - time(z)[seq(1, length(z), 3)]
axis(1, dd, as.character(dd), cex.axis = 0.7, tcl = -0.7)



On 12/26/06, ahmad ajakh [EMAIL PROTECTED] wrote:
 Hi all,

 I am using the zoo package to plot time series. I have a problem with 
 formatting the axes.
 my zoo object (z) looks like the following.

c1
 1992-01-10 21
 1992-01-17 34
 1992-01-24 33
 1992-01-31 41
 1992-02-07 39
 1992-02-14 38
 1992-02-21 37
 1992-02-28 28
 1992-03-06 33
 1992-03-13 40

 plot.zoo(z) produces a plot with the labels on the x-axis that I cannot 
 control.
 I want a an xtick every 10 data points with corresponding date labels.
 I have tried different combination of axis command without success
 any idea?
 Thanks

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


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


Re: [R] writing to S-PLUS .dat file

2006-12-26 Thread ahmad ajakh
Hi Sebastian

try
save(x,y, file = filename.txt, ascii = TRUE)
where x, y are your R objects. You should read
?save
good luck
AA.

- Original Message 
From: Sebastian Michalski [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Monday, December 25, 2006 7:36:50 AM
Subject: [R] writing to S-PLUS .dat file

Dear Users,
I am new to R. I use write() to write my data in .txt format. I'd like 
to write to a disc any kind of data in a .dat S-PLUS format.
Please help.
SM

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

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


[R] how to transform string to variable name in a fuction?

2006-12-26 Thread jingjiangyan
there is a data frame, like this:
 df
  aa   bb
1  a 20.27802
2  b 22.10664
3  c 21.33470
4  a 22.32898
5  b 19.73760
6  c 20.38979
.(suppressed)
what I want to do is to copy the data frame's rows into different data frames 
according to the levels of 'aa' column, 
 df.a - df[df[,1]=='a',] ; df.b - df[df[,1]=='b',] ; 
 df.a
  aa   bb
1  a 20.27802
4  a 22.32898
...

So, when completed, there should be df.a, df.b,df.c, etc. 
If we could do this by hand, it is pretty fine.  But could I write a loop to do 
this ?
when I tried this using a funciton, there is a problem.

 for ( i in levels(df[,1])) {
+  name = paste('df',i,sep='')
+  name - df[df[,1]==i,]
+ }
 name
  aa   bb
3  c 21.33470
6  c 20.38979
 ls()
[1] df   iname
 i
[1] c
there is not data frames df.a, df.b,etc.

Could you please give me some suggestion?
I have found that write a function in R for a beginner is difficult. Is there  
any tutorial on writing the functions in R? 
Furthermore, someone also said that loop is not used as frequently as in other 
script language (e.g. bash, perl). So, If you have any other smart means do 
this more efficiently, please let me know, I would appreciate your kindness.

[[alternative HTML version deleted]]

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


Re: [R] how to transform string to variable name in a fuction?

2006-12-26 Thread Wensui Liu
try ?assign

On 12/26/06, jingjiangyan [EMAIL PROTECTED] wrote:
 there is a data frame, like this:
  df
   aa   bb
 1  a 20.27802
 2  b 22.10664
 3  c 21.33470
 4  a 22.32898
 5  b 19.73760
 6  c 20.38979
 .(suppressed)
 what I want to do is to copy the data frame's rows into different data frames 
 according to the levels of 'aa' column,
  df.a - df[df[,1]=='a',] ; df.b - df[df[,1]=='b',] ; 
  df.a
   aa   bb
 1  a 20.27802
 4  a 22.32898
 ...

 So, when completed, there should be df.a, df.b,df.c, etc.
 If we could do this by hand, it is pretty fine.  But could I write a loop to 
 do this ?
 when I tried this using a funciton, there is a problem.

  for ( i in levels(df[,1])) {
 +  name = paste('df',i,sep='')
 +  name - df[df[,1]==i,]
 + }
  name
   aa   bb
 3  c 21.33470
 6  c 20.38979
  ls()
 [1] df   iname
  i
 [1] c
 there is not data frames df.a, df.b,etc.

 Could you please give me some suggestion?
 I have found that write a function in R for a beginner is difficult. Is there 
  any tutorial on writing the functions in R?
 Furthermore, someone also said that loop is not used as frequently as in 
 other script language (e.g. bash, perl). So, If you have any other smart 
 means do this more efficiently, please let me know, I would appreciate your 
 kindness.

 [[alternative HTML version deleted]]

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



-- 
WenSui Liu
A lousy statistician who happens to know a little programming
(http://spaces.msn.com/statcompute/blog)

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


Re: [R] plotting time series with zoo pckg

2006-12-26 Thread Gabor Grothendieck
Please read the last line of every message to r-help and follow that.

On 12/26/06, ahmad ajakh [EMAIL PROTECTED] wrote:
 Dear Gabor,
 Thank you for your quick reply.
 This solution works for my univariate zoo class time series. I first tried
 it for a timeseries with 4 columns of data, it did not plot the labels nor the
 ticks, I tried it on a one dim timeseries (one column zoo class data as the 
 example
 in the question) and it worked!  is there something that I am missing?
 Thanks again.
 AA.


 - Original Message 
 From: Gabor Grothendieck [EMAIL PROTECTED]
 To: ahmad ajakh [EMAIL PROTECTED]
 Cc: r-help@stat.math.ethz.ch
 Sent: Tuesday, December 26, 2006 8:31:07 PM
 Subject: Re: [R] plotting time series with zoo pckg

 Try this:


 # test data
 library(zoo)
 z - structure(c(21, 34, 33, 41, 39, 38, 37, 28, 33, 40),
 index = structure(c(8044, 8051, 8058, 8065, 8072, 8079, 8086,
 8093, 8100, 8107), class = Date), class = zoo)
 z

 # plot without X axis
 plot(z, xaxt = n)

 # unlabelled tick at each point
 axis(1, time(z), lab = FALSE)

 # labelled tick every third point
 dd - time(z)[seq(1, length(z), 3)]
 axis(1, dd, as.character(dd), cex.axis = 0.7, tcl = -0.7)



 On 12/26/06, ahmad ajakh [EMAIL PROTECTED] wrote:
  Hi all,
 
  I am using the zoo package to plot time series. I have a problem with 
  formatting the axes.
  my zoo object (z) looks like the following.
 
 c1
  1992-01-10 21
  1992-01-17 34
  1992-01-24 33
  1992-01-31 41
  1992-02-07 39
  1992-02-14 38
  1992-02-21 37
  1992-02-28 28
  1992-03-06 33
  1992-03-13 40
 
  plot.zoo(z) produces a plot with the labels on the x-axis that I cannot 
  control.
  I want a an xtick every 10 data points with corresponding date labels.
  I have tried different combination of axis command without success
  any idea?
  Thanks
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 




 __
 Do You Yahoo!?
 Tired of spam?  Yahoo! Mail has the best spam protection around
 http://mail.yahoo.com


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


Re: [R] how to transform string to variable name in a fuction?

2006-12-26 Thread Gabor Grothendieck
In the following the components of ss are the data frames in question:

ss - split(df, df$aa)

On 12/26/06, jingjiangyan [EMAIL PROTECTED] wrote:
 there is a data frame, like this:
  df
  aa   bb
 1  a 20.27802
 2  b 22.10664
 3  c 21.33470
 4  a 22.32898
 5  b 19.73760
 6  c 20.38979
 .(suppressed)
 what I want to do is to copy the data frame's rows into different data frames 
 according to the levels of 'aa' column,
  df.a - df[df[,1]=='a',] ; df.b - df[df[,1]=='b',] ; 
  df.a
  aa   bb
 1  a 20.27802
 4  a 22.32898
 ...

 So, when completed, there should be df.a, df.b,df.c, etc.
 If we could do this by hand, it is pretty fine.  But could I write a loop to 
 do this ?
 when I tried this using a funciton, there is a problem.

  for ( i in levels(df[,1])) {
 +  name = paste('df',i,sep='')
 +  name - df[df[,1]==i,]
 + }
  name
  aa   bb
 3  c 21.33470
 6  c 20.38979
  ls()
 [1] df   iname
  i
 [1] c
 there is not data frames df.a, df.b,etc.

 Could you please give me some suggestion?
 I have found that write a function in R for a beginner is difficult. Is there 
  any tutorial on writing the functions in R?
 Furthermore, someone also said that loop is not used as frequently as in 
 other script language (e.g. bash, perl). So, If you have any other smart 
 means do this more efficiently, please let me know, I would appreciate your 
 kindness.

[[alternative HTML version deleted]]

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


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


Re: [R] McNemar test in R SPSS

2006-12-26 Thread Bob Green

Peter,

  I now see the original E  H table was based on matched pairs not the raw 
counts. I now understand this much better and have the syntax generates 
results that correspond with your results  (and SPSS),

Thanks again,

Bob

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


Re: [R] Rating competitors

2006-12-26 Thread Jeff Newmiller
Spencer Graves wrote:
  Have you considered Bradley-Terry models?   RSiteSearch(bradley, 
 functions) just returned 31 hits for me.
  Hope this helps.  Spencer Graves

Thanks to everyone who responded... this was very helpful. I have a bit of
reading and investigation to do.

I think the Bradley-Terry model is going to be sufficient for my purposes,
if I can figure out how to model handicaps.  The eba library mentioned by
Kubovy seems more complex than what I need now, but it does look interesting
and if I can obtain a copy of the Tversky paper I will read it.  The SIS
link mentioned by Berry didn't seem to have much, but the article on
Bridging Different Eras in Sports is quite interesting.

 Jeff Newmiller wrote:
 
 I am looking for hints on how to estimate ratings for competitors
 in an ongoing pairwise competition using R... my particular area of
 interest being the game of Go, but the idea of identifying ratings
 (on a continuous scale) rather than relative rankings seems easily
 generalized to other competitions so I thought someone might be
 studying something related already.

 I presume the rating of a competitor would be best modeled as a random
 variate on the rating scale, and an encounter between two
 competitors would be represented by a binary result.  Logistic regression
 seems promising, but I am at a loss how to represent the model since
 the pairings are arbitrary and not necessarily repeated often.

 I have read about some approaches to estimating ratings for Go,
 but they seem to involve optimization using assumed distributions
 rather than model fitting which characterizes analysis in R.

 Does any of this sound familiar? Suggestions for reading, anyone?

   
 
 


-- 
---
Jeff NewmillerThe .   .  Go Live...
DCN:[EMAIL PROTECTED]Basics: ##.#.   ##.#.  Live Go...
   Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k

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