Re: [R] how to multiply a constant to a matrix?

2006-05-24 Thread Michael
imagine when you have complicated matrix algebra computation using R,

you cannot prevent some middle-terms become quadratic and absorbs into one
scalar, right?

if R cannot intelligently determine this, and you  have to manually add
drop everywhere,

do you think it is reasonable?

On 5/23/06, Patrick Burns [EMAIL PROTECTED] wrote:

 I think

 drop(B/D) * solve(A)

 would be a more transparent approach.

 It isn't that R can not do what you want, it is that
 it is saving you from shooting yourself in the foot
 in your attempt.  What you are doing is not really
 a matrix computation.


 Patrick Burns
 [EMAIL PROTECTED]
 +44 (0)20 8525 0696
 http://www.burns-stat.com
 (home of S Poetry and A Guide for the Unwilling S User)

 Michael wrote:

 This is very strange:
 
 I want compute the following in R:
 
 g = B/D * solve(A)
 
 where B and D are  quadratics so they are just a scalar number, e.g.
 B=t(a)
 %*% F %*% a;
 
 I want to multiply B/D to A^(-1),
 
 but R just does not allow me to do that and it keeps complaining that
 nonconformable array, etc.
 
 
 I tried the following two tricks and they worked:
 
 as.numeric(B/D) * solve(A)
 
 diag(as.numeric(B/D), 5, 5) %*% solve (A)
 
 
 
 But if R cannot intelligently do scalar and matrix multiplication, it is
 really problemetic.
 
 It basically cannot be used to do computations, since in complicated
 matrix
 algebras, you have to distinguish where is scalar, and scalars obtained
 from
 quadratics cannot be directly used to multiply another matrix, etc. It is
 going to a huge mess...
 
 Any thoughts?
 
[[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
 
 
 
 


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


Re: [R] conditional replacement

2006-05-24 Thread Petr Pikal
Hi

if speed is critical you can use

(x=30x=60)*x+(x30)*30+(x60)*60

HTH
Petr


On 23 May 2006 at 16:34, Rogerio Porto wrote:

From:   Rogerio Porto [EMAIL PROTECTED]
To: Sachin J [EMAIL PROTECTED], 
R-help@stat.math.ethz.ch
Date sent:  Tue, 23 May 2006 16:34:04 -0300
Subject:Re: [R] conditional replacement

 Sachin,
 
 there's another slower but more flexible way than Gabor's solution:
 
 ifelse(x30,30,ifelse(x60,60,x))
 
 HTH,
 
 Rogerio.
 - Original Message - 
 From: Sachin J [EMAIL PROTECTED]
 To: R-help@stat.math.ethz.ch
 Sent: Tuesday, May 23, 2006 3:40 PM
 Subject: [R] conditional replacement
 
 
  Hi
 
   How can do this in R.
 
   df
 
   48
   1
   35
   32
   80
 
   If df  30  then replace it with 30 and else if df  60 replace it
   with 
  60. I have a large dataset so I cant afford to identify indexes and
  then replace.
   Desired o/p:
 
   48
   30
   35
   32
   60
 
   Thanx in advance.
 
  Sachin
  __
 
 
 
  [[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
 
 
 __
 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

Petr Pikal
[EMAIL PROTECTED]

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


Re: [R] problem with ad.test

2006-05-24 Thread Raymond Wan

Hi,

On Tue, 23 May 2006, Bhismadev Chakrabarti wrote:
 i am a novice and  have been trying to use the anderson-darling test
 on a simple text file with one column of data.
...
 EQ is the name ( in the top row of the column, imported with
 read.table( file, header=TRUE) of the column of the data.

Well, unfortunately, this is going to be a case of a novice giving 
advice to a novice as I'm just learning this too and was recently having 
problem with the normality tests.

The source of your problem is the read.table command and the data 
structure it creates.  I have never used it and am too lazy now to read 
about it for you.  :)  I've used the scan method instead, as follows:

 library(nortest)
 A - scan(tmp)
Read 9 items
 summary(A)
Min. 1st Qu.  MedianMean 3rd Qu.Max.
   1   3   5   5   7   9
 A
[1] 1 2 3 4 5 6 7 8 9
 ad.test(A)

 Anderson-Darling normality test

data:  A
A = 0.1368, p-value = 0.9606

Good luck!

Ray

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


Re: [R] normality testing with nortest

2006-05-24 Thread Raymond Wan

Hi all,

On Mon, 22 May 2006, Rolf Turner wrote:
   It is worth noting that if the null hypothesis is true, then
   the p-value is
   uniformly distributed on [0,1].
   This should be kept in mind when assessing the ``instability''
   of p-values.

Just wanted to thank everyone who participated in this thread for 
clarifying things for me.  I guess I knew bits and pieces but your 
messages put them together and gave me some R commands (which I am still 
new to) to check things myself.

Thanks a lot!

Ray

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


[R] Does R have EGARCH modeling function?

2006-05-24 Thread Michael
I've downloaded fSeries, but looks like it just has an interface to OX(TM)
Garch Modeling Software,and that OX(TM) software package is not free.

So where can I find an EGARCH function that is truely usable?

Thanks a lot!

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


[R] ASC/NZSA 2006 - Detailed Program Available via the Website

2006-05-24 Thread David Scott
Australian Statistical Conference / New Zealand Statistical
Association Conference
'Statistical Connections'
SKYCITY, Auckland, New Zealand
3 - 6 July 2006



LESS THAN TWO MONTHS TO GO

Register Online Now!





Register now for ASCNZ06 - an international conference with a full and
varied scientific program.



For up to date and detailed information on the 2006 Program visit:
http://www.statsnz2006.com/program.asp
http://www.statsnz2006.com/program.asp



ASC / NZSA 2006 with less than two months to go has attracted
substantial registrations to its outstanding scientific program
featuring ;



*  4 Plenary Sessions featuring leading international
speakers:

Professor David Donoho - Stanford University, Title: Sparsity in
Estimation and Detection

Professor Peter Hall  -   ANU, Title: PCA For FDA

Professor Ray Chambers - University of Southampton Title:  Models and
Auxiliary Information in Survey Sampling

Professor Xiao-Li Meng  - Harvard University Title: (Data) Size Does
Matter,  But You Might Be In for a Surprise ...



   25 Invited Speaker Sessions covering leading international and local
speakers featuring a wide range of topics in Statistical and Machine
Learning, Statistical Inference, Statistics in Ecology and the
Environment, Statistics in Biological Sciences and Medicine, Stochastic
Processes, Econometrics and Finance, Computational Statistics and High
Dimensional Data Modelling.



 Over 30 contributed paper sessions complementing the Plenary and
Invited Sessions



   A full day theme devoted  to Official Statistics starting with the
Foreman Lecture by Professor Ray Chambers, followed by an invited
session featuring   Professor Alastair Scott and Professor Kirk Wolter.
After lunch there will be an Official Statistics Forum featuring the New
Zealand Government Statistician Mr Brian Pink  and the Australian
Statistician  Mr Dennis Trewin, followed by a contributed session. Other
contributed sessions on various aspects of official statistics will be
held throughout the conference.



Also included in the conference program is a Young Statisticians
program



 Associated workshops on Distance Sampling, Stochastic Processes and
the R-Fest Workshops on R Graphics, S programming and Bioconductor.
Find out more on the workshops  at the following link
http://www.statsnz2006.com/workshop.asp
http://www.statsnz2006.com/workshop.asp





For information on Tours and Social events Please visit the website
http://www.statsnz2006.com/sprogram.asp
http://www.statsnz2006.com/sprogram.asp





We look forward to seeing you in Auckland!

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


[R] general Gauss-Newton or support for NSUR: contemporaneously correlated non-linear models

2006-05-24 Thread Thomas Wutzler
Dear r-Help readers,

1) Is there support for NSUR in some R package yet?
2) Is there a general function of applying the Gauss-Newton or Marquard 
method, in which the function of calculating the partial derivatives can 
be specified by the user?

Contemporaneously correlated non-linear models (NSUR) is a method to fit 
a system of non-linear equations.

I want to use to fit several non-linear models at the same time, so that 
one the independent variable is alsway the sum of several other 
independent variable of other models.
This procedure is described in detail by Parresol 2001. He used PROC 
MODEL by SAS to accomplish the task.

If there is no support for NSUR yet, I would try to program a function 
by myself, although I only used very simple R-functins yet. The 
essential part is the fit the minimum of complex vector equation. This 
leads to my second question above. The function (as provided as an 
parameter) should accept a vector of model parameters and calculate the 
matrix of partial derivatives at this point in the parameter space.


Thanks
Thomas

Parresol, B.R., 2001. Additivity of nonlinear biomass equations. 
Canadian Journal of Forest Research-Revue Canadienne De Recherche 
Forestiere 31, 865-878.

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


[R] Two functions with the same name

2006-05-24 Thread Ana Conesa

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


Re: [R] Two functions with the same name

2006-05-24 Thread Petr Pikal
Function written or loaded last will mask a function written or 
loaded before.

HTH
Petr

 PLEASE do read the posting guide!
^


On 24 May 2006 at 13:47, Ana Conesa wrote:

Date sent:  Wed, 24 May 2006 13:47:09 +0200
To: r-help@stat.math.ethz.ch
From:   Ana Conesa [EMAIL PROTECTED]
Subject:[R] Two functions with the same name

 
 __
 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

Petr Pikal
[EMAIL PROTECTED]

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


[R] data.frame

2006-05-24 Thread Sara Mouro
Dear all,

 

Does any one knows why should I get the following error message, when trying
to do a simple data.frame??

 

DataF-data.frame(Subject,BiomR,Spp,Capas,Litter,Herbs,LitterD,MaxCanH,DDifS
p,DSSp,Slope, CanDens,NearestSp)

 

Erro em data.frame(Subject, BiomR, Spp, Capas, Litter, Herbs, LitterD,  : 

arguments imply differing number of rows: 202, 0

 

 

The data I am using is:

 


Subject

BiomR

Spp

Capas

Litter

Herbs

LitterD

MaxCanH

DDifSp

DSSp

Slope

CanDens

NearestSp


1

140.74

Qfa

2

1.460

0

0.778

8

70

3.663

28

2.280

Ear


2

7.26

Aun

2

0.660

0

0.477

8

110

3.988

34

2.476

Ear


3

68.72

Qfa

2

1.019

0

1.000

8

48

2.300

48

2.476

Ear


4

0.13

Vti

2

1.719

0

0.903

4

55

4.141

28

3.258

Qco


5

2.32

Vti

2

1.719

0

0.954

4

65

3.984

32

3.051

Aun


6

2.97

Vti

2

1.719

0

0.954

6

201

3.642

22

2.000

Qfa


7

0.16

Qfa

2

1.238

2

0.778

6

72

3.105

20

1.566

Vti


8

1.76

Qfa

2

1.145

0

0.954

6

67

3.383

22

2.052

Vti


9

0.35

Qfa

3

1.092

2

0.778

6

65

3.557

30

2.106

Vti


10

0.15

Qfa

2

1.092

2

0.778

6

42

3.464

14

2.106

Vti


11

107.33

Qfa

3

1.145

5

0.903

8

147

4.035

24

2.220

Vti


12

12.32

Vti

3

1.145

5

1.000

6

208

3.464

28

2.220

Qfa


13

1.82

Vti

3

1.145

5

0.903

6

251

3.458

20

2.220

Qfa


14

1.84

Vti

1

1.019

5

0.602

6

88

3.960

28

1.363

Aun


15

3.25

Vti

2

1.719

0

0.778

6

70

4.319

14

2.621

Aun


16

3.60

Vti

1

1.460

0

0.954

6

53

4.186

26

1.902

Aun


17

0.69

Vti

2

1.238

5

0.845

4

184

3.856

44

2.547

Aun


18

1.04

Vti

1

1.019

5

0.602

4

144

3.911

32

2.052

Aun


19

0.08

Vti

2

1.460

0

0.699

6

93

3.956

36

2.547

Qco


20

10.43

Vti

2

1.145

5

0.903

6

70

3.919

23

3.258

Qco


21

0.69

Vti

3

1.145

5

0.845

8

120

4.023

30

3.051

Ear


22

13.47

Vti

3

1.460

2

0.811

8

39

3.370

42

3.152

Ear


23

2.83

Vti

2

1.019

5

0.845

6

120

4.102

24

3.258

Ear


24

1.26

Vti

2

1.019

5

0.903

6

153

4.116

30

3.152

Ear


25

0.25

Qfa

2

1.145

5

0.845

6

106

4.210

38

2.699

Qco


26

28.27

Vti

2

0.913

10

0.845

6

203

4.688

32

1.566

Qco


27

0.88

Vti

2

1.460

2

0.845

8

52

4.464

30

3.051

Qfa


28

0.08

Vti

2

1.311

0

0.477

8

86

4.486

48

2.956

Qfa


29

1.13

Vti

3

1.019

5

0.845

8

54

4.291

40

3.492

Qfa


30

11.03

Vti

2

0.821

0

0.903

4

130

4.606

42

2.699

Ear


31

0.63

Vti

2

0.821

5

0.845

4

130

4.464

44

2.699

Ear


32

0.97

Vti

2

0.737

0

0.845

4

123

4.562

34

2.699

Ear


33

4.94

Vti

2

0.737

0

0.903

4

123

4.522

48

2.699

Ear


34

2.26

Vti

2

0.821

5

0.778

4

114

4.478

46

2.699

Ear


35

0.94

Vti

2

0.660

0

0.903

4

144

4.516

31

2.699

Ear


36

0.69

Vti

2

0.589

0

0.699

4

146

4.551

35

2.699

Ear


37

0.13

Vti

3

1.019

0

0.845

8

48

4.362

14

2.343

Qfa


38

2.12

Vti

2

0.737

0

1.041

8

52

4.054

24

2.956

Qfa


39

1.77

Vti

2

0.913

0

0.903

8

56

5.198

6

2.621

Ear


40

0.32

Vti

2

1.145

5

0.954

8

118

5.138

35

3.258

Ear


41

0.11

Vti

2

1.019

0

0.602

8

84

5.237

20

2.621

Ear


42

1.57

Vti

1

0.913

0

0.954

6

137

5.038

12

3.492

Qco


43

1.77

Vti

3

0.737

0

0.954

6

141

5.026

16

3.371

Qco


44

0.17

Vti

2

0.913

0

1.000

8

69

4.901

24

3.258

Qco


45

0.41

Vti

3

1.092

2

0.954

8

81

5.129

44

4.457

Qfa


46

2.62

Vti

1

0.913

0

0.845

4

114

5.047

34

4.457

Ear


47

0.09

Vti

3

0.975

2

0.954

8

98

4.924

20

3.492

Aun


48

0.12

Vti

4

1.311

5

0.845

8

78

4.748

26

3.761

Aun


49

1.70

Vti

3

0.975

2

1.000

8

95

5.146

36

4.457

Qfa


50

14.49

Qfa

1

1.719

0

0.778

6

37

2.962

32

1.766

Pan


51

0.09

Vti

2

1.311

0

0.778

6

56

2.872

20

1.950

Pan


52

2.12

Qfa

2

1.460

0

0.845

6

203

3.097

18

3.152

Vti


53

0.23

Qfa

2

1.238

2

0.778

8

86

2.190

30

2.476

Ear


54

5.36

Qfa

2

0.975

0

0.954

6

134

3.409

42

4.684

Vti


55

0.41

Vti

2

1.145

5

0.845

6

108

3.890

36

4.945

Qco


56

0.19

Vti

1

1.719

0

0.845

6

42

4.130

35

3.492

Qco


57

15.59

Vti

3

1.719

0

1.114

6

91

4.386

16

4.257

Ear


58

3.25

Vti

3

1.719

0

0.903

6

85

4.275

36

4.257

Ear


59

2.32

Vti

3

1.460

0

0.954

6

91

4.223

32

4.257

Ear


60

4.24

Vti

3

1.719

0

1.041

6

36

4.386

42

4.257

Ear


61

31.49

Vti

3

1.719

0

1.176

6

78

4.371

43

4.257

Ear


62

2.97

Vti

3

0.786

2

0.954

6

71

3.988

22

4.076

Qco


63

0.50

Vti

3

0.706

2

0.903

6

76

4.134

20

4.076

Qco


64

20.20

Vti

2

1.719

0

1.079

6

62

3.557

18

5.640

Qfa


65

0.12

Vti

1

1.460

0

0.903

6

75

3.186

20

3.152

Qfa


66

0.10

Vti

1

1.719

0

0.903

6

90

3.154

20

3.152

Qfa


67

0.79

Vti

1

1.719

0

0.954

6

64

3.154

12

3.152

Ear


68

0.17

Vti

1

1.719

0

0.954

6


Re: [R] data.frame

2006-05-24 Thread Petr Pikal
Hi

Your arguments has different length and therefore the error message

data.frame is an object, which resembles a table from Excel, it has 
the same number of rows in each column

From help page:
A data frame, a matrix-like structure whose columns may be of 
differing types (numeric, logical, factor and character and so on).

 x1-1:5
 x2-1:3
 x3-1:10
 data.frame(x1,x2,x3)
Error in data.frame(x1, x2, x3) : arguments imply differing number of 
rows: 5, 3, 10

So you can recycle shorter vectors

data.frame(cbind(x1,x2,x3))

or you can use list
list(x1,x2,x3)

I wonder how did you created your arguments?

HTH
Petr



On 24 May 2006 at 13:05, Sara Mouro wrote:

From:   Sara Mouro [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Date sent:  Wed, 24 May 2006 13:05:45 +0100
Subject:[R] data.frame

 Dear all,
 
 
 
 Does any one knows why should I get the following error message, when
 trying to do a simple data.frame??
 
 
 
 DataF-data.frame(Subject,BiomR,Spp,Capas,Litter,Herbs,LitterD,MaxCanH
 ,DDifS p,DSSp,Slope, CanDens,NearestSp)
 
 
 
 Erro em data.frame(Subject, BiomR, Spp, Capas, Litter, Herbs, LitterD,
  : 
 
 arguments imply differing number of rows: 202, 0
 
 
 
 
 
 The data I am using is:
 
 
 
 
 Subject
 
 BiomR
 
 Spp
 
 Capas
 
 Litter
 
 Herbs
 
 LitterD
 
 MaxCanH
 
 DDifSp
 
 DSSp
 
 Slope
 
 CanDens
 
 NearestSp
 
 
 1
 
 140.74
 
 Qfa
 
 2
 
 1.460
 
 0
 
 0.778
 
 8
 
 70
 
 3.663
 
 28
 
 2.280
 
 Ear
 
 
 2
 
 7.26
 
 Aun
 
 2
 
 0.660
 
 0
 
 0.477
 
 8
 
 110
 
 3.988
 
 34
 
 2.476
 
 Ear
 
 
 3
 
 68.72
 
 Qfa
 
 2
 
 1.019
 
 0
 
 1.000
 
 8
 
 48
 
 2.300
 
 48
 
 2.476
 
 Ear
 
 
 4
 
 0.13
 
 Vti
 
 2
 
 1.719
 
 0
 
 0.903
 
 4
 
 55
 
 4.141
 
 28
 
 3.258
 
 Qco
 
 
 5
 
 2.32
 
 Vti
 
 2
 
 1.719
 
 0
 
 0.954
 
 4
 
 65
 
 3.984
 
 32
 
 3.051
 
 Aun
 
 
 6
 
 2.97
 
 Vti
 
 2
 
 1.719
 
 0
 
 0.954
 
 6
 
 201
 
 3.642
 
 22
 
 2.000
 
 Qfa
 
 
 7
 
 0.16
 
 Qfa
 
 2
 
 1.238
 
 2
 
 0.778
 
 6
 
 72
 
 3.105
 
 20
 
 1.566
 
 Vti
 
 
 8
 
 1.76
 
 Qfa
 
 2
 
 1.145
 
 0
 
 0.954
 
 6
 
 67
 
 3.383
 
 22
 
 2.052
 
 Vti
 
 
 9
 
 0.35
 
 Qfa
 
 3
 
 1.092
 
 2
 
 0.778
 
 6
 
 65
 
 3.557
 
 30
 
 2.106
 
 Vti
 
 
 10
 
 0.15
 
 Qfa
 
 2
 
 1.092
 
 2
 
 0.778
 
 6
 
 42
 
 3.464
 
 14
 
 2.106
 
 Vti
 
 
 11
 
 107.33
 
 Qfa
 
 3
 
 1.145
 
 5
 
 0.903
 
 8
 
 147
 
 4.035
 
 24
 
 2.220
 
 Vti
 
 
 12
 
 12.32
 
 Vti
 
 3
 
 1.145
 
 5
 
 1.000
 
 6
 
 208
 
 3.464
 
 28
 
 2.220
 
 Qfa
 
 
 13
 
 1.82
 
 Vti
 
 3
 
 1.145
 
 5
 
 0.903
 
 6
 
 251
 
 3.458
 
 20
 
 2.220
 
 Qfa
 
 
 14
 
 1.84
 
 Vti
 
 1
 
 1.019
 
 5
 
 0.602
 
 6
 
 88
 
 3.960
 
 28
 
 1.363
 
 Aun
 
 
 15
 
 3.25
 
 Vti
 
 2
 
 1.719
 
 0
 
 0.778
 
 6
 
 70
 
 4.319
 
 14
 
 2.621
 
 Aun
 
 
 16
 
 3.60
 
 Vti
 
 1
 
 1.460
 
 0
 
 0.954
 
 6
 
 53
 
 4.186
 
 26
 
 1.902
 
 Aun
 
 
 17
 
 0.69
 
 Vti
 
 2
 
 1.238
 
 5
 
 0.845
 
 4
 
 184
 
 3.856
 
 44
 
 2.547
 
 Aun
 
 
 18
 
 1.04
 
 Vti
 
 1
 
 1.019
 
 5
 
 0.602
 
 4
 
 144
 
 3.911
 
 32
 
 2.052
 
 Aun
 
 
 19
 
 0.08
 
 Vti
 
 2
 
 1.460
 
 0
 
 0.699
 
 6
 
 93
 
 3.956
 
 36
 
 2.547
 
 Qco
 
 
 20
 
 10.43
 
 Vti
 
 2
 
 1.145
 
 5
 
 0.903
 
 6
 
 70
 
 3.919
 
 23
 
 3.258
 
 Qco
 
 
 21
 
 0.69
 
 Vti
 
 3
 
 1.145
 
 5
 
 0.845
 
 8
 
 120
 
 4.023
 
 30
 
 3.051
 
 Ear
 
 
 22
 
 13.47
 
 Vti
 
 3
 
 1.460
 
 2
 
 0.811
 
 8
 
 39
 
 3.370
 
 42
 
 3.152
 
 Ear
 
 
 23
 
 2.83
 
 Vti
 
 2
 
 1.019
 
 5
 
 0.845
 
 6
 
 120
 
 4.102
 
 24
 
 3.258
 
 Ear
 
 
 24
 
 1.26
 
 Vti
 
 2
 
 1.019
 
 5
 
 0.903
 
 6
 
 153
 
 4.116
 
 30
 
 3.152
 
 Ear
 
 
 25
 
 0.25
 
 Qfa
 
 2
 
 1.145
 
 5
 
 0.845
 
 6
 
 106
 
 4.210
 
 38
 
 2.699
 
 Qco
 
 
 26
 
 28.27
 
 Vti
 
 2
 
 0.913
 
 10
 
 0.845
 
 6
 
 203
 
 4.688
 
 32
 
 1.566
 
 Qco
 
 
 27
 
 0.88
 
 Vti
 
 2
 
 1.460
 
 2
 
 0.845
 
 8
 
 52
 
 4.464
 
 30
 
 3.051
 
 Qfa
 
 
 28
 
 0.08
 
 Vti
 
 2
 
 1.311
 
 0
 
 0.477
 
 8
 
 86
 
 4.486
 
 48
 
 2.956
 
 Qfa
 
 
 29
 
 1.13
 
 Vti
 
 3
 
 1.019
 
 5
 
 0.845
 
 8
 
 54
 
 4.291
 
 40
 
 3.492
 
 Qfa
 
 
 30
 
 11.03
 
 Vti
 
 2
 
 0.821
 
 0
 
 0.903
 
 4
 
 130
 
 4.606
 
 42
 
 2.699
 
 Ear
 
 
 31
 
 0.63
 
 Vti
 
 2
 
 0.821
 
 5
 
 0.845
 
 4
 
 130
 
 4.464
 
 44
 
 2.699
 
 Ear
 
 
 32
 
 0.97
 
 Vti
 
 2
 
 0.737
 
 0
 
 0.845
 
 4
 
 123
 
 4.562
 
 34
 
 2.699
 
 Ear
 
 
 33
 
 4.94
 
 Vti
 
 2
 
 0.737
 
 0
 
 0.903
 
 4
 
 123
 
 4.522
 
 48
 
 2.699
 
 Ear
 
 
 34
 
 2.26
 
 Vti
 
 2
 
 0.821
 
 5
 
 0.778
 
 4
 
 114
 
 4.478
 
 46
 
 2.699
 
 Ear
 
 
 35
 
 0.94
 
 Vti
 
 2
 
 0.660
 
 0
 
 0.903
 
 4
 
 144
 
 4.516
 
 31
 
 2.699
 
 Ear
 
 
 36
 
 0.69
 
 Vti
 
 2
 
 0.589
 
 0
 
 0.699
 
 4
 
 146
 
 4.551
 
 35
 
 2.699
 
 Ear
 
 
 37
 
 0.13
 
 Vti
 
 3
 
 1.019
 
 0
 
 0.845
 
 8
 
 48
 
 4.362
 
 14
 
 2.343
 
 Qfa
 
 
 38
 
 2.12
 
 Vti
 
 2
 
 0.737
 
 0
 
 1.041
 
 8
 
 52
 
 4.054
 
 24
 
 2.956
 
 Qfa
 
 
 39
 
 1.77
 
 Vti
 

Re: [R] Two functions with the same name

2006-05-24 Thread Petr Pikal
Hi

you probably created the second function in .Global Environment e.g. 
directly in console. 
see 
ls() 
and look for the name of the function. If it is there the only way I 
know about is to remove the function from environment by

rm(name.of.the.function)

then the masked function shall by usable again provided that you did 
not detached the package.

Probably there is some way through environment() but I never used it 
and therefore I can not help you other way than to encourage to read 
its help page.

HTH
Petr



On 24 May 2006 at 14:33, Ana Conesa wrote:

To: Petr Pikal [EMAIL PROTECTED]
From:   Ana Conesa [EMAIL PROTECTED]
Subject:Re: [R] Two functions with the same name

 
 At 14:04 24/05/2006, you wrote:
 Function written or loaded last will mask a function written or
 loaded before.
 
 
 Petr,
 Thanks for your answer. I know that. What I was asking is the way to
 go back to the function loaded in the first place, since I need it
 again. Re-loading the first package does not work for me. 
 
 Ana
 
 
 
 HTH
 Petr
 
  PLEASE do read the posting guide!
 ^
 
 
 On 24 May 2006 at 13:47, Ana Conesa wrote:
 
 Date sent:Wed, 24 May 2006 13:47:09 +0200
 To: r-help@stat.math.ethz.ch
 From:Ana Conesa [EMAIL PROTECTED]
 Subject:[R] Two functions with the same name
 
  
  __
  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
 
 Petr Pikal
 [EMAIL PROTECTED]
 
 
 O @ Ana Conesa, PhD.
 @@@ O @@ O @ Centro de Genómica
 @ O  O @ Instituto Valenciano de Investigaciones Agrarias (IVIA)
 @@@ O  Carretera Moncada - Naquera, Km. 4,5  O @ 46113 Moncada
 (Valencia) SPAIN || Tel. +34 963424000 ext.70161; Fax. +34 963424001
 || email: [EMAIL PROTECTED]
 
 

Petr Pikal
[EMAIL PROTECTED]

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


[R] median of a survfit object

2006-05-24 Thread David Hajage
 Hello R users !

Here a survfit object :

library(survival)

essai - aml[aml$x == Maintained,]

calc - survfit(Surv(essai$time, 1 - essai$status))

calc

Call: survfit(formula = Surv(essai$time, 1 - essai$status))

  n  events  median 0.95LCL 0.95UCL
 11   4 103  28 Inf
I would like to get the median of the object calc...
For example,

med - calc$median

But it doesn't work... How can I do this ?

-- 
David


-- 
David

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


Re: [R] Cross correlation/ bivariate/ mantel

2006-05-24 Thread Marcelino de la Cruz


McClatchie, Sam (PIRSA-SARDI mcclatchie.sam at saugov.sa.gov.au writes:


  Colleagues
  
   I have two spatial datasets (latitude, longitude, fish eggs) and 
(latitude, longitude, fish larvae) at
 the same 280 stations (i.e. 280 cases). I want to determine if the 2 datasets 
are spatially correlated. In
 other words, do high numbers of larvae occur where there are high numbers of 
eggs? I would like to calculate
 the cross correlation for these bivariate data and calculate a Mantel 
statistic as described on pg. 147 of
 Fortin and Dale 2005 Spatial analysis.
 

Package ade4 has mantel.randtest  and package vegan has mantel . Both functions 
find the Mantel statistic. If you need partial Mantel statistic, you can try 
partial.mantel in vegan or this code that I contributed some time ago:

https://stat.ethz.ch/pipermail/r-help/2003-September/038985.html



Marcelino de la Cruz
Departamento de Biologia Vegetal
Universidad Politecnica de Madrid
Spain

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


[R] data transformation

2006-05-24 Thread gabriela escati peñaloza
Hi,
I have great problems with my work in R.
I look for to model the growth of fish.
I have Longitudinal data, a serie of repeated
measures for each individual.
Using the corresponding packages nlme in R.
I treat to fit to the data different growth functions,
wich were entered by me.
Unfortunately for no it was arrived at the
convergence, several error messages appeared.

I am going to display the growth functions so as they
were entered and a nlme call example:

# differents growth function

#vonBertlalanffy
vonBert- function(x, Linf, K, t0)
Linf*(1-exp(-K*(x-t0)))

size ~ vonBert(age, Linf, K,t0)

vonBert -deriv(~ Linf*(1-exp(-K*(x-t0))), 
  c(Linf,K,t0),function(x,Linf,K,t0){})

vonBertInit -  function(mCall, LHS, data)
  {
xy - sortedXyData(mCall[[x]], LHS, data)
Linf - 900
if (Linf != max(xy[,y])) Linf - -Linf
K - 0.3
t0-0
value - c(Linf, K, t0)
names(value) - mCall[c(Linf, K,t0)]
value
 }

vonBert - selfStart(vonBert, initial = vonBertInit)

class(vonBert)


#Richards
Rich - function(x, Linf, K, t0, m)
Linf*(1-exp(-K*(x-t0)))^(1/(1-m))

size ~ Rich(age, Linf, K, t0, m)
 
Rich -deriv(~ Linf*(1-exp(-K*(x-t0)))^(1/(1-m)), 
 
c(Linf,K,t0,m),function(x,Linf,K,t0,m){})

RichInit -  function(mCall, LHS, data)
  {
xy - sortedXyData(mCall[[x]], LHS, data)
Linf - 900
if (Linf != max(xy[,y])) Linf - -Linf
K - 0.3
t0-0
m - 0.3
value - c(Linf, K, t0, m)
names(value) - mCall[c(Linf, K,t0,m)]
value
 }

Rich - selfStart(Rich, initial = RichInit)

class(Rich)

#call
Rich.nlme - nlme(size ~ Rich(age, Linf, K, t0, m),
data = L.gd,
fixed = Linf + K +t0 +m~ 1,
  start = list(fixed = c(900, 0.3,-3,0.9)))

#error message
Error: Singularity in backsolve at level 0, block 1
In addition: Warning message:
NaNs produced in: log(x)


What is the problem? I do not understand that it is
what is bad: the data, the entered growth functions,
some specification...
I will thank for any contribution of information.


Lic. Gabriela Escati Peñaloza
Biología y Manejo de Recursos Acuáticos
Centro Nacional Patagónico(CENPAT). 
CONICET
Bvd. Brown s/nº.
(U9120ACV)Pto. Madryn 
Chubut
Argentina

Tel: 54-2965/451301/451024/451375/45401 (Int:277)
Fax: 54-29657451543



_ 
Horóscopos, Salud y belleza, Chistes, Consejos de amor: 
el contenido más divertido para tu celular está en Yahoo! Móvil. 
Obtenelo en http://movil.yahoo.com.ar

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


Re: [R] median of a survfit object

2006-05-24 Thread Heinz Tuechler
see: [R] How to access results of survival analysis Xiaochun Li (06 May 2006)

At 15:03 24.05.2006 +0200, David Hajage wrote:
 Hello R users !

Here a survfit object :

library(survival)

essai - aml[aml$x == Maintained,]

calc - survfit(Surv(essai$time, 1 - essai$status))

calc

Call: survfit(formula = Surv(essai$time, 1 - essai$status))

  n  events  median 0.95LCL 0.95UCL
 11   4 103  28 Inf
I would like to get the median of the object calc...
For example,

med - calc$median

But it doesn't work... How can I do this ?

-- 
David


-- 
David

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



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


Re: [R] median of a survfit object

2006-05-24 Thread David Hajage
It works ! thank you !

2006/5/24, Heinz Tuechler [EMAIL PROTECTED]:

 see: [R] How to access results of survival analysis Xiaochun Li (06 May
 2006)

 At 15:03 24.05.2006 +0200, David Hajage wrote:
  Hello R users !
 
 Here a survfit object :
 
 library(survival)
 
 essai - aml[aml$x == Maintained,]
 
 calc - survfit(Surv(essai$time, 1 - essai$status))
 
 calc
 
 Call: survfit(formula = Surv(essai$time, 1 - essai$status))
 
   n  events  median 0.95LCL 0.95UCL
  11   4 103  28 Inf
 I would like to get the median of the object calc...
 For example,
 
 med - calc$median
 
 But it doesn't work... How can I do this ?
 
 --
 David
 
 
 --
 David
 
[[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
 
 




-- 
David

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


Re: [R] dendrogram plotting problem

2006-05-24 Thread Marcelino de la Cruz
j.joshua thomas researchjj at gmail.com writes:

 
 Dear List
 
 RGui Version : 2.3.0
 User : 1 month
 
 I am having the *dendrogram plotting problem *
 
 The code i tried:
 
 library(cluster)
  DD-DataSetS01022  # 575 x 2 matrix
  VC-hclust(dist(DD),ave)
 *Warning message:
 NAs introduced by coercion* ( what does it mean? Is that the problem?)
  
  plot(VC,hang=-2)
 
 Output: http://roughjade.blogspot.com


I think the problem is ploting too many branches (575) in the same dendrogram.

You may consider reading help(dendrogram) to find alternative ways of 
visualizing such huge amount of data.
I would try something like 

   VCd-as.dendrogram(VC)
   plot(VCd, nodePar=list(pch = c(NA,NA), cex=0.8, lab.cex = 0.01))

and use a  magnifying glass to se the labels ;)

or better

   VCd2 - cut(VCd, h=5)
   plot(VCd2$upper) #to visualize the general structure of the dendrogram

and then

   plot(VCd 2$lower[[1]])
   plot(VCd 2$lower[[2]])
   plot(VCd 2$lower[[3]])
   ...
 etc, to visualize every branch.



Marcelino de la Cruz 
Departamento de Biologia Vegetal
Universidad Politecnica de Madrid

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


Re: [R] data.frame

2006-05-24 Thread P Ehlers
Sara,

You didn't read your data into R correctly.

If your data are really in the form you posted (one long column
of mixed data types and lots of blank lines), then I would:

1. remove the blank lines with my text editor and save (say, mydata.txt)

2. scan() the variable names into a vector

  nm - scan(mydata.txt, what = , nlines = 13)

3. scan() the data values into a list

  x - scan(mydata.txt,
what = list(0,0,,0,0,0,0,0,0,0,0,0,),
skip = 13)

4. attach the names

  names(x) - nm

5. convert to data frame

  DF - data.frame(x)

(You really shouldn't post your whole data set; a couple of records
would have been sufficient.)

Peter Ehlers


Sara Mouro wrote:
 Dear all,
 
  
 
 Does any one knows why should I get the following error message, when trying
 to do a simple data.frame??
 
  
 
 DataF-data.frame(Subject,BiomR,Spp,Capas,Litter,Herbs,LitterD,MaxCanH,DDifS
 p,DSSp,Slope, CanDens,NearestSp)
 
  
 
 Erro em data.frame(Subject, BiomR, Spp, Capas, Litter, Herbs, LitterD,  : 
 
 arguments imply differing number of rows: 202, 0
 
  
 
  
 
 The data I am using is:
 
  
 
 
 Subject
 
 BiomR
 
 Spp
 
 Capas
 
 Litter
 
 Herbs
 
 LitterD
 
 MaxCanH
 
 DDifSp
 
 DSSp
 
 Slope
 
 CanDens
 
 NearestSp
 
 
 1
 
 140.74
 
 Qfa
 
 2
 
 1.460
 
 0
 
 0.778
 
 8
 
 70
 
 3.663
 
 28
 
 2.280
 
 Ear
 
 
 2
 
 7.26
 
 Aun
 
 2
 
 0.660
 
 0
 
 0.477
 
 8
 
 110
 
 3.988
 
 34
 
 2.476
 
 Ear


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


Re: [R] glmmADMB and the GPL -- formerly-- How to buy R.

2006-05-24 Thread Marc Schwartz
On Tue May 23 18:01:03 CEST 2006 Dave Fourier wrote: 
 Dear List,
 
 Some of you have been following the discussion of the GPL and its inclusion
 in the glmmADMB package we created for R users. I would like to provide 
 a bit of background and include an email we received from
 Prof. Ripley so that everyone can be aware of how some might use the
 GPL to try to force access to proprietary software. I think this is 
 interesting because many have voiced the opinion about the benign nature 
 of the GPL and that commercial enterprises who avoid it do so mainly out 
 of ignorance.
 
 I have noticed two things:
 Users of the R-help list appear to rely largely on the advice of a
 rather small number of statistical experts. Second, the R users regard R 
 as being more cutting edge and up to date than lists devoted to 
 commercial statistical packages like SAS.
 
 For these reasons  I was surprised to see the following post on the web 
 in reply to a question on negative binomial mixed models.
 
  https://stat.ethz.ch/pipermail/r-help/2005-February/066146.html
 
 I thought that this was bad advice as certainly our ADMB-RE software 
 could handle this problem easily.  However one never knows exactly what 
 sort of data people might use in a particular example that could lead to
 difficulties so I decided to code up a program that R users could test 
 for this problem.  However R users are used to a different approach for 
 model formulation so that it was difficult for the average R user to 
 access the program. I approached Anders Nielsen who is both an 
 experienced ADMB user and R user and asked him to write an interface in 
 R which would make the program more accessible to R users. He created a 
 package and the whole thing seems to have had some success with at least 
 one PhD thesis based on calculations using it. The R code that Anders
 wrote is simply an interface which takes the R specification for the 
 model and outputs a data file in the format the an ADMB program expects.
 The ADMB program is a stand alone exe. The R script then reads the ADMB 
 output files and presents the results to the user in a more familiar R
 format. Now it appears at some revision someone put a GPL notice on this 
 package although Anders states that he did not do so, and and he is 
 certain that it was not originally included by him. In any event the R 
 script is easily extracted from the package by those who know how to do 
 so and we have no problem with making the ADMB-RE source to the  exe 
 (TPL file) available. In fact the original was on our web site but was 
 modified as we made to program more robust to deal with difficult data 
 sets.  The compiled TPL file links with our proprietary libraries and we 
 have no intention of providing the source for these, but that is exactly 
 what Prof. Ripley seems to be demanding since he claims that he wants 
 the program to run on his computer which it apparently does not do at 
 present. Prof. Ripley seems to feel that he is a qualified spokesman for 
 the open source community. I have no idea what the community at large 
 feels about this.
 
 What follows is Hans Skaug's post with Prof. Ripley's reply.
 
   On Mon, 22 May 2006, H. Skaug wrote:
  
About glmmADMB and GPL:
   
We were not very cautious when we put in the GPL statement.
What we wanted to say was that the use of glmmADMB is free, and
does not require a license for AD Model Builder.
  
   But that is not what you said, and you are legally and morally bound to
   fulfill the promise you made.
  
Am I correct in interpreting this discussion so that all
we have to do is to remove the License: GPL statement
from the DESCRIPTION file (and everywhere else it may occur),
and there will be no conflict between glmmADMB and the
rules of the R community?
  
   I have made a request under the GPL. `All' you have to do is to fulfill
   it.
  
We have temporarily withdrawn glmmADMB until this question has been
settled.
  
   You can withdraw the package, but it has already been distributed under
   GPL, and those who received it under GPL have the right to 
 redistribute it
   under GPL, including the sources you are obliged to give them.  That's
   part of the `freedom' that GPL gives.
  
hans
   
   
   
Brian Ripley wrote:
   
The issue in the glmmADMB example is not if they were required 
 to release
it under GPL (my reading from the GPL FAQ is that they probably 
 were not,
given that communication is between processes and the R code is
interpreted).
   
Rather, it is stated to be under GPL _but_ there is no source 
 code offer
for the executables (and the GPL FAQ says that for anonymous FTP 
 it should
be downloadable via the same site, and the principles apply 
 equally to
HTTP sites).  As the executables are not for my normal OS and I 
 would like
to exercise my freedom to try the GPLed code, I have requested 
 the sources

Re: [R] multiple plots with par mfg

2006-05-24 Thread Yan Wong

On 23 May 2006, at 21:47, Romain Francois wrote:

 Hi,

 An other possibility might be to use two devices and use dev.set to  
 go from one to another :

Thanks. Actually I did try that, but there are quite a lot of points  
to plot, and the switching between plots slowed the whole simulation  
down a bit.

Thanks too to Henrik Bengtsson for the code snippet. I've managed to  
get it working now, using par(mfg).

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


[R] converting hexadecimal

2006-05-24 Thread Romain Lorrilliere
Hi,

do you know, a method to convert an hexadecimal value to the 
corresponding integer value (decimal) ?

thinks for help.

Romain

-- 

Lorrillière Romain

 

UMR 8079 Laboratoire Ecologie, Systématique et Evolution

Bât. 362

Université Paris-Sud

91405 Orsay cedex

France

 

tel : 01 69 15 56 85

fax : 01 69 15 56 96

mobile : 06 81 70 90 70

 

email : [EMAIL PROTECTED]

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


[R] How to make attributes persist after indexing?

2006-05-24 Thread Heinz Tuechler
Dear All!

For descriptive purposes I would like to add attributes to objects. These
attributes should be kept, even if by indexing only part of the object is
used.
I noted that some attributes like levels and class of a factor exist also
after indexing, while others, like comment or label vanish.
Is there a way to make an arbitrary attribute to be kept after indexing?
This would be especially useful when indexing a data.frame.

## example for loss of attributes
fx - factor(1:5, ordered=TRUE)
attr(fx, 'comment') - 'Comment for fx'
attr(fx, 'label') - 'Label for fx'
attr(fx, 'testattribute') - 'just for fun'
attributes(fx)  # all attributes are shown
attributes(fx[])# all attributes are shown
attributes(fx[1:5]) # only levels and class are shown
attributes(fx[1])   # only levels and class are shown

Thanks,

Heinz Tüchler

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


Re: [R] How to make attributes persist after indexing?

2006-05-24 Thread Gabor Grothendieck
You could create your own child class with its own [ method.

[.myfactor - function(x, ...) {
   attr - attributes(x)
   x - NextMethod([)
   attributes(x) - attr
   x
}

gx - structure(fx, class = c(myfactor, class(fx)))
attributes(gx[1])


On 5/24/06, Heinz Tuechler [EMAIL PROTECTED] wrote:
 Dear All!

 For descriptive purposes I would like to add attributes to objects. These
 attributes should be kept, even if by indexing only part of the object is
 used.
 I noted that some attributes like levels and class of a factor exist also
 after indexing, while others, like comment or label vanish.
 Is there a way to make an arbitrary attribute to be kept after indexing?
 This would be especially useful when indexing a data.frame.

 ## example for loss of attributes
 fx - factor(1:5, ordered=TRUE)
 attr(fx, 'comment') - 'Comment for fx'
 attr(fx, 'label') - 'Label for fx'
 attr(fx, 'testattribute') - 'just for fun'
 attributes(fx)  # all attributes are shown
 attributes(fx[])# all attributes are shown
 attributes(fx[1:5]) # only levels and class are shown
 attributes(fx[1])   # only levels and class are shown

 Thanks,

 Heinz Tüchler

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


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


Re: [R] converting hexadecimal

2006-05-24 Thread Duncan Murdoch
On 5/24/2006 11:01 AM, Romain Lorrilliere wrote:
 Hi,
 
 do you know, a method to convert an hexadecimal value to the 
 corresponding integer value (decimal) ?

as.double (which is called by as.numeric) automatically converts hex to 
numeric values.  You need to make sure the hex strings have a 0x 
prefix, e.g.


  as.numeric(0x0A)
[1] 10

You can use paste() or gsub() to put the prefix on existing strings.

Duncan Murdoch

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


Re: [R] How to make attributes persist after indexing?

2006-05-24 Thread Marc Schwartz (via MN)
On Wed, 2006-05-24 at 17:20 +0100, Heinz Tuechler wrote:
 Dear All!
 
 For descriptive purposes I would like to add attributes to objects. These
 attributes should be kept, even if by indexing only part of the object is
 used.
 I noted that some attributes like levels and class of a factor exist also
 after indexing, while others, like comment or label vanish.
 Is there a way to make an arbitrary attribute to be kept after indexing?
 This would be especially useful when indexing a data.frame.
 
 ## example for loss of attributes
 fx - factor(1:5, ordered=TRUE)
 attr(fx, 'comment') - 'Comment for fx'
 attr(fx, 'label') - 'Label for fx'
 attr(fx, 'testattribute') - 'just for fun'
 attributes(fx)  # all attributes are shown
 attributes(fx[])# all attributes are shown
 attributes(fx[1:5]) # only levels and class are shown
 attributes(fx[1])   # only levels and class are shown
 
 Thanks,
 
 Heinz Tüchler

Non-standard attributes do not survive the use of [. You could
create a new class and subset method for the objects where you require
this type of functionality.

Frank Harrell has done that in the Hmisc package to support the use of
the labeling attributes, which in turn are used by some of his functions
such as latex().  You might want to review what he has done in ?label
where the [.labelled method has been added.

Alternatively, you could create your own function to save the
attributes, do the subsetting and then restore the attributes to the
resultant object.

HTH,

Marc Schwartz

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


[R] multiple destinations in duration (survival) analysis

2006-05-24 Thread Dimitri Szerman
Hi,

I'm trying to estimate a (parametric) competing risks model in the context
of duration (or survival, if you wish) analysis. That is, instead of
studying the transition of subjects to death, I wish to study the
transitions to multiple *destinations* (which is different from studying
multiple *durations*, or recurrent events). I am more interested in the
hazard function rather than the survival, but that would do as some
manipulations in the estimates will give me what I want.

Does any one know were I can find functions/routines to perform such
estimation with R? I'd appreciate any tips on this.

Thanks,
Dimitri

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


[R] R Reference Card (especially useful for Newbies)

2006-05-24 Thread Berton Gunter
 
Newbies (and others!) may find useful the R Reference Card made available by
Tom Short and Rpad at http://www.rpad.org/Rpad/Rpad-refcard.pdf  or through
the Contributed link on CRAN (where some other reference cards are also
linked). It categorizes and organizes a bunch of R's basic, most used
functions so that they can be easily found. For example, paste() is under
the Strings heading and expand.grid() is under Data Creation. For
newbies struggling to find the right R function as well as veterans who
can't quite remember the function name, it's very handy.
 
-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
 
The business of the statistician is to catalyze the scientific learning
process.  - George E. P. Box

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

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


[R] glmmADMB and the GPL -- formerly-- How to buy R.

2006-05-24 Thread dave fournier
I promise the list that this will be my last posting
regarding this matter.

The package glmmADMB is not and never was the property
or a product of Otter Research Ltd. It was simply a probram I wrote
using ADMB-RE and gave away. I do this all the time to help various 
people. I don't monitor or try to control what they do with it.
The executable nbmm.exe was produced by using the ADMB-RE package,
but under our license executables produced using
ADMB are freely distributable. See for example the
software Coleraine or stock synthesis.

As I stated in my earlier post I was motivated to
produce software for negative binomial mixed models
by a post of Prof Ripleys, that no such good software
existed. I assumed that to mean anywhere not just as
a currently existing R package.
I originally intended this to be just a stand alone
program that anyone could use after they put the data
into the proper format. I soon realized, however that
R users had a different way of thinking about the methods
for specifying these models. Since I have extremely limited
R skills I asked Anders Nielsen and Hans Skaug if they would be interested
in producing something that could be used more easily by R users.
They were not paid for this and acted simply out of a wish to provide a 
service to the R community.
I had no idea how that would go and at that point my involvement in the
development (except for modifying the nbmm.exe to deal with difficult
data) came to an end.

Neither Anders or Hans are employees of or own any part of Otter 
Research Ltd. I am its sole employee/owner.

When the package was finished I agreed to host it on my web site.

I also put up a forum because I wanted to see how the software worked 
for people.

I appears that Hans put the GPL on the package. He can speak for
himself, but I believe he intended the GPL to apply to the R package 
which he had taken over from Anders and not the nbmm.exe Certainly he 
would have no authority to bind Otter Research Ltd in this matter.

Now as to flames and Lawyers.  As I said Otter Research Ltd is a 
company of one person. I have successfully sold software for 16 years 
without a lawyer, mostly to the fisheries management community.
I never felt the need for a lawyer until I gave something away for free
to the R community.

I removed the link that Prof Ripley referred to. If there is another 
offending link I will be happy to remove it as well if you tell me where 
it is. For those who want to use the software I will put it up in its
original form which means that you will need to put your data into
the format that an AD Model Builder program requires. It will still have 
the same functionality but unfortunately will be more difficult for R 
users to access.

Of course if Hans or Anders or anyone else wants to they are welcome to 
take the nbmm.exe and make it available with their own R package if they 
can satisfy whatever the requirements are -- just not on my website.

 Cheers,

  Dave



























-- 
David A. Fournier
P.O. Box 2040,
Sidney, B.C. V8l 3S3
Canada
Phone/FAX 250-655-3364
http://otter-rsch.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


Re: [R] glmmADMB and the GPL -- formerly-- How to buy R.

2006-05-24 Thread Jason Barnhart
- Original Message - 
From: dave fournier [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Tuesday, May 23, 2006 9:01 AM
Subject: [R] glmmADMB and the GPL -- formerly-- How to buy R.


 Dear List,

 Some of you have been following the discussion of the GPL and its 
 inclusion
 in the glmmADMB package we created for R users. I would like to provide
 a bit of background and include an email we received from
 Prof. Ripley so that everyone can be aware of how some might use the
 GPL to try to force access to proprietary software. I think this is
 interesting because many have voiced the opinion about the benign nature
 of the GPL and that commercial enterprises who avoid it do so mainly out
 of ignorance.

 I have noticed two things:
 Users of the R-help list appear to rely largely on the advice of a
 rather small number of statistical experts. Second, the R users regard R
 as being more cutting edge and up to date than lists devoted to
 commercial statistical packages like SAS.

 For these reasons  I was surprised to see the following post on the web
 in reply to a question on negative binomial mixed models.

 https://stat.ethz.ch/pipermail/r-help/2005-February/066146.html

 I thought that this was bad advice as certainly our ADMB-RE software
 could handle this problem easily.  However one never knows exactly what
 sort of data people might use in a particular example that could lead to
 difficulties so I decided to code up a program that R users could test
 for this problem.  However R users are used to a different approach for
 model formulation so that it was difficult for the average R user to
 access the program. I approached Anders Nielsen who is both an
 experienced ADMB user and R user and asked him to write an interface in
 R which would make the program more accessible to R users. He created a
 package and the whole thing seems to have had some success with at least
 one PhD thesis based on calculations using it. The R code that Anders
 wrote is simply an interface which takes the R specification for the
 model and outputs a data file in the format the an ADMB program expects.
 The ADMB program is a stand alone exe. The R script then reads the ADMB
 output files and presents the results to the user in a more familiar R
 format. Now it appears at some revision someone put a GPL notice on this
 package although Anders states that he did not do so, and and he is
 certain that it was not originally included by him. In any event the R
 script is easily extracted from the package by those who know how to do
 so and we have no problem with making the ADMB-RE source to the  exe
 (TPL file) available. In fact the original was on our web site but was
 modified as we made to program more robust to deal with difficult data
 sets.  The compiled TPL file links with our proprietary libraries and we
 have no intention of providing the source for these, but that is exactly
 what Prof. Ripley seems to be demanding since he claims that he wants
 the program to run on his computer which it apparently does not do at
 present. Prof. Ripley seems to feel that he is a qualified spokesman for
 the open source community. I have no idea what the community at large
 feels about this.

 What follows is Hans Skaug's post with Prof. Ripley's reply.

  On Mon, 22 May 2006, H. Skaug wrote:
 
   About glmmADMB and GPL:
  
   We were not very cautious when we put in the GPL statement.
   What we wanted to say was that the use of glmmADMB is free, and
   does not require a license for AD Model Builder.
 
  But that is not what you said, and you are legally and morally bound to
  fulfill the promise you made.
 
   Am I correct in interpreting this discussion so that all
   we have to do is to remove the License: GPL statement
   from the DESCRIPTION file (and everywhere else it may occur),
   and there will be no conflict between glmmADMB and the
   rules of the R community?
 
  I have made a request under the GPL. `All' you have to do is to fulfill
  it.
 
   We have temporarily withdrawn glmmADMB until this question has been
   settled.
 
  You can withdraw the package, but it has already been distributed under
  GPL, and those who received it under GPL have the right to
 redistribute it
  under GPL, including the sources you are obliged to give them.  That's
  part of the `freedom' that GPL gives.
 
   hans
  
  
  
   Brian Ripley wrote:
  
   The issue in the glmmADMB example is not if they were required
 to release
   it under GPL (my reading from the GPL FAQ is that they probably
 were not,
   given that communication is between processes and the R code is
   interpreted).
  
   Rather, it is stated to be under GPL _but_ there is no source
 code offer
   for the executables (and the GPL FAQ says that for anonymous FTP
 it should
   be downloadable via the same site, and the principles apply
 equally to
   HTTP sites).  As the executables are not for my normal OS and I
 would like
   to exercise my freedom to try 

Re: [R] normality testing with nortest

2006-05-24 Thread Spencer Graves
see inline

Raymond Wan wrote:
 Hi all,
 
 On Mon, 22 May 2006, Rolf Turner wrote:
  It is worth noting that if the null hypothesis is true, then
  the p-value is
  uniformly distributed on [0,1].

SG:  This is true in many but not all cases, and I think is a reasonable 
approximation even when not exactly true.  Example:  Testing any null 
hypothesis about a discrete distribution with only N possible outcomes 
must produce N possible outcomes in the distribution of the p-value.

  hope this helps,
  Spencer Graves

  This should be kept in mind when assessing the ``instability''
  of p-values.
 
   Just wanted to thank everyone who participated in this thread for 
 clarifying things for me.  I guess I knew bits and pieces but your 
 messages put them together and gave me some R commands (which I am still 
 new to) to check things myself.
 
   Thanks a lot!
 
 Ray
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


Re: [R] Statistical Power

2006-05-24 Thread Charles C. Berry
On Tue, 23 May 2006, Christopher Brown wrote:

 How can I compute a power analysis on a multi-factor within-subjects
 design?

If you are capable of installing source packages and if you know what a 
general linear hypothesis test is, you can:

download 'hpower' to your computer

http://gd.tuwien.ac.at/languages/R/src/contrib/hpower_0.1-0.tar.gz

and install it. Then

library( hpower )
?glhpwr


should get you started.






[ Part 3.28: Included Message ]


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


Re: [R] UBTA - Wall Street Journal Agree - Ref. wj277963

2006-05-24 Thread Alma Lyles
Kelsey, 

P2P Sports Betting Software May Change Casino Sports Betting

VANCOUVER, BRITISH COLUMBIA - UBA Technology Inc. (UBTA), has entered 
into initial negotiations to install its proprietary betting exchange 
software in traditional land-based casinos.

Read the whole story: http://geocities.yahoo.com.br/incidentless63143

Alma Lyles, Acct. Rep. go820972

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


[R] Regression line limited by the rage of values

2006-05-24 Thread Andreas Svensson
Hi

In R, using  plot(x,y)   followed by abline(lm(y~x)) produces a graph 
with a regression line spanning the whole plot . This means that the 
line extends beyond the swarm of data points to the defined of default  
plot region. With par(xpd=T) it will span the entire figure region. But 
how can I limit a regression line to the data range, i.e between  
(xmin,ymin) and  (xmax,ymax)?

Sorry for not knowing the lingo here. If you don't understand the 
question, please run the following script:

x1-c(1,2,3,4)
x2-c(5,6,7,8)
y1-c(2,4,5,8)
y2-c(10,11,12,16)
plot(x1,y1,xlim=c(0,10),ylim=c(0,20),col=blue)
points(x2,y2,col=red)
abline(lm(y1~x1),col=blue)
abline(lm(y2~x2),col=red)

The resulting plot isn't very informative. There is no overlap in the 
two groups of data, yet the two ablines overlap.
I instead  want the blue line to go from (1,2) to (4,8) and the red line 
from (5,10) to (8,16).

So, how can I constrain the abline to the relevant region, i.e stop 
abline from extrapolating beyond the actual range of data.
Or should I use a function line 'lines' to do this?

Cheers
Andres

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


Re: [R] Regression line limited by the rage of values

2006-05-24 Thread Marc Schwartz (via MN)
On Wed, 2006-05-24 at 18:51 +0200, Andreas Svensson wrote:
 Hi
 
 In R, using  plot(x,y)   followed by abline(lm(y~x)) produces a graph 
 with a regression line spanning the whole plot . This means that the 
 line extends beyond the swarm of data points to the defined of default  
 plot region. With par(xpd=T) it will span the entire figure region. But 
 how can I limit a regression line to the data range, i.e between  
 (xmin,ymin) and  (xmax,ymax)?
 
 Sorry for not knowing the lingo here. If you don't understand the 
 question, please run the following script:
 
 x1-c(1,2,3,4)
 x2-c(5,6,7,8)
 y1-c(2,4,5,8)
 y2-c(10,11,12,16)
 plot(x1,y1,xlim=c(0,10),ylim=c(0,20),col=blue)
 points(x2,y2,col=red)
 abline(lm(y1~x1),col=blue)
 abline(lm(y2~x2),col=red)
 
 The resulting plot isn't very informative. There is no overlap in the 
 two groups of data, yet the two ablines overlap.
 I instead  want the blue line to go from (1,2) to (4,8) and the red line 
 from (5,10) to (8,16).
 
 So, how can I constrain the abline to the relevant region, i.e stop 
 abline from extrapolating beyond the actual range of data.
 Or should I use a function line 'lines' to do this?
 
 Cheers
 Andres

Try this instead of the two abline()'s:

  lines(x1, fitted(lm(y1 ~ x1)), col = blue)

  lines(x2, fitted(lm(y2 ~ x2)), col = red)

The function fitted() will extract the model fitted y values from the
lm() model object.

See ?lines and ?fitted

HTH,

Marc Schwartz

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


Re: [R] Statistical Power

2006-05-24 Thread Rick Bilonick
On Wed, 2006-05-24 at 09:22 -0700, Charles C. Berry wrote:
 On Tue, 23 May 2006, Christopher Brown wrote:
 
  How can I compute a power analysis on a multi-factor within-subjects
  design?
 
 If you are capable of installing source packages and if you know what a 
 general linear hypothesis test is, you can:
 
 download 'hpower' to your computer
 
   http://gd.tuwien.ac.at/languages/R/src/contrib/hpower_0.1-0.tar.gz
 
 and install it. Then
 
 library( hpower )
 ?glhpwr
 

Downloading, unzipping the package on to FC4 running R 2.3.0 gives an
error message about a bad description file when trying to install
hpower.

 R CMD INSTALL hpower

Rick B.

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


[R] changing font size in plot(effect())

2006-05-24 Thread Emilie Berthiaume


I can't seem to be able to change the font size in an effect display.  I've
tried the following:

 par(cex.lab=4)
 plot(effect (alti,reg8), ylab=detection probability)

and

 plot(effect (alti,reg8), ylab=detection probability, cex=4)

but nothing changes.  Can anyone help me?
thanks.


Emilie Berthiaume
graduate student
Sherbrooke University
2500 boul. de l'Université
Sherbrooke, Québec
J1K 2R1 CANADA

Phone: 1-819-821-8000 poste 2059
Fax: 1-819-821-8049
[EMAIL PROTECTED]

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


[R] FastICA and matching variance of inputs

2006-05-24 Thread Andrew Moroz
I have been playing around with the FastICA algorithm in R, and I have
come across the following issue. I'm new to this topic, so I'm hoping
someone will be able to shed some insight.

We know that the variance of the Independent Components is constrained
to be 1 and they are uncorrelated, so the sum of squares of the
coefficients of the mixing matrix (a$A) will give the variance of the
reconstructed inputs (a$X). It seems to me that this should match the
variance of the actual inputs (X). But the former seems to be smaller
than the latter, by varying amounts. Does anyone know why that might
be?


# results are close

S - matrix(runif(1), 500, 20)
A - matrix(runif(4000), 20, 200)
X - S%*%A
a - fastICA(X, 20)

as.vector(apply(X,2,sd))[1:10]
apply(a$A,2,function(x) sqrt(sum(x^2)))[1:10]

--

 as.vector(apply(X,2,sd))[1:10]
[1] 0.6815156 0.7160899 0.8237067 0.6777511 0.8045670 0.7584224 0.7818801
[8] 0.8015249 0.7252270 0.6337887
 apply(a$A,2,function(x) sqrt(sum(x^2)))[1:10]
[1] 0.6808337 0.7153735 0.8228825 0.6770730 0.8037620 0.7576636 0.7810978
[8] 0.8007229 0.7245014 0.6331546

--


# results are not close

S - matrix(runif(1), 500, 20)
A - matrix(runif(4000), 20, 200)
X - S%*%A
a - fastICA(X, 2)

as.vector(apply(X,2,sd))[1:10]
apply(a$A,2,function(x) sqrt(sum(x^2)))[1:10]

--

 as.vector(apply(X,2,sd))[1:10]
[1] 0.7400437 0.7775435 0.6862873 0.7890104 0.7516134 0.8099342 0.8095056
[8] 0.7653593 0.6743729 0.7875858
 apply(a$A,2,function(x) sqrt(sum(x^2)))[1:10]
[1] 0.6463631 0.7131771 0.5987285 0.6979883 0.6664734 0.7300787 0.7179024
[8] 0.6571067 0.5549075 0.6684818


--

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


Re: [R] changing font size in plot(effect())

2006-05-24 Thread Chuck Cleland
Try this:

trellis.par.set(par.ylab.text = list(cex = 4))
plot(effect (alti,reg8), ylab=detection probability)

?trellis.par.set

Emilie Berthiaume wrote:
 
 I can't seem to be able to change the font size in an effect display.  I've
 tried the following:
 
 par(cex.lab=4)
 plot(effect (alti,reg8), ylab=detection probability)
 
 and
 
 plot(effect (alti,reg8), ylab=detection probability, cex=4)
 
 but nothing changes.  Can anyone help me?
 thanks.
 
 
 Emilie Berthiaume
 graduate student
 Sherbrooke University
 2500 boul. de l'Université
 Sherbrooke, Québec
 J1K 2R1 CANADA
 
 Phone: 1-819-821-8000 poste 2059
 Fax: 1-819-821-8049
 [EMAIL PROTECTED]
 
 __
 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
 

-- 
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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Statistical Power

2006-05-24 Thread Ioannis Dimakos
On Wed, May 24, 2006 20:22, Rick Bilonick wrote:

 Downloading, unzipping the package on to FC4 running R 2.3.0 gives an
 error message about a bad description file when trying to install
 hpower.

 R CMD INSTALL hpower


Indeed, it does so on both my Ubuntu and Win XP boxes.  The problem is
that the DESCRIPTION file does not have a proper Maintainer line.  If
you simply add the line:

Maintainer: no-one [EMAIL PROTECTED]

and follow the regular procedures, it should install.  However, I am not
so sure that this is the right thing to do with regards to permissions
etc.  Anyone any advice?

Ioannis
-- 
Ioannis C. Dimakos, Ph.D.
University of Patras
Department of Elementary Education
Patras, GR-26500 GREECE
http://www.elemedu.upatras.gr/dimakos/
http://yannishome.port5.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


[R] problem-nlme

2006-05-24 Thread gabriela escati peñaloza
Hi,
I have great problems with my work in R.
I look for to model the growth of fish.
I have Longitudinal data, a serie of repeated
measures for each individual.
Using the corresponding packages nlme in R.
I treat to fit to the data different growth functions,
wich were entered by me.
Unfortunately for no it was arrived at the
convergence, several error messages appeared.

I am going to display the growth functions so as they
were entered and a nlme call example:

# differents growth function

#vonBertlalanffy
vonBert- function(x, Linf, K, t0)
Linf*(1-exp(-K*(x-t0)))

size ~ vonBert(age, Linf, K,t0)

vonBert -deriv(~ Linf*(1-exp(-K*(x-t0))), 
  c(Linf,K,t0),function(x,Linf,K,t0){})

vonBertInit -  function(mCall, LHS, data)
  {
xy - sortedXyData(mCall[[x]], LHS, data)
Linf - 900
if (Linf != max(xy[,y])) Linf - -Linf
K - 0.3
t0-0
value - c(Linf, K, t0)
names(value) - mCall[c(Linf, K,t0)]
value
 }

vonBert - selfStart(vonBert, initial = vonBertInit)

class(vonBert)


#Richards
Rich - function(x, Linf, K, t0, m)
Linf*(1-exp(-K*(x-t0)))^(1/(1-m))

size ~ Rich(age, Linf, K, t0, m)
 
Rich -deriv(~ Linf*(1-exp(-K*(x-t0)))^(1/(1-m)), 
 
c(Linf,K,t0,m),function(x,Linf,K,t0,m){})

RichInit -  function(mCall, LHS, data)
  {
xy - sortedXyData(mCall[[x]], LHS, data)
Linf - 900
if (Linf != max(xy[,y])) Linf - -Linf
K - 0.3
t0-0
m - 0.3
value - c(Linf, K, t0, m)
names(value) - mCall[c(Linf, K,t0,m)]
value
 }

Rich - selfStart(Rich, initial = RichInit)

class(Rich)

#call
Rich.nlme - nlme(size ~ Rich(age, Linf, K, t0, m),
data = L.gd,
fixed = Linf + K +t0 +m~ 1,
  start = list(fixed = c(900, 0.3,-3,0.9)))

#error message
Error: Singularity in backsolve at level 0, block 1
In addition: Warning message:
NaNs produced in: log(x)


What is the problem? I do not understand that it is
what is bad: the data, the entered growth functions,
some specification...
I will thank for any contribution of information.


Lic. Gabriela Escati Peñaloza
Biología y Manejo de Recursos Acuáticos
Centro Nacional Patagónico(CENPAT). 
CONICET
Bvd. Brown s/nº.
(U9120ACV)Pto. Madryn 
Chubut
Argentina

Tel: 54-2965/451301/451024/451375/45401 (Int:277)
Fax: 54-29657451543



__ 
Yahoo! Autos. Más de 100 vehículos vendidos por día. 
¿Qué esperás para vender el tuyo? 
Hacelo ahora y ganate un premio de Yahoo!

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


[R] Joining variables

2006-05-24 Thread Guenther, Cameron
Hello,

If I have two variables that are factors or characters and I want to
create a new variable that is the combination of both what function can
I use to accomplish this?

Ex.

Var1Var2
SA100055113 19851113

And I want

NewVar
SA10005511319851113

Thanks in advance.

Cameron Guenther, Ph.D. 
Associate Research Scientist
FWC/FWRI, Marine Fisheries Research
100 8th Avenue S.E.
St. Petersburg, FL 33701
(727)896-8626 Ext. 4305
[EMAIL PROTECTED]

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


Re: [R] Joining variables

2006-05-24 Thread Marc Schwartz (via MN)
On Wed, 2006-05-24 at 14:45 -0400, Guenther, Cameron wrote:
 Hello,
 
 If I have two variables that are factors or characters and I want to
 create a new variable that is the combination of both what function can
 I use to accomplish this?
 
 Ex.
 
 Var1  Var2
 SA100055113   19851113
 
 And I want
 
 NewVar
 SA10005511319851113
 
 Thanks in advance.

See ?paste and note the 'sep' argument:

 NewVar - paste(Var1, Var2, sep = )

 NewVar
[1] SA10005511319851113

HTH,

Marc Schwartz

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


[R] LARS error

2006-05-24 Thread Cal Stats
Hi All,
  
  when i run 
  
 cv.lars(x3,y3)
  
  it runs fine. but when i run 
  
  cv.lars(x3,y3,fraction=seq(0,0.1,100))
  
  I get the following error.
  
  Error in apply((y[omit] - fit)^2, 2, mean) : dim(X) must have a positive 
length
  
  Any help/suggestions will be appreciated.
  
  Thanks.
  
  Harsh
  

-

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


Re: [R] Joining variables

2006-05-24 Thread Guenther, Cameron
Thanks to all who responded.

The paste function is what I was looking for.

Thanks again. 


Cameron Guenther, Ph.D. 
Associate Research Scientist
FWC/FWRI, Marine Fisheries Research
100 8th Avenue S.E.
St. Petersburg, FL 33701
(727)896-8626 Ext. 4305
[EMAIL PROTECTED]
-Original Message-
From: Berton Gunter [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 24, 2006 2:54 PM
To: Guenther, Cameron; r-help@stat.math.ethz.ch
Subject: RE: [R] Joining variables

What does combination of both mean exactly. I can think of two
interpretations that have two different answers. If you give a small
example (as the posting guide suggests) it would certainly help me
provide an answer.

-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
 

 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Guenther, 
 Cameron
 Sent: Wednesday, May 24, 2006 11:46 AM
 To: r-help@stat.math.ethz.ch
 Subject: [R] Joining variables
 
 Hello,
 
 If I have two variables that are factors or characters and I want to 
 create a new variable that is the combination of both what function 
 can I use to accomplish this?
 
 Ex.
 
 Var1  Var2
 SA100055113   19851113
 
 And I want
 
 NewVar
 SA10005511319851113
 
 Thanks in advance.
 
 Cameron Guenther, Ph.D. 
 Associate Research Scientist
 FWC/FWRI, Marine Fisheries Research
 100 8th Avenue S.E.
 St. Petersburg, FL 33701
 (727)896-8626 Ext. 4305
 [EMAIL PROTECTED]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html


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


Re: [R] multiple destinations in duration (survival) analysis

2006-05-24 Thread Greg Snow
I have been working on a similar project and here is how I approached it
(though I would be very happy to hear other ideas):

Our situation was that we wanted to predict length of stay in the
emergency room of the hospital, there are multiple competing places to
go from the ER: released to go home, admitted to the main hospital,
transferred to another specialty hospital, leave without seeing the
doctor,   Not suprisingly the predictors have opposite effects on
time till admission and time till released to home.

There is a function aj in package changeLOS that computes the
Aalen-Johansen estimator for competing risks, but it does not fit
anything with covariates.  You can also do multiple cox model
regressions using each destination as the event and all other
destinations as censoring, but this does not give some of the nice
interpretations of the Aelen-Johansen estimates, so here is how we
combined the 2 approaches:

1. fit a Cox ph model for each competing risk (using all others as
censoring).  

2. Choose a baseline set of covariates (means of all, or typical values,
...).

3. Compute the predicted survival distribution for this baseline
individual (using survfit on the coxph model) for each of the coxph
models.

4. Simulate 1,000 observations from each of the predicted survival
distributions, put these into a 1,000 by (number of competing risks)
matrix.

5. take the minimum of each row as the time to event and which row has
that minimum as the event that occurred and use that as input to the aj
function (actually I think the trans function is used in there
somewhere, then the aj function).  

6.  Create a plot based on the output of AJ showing at each time period
what the probabilities of being still in the system or any of the
destinations is.

7.  Choose a 2nd set of covariates (generally just change 1 value from
the baseline) and repeate the whole process, compare the 2 graphs to get
a feel for the effect of changing that covariate.

8. Repeate, but changing different covariates to see the effect.


Hope this helps,



-- 
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 Dimitri Szerman
Sent: Wednesday, May 24, 2006 9:47 AM
To: R-Help
Subject: [R] multiple destinations in duration (survival) analysis

Hi,

I'm trying to estimate a (parametric) competing risks model in the
context of duration (or survival, if you wish) analysis. That is,
instead of studying the transition of subjects to death, I wish to
study the transitions to multiple *destinations* (which is different
from studying multiple *durations*, or recurrent events). I am more
interested in the hazard function rather than the survival, but that
would do as some manipulations in the estimates will give me what I
want.

Does any one know were I can find functions/routines to perform such
estimation with R? I'd appreciate any tips on this.

Thanks,
Dimitri

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

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


Re: [R] Joining variables

2006-05-24 Thread Sundar Dorai-Raj


Guenther, Cameron wrote:
 Hello,
 
 If I have two variables that are factors or characters and I want to
 create a new variable that is the combination of both what function can
 I use to accomplish this?
 
 Ex.
 
 Var1  Var2
 SA100055113   19851113
 
 And I want
 
 NewVar
 SA10005511319851113
 
 Thanks in advance.

See ?paste or ?sprintf

Var1 - factor(SA100055113)
Var2 - 19851113

NewVar - paste(Var1, Var2, sep = )
NewVar - sprintf(%s%s, Var1, Var2)

HTH,

--sundar

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


Re: [R] Joining variables

2006-05-24 Thread Berton Gunter
What does combination of both mean exactly. I can think of two
interpretations that have two different answers. If you give a small example
(as the posting guide suggests) it would certainly help me provide an
answer.

-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
 

 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of 
 Guenther, Cameron
 Sent: Wednesday, May 24, 2006 11:46 AM
 To: r-help@stat.math.ethz.ch
 Subject: [R] Joining variables
 
 Hello,
 
 If I have two variables that are factors or characters and I want to
 create a new variable that is the combination of both what 
 function can
 I use to accomplish this?
 
 Ex.
 
 Var1  Var2
 SA100055113   19851113
 
 And I want
 
 NewVar
 SA10005511319851113
 
 Thanks in advance.
 
 Cameron Guenther, Ph.D. 
 Associate Research Scientist
 FWC/FWRI, Marine Fisheries Research
 100 8th Avenue S.E.
 St. Petersburg, FL 33701
 (727)896-8626 Ext. 4305
 [EMAIL PROTECTED]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html


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


[R] Problem with Statistics::R Save plots

2006-05-24 Thread Filipe Garrett

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


Re: [R] Joining variables

2006-05-24 Thread Dimitrios Rizopoulos
look at ?paste().

Best,
Dimitris

 
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
 http://www.student.kuleuven.be/~m0390867/dimitris.htm


Quoting Guenther, Cameron [EMAIL PROTECTED]:

 Hello,
 
 If I have two variables that are factors or characters and I want to
 create a new variable that is the combination of both what function
 can
 I use to accomplish this?
 
 Ex.
 
 Var1  Var2
 SA100055113   19851113
 
 And I want
 
 NewVar
 SA10005511319851113
 
 Thanks in advance.
 
 Cameron Guenther, Ph.D. 
 Associate Research Scientist
 FWC/FWRI, Marine Fisheries Research
 100 8th Avenue S.E.
 St. Petersburg, FL 33701
 (727)896-8626 Ext. 4305
 [EMAIL PROTECTED]
 
 __
 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
 
 


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

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


[R] Decimal places

2006-05-24 Thread Robert Mcfadden
Hello,

I would like to force R to print 2 decimal places. I use options(digits=2)
but as far as I know it prints significant digits so in certain cases is
more then 2.

Is there other way to do it?

Best,

Robert

   

 

 


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


Re: [R] Regression line limited by the range of values

2006-05-24 Thread Andreas Svensson
Thankyou very much Marc for that nifty little script.

When I use it on my real dataset though, the lines are fat in the middle 
and thinner towards the ends. I guess it's because lines draw one 
fitted line for each x, and if you have hundreds of x, this turns into a 
line that is thicker that it should be (due to rounding errors perhaps).

I got the tip to use segments, and draw one line from min(x),min(y) to 
max(x),max(y) but with real data with a bunch of na.rm and 
na.actions this becomes very long and bulky.

For a regression with two data swarms and two trend lines it becomes 
this long mess:

plot(TCgonad[Period==1], 
ABelly[Period==1],xlim=c(0,20),ylim=c(130,160), col=”blue”)
points(TCgonad[Period==2], ABelly[Period==2],col=”red”)

segments(
min(TCgonad[Period==1],na.rm=T), 
min(fitted(lm(ABelly[Period==1]~TCgonad[Period==1],
na.action=na.exclude)),na.rm=T),
max(TCgonad[Period==1],na.rm=T), 
max(fitted(lm(ABelly[Period==1]~TCgonad[Period==1],
na.action=na.exclude)),na.rm=T),col=”blue”)

segments(
min(TCgonad[Period==2],na.rm=T), 
min(fitted(lm(ABelly[Period==2]~TCgonad[Period==2],
na.action=na.exclude)),na.rm=T),
max(TCgonad[Period==2],na.rm=T), 
max(fitted(lm(ABelly[Period==2]~TCgonad[Period==2],
na.action=na.exclude)),na.rm=T),col=”red”)


I just think it's strange that abline has as a nonadjustable default to 
extrapolate the line to outside the data - a mortal sin in my field.

Cheers
Andreas

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


Re: [R] Joining variables

2006-05-24 Thread mark.lopresti
Hello,

Although I cannot speak for the original individual posting this question but I 
would like to see an example, if possible, of how to construct a factor of 
several factors.

I think this would be more efficient than paste if such a procedure were 
possible and, of course, would also answer the postee's original question.

Many thanks,

Mark LoPresti
Thomson Financial/Research Group

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Berton Gunter
Sent: Wednesday, May 24, 2006 2:54 PM
To: 'Guenther, Cameron'; r-help@stat.math.ethz.ch
Subject: Re: [R] Joining variables


What does combination of both mean exactly. I can think of two
interpretations that have two different answers. If you give a small example
(as the posting guide suggests) it would certainly help me provide an
answer.

-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
 

 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of 
 Guenther, Cameron
 Sent: Wednesday, May 24, 2006 11:46 AM
 To: r-help@stat.math.ethz.ch
 Subject: [R] Joining variables
 
 Hello,
 
 If I have two variables that are factors or characters and I want to
 create a new variable that is the combination of both what 
 function can
 I use to accomplish this?
 
 Ex.
 
 Var1  Var2
 SA100055113   19851113
 
 And I want
 
 NewVar
 SA10005511319851113
 
 Thanks in advance.
 
 Cameron Guenther, Ph.D. 
 Associate Research Scientist
 FWC/FWRI, Marine Fisheries Research
 100 8th Avenue S.E.
 St. Petersburg, FL 33701
 (727)896-8626 Ext. 4305
 [EMAIL PROTECTED]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html


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

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


Re: [R] Regression line limited by the range of values

2006-05-24 Thread Marc Schwartz (via MN)
On Wed, 2006-05-24 at 21:53 +0200, Andreas Svensson wrote:
 Thankyou very much Marc for that nifty little script.
 
 When I use it on my real dataset though, the lines are fat in the middle 
 and thinner towards the ends. I guess it's because lines draw one 
 fitted line for each x, and if you have hundreds of x, this turns into a 
 line that is thicker that it should be (due to rounding errors perhaps).
 
 I got the tip to use segments, and draw one line from min(x),min(y) to 
 max(x),max(y) but with real data with a bunch of na.rm and 
 na.actions this becomes very long and bulky.
 
 For a regression with two data swarms and two trend lines it becomes 
 this long mess:
 
 plot(TCgonad[Period==1], 
 ABelly[Period==1],xlim=c(0,20),ylim=c(130,160), col=”blue”)
 points(TCgonad[Period==2], ABelly[Period==2],col=”red”)
 
 segments(
 min(TCgonad[Period==1],na.rm=T), 
 min(fitted(lm(ABelly[Period==1]~TCgonad[Period==1],
 na.action=na.exclude)),na.rm=T),
 max(TCgonad[Period==1],na.rm=T), 
 max(fitted(lm(ABelly[Period==1]~TCgonad[Period==1],
 na.action=na.exclude)),na.rm=T),col=”blue”)
 
 segments(
 min(TCgonad[Period==2],na.rm=T), 
 min(fitted(lm(ABelly[Period==2]~TCgonad[Period==2],
 na.action=na.exclude)),na.rm=T),
 max(TCgonad[Period==2],na.rm=T), 
 max(fitted(lm(ABelly[Period==2]~TCgonad[Period==2],
 na.action=na.exclude)),na.rm=T),col=”red”)
 
 
 I just think it's strange that abline has as a nonadjustable default to 
 extrapolate the line to outside the data - a mortal sin in my field.
 
 Cheers
 Andreas


Andreas,

What is likely happening is that your x values are not sorted in
increasing order as they were in the dummy data set, thus there is
probably some movement of the lines back and forth from one x value to
the next in the order that they appear in the data set.

Here is a more generic approach that should work. It is based upon the
examples in ?predict.lm. We create the two models and then use range(x?)
for the new min,max x values to be used for the prediction of the fitted
y values.

Thus:

# Create model1 using random data
set.seed(1)
x1 - rnorm(15)
y1 - x1 + rnorm(15)
model1 - lm(y1 ~ x1)

# Create model2 using random data
set.seed(2)
x2 - rnorm(15)
y2 - x2 + rnorm(15)
model2 - lm(y2 ~ x2)


# Plot the first set of points
# set the axis ranges based upon the common ranges of the 
# two sets of data
plot(x1, y1, col = red, xlim = range(x1, x2),
 ylim = range(y1, y2))

# Add the second set of points
points(x2, y2, col = blue)

# Create the first fitted line
# Create two x values for the prediction based upon the 
# range of x1
lines(range(x1), predict(model1, data.frame(x1 = range(x1))), 
  col = red)

# Create the second fitted line
# Same here for the x2 values
lines(range(x2), predict(model2, data.frame(x2 = range(x2))), 
  col = blue)


Note that in both cases for the fitted lines, the lines will be
constrained by the range of the actual x? data values.

This should be easier to apply in general.

HTH,

Marc Schwartz

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


Re: [R] Survey proportions... Can I use population as denominator?

2006-05-24 Thread Thomas Lumley
On Tue, 23 May 2006, David L. Van Brunt, Ph.D. wrote:

 Just giving the survey package a spin...

 I'm accustomed to stata, and it seems very similar in many respects. One
 thing is throwing me, however.

 I've gotten my data in, and specified the design. Looks like the weighting
 is right (based on published population estimates from these data), but now
 I'd like to check my marginal means for proportions against those that
 have been published.

No, actually you get means with svymean().

Proportions for factor levels come by svymean() with a factor variable, 
eg:
 data(api)
 dclus1-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc)
 svymean(~stype,dclus1)
mean SE
stypeE 0.786885 0.0463
stypeH 0.076503 0.0268
stypeM 0.136612 0.0296
 svymean(~sch.wide,dclus1)
mean SE
sch.wideNo  0.12568 0.0204
sch.wideYes 0.87432 0.0204

-thomas

Thomas Lumley   Assoc. Professor, Biostatistics
[EMAIL PROTECTED]   University of Washington, Seattle

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


[R] biplot with grouped observations

2006-05-24 Thread Kim Milferstedt
Hi,

I'd like to plot the results of PCA in biplots, grouping the 
observations by using different symbols. With xyplot in lattice I can 
easily differentiate the groups (see for example DAAG, p 285) but it 
seems difficult (or impossible?) to plot the vectors for the 
variables as well as xyplot cannot handle secondary axis very well. 
Using the basic plot I can combine observations and variables in one 
plot but cannot differentiate the groups of observations as easily as 
in xyplot. What could I do to get grouped observations in a biplot?

Thanks already,

Kim

__

Kim Milferstedt
University of Illinois at Urbana-Champaign
Department of Civil and Environmental Engineering
4125 Newmark Civil Engineering Building
205 North Mathews Avenue MC 250
Urbana, IL 61801
USA
phone: (001) 217 333-9663
fax: (001) 217 333-6968
email: [EMAIL PROTECTED]
http://cee.uiuc.edu/research/morgenroth

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


[R] legend title in effects plot

2006-05-24 Thread Viktor Tron
Could someone tell how I can change/remove the legend title in a  
(multiline) effect plot?
Thanks
V

In general, how is one supposed to find out answers to such questions?
It is virtually impossible to keep track of what graphical parameters are  
passed on
to which low level function and which don't. Every funciton calls legend  
labels a different
name (title, key, legend.lab, etc.).
I tried the help pages of par,plot,effect,legend, without an effect :-)

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


Re: [R] Decimal places

2006-05-24 Thread Prof Brian Ripley
On Wed, 24 May 2006, Robert Mcfadden wrote:

 Hello,

 I would like to force R to print 2 decimal places. I use options(digits=2)
 but as far as I know it prints significant digits so in certain cases is
 more then 2.

 Is there other way to do it?

?round, possibly

format(rounf(x, 2), nsmall = 2)

if you want exactly 2 decimal places.

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


Re: [R] problem-nlme

2006-05-24 Thread Andrew Robinson
Gabriela,

it may be that the model that you are trying to fit is vey complex.
Try something simpler.  Note that the default setting for the random
effects is the same as the fixed effects.  In my experience this is a
very difficult model to fit, especially for the Richards and von
Bertalanffy models. So, try a simpler model, and build from there.

Eg

Rich.nlme.linf - nlme(size ~ Rich(age, Linf, K, t0, m), 
   data = L.gd,
   fixed = Linf + K + t0 + m ~ 1,
   random = Linf ~ 1,
   start = list(fixed = c(900, 0.3,-3,0.9))) 


Good luck!

Andrew

On Wed, May 24, 2006 at 06:30:43PM +, gabriela escati pe?aloza wrote:
 Hi,
 I have great problems with my work in R.
 I look for to model the growth of fish.
 I have Longitudinal data, a serie of repeated
 measures for each individual.
 Using the corresponding packages nlme in R.
 I treat to fit to the data different growth functions,
 wich were entered by me.
 Unfortunately for no it was arrived at the
 convergence, several error messages appeared.
 
 I am going to display the growth functions so as they
 were entered and a nlme call example:
 
 # differents growth function
 
 #vonBertlalanffy
 vonBert- function(x, Linf, K, t0)
 Linf*(1-exp(-K*(x-t0)))
 
 size ~ vonBert(age, Linf, K,t0)
 
 vonBert -deriv(~ Linf*(1-exp(-K*(x-t0))), 
   c(Linf,K,t0),function(x,Linf,K,t0){})
 
 vonBertInit -  function(mCall, LHS, data)
   {
 xy - sortedXyData(mCall[[x]], LHS, data)
 Linf - 900
 if (Linf != max(xy[,y])) Linf - -Linf
 K - 0.3
 t0-0
 value - c(Linf, K, t0)
 names(value) - mCall[c(Linf, K,t0)]
 value
  }
 
 vonBert - selfStart(vonBert, initial = vonBertInit)
 
 class(vonBert)
 
 
 #Richards
 Rich - function(x, Linf, K, t0, m)
 Linf*(1-exp(-K*(x-t0)))^(1/(1-m))
 
 size ~ Rich(age, Linf, K, t0, m)
  
 Rich -deriv(~ Linf*(1-exp(-K*(x-t0)))^(1/(1-m)), 
  
 c(Linf,K,t0,m),function(x,Linf,K,t0,m){})
 
 RichInit -  function(mCall, LHS, data)
   {
 xy - sortedXyData(mCall[[x]], LHS, data)
 Linf - 900
 if (Linf != max(xy[,y])) Linf - -Linf
 K - 0.3
 t0-0
 m - 0.3
 value - c(Linf, K, t0, m)
 names(value) - mCall[c(Linf, K,t0,m)]
 value
  }
 
 Rich - selfStart(Rich, initial = RichInit)
 
 class(Rich)
 
 #call
 Rich.nlme - nlme(size ~ Rich(age, Linf, K, t0, m),
   data = L.gd,
   fixed = Linf + K +t0 +m~ 1,
   start = list(fixed = c(900, 0.3,-3,0.9)))
 
 #error message
 Error: Singularity in backsolve at level 0, block 1
 In addition: Warning message:
 NaNs produced in: log(x)
 
 
 What is the problem? I do not understand that it is
 what is bad: the data, the entered growth functions,
 some specification...
 I will thank for any contribution of information.
 
 
 Lic. Gabriela Escati Pe?aloza
 Biolog?a y Manejo de Recursos Acu?ticos
 Centro Nacional Patag?nico(CENPAT). 
 CONICET
 Bvd. Brown s/n?.
 (U9120ACV)Pto. Madryn 
 Chubut
 Argentina
 
 Tel: 54-2965/451301/451024/451375/45401 (Int:277)
 Fax: 54-29657451543
 
 
   
 __ 
 Yahoo! Autos. M?s de 100 veh?culos vendidos por d?a. 
 ?Qu? esper?s para vender el tuyo? 
 Hacelo ahora y ganate un premio de Yahoo!
 
 __
 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

-- 
Andrew Robinson  
Department of Mathematics and StatisticsTel: +61-3-8344-9763
University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599
Email: [EMAIL PROTECTED] http://www.ms.unimelb.edu.au

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


Re: [R] Decimal places

2006-05-24 Thread Robert Mcfadden
Thank you very much. Round(x, digids=2) works perfect.
Rob

-Original Message-
From: Prof Brian Ripley [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 24, 2006 10:47 PM
To: Robert Mcfadden
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] Decimal places

On Wed, 24 May 2006, Robert Mcfadden wrote:

 Hello,

 I would like to force R to print 2 decimal places. I use options(digits=2)
 but as far as I know it prints significant digits so in certain cases is
 more then 2.

 Is there other way to do it?

?round, possibly

format(rounf(x, 2), nsmall = 2)

if you want exactly 2 decimal places.

-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

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


Re: [R] Regression line limited by the rage of values

2006-05-24 Thread Greg Snow
For single lines the usual method is to just use the lines or segments
function, however I have been thinking that there may be some other uses
for clipping within a plot region when adding info (abline, but others
as well).  So here is a first stab at a function to clip within the
region, it needs the TeachingDemos package to work.  I'll probably put
in some more error checking, document it and include it in a future
TeachingDemos release, but you are welcome to use it in the meantime.

For your case you would create your scatterplot the same as you already
did, then add the lines like:

 clipplot( abline(lm(y1~x1),col=blue), xlim=c(1,4) )
 clipplot( abline(lm(y2~x2),col=red), xlim=c(5,8) )

Here is the function definition:

clipplot - function(fun, xlim=par('usr')[1:2], 
ylim=par('usr')[3:4] ){
  old.par - par(c('plt','xpd'))


  if( length(xlim)  2 ) stop('xlim must be a vector with at least 2
elements')
  if( length(ylim)  2 ) stop('ylim must be a vector with at least 2
elements')

  if( !require(TeachingDemos) ) stop('TeachingDemos package needed')

  xl - range(xlim)
  yl - range(ylim)

  pc - cnvrt.coords(xl,yl)$fig

  par(plt=c(pc$x,pc$y),xpd=FALSE)

  fun

  par(old.par)
  box() # need to plot something to reset

}  

 
Hope this helps,


-- 
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 Andreas Svensson
Sent: Wednesday, May 24, 2006 10:52 AM
To: r-help@stat.math.ethz.ch
Subject: [R] Regression line limited by the rage of values

Hi

In R, using  plot(x,y)   followed by abline(lm(y~x)) produces a graph 
with a regression line spanning the whole plot . This means that the
line extends beyond the swarm of data points to the defined of default
plot region. With par(xpd=T) it will span the entire figure region. But
how can I limit a regression line to the data range, i.e between
(xmin,ymin) and  (xmax,ymax)?

Sorry for not knowing the lingo here. If you don't understand the
question, please run the following script:

x1-c(1,2,3,4)
x2-c(5,6,7,8)
y1-c(2,4,5,8)
y2-c(10,11,12,16)
plot(x1,y1,xlim=c(0,10),ylim=c(0,20),col=blue)
points(x2,y2,col=red)
abline(lm(y1~x1),col=blue)
abline(lm(y2~x2),col=red)

The resulting plot isn't very informative. There is no overlap in the
two groups of data, yet the two ablines overlap.
I instead  want the blue line to go from (1,2) to (4,8) and the red line
from (5,10) to (8,16).

So, how can I constrain the abline to the relevant region, i.e stop
abline from extrapolating beyond the actual range of data.
Or should I use a function line 'lines' to do this?

Cheers
Andres

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

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


[R] Logistic Regression - Results?

2006-05-24 Thread Wojciech Gryc
Hi,

I use SPSS at work and have R installed both at work and on my home machine.
I've been trying to do some logistic regressions in R and SPSS, but the
results I'm getting are different. I've followed a few R tutorials, and with
most of them, I get the following instructions:

result - glm(z ~ x + y, family=binomial(logit))

In the case above, with three variables (z being dependent).

In SPSS, I'm told to use Analyze - Regression - Binary Logistic, where I
put x, y in Covariates and z in Dependent. Note that my values for x and
y are either 1 or 0.

The results I get from these two tests are different, however, and I was
wondering why. Am I choosing the wrong commands? If not, why are the results
different? Any help would be greatly appreciated, and please note that I
have a limited amount of stats knowledge.

Thanks,
Wojciech

-- 

Five Minutes to Midnight:
Youth on human rights and current affairs
http://www.fiveminutestomidnight.org/

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


Re: [R] How to make attributes persist after indexing?

2006-05-24 Thread Heinz Tuechler
Thank you for your answer, Gabor. I will see, if I understood it.

Heinz

At 11:31 24.05.2006 -0400, Gabor Grothendieck wrote:
You could create your own child class with its own [ method.

[.myfactor - function(x, ...) {
   attr - attributes(x)
   x - NextMethod([)
   attributes(x) - attr
   x
}

gx - structure(fx, class = c(myfactor, class(fx)))
attributes(gx[1])


On 5/24/06, Heinz Tuechler [EMAIL PROTECTED] wrote:
 Dear All!

 For descriptive purposes I would like to add attributes to objects. These
 attributes should be kept, even if by indexing only part of the object is
 used.
 I noted that some attributes like levels and class of a factor exist also
 after indexing, while others, like comment or label vanish.
 Is there a way to make an arbitrary attribute to be kept after indexing?
 This would be especially useful when indexing a data.frame.

 ## example for loss of attributes
 fx - factor(1:5, ordered=TRUE)
 attr(fx, 'comment') - 'Comment for fx'
 attr(fx, 'label') - 'Label for fx'
 attr(fx, 'testattribute') - 'just for fun'
 attributes(fx)  # all attributes are shown
 attributes(fx[])# all attributes are shown
 attributes(fx[1:5]) # only levels and class are shown
 attributes(fx[1])   # only levels and class are shown

 Thanks,

 Heinz Tüchler

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




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


[R] plot xy data with error bars

2006-05-24 Thread Tibi Codilean
Dear All, 
 
I have x,y data with errors associated with both x and y. What would be the 
easiest way of creating plots with both x and y ? 
 
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


[R] plot xy data with error bars

2006-05-24 Thread Tibi Codilean
Dear All,  
  
I have x,y data with errors associated with both x and y. What would be the 
easiest way of creating plots with both x and y error bars?  
  
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


Re: [R] Does R have EGARCH modeling function?

2006-05-24 Thread Spencer Graves
  I just got 39 hits for RSiteSearch(egarch).  The one that looks to 
me like it comes the closest to answering your question is 
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/49245.html;.

  I don't know the definition of egarch, but I would expect that it 
would not be too hard to program if you know the definition.  You could 
read the source code for some of the other GARCH-type functions, find 
one that's moderately close, and modify it.

  hope this helps.
  Spencer Graves

Michael wrote:
 I've downloaded fSeries, but looks like it just has an interface to OX(TM)
 Garch Modeling Software,and that OX(TM) software package is not free.
 
 So where can I find an EGARCH function that is truely usable?
 
 Thanks a lot!
 
   [[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

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


Re: [R] general Gauss-Newton or support for NSUR: contemporaneously correlated non-linear models

2006-05-24 Thread Spencer Graves
  Have you looked at nlme and the book Pinheiro and Bates (2000) 
Mixed-Effects Models in S and S-Plus (Springer)?  I'm not familiar with 
NSUR, but it sound like nlme might handle it very well.

  hope this helps,
  Spencer Graves

Thomas Wutzler wrote:
 Dear r-Help readers,
 
 1) Is there support for NSUR in some R package yet?
 2) Is there a general function of applying the Gauss-Newton or Marquard 
 method, in which the function of calculating the partial derivatives can 
 be specified by the user?
 
 Contemporaneously correlated non-linear models (NSUR) is a method to fit 
 a system of non-linear equations.
 
 I want to use to fit several non-linear models at the same time, so that 
 one the independent variable is alsway the sum of several other 
 independent variable of other models.
 This procedure is described in detail by Parresol 2001. He used PROC 
 MODEL by SAS to accomplish the task.
 
 If there is no support for NSUR yet, I would try to program a function 
 by myself, although I only used very simple R-functins yet. The 
 essential part is the fit the minimum of complex vector equation. This 
 leads to my second question above. The function (as provided as an 
 parameter) should accept a vector of model parameters and calculate the 
 matrix of partial derivatives at this point in the parameter space.
 
 
 Thanks
 Thomas
 
 Parresol, B.R., 2001. Additivity of nonlinear biomass equations. 
 Canadian Journal of Forest Research-Revue Canadienne De Recherche 
 Forestiere 31, 865-878.
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

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


Re: [R] How to make attributes persist after indexing?

2006-05-24 Thread Marc Schwartz
On Thu, 2006-05-25 at 00:43 +0100, Heinz Tuechler wrote:
 Thank you for your answer, Gabor. I will see, if I understood it.
 
 Heinz
 
 At 11:31 24.05.2006 -0400, Gabor Grothendieck wrote:
 You could create your own child class with its own [ method.
 
 [.myfactor - function(x, ...) {
attr - attributes(x)
x - NextMethod([)
attributes(x) - attr
x
 }
 
 gx - structure(fx, class = c(myfactor, class(fx)))
 attributes(gx[1])
 

Heinz,

What Gabor has proposed is essentially what Frank Harrell does in the
Hmisc package (which I referenced), though in a more generic fashion
with respect to the attributes that are saved and reset.

By using:

  gx - structure(fx, class = c(myfactor, class(fx)))

you are taking an object 'fx' and adding a child class attribute called
myfactor to it. So it is in effect an object that retains the
attributes of the original class of 'fx', plus the new class attribute
'myfactor'.

As a parallel, for example, consider that a square is a child class of a
rectangle. A square inherits all of the attributes of a rectangle, plus
the additional attribute that all four sides are of equal length. So for
example, if 'x' is a square, you might see:

 x
[1] 4 4 4 4
attr(,class)
[1] squarerectangle

as compared to a rectangle 'y':

 y
[1] 4 2 4 2
attr(,class)
[1] rectangle


Note the two class attributes for 'x', with 'square' preceding
'rectangle' in the order. The order is important, because in R, function
methods are dispatched based upon the class attributes in the order that
they appear in the vector.

So...back to 'gx'.

When the generic [ function is called with gx (ie. gx[1]), the first
class attribute 'myfactor' is picked up from 'gx'. Then, the method that
Gabor has presented, [.myfactor, is dispatched (executed). It is the
generic function [ with the specific class method defined by
.myfactor.

In that function, the first thing that takes place is that the
attributes of the 'x' argument are saved in 'attr'. 

  attr - attributes(x)

This would include any new attributes that you have defined and added,
such as labels and comments.

The next thing that happens is that the generic [ is now called again:

  x - NextMethod([)

but this time, the method dispatched is based upon the Next entry in
the class vector. In this case, whatever the original class of 'fx' was,
which could be an atomic vector, a factor, a matrix or a data frame, for
example.

You can see the methods available for [ by using:

   methods([)

The appropriate method for [ is then executed, resulting in 'x', which
is the subset version of 'gx'. 

Then:

  attributes(x) - attr

restores the original attributes saved in 'attr' to 'x'.

Then, finally, the 'x' object is returned to the calling environment.

So, in effect, you have created a new subset function [ that retains
your new attributes. The great thing about this, is that once the method
is defined in your working environment, all you have to do is to add the
newly associated class attribute to the objects you want to subset and R
does the rest transparently.

Thus:

# Add the new method
[.myfactor - function(x, ...) {
   attr - attributes(x)
   x - NextMethod([)
   attributes(x) - attr
   x
}

# Create fx
fx - factor(1:5, ordered = TRUE)
attr(fx, 'comment') - 'Comment for fx'
attr(fx, 'label') - 'Label for fx'
attr(fx, 'testattribute') - 'just for fun'

 attributes(fx)
$levels
[1] 1 2 3 4 5

$class
[1] ordered factor

$comment
[1] Comment for fx

$label
[1] Label for fx

$testattribute
[1] just for fun


# Create gx, which is identical to fx, with the 
# additional class attribute
gx - structure(fx, class = c(myfactor, class(fx)))

 attributes(gx)
$levels
[1] 1 2 3 4 5

$class
[1] myfactor ordered  factor   # - Note change here

$comment
[1] Comment for fx

$label
[1] Label for fx

$testattribute
[1] just for fun


# Show the structure of fx[1]
# Note that other attributes are lost
 str(fx[1])
 Ord.factor w/ 5 levels 1234..: 1


# Show the structure of gx[1]
# Note that attributes are retained
 str(gx[1])
 Ord.factor w/ 5 levels 1234..: 1
 - attr(*, comment)= chr Comment for fx
 - attr(*, label)= chr Label for fx
 - attr(*, testattribute)= chr just for fun


HTH,

Marc Schwartz

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


Re: [R] general Gauss-Newton or support for NSUR: contemporaneously correlated non-linear models

2006-05-24 Thread David Scott
On Wed, 24 May 2006, Spencer Graves wrote:

 Have you looked at nlme and the book Pinheiro and Bates (2000)
 Mixed-Effects Models in S and S-Plus (Springer)?  I'm not familiar with
 NSUR, but it sound like nlme might handle it very well.

 hope this helps,
 Spencer Graves


I don't think this is what Thomas needs. NSUR is I think nonlinear 
seemingly unrelated regressions. The SUR bit means that the response is 
multivariate. If he hasn't already, Thomas should look at systemfit:

systemfit: Simultaneous Equation Estimation Package

This package contains functions for fitting simultaneous systems of linear 
and nonlinear equations using Ordinary Least Squares (OLS), Weighted Least 
Squares (WLS), Seemingly Unrelated Regressions (SUR), Two-Stage Least 
Squares (2SLS), Weighted Two-Stage Least Squares (W2SLS), Three-Stage 
Least Squares (3SLS), and Weighted Three-Stage Least Squares (W3SLS).


David Scott 
_
David Scott Department of Statistics, Tamaki Campus
The University of Auckland, PB 92019
AucklandNEW ZEALAND
Phone: +64 9 373 7599 ext 86830 Fax: +64 9 373 7000
Email:  [EMAIL PROTECTED]


Graduate Officer, Department of Statistics

ASC/NZSA 2006: Statistical Connections
The joint conference of the Statistical Society of Australia Inc.
and the New Zealand Statistical Association, July 3--6, 2006
in Auckland. Go to:

http://www.statsnz2006.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


[R] Ploting two datasets

2006-05-24 Thread Anderson de Rezende Rocha
Dears, 

I need your help. I have two sets A and B each one containing 
n lines and being composed by the atributes x and y. 

Three questions:
1) How can I plot A and B both on the same graphic? I need to show 
   that the classes A and B are separable. In this way, I need 
   to plot the points of A as *, and the points of B as +, for   
   example. This would result two clouds. 

2) How can I plot the result of question one using multi-levels, that 
   is, a set of ellipsis that start on the mean of A and on the 
   mean of B? 

3) How can I trace an hiperplane separating the classes A and B just 
   depicted in question 1?

I appreciate any help. Thanks for all.

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


[R] boosting

2006-05-24 Thread stephenc
Hi
 
I am using boosting for a classification and prediction problem.
 
For some reason it is giving me an outcome that doesn't fall between 0
and 1 for the predictions.  I have tried type=response but it made no
difference.
 
Can anyone see what I am doing wrong?
 
Screen output shown below:
 
 
 boost.model - gbm(as.factor(train$simNuance) ~ ., # formula
+  data=train,   # dataset
+   # +1: monotone increase,
+   #  0: no monotone restrictions
+  distribution=gaussian, # bernoulli, adaboost, gaussian,
+   # poisson, and coxph available
+  n.trees=3000,# number of trees
+  shrinkage=0.005, # shrinkage or learning rate,
+   # 0.001 to 0.1 usually work
+  interaction.depth=3, # 1: additive model, 2: two-way
interactions, etc.
+  bag.fraction = 0.5,  # subsampling fraction, 0.5 is
probably best
+  train.fraction = 0.5,# fraction of data for training,
+   # first train.fraction*N used
for training
+  n.minobsinnode = 10, # minimum total weight needed in
each node
+  cv.folds = 5,# do 5-fold cross-validation
+  keep.data=TRUE,  # keep a copy of the dataset
with the object
+  verbose=FALSE)# print out progress
 
 best.iter = gbm.perf(boost.model,method=cv)
 pred = predict.gbm(boost.model, test, best.iter)
 summary(pred)
   Min. 1st Qu.  MedianMean 3rd Qu.Max. 
 0.4772  1.5140  1.6760  1.5100  1.7190  1.9420   

Checked by AVG Free Edition.

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

Re: [R] exporting long character vectors to dbf

2006-05-24 Thread Eduardo Leoni
I am trying to use RODBC, but still run into some problems. If I
understood correctly, I have to change the default type for char
vectors to text (or varchar(3000)). But when I try something like

library(RODBC)
channel - odbcConnect(supremo, uid=R, case=tolower)
setSqlTypeInfo(MySQL,
list(double=double,
 integer=integer,
 character=varchar(3000),
 logical=varchar(5)))

Warning message:
number of items to replace is not a multiple of replacement length

I think there is a pair of brackets missing in setSqlTypeInfo here
typesR2DBMS[driver] - value[c(double, integer, character,
logical)]

by the way, is there any easy way to debug packages that does not
involve reapeatedly modifying, compiling and installing them again??






On 5/24/06, Prof Brian Ripley [EMAIL PROTECTED] wrote:
 On Wed, 24 May 2006, Mulholland, Tom wrote:

  I assume this is (or was) a specification issue. I think write.dbf uses
  the shapefile library (C not R library) so it applies to the use of
  shapefiles and just happens to have been included in the foreign package
  because it has a generic usefullness. (Is that a word?)

 Actually, the width of the dbf field comes from the lines in write.dbf:

  else if (is.character(x)) {
  mf - max(nchar(x[!is.na(x)]))
  precision[i] - min(max(nlen, mf), 254)
  scale[i] - 0

 so that's the limit (254, not 255).  This is stated as a limitation of the
 dbf format at
 http://www.clicketyclick.dk/databases/xbase/format/data_types.html
 so I don't think you can do what you want with .dbf.

  Since I very rarely care about the elegance of my solutions, just that
  they work, I would try saving the file in another format that you can
  get open office to read and let it do the conversion rather than trying
  to get R to do it. I'm sure OpenOffice can deal with straightforward
  text files if that's a last resort.

 Indeed.  Using an ODBC driver (and RODBC) to write to the database might
 be a good option.

 
  Tom
 
  -Original Message-
  From: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED] Behalf Of Eduardo Leoni
  Sent: Wednesday, 24 May 2006 7:13 AM
  To: r-help@stat.math.ethz.ch
  Subject: [R] exporting long character vectors to dbf
 
 
  Hi -
 
  I need to export data to openoffice base, where one of the elements is
  a long character vector (255 characters.) write.dbf exports it as
  varchar, truncating the data. Any idea how to do this?
 
  thanks,
 
  -eduardo
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide!
  http://www.R-project.org/posting-guide.html
 
 
  __
  R-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
 

 --
 Brian D. Ripley,  [EMAIL PROTECTED]
 Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
 University of Oxford, Tel:  +44 1865 272861 (self)
 1 South Parks Road, +44 1865 272866 (PA)
 Oxford OX1 3TG, UKFax:  +44 1865 272595


__
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