[R] Help on read in a txt file

2008-04-25 Thread ssls sddd
Dear list,

Hello! I had a problem of reading in a txt file and need your help.
The txt file, called A, comprises of 592 columns and 34179 rows.
I need to note that for some cells of A , A[i,j], are blank.

I used read.table() and got the warning message:

 A-read.table(file=A.txt,sep=\t)
Warning message:
In scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  :
  number of items read is not a multiple of the number of columns
 dim(A)
[1] 33623   592

However, as some rows were missed because the original number
of rows is 34179, after read.table(), it was decreased to 33623.
I have no idea whether it has anything to do with the warning message.

Do you have any suggestions for this problem?

Thanks much,
Alex

[[alternative HTML version deleted]]

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


Re: [R] Use of survreg.distributions

2008-04-25 Thread Abdus Sattar
Dear R-user: 
 
I am using survreg(Surv()) for fitting a Tobit model of left-censored 
longitudinal data. For logarithmic transformation of y data, I am trying use 
survreg.distributions in the following way: 
tfit=survreg(Surv(y, y=-5, type=left)~x + cluster(id), dist=gaussian, 
data=y.data, scale=0, weights=w) 
my.gaussian-survreg.distributions$gaussian
my.gaussian$name=lognormal
my.gaussian$dist-my.gaussian
tfit=survreg(Surv(y, y=-5, type=left)~x + cluster(id), dist=my.gaussian, 
data=y.data, scale=0, weights=w) 
 
If I run these codes then I got the following error message, 
 
Error in survreg(Surv(y, y = -5, type = left) ~ x +  :
Invalid distribution object

Does anybody can help me in identifying the error(s) in these code please? 
 
Advance thanks for your time. 
 
Abdus Sattar
[EMAIL PROTECTED] 


  


[[elided Yahoo spam]]
[[alternative HTML version deleted]]

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


[R] request for Unsubscribe

2008-04-25 Thread Amir Kavousi
Dear 
   
  Please unsubscribe my email from mailing list of R-Help. 
   
  Thanks 
   
  Amir Kavousi 
   
  [EMAIL PROTECTED]

   
-
[[elided Yahoo spam]]
[[alternative HTML version deleted]]

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


Re: [R] Using image function to plot character values

2008-04-25 Thread Dieter Menne
Eric Bell eric at ericjbell.com writes:

 A secondary problem is that after I do the conversion, I need to know
 what codes were converted to what numeric values.
 

Column-wise factor conversion can be handy, but often it bites.

# Assume you have the data file
m1 m2
A B
B C
C D

#---
# make sure that no column-wise factor conversion is done
dv - read.csv( a.txt, header=TRUE,sep= ,stringsAsFactors=FALSE)
# find unique levels in the whole data set
faklevels = unique(unlist(dv))
dv[] = lapply(dv,function(x) factor(x,levels=faklevels))
# now we have common levels for all columns, we can convert to numerics
dv[] = lapply(dv,as.numeric)

# or combine the two above
#dv[] = lapply(dv,function(x) as.numeric(factor(x,levels=faklevels)))


Dieter

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


Re: [R] request for Unsubscribe

2008-04-25 Thread Peter Dalgaard
Amir Kavousi wrote:
 Dear 

   Please unsubscribe my email from mailing list of R-Help. 

   
Please use the unsubscription mechanism at
 https://stat.ethz.ch/mailman/listinfo/r-help
   
(near the bottom)


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

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


[R] Constructing dummy variables for months for a time series object

2008-04-25 Thread Megh Dal
I have a TS of monthly observations. 
   
  head(data4)
 1991(1)  1991(2)  1991(3)  1991(4)  1991(5)  1991(6) 
12.00864 11.94203 11.98386 12.01900 12.19226 12.15488 

  Now I want to make 11 dummy variables indicating months. Therefore I did 
followings :
   
  For Jan :
  rep(c(rep(0,0), 1, rep(0, 11)), 17)
   
  For Feb :
  rep(c(rep(0,1), 1, rep(0, 10)), 17)
   
   and so on
   
  But my question is there any way to aumate this? Or I have to do the above 
thing for all 11 months?

   
-
[[elided Yahoo spam]]
[[alternative HTML version deleted]]

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


[R] How to overlap two density plots?

2008-04-25 Thread Emre Unal
Hi,

How can I overlap two density plots?


A - c(8,10,10,11,11,11,12,12,12,12,11,11,11,10,10,7)
B - c(11,13,13,14,14,14,15,15,15,15,14,14,14,13,13,10)

plot(density(A))
plot(density(B))

Regards,
Emre


P.S. There's a overlap.density function in package DAAG
Is there another way to do this?




-- 
---
Emre ÜNAL
http://www.geocities.com/dusemre

[[alternative HTML version deleted]]

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


Re: [R] force glm estimates to be nonnegative

2008-04-25 Thread Samu Mäntyniemi
You could use the BRugs package and formulate your prior knowledge about 
  slopes in terms of a probability distribution.

Michele Christina Itten kirjoitti:
 Is there a way to force certain formula parameters to be nonnegative?
 
 What I want to do is to estimate student capacity over time, namely by
 
  capacity ~ Student + Student:Day
 
 I add this formula to a glm call and obtain negative learning slope estimates 
 (Student:Day) in some cases. 
 However, I don't want to allow for that. In such a case, glm should solve 
 
 capacity ~ Student
 
 and I will set the slope to zero. 
 
 Is there an option to constrain a parameter set to nonnegative values?
 
 
 
 
 Many thanks in advance!
 
 Michele Itten,
 BS. Carnegie Mellon
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 


-- 
--
Samu Mäntyniemi
Researcher
Fisheries and Environmental Management Group (FEM)
Department of Biological and Environmental Sciences
Biocenter 3, room 4414
Viikinkaari 1
P.O. Box 65
FIN-00014 University of Helsinki

Phone: +358 9 191 58710
Fax: +358 9 191 58257

email: [EMAIL PROTECTED]
personal webpage: http://www.helsinki.fi/people/samu.mantyniemi/
FEM webpage: http://www.helsinki.fi/science/fem/

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


Re: [R] make check errors with R 2.7.0

2008-04-25 Thread Patrick Connolly
On Fri, 25-Apr-2008 at 06:12AM +0100, Prof Brian Ripley wrote:

 Note that the problem is not that you got the message, but an apparent 
 whitespace issue in the output.  That's clearer in this version: note that 
 the output for reg-IO.Rout.save is shifted left one column.  But I don't 
 trust email to transmit these things faithfully (especially after the last 
 two days of encoding issues).

 So the problem is most likely either the way reg-IO.Rout.save got unpacked 
 or your 'diff' function.

That was well-spotted.  I notice that according to Emacs,
reg-IO.Rout.save is a DOS text file.  Can't say I've seen that before.


 You don't mention an OS, but my recollection is that you usually use Linux. 
  I *have* seen an error in this test on Cygwin, where the issue was the 
 unpacking by tar.

This is Fedora 8 (32 bit).  Previously, I'd used FC6 (64 bit) which
had a problem unpacking the gz file.  That was simply fixed by redoing
it -- so much for the deterministic nature of that machine.

[]

 Do I have any cause for concern?

 Some, but with your toolset.

Thanks for the hint.  On the strength of it, I checked and noticed
that there were, indeed, updates for make, diffutils and unzip.  So I
updated them and retried the installation.  Everything went fine as
I'm accustomed to seeing (and Emacs doesn't think it's reading DOS
text files).

Brian, you're a genius.

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___Patrick Connolly   
 {~._.~} Great minds discuss ideas
 _( Y )_Middle minds discuss events 
(:_~*~_:)Small minds discuss people  
 (_)-(_)   . Anon
  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.

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


Re: [R] Constructing dummy variables for months for a time series object

2008-04-25 Thread N. Lapidus
 GenDummyVar - function (NumMonth) rep(c(rep(0, NumMonth-1), 1, rep(0,
12-NumMonth)), 17)
 NameDummy - c(DJan, DFeb, DMar, DApr, DMay, DJun, DJul,
DAug, DSep, DOct, DNov, DDec)
 for (NumMonth in 1:12) assign(NameDummy, GenDummyVar (NumMonth))

 DJan
  [1] 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0
 [74] 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0
[147] 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1
 DFeb
  [1] 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
 [74] 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1
[147] 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0

Is this what you need ?
Why 11 (and not 12) months ?
Nael


On Fri, Apr 25, 2008 at 9:40 AM, Megh Dal [EMAIL PROTECTED] wrote:

 I have a TS of monthly observations.

  head(data4)
  1991(1)  1991(2)  1991(3)  1991(4)  1991(5)  1991(6)
 12.00864 11.94203 11.98386 12.01900 12.19226 12.15488

  Now I want to make 11 dummy variables indicating months. Therefore I did
 followings :

  For Jan :
  rep(c(rep(0,0), 1, rep(0, 11)), 17)

  For Feb :
  rep(c(rep(0,1), 1, rep(0, 10)), 17)

   and so on

  But my question is there any way to aumate this? Or I have to do the above
 thing for all 11 months?


 -
 [[elided Yahoo spam]]
[[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


Re: [R] Constructing dummy variables for months for a time series object

2008-04-25 Thread N. Lapidus
Oops.. the last line should have been :
for (NumMonth in 1:12) assign(NameDummy[NumMonth], GenDummyVar (NumMonth))

On Fri, Apr 25, 2008 at 10:18 AM, N. Lapidus [EMAIL PROTECTED] wrote:

  GenDummyVar - function (NumMonth) rep(c(rep(0, NumMonth-1), 1, rep(0,
 12-NumMonth)), 17)
  NameDummy - c(DJan, DFeb, DMar, DApr, DMay, DJun, DJul,
 DAug, DSep, DOct, DNov, DDec)
  for (NumMonth in 1:12) assign(NameDummy, GenDummyVar (NumMonth))

  DJan
   [1] 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0
  [74] 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1
 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0
 [147] 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0
 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1
  DFeb
   [1] 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0
 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
  [74] 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1
 [147] 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0

 Is this what you need ?
 Why 11 (and not 12) months ?
 Nael



 On Fri, Apr 25, 2008 at 9:40 AM, Megh Dal [EMAIL PROTECTED] wrote:

 I have a TS of monthly observations.

  head(data4)
  1991(1)  1991(2)  1991(3)  1991(4)  1991(5)  1991(6)
 12.00864 11.94203 11.98386 12.01900 12.19226 12.15488

  Now I want to make 11 dummy variables indicating months. Therefore I did
 followings :

  For Jan :
  rep(c(rep(0,0), 1, rep(0, 11)), 17)

  For Feb :
  rep(c(rep(0,1), 1, rep(0, 10)), 17)

   and so on

  But my question is there any way to aumate this? Or I have to do the
 above thing for all 11 months?


 -
 [[elided Yahoo spam]]
[[alternative HTML version deleted]]

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




[[alternative HTML version deleted]]

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


Re: [R] request for Unsubscribe

2008-04-25 Thread Knut Krueger
Amir Kavousi schrieb:
 Dear 

   Please unsubscribe my email from mailing list of R-Help. 

   Thanks 

   Amir Kavousi 

   [EMAIL PROTECTED]
   
you can unsubsribe at the following page by yourself.
(including password reminder)

https://stat.ethz.ch/mailman/listinfo/r-help

Regards Knut

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


[R] Non-linear system of equations

2008-04-25 Thread Radka Pancheva
Hello R users,

I am trying to estimate the parameters of a bimodal normal distribution using 
moments matching, so I have to solve a non-linear system of equations. How can 
I solve the following simple example? 

x^2 - y^2 = 6
x – y = 3

I heard about nlsystemfit, but I don’t know how to run it exactly. I have tried 
the following code, but it doesn’t really work:


f1 -y~ x[1]^2-x[2]^2-6
f2 -z~ x[1]-x[2]-3
f  - list(f1=0,f2=0)
nlsystemfit(OLS,f,startvals=c(0,0))

Thank You in advance for your help.

Evgeniq Petrova

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


Re: [R] Using image function to plot character values

2008-04-25 Thread Jim Lemon
Eric Bell wrote:
 Hello. I am a newbie to R. If I should be reading some FAQ or manual
 that could help answer my question please tell me and I will go there.
 
 Problem: 
 
 I have a spreadsheet that contains a character code in each cell. The
 columns in the spreadsheet represent time and the rows represent people.
 I want to use the image function to display this information, but the
 image function requires numeric data. I know how to read in the
 spreadsheet into a data frame, but if I use data.matrix to convert data
 frame into a numeric matrix, each column gets converted separately, so
 that the same character code may get converted to a different numeric
 code depending on the column. How do I apply the character to numeric
 conversion so that each character gets converted to the same numeric
 value?
 
 A secondary problem is that after I do the conversion, I need to know
 what codes were converted to what numeric values.
 
Hi Eric,
Using your example data frame,

matrix(as.numeric(unlist(dv)),nrow=dim(dv)[1])

gives you the matrix you want, and

levels(unlist(dv))
unique(as.numeric(unlist(dv)))

gives you the correspondence between character codes and numbers.

Jim

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


[R] grid() : start values?

2008-04-25 Thread Agustin Lobo
Hi,
is not there any way to tell grid() the starting value? With nx,ny
I get the right number of grid cells, but not on the exact
values I would like them. (I know I can do it with abline(), just
asking for an easier way, i.e. grid(nx,nx,start.x,start.y))

An alternative way (which would solve another problem) would be making 
the axes coincident with the rectangular plot region, that is, if ploting
plot(0:10,0:10)

get (0,0) just on the bottom down corner of the rectangle. I've tried 
with several par() and could not find the way.

Thanks

Agus
-- 
Dr. Agustin Lobo
Institut de Ciencies de la Terra Jaume Almera (CSIC)
LLuis Sole Sabaris s/n
08028 Barcelona
Spain
Tel. 34 934095410
Fax. 34 934110012
email: [EMAIL PROTECTED]
http://www.ija.csic.es/gt/obster

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


Re: [R] Non-linear system of equations

2008-04-25 Thread Paul Smith
2008/4/25 Radka Pancheva [EMAIL PROTECTED]:
  I am trying to estimate the parameters of a bimodal normal distribution 
 using moments matching, so I have to solve a non-linear system of equations. 
 How can I solve the following simple example?

  x^2 - y^2 = 6
  x – y = 3

  I heard about nlsystemfit, but I don't know how to run it exactly. I have 
 tried the following code, but it doesn't really work:


  f1 -y~ x[1]^2-x[2]^2-6
  f2 -z~ x[1]-x[2]-3
  f  - list(f1=0,f2=0)
  nlsystemfit(OLS,f,startvals=c(0,0))

You could try the recent package BB by Ravi Varadhan. The code could
be the following:

library(BB)

f - function(x) {
  x1 - x[1]
  x2 - x[2]

  F - rep(NA, 2)

  F[1] - x1^2 - x2^2 - 6
  F[2] - x1 - x2 - 3

  return(F)
}

p0 - c(1,2)
dfsane(par=p0, fn=f,control=list(maxit=3000))

I got the solution:

x1 = 2.5
x2 = -0.5

Paul

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


Re: [R] How to overlap two density plots?

2008-04-25 Thread David Winsemius
Emre Unal [EMAIL PROTECTED] wrote in 
news:[EMAIL PROTECTED]:

 Hi,
 
 How can I overlap two density plots?
 
 
 A - c(8,10,10,11,11,11,12,12,12,12,11,11,11,10,10,7)
 B - c(11,13,13,14,14,14,15,15,15,15,14,14,14,13,13,10)
 
 plot(density(A))

Instead:
lines(density(B))

-- 
David Winsemius



 plot(density(B))
 
 Regards,
 Emre
 
 
 P.S. There's a overlap.density function in package DAAG
 Is there another way to do this?
 
 
 


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


Re: [R] Non-linear system of equations

2008-04-25 Thread Radka Pancheva
Hello Paul,

Thank you for your quick answer. I have tried to use your advice and to 
estimate the parameters of beta distribution with moments matching. This is my 
code:


ex - 0.3914877
ex2 - 0.2671597

my.mm - function(x){
p - x[1]
q - x[2]
p -  .Machine$double.eps
q -  .Machine$double.eps

F - rep(NA,2)

F[1] - p/(p + q)
F[2]- (p*q + (p + q + 1)*p^2)/((p + q + 1)*(p + q)^2)

return(F)
}

p0 - c(ex,ex2)

dfsane(par=p0, fn=my.mm,control=list(maxit=5))

and I became the following output:

…
iteration:  3640  ||F(xn)|| =   0.7071068
iteration:  3641  ||F(xn)|| =   0. 7071068
…
iteration:  49990  ||F(xn)|| =   0. 7071068
iteration:  5  ||F(xn)|| =   0. 7071068
$par
[1] -446.2791 -446.4034

$residual
[1] 0.5

$fn.reduction
[1] 0

$feval
[1] 828495

$iter
[1] 50001

$convergence
[1] 1

$message
[1] Maximum limit for iterations exceeded

I have tried maxiter=10 but the output is the same. I know that ex and ex2 
are bringing the problems, but I am stuck with them. How can I make it 
convergent?

Thank you,

Evgeniq

 2008/4/25 Radka Pancheva [EMAIL PROTECTED]:
   I am trying to estimate the parameters of a bimodal normal distribution 
  using moments matching, so I have to solve a non-linear system of 
  equations. How can I solve the following simple example?
 
   x^2 - y^2 = 6
   x – y = 3
 
   I heard about nlsystemfit, but I don't know how to run it exactly. I have 
  tried the following code, but it doesn't really work:
 
 
   f1 -y~ x[1]^2-x[2]^2-6
   f2 -z~ x[1]-x[2]-3
   f  - list(f1=0,f2=0)
   nlsystemfit(OLS,f,startvals=c(0,0))
 
 You could try the recent package BB by Ravi Varadhan. The code could
 be the following:
 
 library(BB)
 
 f - function(x) {
   x1 - x[1]
   x2 - x[2]
 
   F - rep(NA, 2)
 
   F[1] - x1^2 - x2^2 - 6
   F[2] - x1 - x2 - 3
 
   return(F)
 }
 
 p0 - c(1,2)
 dfsane(par=p0, fn=f,control=list(maxit=3000))
 
 I got the solution:
 
 x1 = 2.5
 x2 = -0.5
 
 Paul
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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


Re: [R] grid() : start values?

2008-04-25 Thread Duncan Murdoch
On 4/25/2008 5:32 AM, Agustin Lobo wrote:
 Hi,
 is not there any way to tell grid() the starting value? With nx,ny
 I get the right number of grid cells, but not on the exact
 values I would like them. (I know I can do it with abline(), just
 asking for an easier way, i.e. grid(nx,nx,start.x,start.y))

See the help page:

If more fine tuning is required, use 'abline(h = ., v = .)'
  directly.

Just use

abline(h=seq(starty, stopy, len=ny), v=seq(startx, stopx, len=nx))

Duncan Murdoch

 
 An alternative way (which would solve another problem) would be making 
 the axes coincident with the rectangular plot region, that is, if ploting
 plot(0:10,0:10)
 
 get (0,0) just on the bottom down corner of the rectangle. I've tried 
 with several par() and could not find the way.
 
 Thanks
 
 Agus

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


Re: [R] How to overlap two density plots?

2008-04-25 Thread Philipp Pagel
On Fri, Apr 25, 2008 at 10:57:27AM +0300, Emre Unal wrote:
 
 How can I overlap two density plots?
 
 A - c(8,10,10,11,11,11,12,12,12,12,11,11,11,10,10,7)
 B - c(11,13,13,14,14,14,15,15,15,15,14,14,14,13,13,10)
 
plot(density(A))
lines(density(B))

cu
Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
 
 and
 
Institut für Bioinformatik und Systembiologie / MIPS
Helmholtz Zentrum München -
Deutsches Forschungszentrum für Gesundheit und Umwelt
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany
http://mips.gsf.de/staff/pagel

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


[R] No rule to make target 'R/Copy'

2008-04-25 Thread Ardia David
Dear all,
I am currently building  a package with C code (in scr folder). 
Everything was ok, but now, I get the following error message when 
compiling the package using R CMD INSTALL:
make[2]: *** No rule to make target 'R/Copy', needed in [...]
What does that mean? I can still compile other packages containing C 
code, but not that one. No 00UNLOCK directory has been created . I am on 
a IBM PC, and use windows XP.
Thanks for your help
-- 
David Ardia
H-building, room 11-26
Econometric Institute
Erasmus University
PO Box 1738
NL 3000 DR Rotterdam
The Netherlands
Phone: +31 (0)10 408 2269

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


Re: [R] Use of survreg.distributions

2008-04-25 Thread Terry Therneau
--begin included message ---
 
I am using survreg(Surv()) for fitting a Tobit model of left-censored 
longitudinal data. For logarithmic transformation of y data, I am trying use 
survreg.distributions in the following way: 
tfit=survreg(Surv(y, y=-5, type=left)~x + cluster(id), dist=gaussian, 
data=y.data, scale=0, weights=w) 
my.gaussian-survreg.distributions$gaussian
my.gaussian$name=lognormal
my.gaussian$dist-my.gaussian
tfit=survreg(Surv(y, y=-5, type=left)~x + cluster(id), dist=my.gaussian, 
data=y.data, scale=0, weights=w) 
 
If I run these codes then I got the following error message, 
 
Error in survreg(Surv(y, y = -5, type = left) ~ x +  :
Invalid distribution object

Does anybody can help me in identifying the error(s) in these code please? 
 
--- end include 

  Can you tell us what you are trying to do?  
  Your first model was a fit of y ~ x + eps, eps ~ Gaussian.  If what you want 
is log(y) ~ x + eps, then all that you need do is use dist=loggaussian in the 
survreg call.  (Or 'lognormal'; which is the same distribution.)
  
Terry Therneau

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


Re: [R] Non-linear system of equations

2008-04-25 Thread Berend Hasselman



 x^2 - y^2 = 6
 x – y = 3
 
 

You can also try this

# function

f - function(x) {
y - numeric(2)
y[1] - x[1]^2-x[2]^2-6
y[2] - x[1]-x[2]-3

y
}   

# function values transformed to scalar 
# minimising fnorm this way is not the best method of finding a solution for
f(x)=0
# there may be values for x which minimise fnorm but do not set f(x) = 0
# but you can always try

fnorm - function(z) {p - f(z);return(crossprod(p))}

#starting values
xstart - c(0,0)

# You can use nlm or nlminb

nlm(fnorm,xstart)

nlminb(xstart,fnorm)

Sometimes minpack.lm can be used to find roots.
Do

library(minpack.lm)
nls.lm(xstart,f)

and in this case you'll see that it doesn't work.

In this case stick to nlm and/or nlminb.

Berend
-- 
View this message in context: 
http://www.nabble.com/Non-linear-system-of-equations-tp16893056p16895541.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Non-linear system of equations

2008-04-25 Thread Paul Smith
Try to change the initial values of the parameters with, for instance,

p0 - rnorm(2)

But you sure that your system has a solution, Evgeniq?

Paul


2008/4/25 Radka Pancheva [EMAIL PROTECTED]:
 Hello Paul,

  Thank you for your quick answer. I have tried to use your advice and to 
 estimate the parameters of beta distribution with moments matching. This is 
 my code:


  ex - 0.3914877
  ex2 - 0.2671597

  my.mm - function(x){
 p - x[1]
 q - x[2]
 p -  .Machine$double.eps
 q -  .Machine$double.eps

 F - rep(NA,2)

 F[1] - p/(p + q)
 F[2]- (p*q + (p + q + 1)*p^2)/((p + q + 1)*(p + q)^2)

 return(F)
  }

  p0 - c(ex,ex2)

  dfsane(par=p0, fn=my.mm,control=list(maxit=5))

  and I became the following output:

  …
  iteration:  3640  ||F(xn)|| =   0.7071068
  iteration:  3641  ||F(xn)|| =   0. 7071068
  …
  iteration:  49990  ||F(xn)|| =   0. 7071068
  iteration:  5  ||F(xn)|| =   0. 7071068
  $par
  [1] -446.2791 -446.4034

  $residual
  [1] 0.5

  $fn.reduction
  [1] 0

  $feval
  [1] 828495

  $iter
  [1] 50001

  $convergence
  [1] 1

  $message
  [1] Maximum limit for iterations exceeded

  I have tried maxiter=10 but the output is the same. I know that ex and 
 ex2 are bringing the problems, but I am stuck with them. How can I make it 
 convergent?

  Thank you,

  Evgeniq



   2008/4/25 Radka Pancheva [EMAIL PROTECTED]:
 I am trying to estimate the parameters of a bimodal normal distribution 
 using moments matching, so I have to solve a non-linear system of equations. 
 How can I solve the following simple example?
   
 x^2 - y^2 = 6
 x – y = 3
   
 I heard about nlsystemfit, but I don't know how to run it exactly. I 
 have tried the following code, but it doesn't really work:
   
   
 f1 -y~ x[1]^2-x[2]^2-6
 f2 -z~ x[1]-x[2]-3
 f  - list(f1=0,f2=0)
 nlsystemfit(OLS,f,startvals=c(0,0))
   
   You could try the recent package BB by Ravi Varadhan. The code could
   be the following:
   
   library(BB)
   
   f - function(x) {
 x1 - x[1]
 x2 - x[2]
   
 F - rep(NA, 2)
   
 F[1] - x1^2 - x2^2 - 6
 F[2] - x1 - x2 - 3
   
 return(F)
   }
   
   p0 - c(1,2)
   dfsane(par=p0, fn=f,control=list(maxit=3000))
   
   I got the solution:
   
   x1 = 2.5
   x2 = -0.5
   
   Paul
   


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

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


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


Re: [R] No rule to make target 'R/Copy'

2008-04-25 Thread Prof Brian Ripley
Do you have a space in some file name?  Starting 'Copy '?

On Fri, 25 Apr 2008, Ardia David wrote:

 Dear all,
 I am currently building  a package with C code (in scr folder).
 Everything was ok, but now, I get the following error message when
 compiling the package using R CMD INSTALL:
 make[2]: *** No rule to make target 'R/Copy', needed in [...]
 What does that mean? I can still compile other packages containing C
 code, but not that one. No 00UNLOCK directory has been created . I am on
 a IBM PC, and use windows XP.
 Thanks for your help
 -- 
 David Ardia
 H-building, room 11-26
 Econometric Institute
 Erasmus University
 PO Box 1738
 NL 3000 DR Rotterdam
 The Netherlands
 Phone: +31 (0)10 408 2269

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


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


Re: [R] R Newbie Question/Data Model

2008-04-25 Thread Rubén Roa-Ureta
[EMAIL PROTECTED] wrote:
 Given a data set and a set of predictors and a response in the data,
 we would like to find a model that fits the data set best.
 Suppose that we do not know what kind of model (linear, polynomial
 regression,... ) might be good, we are wondering if there is R-package(s)
 can auctomatically do this.
 Otherwise, can you direct me, or point out reference(s),
 basic steps to do this. Thanks.
 
 -james

The best-fitting model for any data is a model with a lot of parameters, 
so maybe the best fitting model for any data is a model with an infinite 
number of parameters. However, any model with more parameters than data 
will have a negative number of degrees of freedom, and you do not want 
that. The best-fitting model for any data subject to the constraint that 
the number of degrees of freedom is non-negative, is the data itself, 
with zero degrees of freedom.
The AIC tells you this too. The AIC for the model formed by the data 
itsel is 2n, whereas the AIC for any model with negative degrees of 
freedom is  2n.
But I guess you want to make inference from sample to population. If 
that is indeed the case, then you should consider changing your focus 
from finding a model that fits the data set best to a model that best 
summarizes the information contained in your sample about the population 
the sample comes from. To do that, start by defining the nature of your 
response variable. What is the nature of the natural process generating 
this response variable? Is it continuous or discrete? Is it univariate 
or multivariate? Can it take negative and positive values? Can it take 
values of zero? After you have clarified the probabilistic model for the 
response variable, then you can start thinking about the mathematical 
relation between the response variable and the predictors. Is it linear 
or nonlinear? Are the predictors categorical or continuous?
Read the posting guide, formulate a clear question, and maybe you will 
be given more specific help.
Rubén

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


[R] package compilation: including external libraries in windows compilation

2008-04-25 Thread Jonathan Lees
Dear R package developers:

I need help on getting a package compiled for windows.
I am trying to use definitions and routines from a
set of libraries in that are in LINUX under
#include netdb.h
#include sys/socket.h
#include netinet/in.h
#include arpa/inet.h

but these are unavailable in windows.
I found that we can get these by including, in windows these includes:

#include winsock2.h
#include io.h

My problem is I do not know how to instruct the preprocessor to include 
the linux .h files
when in linux and the windows one in windows.

I thought I found a solution online by using:

#if defined(Win32)
#include winsock2.h
#include io.h
#else
#ifdef HAVE_UNISTD_H
#include unistd.h
#endif
#ifdef HAVE_BSD_NETWORKING
#include netdb.h
#include sys/socket.h
#include netinet/in.h
#include arpa/inet.h
#endif
#endif

But I still get an error when these are compiled on the R-distribution.
I do not understand where I am supposed to set the Win32 flag so
that it will be ignored in LINUX but used in windows.
where is Win32 HAVE_UNISTD_H and HAVE_BSD_NETWORKING set?

It seems that Makevars.win would be logical place, but
I do not see how to do this.

Thanks for any help.

Jonathan Lees


-- Making package WINRPACK 
  adding build stamp to DESCRIPTION
  making DLL ...
making win2R.d from win2R.c
making win2asc.d from win2asc.c
gcc-sjlj  -std=gnu99  -Id:/Rcompile/recent/R-26~1.2/include -O3 -Wall  -c 
win2R.c -o win2R.o
win2R.c:21:24: error: sys/socket.h: No such file or directory
win2R.c:22:24: error: netinet/in.h: No such file or directory
win2R.c:23:23: error: arpa/inet.h: No such file or directory
win2R.c: In function 'read_data':
win2R.c:591: warning: implicit declaration of function 'ntohl'
win2R.c: In function 'read_one_sec':
win2R.c:723: warning: implicit declaration of function 'ntohs'
make[3]: *** [win2R.o] Error 1
make[2]: *** [srcDynlib] Error 2
make[1]: *** [all] Error 2
make: *** [pkg-WINRPACK] Error 2
*** Installation of WINRPACK failed ***








-- 
==
Prof. Jonathan M. Lees
Department of Geological Sciences
CB #3315, Mitchell Hall
University of North Carolina
Chapel Hill, NC  27599-3315
(919) 962-0695
FAX (919) 966-4519

[EMAIL PROTECTED]
http://www.unc.edu/~leesj

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


Re: [R] Non-linear system of equations

2008-04-25 Thread Ravi Varadhan
Hi Radka,

The problem lies in your function my.mm().  Especially, the following lines:

p -  .Machine$double.eps
q -  .Machine$double.eps

Even if you take out these 2 lines, still the definition is not correct, I
think, since there is a trivial answer x* = c(0, q).  


I am not sure how you intended to use these, but they are the problem.  
Therefore, you need to define your function correctly.  

Ravi.



---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

 





-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Radka Pancheva
Sent: Friday, April 25, 2008 8:13 AM
To: R-help@r-project.org
Subject: Re: [R] Non-linear system of equations

Hello Paul,

Thank you for your quick answer. I have tried to use your advice and to
estimate the parameters of beta distribution with moments matching. This is
my code:


ex - 0.3914877
ex2 - 0.2671597

my.mm - function(x){
p - x[1]
q - x[2]
p -  .Machine$double.eps
q -  .Machine$double.eps

F - rep(NA,2)

F[1] - p/(p + q)
F[2]- (p*q + (p + q + 1)*p^2)/((p + q + 1)*(p + q)^2)

return(F)
}

p0 - c(ex,ex2)

dfsane(par=p0, fn=my.mm,control=list(maxit=5))

and I became the following output:

.
iteration:  3640  ||F(xn)|| =   0.7071068
iteration:  3641  ||F(xn)|| =   0. 7071068
.
iteration:  49990  ||F(xn)|| =   0. 7071068
iteration:  5  ||F(xn)|| =   0. 7071068
$par
[1] -446.2791 -446.4034

$residual
[1] 0.5

$fn.reduction
[1] 0

$feval
[1] 828495

$iter
[1] 50001

$convergence
[1] 1

$message
[1] Maximum limit for iterations exceeded

I have tried maxiter=10 but the output is the same. I know that ex and
ex2 are bringing the problems, but I am stuck with them. How can I make it
convergent?

Thank you,

Evgeniq

 2008/4/25 Radka Pancheva [EMAIL PROTECTED]:
   I am trying to estimate the parameters of a bimodal normal distribution
using moments matching, so I have to solve a non-linear system of equations.
How can I solve the following simple example?
 
   x^2 - y^2 = 6
   x - y = 3
 
   I heard about nlsystemfit, but I don't know how to run it exactly. I
have tried the following code, but it doesn't really work:
 
 
   f1 -y~ x[1]^2-x[2]^2-6
   f2 -z~ x[1]-x[2]-3
   f  - list(f1=0,f2=0)
   nlsystemfit(OLS,f,startvals=c(0,0))
 
 You could try the recent package BB by Ravi Varadhan. The code could
 be the following:
 
 library(BB)
 
 f - function(x) {
   x1 - x[1]
   x2 - x[2]
 
   F - rep(NA, 2)
 
   F[1] - x1^2 - x2^2 - 6
   F[2] - x1 - x2 - 3
 
   return(F)
 }
 
 p0 - c(1,2)
 dfsane(par=p0, fn=f,control=list(maxit=3000))
 
 I got the solution:
 
 x1 = 2.5
 x2 = -0.5
 
 Paul
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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

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


Re: [R] Non-linear system of equations

2008-04-25 Thread Ravi Varadhan
Radka,

Generally, there is no need to increase `maxit' to beyond default.  If you
are unable to obtain a reasonable approximation to your system within
`maxit', then you should do the following (not necessarily in that order):

1.  Try a few different starting values and see if you can obtain a residual
closer to zero.
2.  Try a different method within dfsane, try method=1 or method=3. 
3.  If neither (1) nor (2) works, then try a different algorithm, sane.
4.  If none of the above steps is successful, then check your function
definition carefully for possible errors.

Ravi.

---

Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology 

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: [EMAIL PROTECTED]

Webpage:  http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html

 





-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Radka Pancheva
Sent: Friday, April 25, 2008 8:13 AM
To: R-help@r-project.org
Subject: Re: [R] Non-linear system of equations

Hello Paul,

Thank you for your quick answer. I have tried to use your advice and to
estimate the parameters of beta distribution with moments matching. This is
my code:


ex - 0.3914877
ex2 - 0.2671597

my.mm - function(x){
p - x[1]
q - x[2]
p -  .Machine$double.eps
q -  .Machine$double.eps

F - rep(NA,2)

F[1] - p/(p + q)
F[2]- (p*q + (p + q + 1)*p^2)/((p + q + 1)*(p + q)^2)

return(F)
}

p0 - c(ex,ex2)

dfsane(par=p0, fn=my.mm,control=list(maxit=5))

and I became the following output:

.
iteration:  3640  ||F(xn)|| =   0.7071068
iteration:  3641  ||F(xn)|| =   0. 7071068
.
iteration:  49990  ||F(xn)|| =   0. 7071068
iteration:  5  ||F(xn)|| =   0. 7071068
$par
[1] -446.2791 -446.4034

$residual
[1] 0.5

$fn.reduction
[1] 0

$feval
[1] 828495

$iter
[1] 50001

$convergence
[1] 1

$message
[1] Maximum limit for iterations exceeded

I have tried maxiter=10 but the output is the same. I know that ex and
ex2 are bringing the problems, but I am stuck with them. How can I make it
convergent?

Thank you,

Evgeniq

 2008/4/25 Radka Pancheva [EMAIL PROTECTED]:
   I am trying to estimate the parameters of a bimodal normal distribution
using moments matching, so I have to solve a non-linear system of equations.
How can I solve the following simple example?
 
   x^2 - y^2 = 6
   x - y = 3
 
   I heard about nlsystemfit, but I don't know how to run it exactly. I
have tried the following code, but it doesn't really work:
 
 
   f1 -y~ x[1]^2-x[2]^2-6
   f2 -z~ x[1]-x[2]-3
   f  - list(f1=0,f2=0)
   nlsystemfit(OLS,f,startvals=c(0,0))
 
 You could try the recent package BB by Ravi Varadhan. The code could
 be the following:
 
 library(BB)
 
 f - function(x) {
   x1 - x[1]
   x2 - x[2]
 
   F - rep(NA, 2)
 
   F[1] - x1^2 - x2^2 - 6
   F[2] - x1 - x2 - 3
 
   return(F)
 }
 
 p0 - c(1,2)
 dfsane(par=p0, fn=f,control=list(maxit=3000))
 
 I got the solution:
 
 x1 = 2.5
 x2 = -0.5
 
 Paul
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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

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


[R] Extracting coefficients' standard errors from linear model

2008-04-25 Thread Uli Kleinwechter
Dear all,

Hope this question is not too trivial...

In order to correct standard errors from an estimation of a fixed 
effects regression model y need to extract the vector of standard errors 
of the coefficients of a simple linear model estimated using

lm(var1~var2+var3+var4)

Unfortunately I can't find out the corresponding function.

Thank you very much for your help.

Uli



-- 
Uli Kleinwechter
Department of Agricultural Economics and Social Sciences
Faculty of Agriculture and Horticulture
Humboldt University of Berlin
Unter den Linden 6
D-10099 Berlin, Germany
Phone: (+49) 30 2093 6124, Fax. (+49) 30 2093 6301
E-mail: [EMAIL PROTECTED]

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


[R] remarks on function pnbeta

2008-04-25 Thread Ali Baharev
Dear Developers,

The pnbeta function has been reviewed recently in the article of A.
Baharev, S. Kemény, On the computation of the noncentral F and
noncentral beta distribution, Statistics and Computing, 2008, in
press. Preprint of the paper is available here:

http://reliablecomputing.eu/publications.html

and the article here

http://dx.doi.org/10.1007/s11222-008-9061-3

I suggest increasing the itrmax to (at least) 2000, since practically
important values cannot be computed with the current value. For
example:

pnbeta(0.2057, 25.0, 0.5, 34012.98, 1, 0);

needs 1649 iterations on my machine, and returns 0.0752037 instead of
the true value 0.10. This is not a bug, i got a warning, however i
think it would be better to increase the iteration limit.

According to my experience the users tend to ignore warning messages
and would use the incorrect values that is why i think it would be
better if pnbeta called exit(EXIT_FAILURE) or throw an exception than
returning a completely incorrect value and let the user use that. This
is my personal opinion, i do not know more about the design and
application logic of R.

The source file pnbeta.c refers to the paper of Frick (1990, AS R84)
giving a FORTRAN implementation. That paper contains typos; those were
corrected by Lam (1995, AS R95). Lam also made some remarks that are
worth considering.

The R implementation is a revised C code, and it seems to me that the
pnbeta's implementation is not influenced by the typos in the paper of
Frick.
However it would be better to indicate that the pnbeta is a revised
implementation compared to AS 226 and AS R84, and is not influenced by
AS R95.

Cancellation may occur during the recursion in the do while loop, we
failed to produce an example using practically meaningful parameter
values where serious cancellation occurs. We suspect it may be an
issue where the corresponding probability is small (less then
1.0E-30).

We plan to contribute a C implementation of our algorithm where
cancellation cannot occur, and newton iteration for the noncentrality
parameter is included. The computation of the noncentrality parameter
is need for ANOVA purposes.

Best regards,

Ali Baharev

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


Re: [R] package compilation: including external libraries in windows compilation

2008-04-25 Thread Prof Brian Ripley
The standard C define is WIN32, not Win32 (which R uses as private 
define).  You could have

PKG_CPPFLAGS=-DWin32

in Makevars.win, but this is unnecessary.

See e.g. Rmath.h.

On Fri, 25 Apr 2008, Jonathan Lees wrote:

 Dear R package developers:

 I need help on getting a package compiled for windows.
 I am trying to use definitions and routines from a
 set of libraries in that are in LINUX under
 #include netdb.h
 #include sys/socket.h
 #include netinet/in.h
 #include arpa/inet.h

 but these are unavailable in windows.
 I found that we can get these by including, in windows these includes:

 #include winsock2.h
 #include io.h

 My problem is I do not know how to instruct the preprocessor to include
 the linux .h files
 when in linux and the windows one in windows.

 I thought I found a solution online by using:

You mean in the R sources?


 #if defined(Win32)
 #include winsock2.h
 #include io.h
 #else
 #ifdef HAVE_UNISTD_H
 #include unistd.h
 #endif
 #ifdef HAVE_BSD_NETWORKING
 #include netdb.h
 #include sys/socket.h
 #include netinet/in.h
 #include arpa/inet.h
 #endif
 #endif

 But I still get an error when these are compiled on the R-distribution.
 I do not understand where I am supposed to set the Win32 flag so
 that it will be ignored in LINUX but used in windows.
 where is Win32 HAVE_UNISTD_H and HAVE_BSD_NETWORKING set?

In config.h.

 It seems that Makevars.win would be logical place, but
 I do not see how to do this.

 Thanks for any help.

 Jonathan Lees


 -- Making package WINRPACK 
  adding build stamp to DESCRIPTION
  making DLL ...
 making win2R.d from win2R.c
 making win2asc.d from win2asc.c
 gcc-sjlj  -std=gnu99  -Id:/Rcompile/recent/R-26~1.2/include -O3 -Wall  -c 
 win2R.c -o win2R.o
 win2R.c:21:24: error: sys/socket.h: No such file or directory
 win2R.c:22:24: error: netinet/in.h: No such file or directory
 win2R.c:23:23: error: arpa/inet.h: No such file or directory
 win2R.c: In function 'read_data':
 win2R.c:591: warning: implicit declaration of function 'ntohl'
 win2R.c: In function 'read_one_sec':
 win2R.c:723: warning: implicit declaration of function 'ntohs'
 make[3]: *** [win2R.o] Error 1
 make[2]: *** [srcDynlib] Error 2
 make[1]: *** [all] Error 2
 make: *** [pkg-WINRPACK] Error 2
 *** Installation of WINRPACK failed ***








 -- 
 ==
 Prof. Jonathan M. Lees
 Department of Geological Sciences
 CB #3315, Mitchell Hall
 University of North Carolina
 Chapel Hill, NC  27599-3315
 (919) 962-0695
 FAX (919) 966-4519

 [EMAIL PROTECTED]
 http://www.unc.edu/~leesj

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


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


Re: [R] Extracting coefficients' standard errors from linear model

2008-04-25 Thread David Winsemius
Uli Kleinwechter [EMAIL PROTECTED] wrote in
news:[EMAIL PROTECTED]: 

 Dear all,
 
 Hope this question is not too trivial...
 
 In order to correct standard errors from an estimation of a fixed 
 effects regression model y need to extract the vector of standard
 errors of the coefficients of a simple linear model estimated using
 
 lm(var1~var2+var3+var4)
 
 Unfortunately I can't find out the corresponding function.

See if vcov() suits. From the lm() help page an example:

 ctl - c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
 trt - c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
 group - gl(2,10,20, labels=c(Ctl,Trt))
 weight - c(ctl, trt)
 lm.D9 - lm(weight ~ group)

Then look at summary(lm.D9) and these results:

 vcov(lm.D9)[2,2]
[1] 0.09699167
 vcov(lm.D9)[2,2]^(1/2)
[1] 0.3114349

diag(vcov(lm.mdl))^(1/2) may be needed to get the vector you seek.

-- 
David Winsemius

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


Re: [R] Documentation General Comments

2008-04-25 Thread Tubin



I realize the R developers are probably overwhelmed and have little time
for this, but the documentation really needs some serious reorganizaton.

My reply:

I'm quite new to R and so have spent a lot of time in the last few days
reading documentation both online and text.  I'm incredibly impressed by the
language and, overall, by the documentation - the documentation tools are so
well integrated into the program, and in most cases the documentation does a
good job of balancing brevity and completeness. The original poster noted a
need for reorganization (not revision) and I think that's key.  Several
people have posted about potential projects in several threads - so I'll try
combining those thoughts in a new response thread.

Summary:  
1)  New users have questions based on common tasks, which don't necessarily
reflect the structure of the language
2)  There's a lot of good documentation out there already, both official and
unofficial
3)  It doesn't break intellectual property laws to create an annotated
bibliography of existing references, with a task-based topic structure.
4) I suspect new and old users would contribute to such a project if it
allowed external contributions - as in, suggest a resource (under an
existing topic) along with a brief explanation about why that resource was
helpful.

Detailed comments:

One thing I notice in the official documentation is that it's organized
around the R language structure.  The help table of contents does include
a listing of natural-language titles, but they're listed alphabetically
rather than organized by task-based concept.  

But when you look at the forums, the new users are searching for information
by task or by concept - what are the classes of object?  How do I manipulate
a data frame?  What are my tools for regular expressions?  Many of my texts
(and some independent web pages) seem to try to organize by task, but all
are incomplete - perhaps because of space limitations, perhaps because the
language is so dynamic that useful functions hadn't yet been developed when
a text was published.  Also, most of my books actually only introduce the R
language then move on to discussing the use of R for specific statistical
functions.  Yet, most of the forum questions seem to be about things like
loading and manipulating the data to get it into the appropriate format for
the desired analysis.

So I really like the suggestion to try creating some cross-indexing for the
materials that are out there already.  Perhaps a wiki-based annotated
bibliography with a task-based structure.  I'm tempted to suggest that we
just expand on the wikipedia content for R!  

The structure of such a thing should have categories like managing regular
expressions or manipulating data in dataframes - and often a particular
topic might be cross-referenced to more than one category, I'd think.

By annotated bibliography I mean that most of the entries under a topic
would be here's a link or reference to a source that seems to explain this
topic well - and here's why I like it.  

And - I have to run to a meeting.  So I will stop brainstorming now.
-- 
View this message in context: 
http://www.nabble.com/Documentation-General-Comments-tp16821085p16895859.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] join chars in loops

2008-04-25 Thread Dirkheld

Hi,

Is it possible to create new vars in a loop

For instance: 

for (i in 1:11)
var'i' - assign something

output =
var1
var2
...
var11

Is there a way to combine/join the value of 'i' to the string/char var in de
loop. 

-- 
View this message in context: 
http://www.nabble.com/join-chars-in-loops-tp16895854p16895854.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] join chars in loops

2008-04-25 Thread jim holtman
for (i in 1:11){
assign(paste('var', i, sep=''), value)
}

On Fri, Apr 25, 2008 at 10:40 AM, Dirkheld [EMAIL PROTECTED] wrote:

 Hi,

 Is it possible to create new vars in a loop

 For instance:

 for (i in 1:11)
 var'i' - assign something

 output =
 var1
 var2
 ...
 var11

 Is there a way to combine/join the value of 'i' to the string/char var in de
 loop.

 --
 View this message in context: 
 http://www.nabble.com/join-chars-in-loops-tp16895854p16895854.html
 Sent from the R help mailing list archive at Nabble.com.

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




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

What is the problem you are trying to solve?

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


Re: [R] Extracting coefficients' standard errors from linear model

2008-04-25 Thread Henrique Dallazuanna
Try:

 summary(lm.D9)[[coefficients]][,2]

On Fri, Apr 25, 2008 at 10:55 AM, Uli Kleinwechter 
[EMAIL PROTECTED] wrote:

 Dear all,

 Hope this question is not too trivial...

 In order to correct standard errors from an estimation of a fixed
 effects regression model y need to extract the vector of standard errors
 of the coefficients of a simple linear model estimated using

 lm(var1~var2+var3+var4)

 Unfortunately I can't find out the corresponding function.

 Thank you very much for your help.

 Uli



 --
 Uli Kleinwechter
 Department of Agricultural Economics and Social Sciences
 Faculty of Agriculture and Horticulture
 Humboldt University of Berlin
 Unter den Linden 6
 D-10099 Berlin, Germany
 Phone: (+49) 30 2093 6124, Fax. (+49) 30 2093 6301
 E-mail: [EMAIL PROTECTED]

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




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

[[alternative HTML version deleted]]

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


Re: [R] join chars in loops

2008-04-25 Thread Dimitris Rizopoulos
look at ?assign(), e.g.,

for (i in 1:11) {
assign(paste(var, i, sep = ), i)
}
var1
var2
var10

but I'd prefer to use a list. I hope it helps.

Best,
Dimitris


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


- Original Message - 
From: Dirkheld [EMAIL PROTECTED]
To: r-help@r-project.org
Sent: Friday, April 25, 2008 4:40 PM
Subject: [R] join chars in loops



 Hi,

 Is it possible to create new vars in a loop

 For instance:

 for (i in 1:11)
 var'i' - assign something

 output =
 var1
 var2
 ...
 var11

 Is there a way to combine/join the value of 'i' to the string/char 
 var in de
 loop.

 -- 
 View this message in context: 
 http://www.nabble.com/join-chars-in-loops-tp16895854p16895854.html
 Sent from the R help mailing list archive at Nabble.com.

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


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

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


Re: [R] matrix from list

2008-04-25 Thread Greg Snow
You may want to read the help page for '[' and '[[' a few more times
(the differencese can be subtle).

The '[[' only returns a single element from a data structure (but in the
case of a list, that single element can be quite complex).  So something
like list[[1:2]] does not make sense because you are asking something
that returns 1 thing to return 2.  You can do list[1:2] which will
return a list consisting of the 1st 2 elements of the original list.  If
you list happens to be a data frame as well, then you can subset it like
a matrix: mydf[1:2, 3:4] gives the 1st 2 rows of columns 3 and 4,
mydf[,1:2] gives the first 2 columns.  These will continue to be data
frames (since '[' returns the same type of object), but tools like
as.matrix can convert this into a matrix.

-- 
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 Olivier Lefevre
 Sent: Thursday, April 24, 2008 4:16 PM
 To: [EMAIL PROTECTED]
 Subject: Re: [R] matrix from list
 
 Yes, unlist is the magic wand I was looking for. Thanks a million!
 
 Having said that, I find it rather arbitrary that you can 
 write mat[1:4] but not list[[1:2]]; IMO there should be no 
 need for a magic operator like unlist: 
 list[[1:length(list)]] could do the job.
 
 -- O.L.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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


Re: [R] No rule to make target 'R/Copy'

2008-04-25 Thread Ardia David
No... don't think so. I rerun my computer, moved some folders (I deleted 
the folder with .C file), rerun the compilation, and it worked... Not 
sure to understand why.
Any idea?

Prof Brian Ripley wrote:
 Do you have a space in some file name?  Starting 'Copy '?
 
 On Fri, 25 Apr 2008, Ardia David wrote:
 
 Dear all,
 I am currently building  a package with C code (in scr folder).
 Everything was ok, but now, I get the following error message when
 compiling the package using R CMD INSTALL:
 make[2]: *** No rule to make target 'R/Copy', needed in [...]
 What does that mean? I can still compile other packages containing C
 code, but not that one. No 00UNLOCK directory has been created . I am on
 a IBM PC, and use windows XP.
 Thanks for your help
 -- 
 David Ardia
 H-building, room 11-26
 Econometric Institute
 Erasmus University
 PO Box 1738
 NL 3000 DR Rotterdam
 The Netherlands
 Phone: +31 (0)10 408 2269

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

 

-- 
David Ardia
H-building, room 11-26
Econometric Institute
Erasmus University
PO Box 1738
NL 3000 DR Rotterdam
The Netherlands
Phone: +31 (0)10 408 2269

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


Re: [R] Extracting coefficients' standard errors from linear model

2008-04-25 Thread Marc Schwartz
Or use:

   mod - lm(var1 ~ var2 + var3 + var4)

   coef(summary(mod))[, 2]

or

   coef(summary(lm.D9))[, Std. Error]

if you prefer using column names.

coef() extracts the model coefficients from the lm object and the 
additional content in a summary.lm object.

There are accessor functions for model objects and these are referenced 
in An Introduction to R and in the See Also section of ?lm.

HTH,

Marc Schwartz

Henrique Dallazuanna wrote:
 Try:
 
  summary(lm.D9)[[coefficients]][,2]
 
 On Fri, Apr 25, 2008 at 10:55 AM, Uli Kleinwechter 
 [EMAIL PROTECTED] wrote:
 
 Dear all,

 Hope this question is not too trivial...

 In order to correct standard errors from an estimation of a fixed
 effects regression model y need to extract the vector of standard errors
 of the coefficients of a simple linear model estimated using

 lm(var1~var2+var3+var4)

 Unfortunately I can't find out the corresponding function.

 Thank you very much for your help.

 Uli


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


Re: [R] Sum of random values

2008-04-25 Thread Greg Snow
You might want to look at the distr package (and its relatives).  It
provides methods for calculating the distribution function of
combinations (the sum is one) of other distributions.  I'm not sure how
you would convert your percentiles to a distribution function, but there
may be a way in the documentation for distr and friends.

-- 
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 Ricardo Bessa
 Sent: Thursday, April 24, 2008 5:12 PM
 To: r-help@r-project.org
 Subject: [R] Sum of random values
 
 
 Hello,
 I have two random variables with their percentiles which 
 correspond to their probability distribution function. My 
 objective is to sum these two random variables. There exists 
 any algorithm or procedure in R capable of converting the 
 percentiles to a probability density function? is the fast 
 Fourier transform function of R(fft) capable of doing the sum 
 with a convolution?
  
 I'm just starting with this specific problem, so any help it 
 will be very useful.
  
 Best regards,
 Ricardo Bessa
  
 _
 
 [[elided Hotmail spam]]
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 

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


Re: [R] join chars in loops

2008-04-25 Thread Bert Gunter
...
That is, use the construction

thelist - lapply(1:11,function(i){...return something}) 

I would go further then Dmitris and say that this should be the canonical
answer to this frequently asked question and that perhaps in 7.21 in the R
FAQ (Version 2.6.2 -- I haven't yet upgraded) -- How can I turn a string
into a variable? --  this could be explicitly stated (it's in there, but
not quite so explicitly). Or perhaps it might be a separate FAQ
question:How to create new variables from their character string names in a
loop? This might make it a little easier for people to find and a little
less likely that the question will get asked on the list -- though I must
agree with those who have lamented that it often seems pointless to make
such efforts because people don't bother to use the resources anyway. Ah,
but that's just the grumbling of an old reprobate...

Cheers,
Bert

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Dimitris Rizopoulos
Sent: Friday, April 25, 2008 8:07 AM
To: Dirkheld
Cc: r-help@r-project.org
Subject: Re: [R] join chars in loops

look at ?assign(), e.g.,

for (i in 1:11) {
assign(paste(var, i, sep = ), i)
}
var1
var2
var10

but I'd prefer to use a list. I hope it helps.

Best,
Dimitris


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


- Original Message - 
From: Dirkheld [EMAIL PROTECTED]
To: r-help@r-project.org
Sent: Friday, April 25, 2008 4:40 PM
Subject: [R] join chars in loops



 Hi,

 Is it possible to create new vars in a loop

 For instance:

 for (i in 1:11)
 var'i' - assign something

 output =
 var1
 var2
 ...
 var11

 Is there a way to combine/join the value of 'i' to the string/char 
 var in de
 loop.

 -- 
 View this message in context: 
 http://www.nabble.com/join-chars-in-loops-tp16895854p16895854.html
 Sent from the R help mailing list archive at Nabble.com.

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


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

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

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


[R] fix variance parameter values for lmer estimation

2008-04-25 Thread Wilfried Cools
Dear list-members,

a model is fit with lmer, but I want to force the variance parameter values
to be as defined by me

I thought, use 'start' to specify initial values and only allow for one
iteration ?
my question is how to do that ?

to specify the 2x2 matrix of variance parameter values:
start=list(groups=array(2,-0.5,1),dim=c(2,2))

now I need to make sure the mean structure is estimated, while the variance
parameter values are kept constant ??
e.g. lmer(resp~pred1+pred2+(1 +
pred1|groups),start=list(groups=array(2,-0.5,1),dim=c(2,2)),)


cheers,

 
Wilfried
 


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

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


[R] FASeg

2008-04-25 Thread Vidhu Choudhary
Hi All,
I was using FASeg package. Now when I am trying to install this library I
get the message
Warning message:
package 'FASeg' is not available

Can someone please suggest something.

Thank you
vidhu

[[alternative HTML version deleted]]

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


[R] Rows assignment

2008-04-25 Thread Yuri Volchik

Hi to all members,

i encountered a weird problem when trying to assign subset of rows in a
matrix.
Simple example works fine:
z-matrix(NA,ncol=3,nrow=10)
z[,1]-1:10
y-matrix(1:30,ncol=3,nrow=10)
y[,1]-5:14
z[z[,1]%in%y[,1],2]-y[y[,1]%in%z[,1],2]
z
z[z[,1]%in%y[,1],]-y[y[,1]%in%z[,1],]
z


When i try it on a bigger matrix it works fine when i try to assign 1
element, but converts original matrix to a list when trying to assign 2 or 3
columns for example.
What can be a problem, as it seems that matrices are both numbers only?


Thanks
-- 
View this message in context: 
http://www.nabble.com/Rows-assignment-tp16896591p16896591.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] fix variance parameter values for lmer estimation

2008-04-25 Thread Douglas Bates
On 4/25/08, Wilfried Cools [EMAIL PROTECTED] wrote:
 Dear list-members,

  a model is fit with lmer, but I want to force the variance parameter values
  to be as defined by me

  I thought, use 'start' to specify initial values and only allow for one
  iteration ?
  my question is how to do that ?

  to specify the 2x2 matrix of variance parameter values:
  start=list(groups=array(2,-0.5,1),dim=c(2,2))

Well, the problem is that if you are going to decide what the
arguments to the function should be and how they should be interpreted
you are going to need to write the function yourself.  There is
nothing in the lmer documentation that says it will fit a model with
the variance parameter values as defined by you and there is nothing
to say that you can specify a list with arbitrary names as the value
of the start parameter and somehow lmer will magically infer what you
mean by these starting values and do the right thing.  Sorry but I
don't write mind-reading software.  You are going to have to write it
yourself.


  now I need to make sure the mean structure is estimated, while the variance
  parameter values are kept constant ??
  e.g. lmer(resp~pred1+pred2+(1 +
  pred1|groups),start=list(groups=array(2,-0.5,1),dim=c(2,2)),)


  cheers,


  Wilfried



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

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


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


Re: [R] Use of survreg.distributions

2008-04-25 Thread Abdus Sattar
Hello Dr. Therneau:
 
Thank you for your response. Let me explain to you want I want. My y 
variable(time) is normal and would like to fit the model on logarithmic 
transformation of y (log(y)). I tried to run codes according to your suggestion:
tfit=survreg(Surv(y, y=-5, type=left)~x + cluster(id), dist=lognormal, 
data=y.data, scale=0, weights=w) 

The following error message is giving:
 
Error in survreg(Surv(y, y = -5, type = left) ~ x +  : 
  Invalid survival times for this distribution
In addition: Warning messages:
1: In log(dlist$dtrans(Y[exactsurv, 1])) : NaNs produced
2: In log(y) : NaNs produced

Note, the data file y.data does not contain any missing data! Do you know why 
it is giving me such an error message please?
Thank you again for your helpful comment/suggestion. 
 
Best Regards, 
 
Abdus Sattar
[EMAIL PROTECTED]



- Original Message 
From: Terry Therneau [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: r-help@R-project.org
Sent: Friday, April 25, 2008 8:46:45 AM
Subject: Re: [R] Use of survreg.distributions

--begin included message ---

I am using survreg(Surv()) for fitting a Tobit model of left-censored 
longitudinal data. For logarithmic transformation of y data, I am trying use 
survreg.distributions in the following way: 
tfit=survreg(Surv(y, y=-5, type=left)~x + cluster(id), dist=gaussian, 
data=y.data, scale=0, weights=w) 
my.gaussian-survreg.distributions$gaussian
my.gaussian$name=lognormal
my.gaussian$dist-my.gaussian
tfit=survreg(Surv(y, y=-5, type=left)~x + cluster(id), dist=my.gaussian, 
data=y.data, scale=0, weights=w) 

If I run these codes then I got the following error message, 

Error in survreg(Surv(y, y = -5, type = left) ~ x +  :
Invalid distribution object

Does anybody can help me in identifying the error(s) in these code please? 

--- end include 

  Can you tell us what you are trying to do?  
  Your first model was a fit of y ~ x + eps, eps ~ Gaussian.  If what you want 
is log(y) ~ x + eps, then all that you need do is use dist=loggaussian in the 
survreg call.  (Or 'lognormal'; which is the same distribution.)
  
      Terry Therneau


  


[[elided Yahoo spam]]
=Ahu06i62sR8HDtDypao8Wcj9tAcJ
[[alternative HTML version deleted]]

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


[R] making a dll for windows eviornment for R

2008-04-25 Thread Vidhu Choudhary
Hi All,
 I have a .c file and I need to make a dll so that it could be called by R.
I have successfully made .so from .c file and its working great. But i have
no clue of making dll. I tried googling for help ...but not much of use

Please suggest something

regards
Vidhu

[[alternative HTML version deleted]]

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


Re: [R] Documentation General Comments

2008-04-25 Thread Spinu Vitalie
  Each pdf reference manual includes an index of functions classified  
according to keywords.
I wonder why indexes in on-line documentation do not include similar  
categorisation.
It would be much easier to figure out all related functions and topics.

Thanks,
Vitalie.

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


Re: [R] making a dll for windows eviornment for R

2008-04-25 Thread Duncan Murdoch
On 4/25/2008 1:12 PM, Vidhu Choudhary wrote:
 Hi All,
  I have a .c file and I need to make a dll so that it could be called by R.
 I have successfully made .so from .c file and its working great. But i have
 no clue of making dll. I tried googling for help ...but not much of use
 
 Please suggest something

Take a look at the Writing R Extensions manual.  Lots of detail there.

Quick version: Install Rtools, put Rtools/bin first on your path, the 
other tools somewhere on it, then just do as you do anywhere else.

Duncan Murdoch

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


Re: [R] Obtaining correlation parameters for multiple rows

2008-04-25 Thread jpnitya

Hi Jorge,

That was great! Thank you very much for the suggestion.

I just had to make a couple of minor changes (e.g., pearson vs. spearman)
and it worked perfectly.

Thanks,
Joao Pedro



Hi,

I'm sure it could be better but try this:

# F statistics based on lm
FSTAT=function(y,x) summary(lm(y~x))$f[1]

# Correlation and p-value
CORR=function(y,x){
tc=cor.test(x,y,method=spearman,alternative=two.sided)
temp=matrix(c(tc$estimate,tc$p.value),ncol=2)
colnames(temp)=c('rho','pvalue')
temp
}

# 1000 variables and 100 samples
set.seed(124)
X=matrix(rnorm(1000*100),ncol=100)

# Correlation coefficient, p-value and F statistics
corr=t(apply(X[-1,],1,CORR,x=X[1,]))  # Your reference is X[1,]
fs=apply(X[-1,],1,FSTAT,x=X[1,])  # Your reference is X[1,]

# Report
temp=data.frame(fstats=fs,rho=corr[,1],pvalue=corr[,2])
rownames(temp)=paste(X,2:nrow(X),sep=)
dim(temp)
[1] 999   3

temp[1:10,]
fstats rho pvalue
X2  1.421307790 -0.05038104 0.61807912
X3  0.051423768 -0.04614461 0.64795111
X4  0.128000634  0.01795380 0.85902211
X5  0.990235820 -0.06540654 0.51730942
X6  5.569006085  0.24232823 0.01532172
X7  0.001862766 -0.01436544 0.88703532
X8  1.025363077 -0.10628263 0.29206908
X9  0.679794149  0.06509451 0.51927479
X10 1.296034903  0.09492949 0.34686211
X11 0.126636867  0.05137714 0.61110106


HTH,

Jorge


-- 
View this message in context: 
http://www.nabble.com/Obtaining-correlation-parameters-for-multiple-rows-tp16851980p16904683.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Differentiate alphanumeric vs numeric strings

2008-04-25 Thread Farrel Buchinsky
This is fantastic.
As a future note to myself and to others who may stumble upon this:
further documentation for all one's heart could desire is in the base
help system at.

Regular Expressions as used in R - regexp

Pattern Matching and Replacement - grep

Split the Elements of a Character Vector  - strsplit

The following worked in my situation:
channel2007-odbcConnectAccess(filename for 2007 data)
tables -sqlTables(channel2007)[,3]
tables -grep([[:digit:]],tables,value=TRUE)
all2007 -sqlFetch(channel2007, tables[1])
for (f in tables[-1]) all2007-rbind(all2007, sqlFetch(channel2007, f))

Thanks for your help



On Thu, Apr 24, 2008 at 11:34 PM, jim holtman [EMAIL PROTECTED] wrote:
 The following will return the indices or the values of character
 strings that are all numeric:

  x - c(12345, 123AS23, A123, 398457)
  grep(^[[:digit:]]*$, x)   # index
 [1] 1 4
  grep(^[[:digit:]]*$, x, value=TRUE)   # values
 [1] 12345  398457



 



 On Thu, Apr 24, 2008 at 10:39 PM, Farrel Buchinsky [EMAIL PROTECTED] wrote:
  I have a bunch of tables in a Microsoft Access database. An updated database
  is sent to me every week containing a new table. I know that is inefficient
  and weird but welcome to my life. I want to read the tables whose names are
  something such as 040207 but not the ones that have alphanumeric names
  such as everyone. Using RODBC I am easily able to create a character
  vector of the names of the tables. Is there a function that can
  differentiate values consisting only of digits (numerics) as opposed to ones
  that contain letters (and perhaps digts as well)? I am sure there is. What
  is it and where should I have found it?
 
  --
  Farrel Buchinsky
  GrandCentral Tel: (412) 567-7870
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 



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

 What is the problem you are trying to solve?




-- 
Farrel Buchinsky
GrandCentral Tel: (412) 567-7870

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


[R] hist densities

2008-04-25 Thread Sarah Hardy
This is a reply to Luke Spadavecchia's question about hist densities.

 

If you want to construct a histogram where the bar heights are the
percentage of observations in the intervals you can use this code:

 

x-rnorm(n=5000,mean=1.5,sd=0.25)

h-hist(x)

h$density-h$counts/sum(h$counts)

plot(h,freq=F,ylab=Percentage)

 

Sarah Hardy

[EMAIL PROTECTED]

 

 


[[alternative HTML version deleted]]

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


Re: [R] Constructing dummy variables for months for a time series object

2008-04-25 Thread Bill.Venables
The simplest way is probably to generate them as the columns of a
matrix.  Let's suppose you have data from Jan 1991 up to Mar 2008.

 X - outer(rep(month.abb, length = 16*12+3), month.abb, ==) + 0

 ## the + 0 will convert logical to numeric

 dim(X)
[1] 195  12

 dimnames(X)[[2]] - month.abb
 head(X)
 Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
[1,]   1   0   0   0   0   0   0   0   0   0   0   0
[2,]   0   1   0   0   0   0   0   0   0   0   0   0
[3,]   0   0   1   0   0   0   0   0   0   0   0   0
[4,]   0   0   0   1   0   0   0   0   0   0   0   0
[5,]   0   0   0   0   1   0   0   0   0   0   0   0
[6,]   0   0   0   0   0   1   0   0   0   0   0   0
  

To get the July indicators, use X[, Jul], c


Bill Venables
CSIRO Laboratories
PO Box 120, Cleveland, 4163
AUSTRALIA
Office Phone (email preferred): +61 7 3826 7251
Fax (if absolutely necessary):  +61 7 3826 7304
Mobile: +61 4 8819 4402
Home Phone: +61 7 3286 7700
mailto:[EMAIL PROTECTED]
http://www.cmis.csiro.au/bill.venables/ 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Megh Dal
Sent: Friday, 25 April 2008 5:40 PM
To: [EMAIL PROTECTED]
Subject: [R] Constructing dummy variables for months for a time series
object

I have a TS of monthly observations. 
   
  head(data4)
 1991(1)  1991(2)  1991(3)  1991(4)  1991(5)  1991(6) 
12.00864 11.94203 11.98386 12.01900 12.19226 12.15488 

  Now I want to make 11 dummy variables indicating months. Therefore I
did followings :
   
  For Jan :
  rep(c(rep(0,0), 1, rep(0, 11)), 17)
   
  For Feb :
  rep(c(rep(0,1), 1, rep(0, 10)), 17)
   
   and so on
   
  But my question is there any way to aumate this? Or I have to do the
above thing for all 11 months?

   
-
[[elided Yahoo spam]]
[[alternative HTML version deleted]]

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

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


[R] Equivalent of Excel pivot tables in R

2008-04-25 Thread ppaarrkk

Can somebody tell me how to do the equivalent of a pivot table in R ?


For example, if I have :

var1var2   var3
a x10
b y20
a z10
b z20
a z10
b z20

I could have :

  x   y   z
a1   0   2 
b0   1   2

where entries in the table are counts of var3.

  x   y   z
a10   0   20 
b0   20   40

where entries are sums of var3.



I would expect it to be tapply(), but I can't see how it would be done.


Any suggestions please.


-- 
View this message in context: 
http://www.nabble.com/Equivalent-of-Excel-pivot-tables-in-R-tp16906289p16906289.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Equivalent of Excel pivot tables in R

2008-04-25 Thread Jorge Ivan Velez
Hi,

Try this:

x=var1var2   var3
a x10
b y20
a z10
b z20
a z10
b z20

yourdata=read.table(textConnection(x),header=TRUE)
attach(yourdata)

res=tapply(var3,yourdata[,-3],sum)  # With tapply!
res[is.na(res)]-0
res
var2
var1  x  y  z
   a 10  0 20
   b  0 20 40

See also ?tapply.


HTH,

Jorge


On Fri, Apr 25, 2008 at 5:54 PM, ppaarrkk [EMAIL PROTECTED] wrote:


 Can somebody tell me how to do the equivalent of a pivot table in R ?


 For example, if I have :

 var1var2   var3
 a x10
 b y20
 a z10
 b z20
 a z10
 b z20

 I could have :

  x   y   z
 a1   0   2
 b0   1   2

 where entries in the table are counts of var3.

  x   y   z
 a10   0   20
 b0   20   40

 where entries are sums of var3.



 I would expect it to be tapply(), but I can't see how it would be done.


 Any suggestions please.


 --
 View this message in context:
 http://www.nabble.com/Equivalent-of-Excel-pivot-tables-in-R-tp16906289p16906289.html
 Sent from the R help mailing list archive at Nabble.com.

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


[[alternative HTML version deleted]]

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


Re: [R] Equivalent of Excel pivot tables in R

2008-04-25 Thread Jim Porzak
See Hadley's reshape package http://had.co.nz/reshape/
and on CRAN.

On Fri, Apr 25, 2008 at 2:54 PM, ppaarrkk [EMAIL PROTECTED] wrote:


 Can somebody tell me how to do the equivalent of a pivot table in R ?


 For example, if I have :

 var1var2   var3
 a x10
 b y20
 a z10
 b z20
 a z10
 b z20

 I could have :

  x   y   z
 a1   0   2
 b0   1   2

 where entries in the table are counts of var3.

  x   y   z
 a10   0   20
 b0   20   40

 where entries are sums of var3.



 I would expect it to be tapply(), but I can't see how it would be done.


 Any suggestions please.


 --
 View this message in context:
 http://www.nabble.com/Equivalent-of-Excel-pivot-tables-in-R-tp16906289p16906289.html
 Sent from the R help mailing list archive at Nabble.com.

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




-- 
HTH,
Jim Porzak
Responsys, Inc.
San Francisco, CA
http://www.linkedin.com/in/jimporzak

[[alternative HTML version deleted]]

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


Re: [R] Equivalent of Excel pivot tables in R

2008-04-25 Thread Henrique Dallazuanna
Try:

with(x, tapply(var3, list(var1, var2), length))

with(x, tapply(var3, list(var1, var2), sum))

Or with xtabs

xtabs(as.logical(var3) ~ var1 + var2, data = x)

xtabs(var3 ~ var1 + var2, data = x)




On 4/25/08, ppaarrkk [EMAIL PROTECTED] wrote:


 Can somebody tell me how to do the equivalent of a pivot table in R ?


 For example, if I have :

 var1var2   var3
 a x10
 b y20
 a z10
 b z20
 a z10
 b z20

 I could have :

   x   y   z
 a1   0   2
 b0   1   2

 where entries in the table are counts of var3.

   x   y   z
 a10   0   20
 b0   20   40

 where entries are sums of var3.



 I would expect it to be tapply(), but I can't see how it would be done.


 Any suggestions please.


 --
 View this message in context:
 http://www.nabble.com/Equivalent-of-Excel-pivot-tables-in-R-tp16906289p16906289.html
 Sent from the R help mailing list archive at Nabble.com.

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




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

[[alternative HTML version deleted]]

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


Re: [R] matrix from list

2008-04-25 Thread Olivier Lefevre
Greg Snow wrote:
 The '[[' only returns a single element from a data structure

I know but that is precisely what I find arbitrary.

Anyway you are right that it would still return the kind of object, only 
subsetted, which is not I want. As someone kindly pointed out to me 
offline, besides the unlist trick posted before, you can also achieve the 
desired result with

   m - as.matrix(l)
   dimnames(m) - NULL

-- O.L.

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


[R] Ubuntu vs Mac OS X

2008-04-25 Thread Guillaume Blanchet
Hi !

I have installed R-2.7.0 64-bits on a computer where the new Ubuntu 
version (8.04) was installed. This computer is a 3.2 GHz Dual-core with 
2 Gb of RAM.

To test how fast (I though !) this machine is, I compared two simple 
matrix manipulations between Ubuntu and my laptop (a MacBook Pro 2.2 GHz 
with also 2 Gb of RAM under Mac OS X 10.5.2). By the way, I install the 
normal version of R on my MacBook Pro (32-bits)

I decided to use the following matrix manipulation because they are 
typical manipulation that I was planning to do repetitively and with 
much larger matrices for my PhD project.

First matrix manipulation:

coco-matrix(rnorm(100),1000,1000)
system.time(coco2-eigen(coco))

Results on the Mac:
user system  elapsed
7.301   0.974   7.376

Results on Ubuntu:
user system  elapsed
20.573   0.088   20.766

Second matrix manipulation:

coco-matrix(rnorm(100),1000,1000)
system.time(coco3-coco%*%coco)

Results on the Mac:
user system  elapsed
0.360   0.024   0.224

Results on Ubuntu:
user system  elapsed
2.756   0.000   2.758

If I understand these results right, my MacBook Pro is far better than 
this Desk computer. I know Macs are good but that difference of 
performance is surprising me, did I do something wrong considering the 
large difference in processor?

Thanks in advance

Guillaume Blanchet

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


Re: [R] Equivalent of Excel pivot tables in R

2008-04-25 Thread Jorge Ivan Velez
Hi,

I forgot the first part (I'm sorry):

table(var1,var2)
 var2
var1 x y z
   a 1 0 2
   b 0 1 2

HTH,

Jorge



On Fri, Apr 25, 2008 at 7:25 PM, Jorge Ivan Velez [EMAIL PROTECTED]
wrote:


 Hi,

 Try this:

 x=var1var2   var3
 a x10
 b y20
 a z10
 b z20
 a z10
 b z20

 yourdata=read.table(textConnection(x),header=TRUE)
 attach(yourdata)

 res=tapply(var3,yourdata[,-3],sum)  # With tapply!
 res[is.na(res)]-0
 res
 var2
 var1  x  y  z
a 10  0 20
b  0 20 40

 See also ?tapply.


 HTH,

 Jorge



 On Fri, Apr 25, 2008 at 5:54 PM, ppaarrkk [EMAIL PROTECTED] wrote:


 Can somebody tell me how to do the equivalent of a pivot table in R ?


 For example, if I have :

 var1var2   var3
 a x10
 b y20
 a z10
 b z20
 a z10
 b z20

 I could have :

  x   y   z
 a1   0   2
 b0   1   2

 where entries in the table are counts of var3.

  x   y   z
 a10   0   20
 b0   20   40

 where entries are sums of var3.



 I would expect it to be tapply(), but I can't see how it would be done.


 Any suggestions please.


 --
 View this message in context:
 http://www.nabble.com/Equivalent-of-Excel-pivot-tables-in-R-tp16906289p16906289.html
 Sent from the R help mailing list archive at Nabble.com.

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





[[alternative HTML version deleted]]

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


Re: [R] Constructing dummy variables for months for a time series object

2008-04-25 Thread Gabor Grothendieck
First generate a factor and then calculate its model matrix:

month. - factor(cycle(x), labels = month.abb)
model.matrix(~ month.)[,-1]

Actually you may not even need the dummy variables at all if your
purpose is to do a regression.  You can use the factor
directly:

lm(x ~ month.)

By the way, be sure to check out ?monthplot


On Fri, Apr 25, 2008 at 3:40 AM, Megh Dal [EMAIL PROTECTED] wrote:
 I have a TS of monthly observations.

  head(data4)
  1991(1)  1991(2)  1991(3)  1991(4)  1991(5)  1991(6)
 12.00864 11.94203 11.98386 12.01900 12.19226 12.15488

  Now I want to make 11 dummy variables indicating months. Therefore I did 
 followings :

  For Jan :
  rep(c(rep(0,0), 1, rep(0, 11)), 17)

  For Feb :
  rep(c(rep(0,1), 1, rep(0, 10)), 17)

   and so on

  But my question is there any way to aumate this? Or I have to do the above 
 thing for all 11 months?


 -
 [[elided Yahoo spam]]
[[alternative HTML version deleted]]

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


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


Re: [R] Ubuntu vs Mac OS X

2008-04-25 Thread Roy Mendelssohn

On Apr 25, 2008, at 4:34 PM, Guillaume Blanchet wrote:

 Hi !

 I have installed R-2.7.0 64-bits on a computer where the new Ubuntu
 version (8.04) was installed. This computer is a 3.2 GHz Dual-core  
 with
 2 Gb of RAM.

 To test how fast (I though !) this machine is, I compared two simple
 matrix manipulations between Ubuntu and my laptop (a MacBook Pro  
 2.2 GHz
 with also 2 Gb of RAM under Mac OS X 10.5.2). By the way, I install  
 the
 normal version of R on my MacBook Pro (32-bits)



A guess to get that big a difference is that one has an optimized  
BLAS and the other doesn't.  Try something not so heavily dependent  
on  BLAS and see what the times are.

-Roy M

**
The contents of this message do not reflect any position of the U.S.  
Government or NOAA.
**
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
Environmental Research Division 
Southwest Fisheries Science Center
1352 Lighthouse Avenue
Pacific Grove, CA 93950-2097

e-mail: [EMAIL PROTECTED] (Note new e-mail address)
voice: (831)-648-9029
fax: (831)-648-8440
www: http://www.pfeg.noaa.gov/

Old age and treachery will overcome youth and skill.

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


[R] R question about prediction from a fitted model

2008-04-25 Thread Lisa
Hi, I have a question about predicting new values from a fitted model in R.

 For example, if i fit a linear model

fit-lm(y~x)

predict(fit) will give the fitted values for each x.

I am wondering if there is a way to do some prediction of the fitted for
some new values of x that are not in the data points?

for example, x=0.5 is not in the original data (not a datapoint), is there a
way to predict the fitted value corresponding to x=0.5 easily?

Thank you!

[[alternative HTML version deleted]]

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


Re: [R] R question about prediction from a fitted model

2008-04-25 Thread Jorge Ivan Velez
Hi Lisa,

See examples in ?predict.lm

HTH,

Jorge


On Fri, Apr 25, 2008 at 7:47 PM, Lisa [EMAIL PROTECTED] wrote:

 Hi, I have a question about predicting new values from a fitted model in R.

  For example, if i fit a linear model

 fit-lm(y~x)

 predict(fit) will give the fitted values for each x.

 I am wondering if there is a way to do some prediction of the fitted for
 some new values of x that are not in the data points?

 for example, x=0.5 is not in the original data (not a datapoint), is there
 a
 way to predict the fitted value corresponding to x=0.5 easily?

 Thank you!

[[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


[R] Summarize data for MCA (FactoMineR)

2008-04-25 Thread Nelson Castillo
Hi :-)

I'm new to R and I started using it for a project (I'm the CS guy in a group
of statisticians helping them find out how to solve issues as they come out).
This is my first post to the list and I am starting to learn R.

Well, they were used to doing MCA analysis in other programs where the data
seems to be preprocessed automatically before running MCA.

So, they need to process a data set that comes with N=100 of elements,
but there are really about N/100 distinct elements over all the variables, so
the MCA can be run in reasonable time summarizing data.

So, the question is:

How can I turn x from:

x -
structure(list(weight = c(1, 1, 2, 1, 2), var1 = structure(c(1L,
1L, 1L, 1L, 2L), .Label = c(A, C), class = factor), var2 =
structure(c(1L,
1L, 1L, 1L, 2L), .Label = c(B, D), class = factor)), .Names = c(weight,
var1, var2), row.names = c(NA, 5L), class = data.frame)

to:

y -
structure(list(weihgt = c(5L, 2L), var1 = structure(1:2, .Label = c(A,
C), class = factor), var2 = structure(1:2, .Label = c(B,
D), class = factor)), .Names = c(weihgt, var1, var2
), class = data.frame, row.names = c(NA, -2L))

using R?

That is, from:

 x
  weight var1 var2
1  1AB
2  1AB
3  2AB
4  1AB
5  2CD

to:

 y
  weihgt var1 var2
1  5AB
2  2CD


The idea is that there is one occurrence of A B repeated 4 times in
the original table,
and it is summarized in the second table, computing the sum of the weights.

I solved the problem using Perl, but I'd like to know what I have to
read in order to
do it in R.

Regards,
Nelson.-

-- 
http://arhuaco.org

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


[R] Details regarding the nnet package

2008-04-25 Thread Colin Blake Rickert
Hello,

I've recently been using the nnet package to do some basic forecast  
predictions. I've found the package to be quite useful and I am  
getting some good results. However, I am in the midst of writing a  
small paper on the results I am getting and wish to clarify some  
things about the nnet package that are not made clear in the  
documentation. In particular I would like to know the following:

1) Is it a standard feed forward network trained using gradient  
descent (I am assuming this is the case, seems like a no brainer but  
just to be sure)?

2) What is the sigmoidal function used for the activation/firing of a  
node in the network?

3) What exactly does the output value consist of at each iteration?  
Is this the value of the Least Mean Square function of the difference  
between the output layer and the target values or is it something else?

4) Will this package ever be updated to allow for multiple layers  
instead of just one? (just out of curiousity)


I have to present this paper on Friday May 2nd so I would greatly  
appreciate a timely response.

Thanks,

-Colin

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


[R] function clogit

2008-04-25 Thread Carmen Lishman

Hello,
 
I am using the clogit (conditional logistic regression) on a simple data set 
which is not related to survivorship, which I understand to be fine.
 
I have trouble understanding the output. I would like to find parameter 
estimates of the logistic models I am constructing with R, and am unclear as to 
what the coefficients represent that are provided.  
 
The below is a copy of my output.
 
 summary(clogit(Pluv~Clay+ Veg+ Grav+ Cobb+ strata(Site), 
 data=microsite1))Call:coxph(formula = Surv(rep(1, 50L), Pluv) ~ Clay + Veg + 
 Grav + Cobb + strata(Site), data = microsite1, method = exact)
  n= 50coef exp(coef) se(coef)  z pClay -14.15  7.16e-07 
8.43 -1.679 0.093Veg   -4.13  1.60e-0213.04 -0.317 0.750Grav  -6.93  
9.76e-04 8.63 -0.803 0.420Cobb  17.70  4.89e+0715.37  1.152 0.250
 exp(coef) exp(-coef) lower .95 upper .95Clay  7.16e-07   1.40e+06  
4.79e-14  1.07e+01Veg   1.60e-02   6.23e+01  1.27e-13  2.02e+09Grav  9.76e-04   
1.02e+03  4.42e-11  2.16e+04Cobb  4.89e+07   2.05e-08  4.03e-06  5.93e+20
Rsquare= 0.397   (max possible= 0.5 )Likelihood ratio test= 25.3  on 4 df,   
p=4.46e-05Wald test= 3.8  on 4 df,   p=0.434Score (logrank) test = 
14.3  on 4 df,   p=0.00625
Any help is greatly appreciated,
Thank you,
Carmen
 
_

n more at SignInAndWIN.ca

[[alternative HTML version deleted]]

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


Re: [R] R question about prediction from a fitted model

2008-04-25 Thread Lisa
Hi Jorge,

thank you very much for your reply.  I checked and have got the prediction
of new values for lm or glm or nls, the new question is, is there any
prediction for the cox model? I tried predict(Surv(y~x),newdata), it only
gave the fitted values. Any clue on this? thanks a lot!


On 4/25/08, Jorge Ivan Velez [EMAIL PROTECTED] wrote:


 Hi Lisa,

 See examples in ?predict.lm

 HTH,

 Jorge


  On Fri, Apr 25, 2008 at 7:47 PM, Lisa [EMAIL PROTECTED] wrote:

 Hi, I have a question about predicting new values from a fitted model in
 R.

  For example, if i fit a linear model

 fit-lm(y~x)

 predict(fit) will give the fitted values for each x.

 I am wondering if there is a way to do some prediction of the fitted for
 some new values of x that are not in the data points?

 for example, x=0.5 is not in the original data (not a datapoint), is there
 a
 way to predict the fitted value corresponding to x=0.5 easily?

 Thank you!

[[alternative HTML version deleted]]

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





[[alternative HTML version deleted]]

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