Re: [R] getWinProgressBar does not return previous value

2008-05-10 Thread Prof Brian Ripley

On Fri, 9 May 2008, Michael DiPersio wrote:


I am trying to use winProgressBar, however I find that although
setWinProgressBar updates the value on the screen, getWinProgressBar does
not return this value.
E.g

pb - winProgressBar()
setWinProgressBar(pb, 0.2)
getWinProgressBar(pb)

[1] 0


It does, but rounded to an integer.  Look at typeof() on the value, or

pb - winProgressBar(max=100)
setWinProgressBar(pb, 20)
getWinProgressBar(pb)

It would be more flexible to allow the user to round, so I'll change it.



I tried the same with tkProgressBar, and it is working as I would expect
from the documentation.

pb - tkProgressBar()
setTkProgressBar(pb, 0.5)
getTkProgressBar(pb)

[1] 0.5
... and I get the same result using txtProgressBar .

Does anyone using winProgressBar find the same behaviour, or know the reason
for it?  A search for winProgressBar in R-help archive did not reveal
anything, I believe it is a new function to v2.7.0.


sessionInfo()

R version 2.7.0 (2008-04-22)
i386-pc-mingw32

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

attached base packages:
[1] tcltk stats graphics  grDevices utils datasets  methods
[8] base

Thanks,

Michael

__
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] lme nesting/interaction advice

2008-05-10 Thread Kingsford Jones
On Fri, May 9, 2008 at 4:04 AM, Federico Calboli
[EMAIL PROTECTED] wrote:

 Note that random can be a list:

 a one-sided formula of the form ~x1+...+xn, or a pdMat object with a
 formula
 (i.e. a non-NULL value for formula(object)), or a list of such formulas or
 pdMat
 objects. 

 If you can translate that into *informative* English I'd be grateful. I have
 the Pinheiro and Bates book under my nose now, and I suspect it's pretty
 more extensive that the helpfile, but it's still nowhere close to providing
 a straigtforward answer to my question.


Federico,

I think you'll be more likely to receive the type of response you're
looking for if you formulate your question more clearly.  The
inclusion of commented, minimal, self-contained, reproducible code
(as is requested at the bottom of every email sent by r-help) is an
effective way to clarify the issues.  Also, when asking a question
about fitting a model it's helpful to describe the specific research
questions you want the model to answer.

I'll offer my interpretation of your study design so you can see where
questions might arise.
It sounds like you have protein measures (on how many units?) at
various levels of 'male' (which at first you described as
presence/absence, but later as continuous - also you descibed 'male'
as fixed and continuous but then entered it in the formula as though
it were a random grouping factor), within the second level of
'selection' (e.g. large1), within the first level of selection (e.g.
large), within a random block (what are the blocks?)  within a random
month.  Is this right -- multiple observations within 4 levels of
nesting - some of which are random and some fixed?

Finally, I'll point out that there's an R list dedicated to mixed
models, with a particular focus on the lmer function, which might be
the right tool for your analyses (
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models ).


Kingsford Jones



 Cheers,

 Federico


 --
 Federico C. F. Calboli
 Department of Epidemiology and Public Health
 Imperial College, St Mary's Campus
 Norfolk Place, London W2 1PG

 Tel  +44 (0)20 7594 1602 Fax (+44) 020 7594 3193

 f.calboli [.a.t] imperial.ac.uk
 f.calboli [.a.t] gmail.com

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


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


[R] problem reading .por SPSS file

2008-05-10 Thread Viktor Nagy
Hello,

I've a .por file from 1998. I've tried to read it with

library(foreign)
read.spss(mhp_hu.por)

at this point R simply stops working and my whole system is close to unusable

I've found one related thread, but even there no real solution was given
https://stat.ethz.ch/pipermail/r-help/2007-February/125071.html

Unfortunately, I have no SPSS, and I can't convert it to txt or any
other format. I was trying to use PSPP as well, but I could not
understand how to open a file in it. :(

Does any of you have an idea?

Thanks, Viktor

__
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] Create pairwise table from columns?

2008-05-10 Thread Bill.Venables
Here is a suggestion

 con - textConnection(AnimalA,AnimalB,Score
A1,A2,1
A1,A3,2
A1,A4,3
A2,A3,4
A2,A4,5
A3,A4,6
)
 tst - read.csv(con)
 close(con)
 an - with(tst, sort(unique(c(as.character(AnimalA),
as.character(AnimalB)
 M - array(0, c(length(an), length(an)), list(an, an))
 i - match(tst$AnimalA, an)
 j - match(tst$AnimalB, an)
 M[cbind(i,j)] - M[cbind(j,i)] - tst$Score
 
 M
   A1 A2 A3 A4
A1  0  1  2  3
A2  1  0  4  5
A3  2  4  0  6
A4  3  5  6  0
 


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 knussear
Sent: Saturday, 10 May 2008 10:18 AM
To: r-help@r-project.org
Subject: [R] Create pairwise table from columns?


Hi Group

I have a large data set of individual pairwise values (250,000 rows)
that I
need to reshape into a pairwise matrix for mantel tests of these values
versus genetic distances.

the data are currently in columns formatted like so
AnimalA, AnimalB, Score
A1, A2, S1
A1, A3, S2
A1, A4, S3
A2, A3, S4
A2, A4, S5
A3, A4, S6
...,,


I need the final matrix to be formatted as
 A1A2A3A4
A1  0 S1S2S3
A2  S10 S4S5
A3  S2S4   0  S6
A4  S3S4   S6 0

are there any functions/packages that will make this easier?

Thanks

Ken
-- 
View this message in context:
http://www.nabble.com/Create-pairwise-table-from-columns--tp17158538p171
58538.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-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] function in nls argument -- robust estimation

2008-05-10 Thread Martin Maechler
Hi Kate and Fernando,

I'm late into this thread,
but from reading it I get the impression that Fernando really
wants to do *robust* (as opposed to least-squares) non-linear
model fitting.  His proposal to set residuals to zero when they
are outside a given bound is a very special case of an
M-estimator, namely (if I'm not mistaken) the so-called Huber
skipped-mean, an M-estimator with psi-function 
   psi - function(x, k) ifelse(abs(x) = k, x, 0)
It is known that this can be far from optimal, and either using
Huber-psi or a redescender such as Tukey's biweight can be
considerably better.
Also note that the standard inference (std.errors, P-values, ...)
that you'd get from summary(nlsfit) or anova(nls1, nl2) is 
*invalid* here, since you are effectively using *random* weighting.

The nlrob() function in package 'robustbase'
implements M-estimation of nonlinear models directly.
Unfortunately, how to do correct inference in this situation
is a hard problem, probably even an open research question in
parts. I would expect that the bootstrap should work if you only
have a few outliers.

I don't have time at the moment to look at the example data and
the model, and show you how to use it for nlrob();
if you find a way to you it for nls() , then the same should
work for nlrob().

I'm CCing this to the specialists for Robust Stats with R
mailing list, R-SIG-robust.

Best regards,
Martin Maechler
ETH Zurich

 KateM == Katharine Mullen [EMAIL PROTECTED]
 on Fri, 9 May 2008 15:50:08 +0200 (CEST) writes:

KateM You can take minpack.lm_1.1-0 (source code and MS Windows build,
KateM respectively) from here:

KateM http://www.nat.vu.nl/~kate/minpack.lm_1.1-0.tar.gz
KateM http://www.nat.vu.nl/~kate/minpack.lm_1.1-0.zip

KateM The bug that occurs when nprint = 0 is fixed.  Also fixed is another
KateM problem suggested your example: when the argument par is a list, 
calling
KateM summary on the output of nls.lm was not working.

KateM I'll submit the new version to CRAN soon.

KateM This disscusion has been fruitful - thanks for it.

KateM On Fri, 9 May 2008, Katharine Mullen wrote:

 You indeed found a bug.  I can reproduce it (which I should have tried to
 do on other examples in the first place!).  Thanks for finding it.
 
 It will be fixed in version 1.1-0 which I will submit to CRAN soon.
 
 On Fri, 9 May 2008, elnano wrote:
 
 
  Find the data (data_nls.lm_moyano.txt) here:
  ftp://ftp.bgc-jena.mpg.de/pub/outgoing/fmoyano
 
 
 
  Katharine Mullen wrote:
  
   Thanks for the details - it sounds like a bug.  You can either send 
me the
   data in an email off-list or make it available on-line somewhere, so 
that
   I and other people can download it.
  
  
   __
   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.
  
  
 
  --
  View this message in context: 
http://www.nabble.com/function-in-nls-argument-tp17108100p17146812.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-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.
 

KateM __
KateM R-help@r-project.org mailing list
KateM https://stat.ethz.ch/mailman/listinfo/r-help
KateM PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
KateM 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] problem reading .por SPSS file

2008-05-10 Thread Prof Brian Ripley
And how are we supposed to help without knowing your version of R, the 
version of 'foreign', anything about your system (or you) and without 
access to the file?


Please do consult the posting guide and supply enough information that we 
have a chance of helping you.


On Sat, 10 May 2008, Viktor Nagy wrote:


Hello,

I've a .por file from 1998. I've tried to read it with

library(foreign)
read.spss(mhp_hu.por)

at this point R simply stops working and my whole system is close to unusable

I've found one related thread, but even there no real solution was given
https://stat.ethz.ch/pipermail/r-help/2007-February/125071.html


That is not about .por files.


Unfortunately, I have no SPSS, and I can't convert it to txt or any
other format. I was trying to use PSPP as well, but I could not
understand how to open a file in it. :(

Does any of you have an idea?

Thanks, Viktor

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


[R] How many random numbers needed?

2008-05-10 Thread Birgit Lemcke

Hello R-People!

I am running R 2.7.0 on a Power Book (Tiger). (I am still R and  
statistics beginner)


Perhaps this is another stupid question of me, but I was wondering  
how I know the needed random (set.seed) numbers, when running  
randomForest (library randomForest) on a large dataset.


Thanks in advance

Birgit



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

175 Jahre UZH
«staunen.erleben.begreifen. Naturwissenschaft zum Anfassen.»
MNF-Jubiläumsevent für gross und klein.
19. April 2008, 10.00 Uhr bis 02.00 Uhr
Campus Irchel, Winterthurerstrasse 190, 8057 Zürich
Weitere Informationen http://www.175jahre.uzh.ch/naturwissenschaft

__
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] Hashes as S4 Classes, or: How to separate environments

2008-05-10 Thread Hans W Borchers
For learning purposes mainly I attempted to implement hashes/maps/dictionaries
(Python lingua) as S4 classes, see the coding below. I came across some rough S4
edges, but in the end it worked (for one dictionary).

When testing ones sees that the dictionaries D1 and D2 share their environments
[EMAIL PROTECTED] and [EMAIL PROTECTED], though I thought a new and empty 
environment would be
generated each time 'new(Dict)' is called.

QUESTION: How can I separate the environments [EMAIL PROTECTED] and [EMAIL 
PROTECTED] ?

Reading the articles mentioned in Tipps and Tricks didn't help me really.
Of course, I will welcome other corrections and improvements as well.
Working in R 2.7.0 under Windows.

Hans Werner


#-- Class and method definition for dictionaries ---

setClass(Dict,
representation (hash = environment),
prototype (hash = new.env(hash=T, parent = emptyenv()))
)

setMethod(show, signature(object=Dict),
definition = function(object) ls([EMAIL PROTECTED])
)

setGeneric(hclear, function(object) standardGeneric(hclear))
setMethod(hclear, signature(object=Dict),
function(object) rm(list=ls([EMAIL PROTECTED]), [EMAIL PROTECTED])
)

setGeneric(hput, function(object, key, value) standardGeneric(hput))
setMethod(hput, signature(object=Dict, key=character, value=ANY),
function(object, key, value) assign(key, value, [EMAIL PROTECTED])
)

setGeneric(hget, function(object, key, ...) standardGeneric(hget))
setMethod(hget, signature(object=Dict, key=character),
function(object, key) {
if (exists(key, [EMAIL PROTECTED], inherits = FALSE)) {
get(key, [EMAIL PROTECTED])
} else {
return(NULL)
}
}
)

#  Some tests 
D1 - new(Dict)
hput(D1, a, 1)   # Same as: [EMAIL PROTECTED] - 1
hput(D1, b, 2)
hget(D1, a)
hget(D1, b)
show(D1)

D2 - new(Dict)
hput(D2, c, 3)
hput(D2, d, 4)
hget(D2, a)  # Wrong: was defined only for D1
hget(D2, b)
show(D2)

hclear(D2) # Wrong: clears D1 too
show(D1)
#-

__
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] irregular time series and multiple, overlaid plots

2008-05-10 Thread Gabor Grothendieck
Look at the zoo and quantmod packages.

On Sat, May 10, 2008 at 12:51 AM, falcon [EMAIL PROTECTED] wrote:

 I am new to R and am trying to solve the following problem:

 I have a data file containing tick-by-tick, millisecond level prices for
 some stocks.  I have another file or two containing orders and trades,
 again, with millisecond time-stamps.  Both of these files are irregularly
 spaced and the time stamps are in an iso format (date
 time.millisecond)

 I would like to create a price chart, and overlay on it the times and prices
 at which orders were sent out and trades were received.

 My purpose is basically to visualize the data to help me pinpoint problems
 and visually describe a day's trading activity.  I am not (yet) interested
 in any detailed statistical analysis.

 From what I have read, the basic time series (ts) object is not appropriate
 since it is only for regularly spaced time series.  The few examples I have
 seen for the 'its' package, generate an artificial time series, rather than
 reading from a file, extracting out relevant columns (say a time stamp
 column and a price column) and converting that to the right time series
 object (including taking care of time stamp formats).

 Any idea how I can approach this problem?

 Thanks
 Falcon
 --
 View this message in context: 
 http://www.nabble.com/irregular-time-series-and-multiple%2C-overlaid-plots-tp17159961p17159961.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-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] problem reading .por SPSS file

2008-05-10 Thread Viktor Nagy
sorry, but it turned out that only the file was bigger than my patience

(next time I will be more careful about the posting guide as well)

thanks for your time!

Viktor

2008/5/10 Prof Brian Ripley [EMAIL PROTECTED]:
 And how are we supposed to help without knowing your version of R, the
 version of 'foreign', anything about your system (or you) and without access
 to the file?

 Please do consult the posting guide and supply enough information that we
 have a chance of helping you.

 On Sat, 10 May 2008, Viktor Nagy wrote:

 Hello,

 I've a .por file from 1998. I've tried to read it with

 library(foreign)
 read.spss(mhp_hu.por)

 at this point R simply stops working and my whole system is close to
 unusable

 I've found one related thread, but even there no real solution was given
 https://stat.ethz.ch/pipermail/r-help/2007-February/125071.html

 That is not about .por files.

 Unfortunately, I have no SPSS, and I can't convert it to txt or any
 other format. I was trying to use PSPP as well, but I could not
 understand how to open a file in it. :(

 Does any of you have an idea?

 Thanks, Viktor

 __
 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] Create pairwise table from columns?

2008-05-10 Thread knussear

Fantastic! Thanks very much!

Where can I read more about the double assignment statement at the bottom? 
Closest I could get was a double for loop, which takes a long time


Bill.Venables wrote:
 
 Here is a suggestion
 
 con - textConnection(AnimalA,AnimalB,Score
 A1,A2,1
 A1,A3,2
 A1,A4,3
 A2,A3,4
 A2,A4,5
 A3,A4,6
 )
 tst - read.csv(con)
 close(con)
 an - with(tst, sort(unique(c(as.character(AnimalA),
 as.character(AnimalB)
 M - array(0, c(length(an), length(an)), list(an, an))
 i - match(tst$AnimalA, an)
 j - match(tst$AnimalB, an)
 M[cbind(i,j)] - M[cbind(j,i)] - tst$Score
 
 M
A1 A2 A3 A4
 A1  0  1  2  3
 A2  1  0  4  5
 A3  2  4  0  6
 A4  3  5  6  0
 
 
 
 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 knussear
 Sent: Saturday, 10 May 2008 10:18 AM
 To: r-help@r-project.org
 Subject: [R] Create pairwise table from columns?
 
 
 Hi Group
 
 I have a large data set of individual pairwise values (250,000 rows)
 that I
 need to reshape into a pairwise matrix for mantel tests of these values
 versus genetic distances.
 
 the data are currently in columns formatted like so
 AnimalA, AnimalB, Score
 A1, A2, S1
 A1, A3, S2
 A1, A4, S3
 A2, A3, S4
 A2, A4, S5
 A3, A4, S6
 ...,,
 
 
 I need the final matrix to be formatted as
  A1A2A3A4
 A1  0 S1S2S3
 A2  S10 S4S5
 A3  S2S4   0  S6
 A4  S3S4   S6 0
 
 are there any functions/packages that will make this easier?
 
 Thanks
 
 Ken
 -- 
 View this message in context:
 http://www.nabble.com/Create-pairwise-table-from-columns--tp17158538p171
 58538.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-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.
 
 

-- 
View this message in context: 
http://www.nabble.com/Create-pairwise-table-from-columns--tp17158538p17162698.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] Hashes as S4 Classes, or: How to separate environments

2008-05-10 Thread Martin Morgan
Hi Hans --

Hans W Borchers [EMAIL PROTECTED] writes:

 For learning purposes mainly I attempted to implement hashes/maps/dictionaries
 (Python lingua) as S4 classes, see the coding below. I came across some rough 
 S4
 edges, but in the end it worked (for one dictionary).

 When testing ones sees that the dictionaries D1 and D2 share their 
 environments
 [EMAIL PROTECTED] and [EMAIL PROTECTED], though I thought a new and empty 
 environment would be
 generated each time 'new(Dict)' is called.

 QUESTION: How can I separate the environments [EMAIL PROTECTED] and [EMAIL 
 PROTECTED] ?

The prototype is created once, at class creation time. So all objects
derived from the prototype share the same environment (other types
like 'list' would have the illusion of being created anew, because of
copy-on-change semantics). A solution is to have an initialize method
that recreates the hash each time.

setMethod(initialize, signature=signature(.Object=Dict),
function(.Object,
 hash=new.env(hash=TRUE, parent=emptyenv()),
 ...) {
callNextMethod(.Object, hash=hash, ...)
})

Another solution is to have a constructor that feeds Dict a new
environment

Dict - function() {
new(Dict, hash=new.env(hash=TRUE, parent=emptyenv())
}

The latter is perhaps preferable, both from an aesthetic / user point
of view ('Dict()' better than 'new(Dict)') and from the
nuances-of-S4 point of view (e.g., the default 'initialize' method is
documented, though not in so many words, as a copy constructor, taking
slots in it's first argument as defaults; 'initialize' above does not
satisfy that contract).

I know others have implemented Dict objects; it would be fun to hear
from them.

Martin

 Reading the articles mentioned in Tipps and Tricks didn't help me really.
 Of course, I will welcome other corrections and improvements as well.
 Working in R 2.7.0 under Windows.

 Hans Werner


 #-- Class and method definition for dictionaries 
 ---

 setClass(Dict,
 representation (hash = environment),
 prototype (hash = new.env(hash=T, parent = emptyenv()))
 )

 setMethod(show, signature(object=Dict),
 definition = function(object) ls([EMAIL PROTECTED])
 )

 setGeneric(hclear, function(object) standardGeneric(hclear))
 setMethod(hclear, signature(object=Dict),
 function(object) rm(list=ls([EMAIL PROTECTED]), [EMAIL PROTECTED])
 )

 setGeneric(hput, function(object, key, value) standardGeneric(hput))
 setMethod(hput, signature(object=Dict, key=character, value=ANY),
 function(object, key, value) assign(key, value, [EMAIL PROTECTED])
 )

 setGeneric(hget, function(object, key, ...) standardGeneric(hget))
 setMethod(hget, signature(object=Dict, key=character),
 function(object, key) {
 if (exists(key, [EMAIL PROTECTED], inherits = FALSE)) {
 get(key, [EMAIL PROTECTED])
 } else {
 return(NULL)
 }
 }
 )

 #  Some tests 
 D1 - new(Dict)
 hput(D1, a, 1)   # Same as: [EMAIL PROTECTED] - 1
 hput(D1, b, 2)
 hget(D1, a)
 hget(D1, b)
 show(D1)

 D2 - new(Dict)
 hput(D2, c, 3)
 hput(D2, d, 4)
 hget(D2, a)  # Wrong: was defined only for D1
 hget(D2, b)
 show(D2)

 hclear(D2) # Wrong: clears D1 too
 show(D1)
 #-

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

-- 
Martin Morgan
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M2 B169
Phone: (206) 667-2793

__
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 many random numbers needed?

2008-05-10 Thread Gavin Simpson
On Sat, 2008-05-10 at 13:21 +0200, Birgit Lemcke wrote:
 Hello R-People!
 
 I am running R 2.7.0 on a Power Book (Tiger). (I am still R and  
 statistics beginner)
 
 Perhaps this is another stupid question of me, but I was wondering  
 how I know the needed random (set.seed) numbers, when running  
 randomForest (library randomForest) on a large dataset.

The seed is just a starting point for the RNG. You can draw as many
numbers as you like once the RNG has been seeded.

The ability to set the seed allows repeated runs of functions like
randomForest to provide the same results for each run. This is a basic
requirement of reproducible research.

require(randomForest)
set.seed(1)
mod1 - randomForest(Species ~ ., data = iris)
mod2 - randomForest(Species ~ ., data = iris)
set.seed(1)
mod3 - randomForest(Species ~ ., data = iris)

all.equal(mod1, mod2)
all.equal(mod1, mod3)

You could put whatever (within reason - up to limits of an integer in R)
into the set.seed function, but the point is to provide the same number
in the seed if you want to make sure your results are reproducible.

HTH

G

 
 Thanks in advance
 
 Birgit
 
 
 
 Birgit Lemcke
 Institut für Systematische Botanik
 Zollikerstrasse 107
 CH-8008 Zürich
 Switzerland
 Ph: +41 (0)44 634 8351
 [EMAIL PROTECTED]
 
 175 Jahre UZH
 «staunen.erleben.begreifen. Naturwissenschaft zum Anfassen.»
 MNF-Jubiläumsevent für gross und klein.
 19. April 2008, 10.00 Uhr bis 02.00 Uhr
 Campus Irchel, Winterthurerstrasse 190, 8057 Zürich
 Weitere Informationen http://www.175jahre.uzh.ch/naturwissenschaft
 
 __
 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.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

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


Re: [R] Create pairwise table from columns?

2008-05-10 Thread hadley wickham
On Fri, May 9, 2008 at 7:17 PM, knussear [EMAIL PROTECTED] wrote:

 Hi Group

 I have a large data set of individual pairwise values (250,000 rows) that I
 need to reshape into a pairwise matrix for mantel tests of these values
 versus genetic distances.

 the data are currently in columns formatted like so
 AnimalA, AnimalB, Score
 A1, A2, S1
 A1, A3, S2
 A1, A4, S3
 A2, A3, S4
 A2, A4, S5
 A3, A4, S6
 ...,,


 I need the final matrix to be formatted as
 A1A2A3A4
 A1  0 S1S2S3
 A2  S10 S4S5
 A3  S2S4   0  S6
 A4  S3S4   S6 0

One approach would be to use the reshape package (http://had.co.nz/reshape) -

dfm - melt(mydf, id = c(AnimalA, AnimalB))
cast(dfm, AnimalA ~ AnimalB)

Hadley

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

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


Re: [R] Hashes as S4 Classes, or: How to separate environments

2008-05-10 Thread Charilaos Skiadas

On May 10, 2008, at 7:30 AM, Hans W Borchers wrote:

For learning purposes mainly I attempted to implement hashes/maps/ 
dictionaries
(Python lingua) as S4 classes, see the coding below. I came across  
some rough S4

edges, but in the end it worked (for one dictionary).

When testing ones sees that the dictionaries D1 and D2 share their  
environments
[EMAIL PROTECTED] and [EMAIL PROTECTED], though I thought a new and empty environment  
would be

generated each time 'new(Dict)' is called.

QUESTION: How can I separate the environments [EMAIL PROTECTED] and [EMAIL 
PROTECTED] ?


The problem you are encountering is that the prototype is only  
created once. Because environments are passed by reference, [EMAIL PROTECTED]  
and [EMAIL PROTECTED] are the exact same environment:


 D1 - new(Dict)
 D1
 [EMAIL PROTECTED]
environment: 0x182ac870
 D2 - new(Dict)
 [EMAIL PROTECTED]
environment: 0x182ac870

You have assumed that setClass will be executed for each new  
dictionary, or at least that the prototype(...) part of it would run  
each time. Not wanting right now to dig into the internals of  
setClass, my guess is that it only creates a prototype once, and then  
just reuses it each time, with something like an assignment operator.  
One solution, very similar to what Martin just suggested, is below. I  
believe another solution might be to have the hash be a list  
containing an environment, though I haven't tried that.


The solution is to create a constructor function, the function  
newDict below:


setClass(Dict,
representation (hash = environment))
)
newDict - function() {
obj - new(Dict)
[EMAIL PROTECTED] - new.env(hash=T, parent = emptyenv())
obj
}

In practice, you would probably want newDict to accept an arguments,  
which may be a list or another Dict object, and then use that as a  
starting point for the new hash.


Here's a sample run:

 #  Some tests 
 D1 - newHash()
 D2 - newHash()
 [EMAIL PROTECTED]
environment: 0x1e80c98
 [EMAIL PROTECTED]# Notice the different address
environment: 0x1e868fc
 hput(D1, a, 1)
 hget(D1, a)
[1] 1
 show(D1)
[1] a
 hput(D2, c, 3)
 hget(D2, a)  # Does the correct thing this time
NULL
 hget(D2, c)
[1] 3
 show(D2)
[1] c
 hclear(D2)
 show(D1)# Works properly now
[1] a
 #-

Haris Skiadas
Department of Mathematics and Computer Science
Hanover College

Reading the articles mentioned in Tipps and Tricks didn't help me  
really.

Of course, I will welcome other corrections and improvements as well.
Working in R 2.7.0 under Windows.

Hans Werner





#-- Class and method definition for dictionaries  
---


setClass(Dict,
representation (hash = environment),
prototype (hash = new.env(hash=T, parent = emptyenv()))
)

setMethod(show, signature(object=Dict),
definition = function(object) ls([EMAIL PROTECTED])
)

setGeneric(hclear, function(object) standardGeneric(hclear))
setMethod(hclear, signature(object=Dict),
function(object) rm(list=ls([EMAIL PROTECTED]), [EMAIL PROTECTED])
)

setGeneric(hput, function(object, key, value) standardGeneric 
(hput))
setMethod(hput, signature(object=Dict, key=character,  
value=ANY),

function(object, key, value) assign(key, value, [EMAIL PROTECTED])
)

setGeneric(hget, function(object, key, ...) standardGeneric(hget))
setMethod(hget, signature(object=Dict, key=character),
function(object, key) {
if (exists(key, [EMAIL PROTECTED], inherits = FALSE)) {
get(key, [EMAIL PROTECTED])
} else {
return(NULL)
}
}
)

#  Some tests 
D1 - new(Dict)
hput(D1, a, 1)   # Same as: [EMAIL PROTECTED] - 1
hput(D1, b, 2)
hget(D1, a)
hget(D1, b)
show(D1)

D2 - new(Dict)
hput(D2, c, 3)
hput(D2, d, 4)
hget(D2, a)  # Wrong: was defined only for D1
hget(D2, b)
show(D2)

hclear(D2) # Wrong: clears D1 too
show(D1)
#-


__
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 many random numbers needed?

2008-05-10 Thread Birgit Lemcke

Thank you Gavin.

I knew about the meaning set.seed for reproducability but  I did not  
realise that it is only the starting point.


Is it possible that very small or very big random numbers cause any  
kind of bias?


B.


Am 10.05.2008 um 14:50 schrieb Gavin Simpson:

On Sat, 2008-05-10 at 13:21 +0200, Birgit Lemcke wrote:

Hello R-People!

I am running R 2.7.0 on a Power Book (Tiger). (I am still R and
statistics beginner)

Perhaps this is another stupid question of me, but I was wondering
how I know the needed random (set.seed) numbers, when running
randomForest (library randomForest) on a large dataset.


The seed is just a starting point for the RNG. You can draw as many
numbers as you like once the RNG has been seeded.

The ability to set the seed allows repeated runs of functions like
randomForest to provide the same results for each run. This is a basic
requirement of reproducible research.

require(randomForest)
set.seed(1)
mod1 - randomForest(Species ~ ., data = iris)
mod2 - randomForest(Species ~ ., data = iris)
set.seed(1)
mod3 - randomForest(Species ~ ., data = iris)

all.equal(mod1, mod2)
all.equal(mod1, mod3)

You could put whatever (within reason - up to limits of an integer  
in R)
into the set.seed function, but the point is to provide the same  
number

in the seed if you want to make sure your results are reproducible.

HTH

G



Thanks in advance

Birgit



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

175 Jahre UZH
«staunen.erleben.begreifen. Naturwissenschaft zum Anfassen.»
MNF-Jubiläumsevent für gross und klein.
19. April 2008, 10.00 Uhr bis 02.00 Uhr
Campus Irchel, Winterthurerstrasse 190, 8057 Zürich
Weitere Informationen http://www.175jahre.uzh.ch/naturwissenschaft

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

--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



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

175 Jahre UZH
«staunen.erleben.begreifen. Naturwissenschaft zum Anfassen.»
MNF-Jubiläumsevent für gross und klein.
19. April 2008, 10.00 Uhr bis 02.00 Uhr
Campus Irchel, Winterthurerstrasse 190, 8057 Zürich
Weitere Informationen http://www.175jahre.uzh.ch/naturwissenschaft

__
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] function in nls argument -- robust estimation

2008-05-10 Thread Katharine Mullen
Dear Martin,

Thanks for the ideas regarding the relation of what Fernando is doing with
robust regression.  Indeed, it's an important point that he can't consider
the standard error estimates on his parameters correct.

I know from discussion off-list that he's happy with the results he has
now; nevertheless the robust regression route may be an interesting
alternative.  I'm posting a scipt to R-SIG-robust now that compares the 3
ways (nls, nlrob and nls.lm w/residuals above a certain quantile set to
zero).

best,
Kate

On Sat, 10 May 2008, Martin Maechler wrote:

 Hi Kate and Fernando,

 I'm late into this thread,
 but from reading it I get the impression that Fernando really
 wants to do *robust* (as opposed to least-squares) non-linear
 model fitting.  His proposal to set residuals to zero when they
 are outside a given bound is a very special case of an
 M-estimator, namely (if I'm not mistaken) the so-called Huber
 skipped-mean, an M-estimator with psi-function
psi - function(x, k) ifelse(abs(x) = k, x, 0)
 It is known that this can be far from optimal, and either using
 Huber-psi or a redescender such as Tukey's biweight can be
 considerably better.
 Also note that the standard inference (std.errors, P-values, ...)
 that you'd get from summary(nlsfit) or anova(nls1, nl2) is
 *invalid* here, since you are effectively using *random* weighting.

 The nlrob() function in package 'robustbase'
 implements M-estimation of nonlinear models directly.
 Unfortunately, how to do correct inference in this situation
 is a hard problem, probably even an open research question in
 parts. I would expect that the bootstrap should work if you only
 have a few outliers.

 I don't have time at the moment to look at the example data and
 the model, and show you how to use it for nlrob();
 if you find a way to you it for nls() , then the same should
 work for nlrob().

 I'm CCing this to the specialists for Robust Stats with R
 mailing list, R-SIG-robust.

 Best regards,
 Martin Maechler
 ETH Zurich

  KateM == Katharine Mullen [EMAIL PROTECTED]
  on Fri, 9 May 2008 15:50:08 +0200 (CEST) writes:

 KateM You can take minpack.lm_1.1-0 (source code and MS Windows build,
 KateM respectively) from here:

 KateM http://www.nat.vu.nl/~kate/minpack.lm_1.1-0.tar.gz
 KateM http://www.nat.vu.nl/~kate/minpack.lm_1.1-0.zip

 KateM The bug that occurs when nprint = 0 is fixed.  Also fixed is 
 another
 KateM problem suggested your example: when the argument par is a list, 
 calling
 KateM summary on the output of nls.lm was not working.

 KateM I'll submit the new version to CRAN soon.

 KateM This disscusion has been fruitful - thanks for it.

 KateM On Fri, 9 May 2008, Katharine Mullen wrote:

  You indeed found a bug.  I can reproduce it (which I should have tried 
 to
  do on other examples in the first place!).  Thanks for finding it.
 
  It will be fixed in version 1.1-0 which I will submit to CRAN soon.
 
  On Fri, 9 May 2008, elnano wrote:
 
  
   Find the data (data_nls.lm_moyano.txt) here:
   ftp://ftp.bgc-jena.mpg.de/pub/outgoing/fmoyano
  
  
  
   Katharine Mullen wrote:
   
Thanks for the details - it sounds like a bug.  You can either 
 send me the
data in an email off-list or make it available on-line somewhere, 
 so that
I and other people can download it.
   
   
__
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.
   
   
  
   --
   View this message in context: 
 http://www.nabble.com/function-in-nls-argument-tp17108100p17146812.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-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.
 

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


__

Re: [R] Error while making R package

2008-05-10 Thread Uwe Ligges



Vidhu Choudhary wrote:

Hi All,
*I am still facing the problems in making R package on windows. *


-- Making package t1 
  adding build stamp to DESCRIPTION
  installing NAMESPACE file and metadata
  making DLL ...
making CGHseg_rewrite.d from CGHseg_rewrite.c
making rowMedians.d from rowMedians.c
making runavg.d from runavg.c
gcc-sjlj  -std=gnu99  -IC:/R/R-2.6.2/include -O3 -Wall  -c
CGHseg_rewrite.c -o CGHseg_rewrite.o
gcc-sjlj  -std=gnu99  -IC:/R/R-2.6.2/include -O3 -Wall  -c rowMedians.c
-o rowMedians.o
gcc-sjlj  -std=gnu99  -IC:/R/R-2.6.2/include -O3 -Wall  -c runavg.c -o
runavg.o
windres --preprocessor=gcc-sjlj -E -xc -DRC_INVOKED -I
C:/R/R-2.6.2/include  -i t1_res.rc -o t1_res.
o
gcc-sjlj  -std=gnu99  -shared -s  -o t1.dll t1.def CGHseg_rewrite.o
rowMedians.o runavg.o t1_res.o  -L
C:/R/R-2.6.2/bin-lR
  ... DLL made
  installing DLL
  installing R files
  installing data files
rm: failed to get attributes of `/': No such file or directory


Do you have the recent Rtools and none else?
Where is the package located and how do you invoke the install command?

I have no further ideas. It works for me some lines further on but I do 
not have all 120 or so packages installed that are required (although I 
do have all CRAN and BioC packages for R-2.7.x for Windows installed).


Uwe Ligges





make[2]: *** [c:/R/R-2.6.2/library/t1/data] Error 1
make[1]: *** [all] Error 2
make: *** [pkg-t1] Error 2
*** Installation of t1 failed ***

Removing 'c:/R/R-2.6.2/library/t1'
Restoring previous 'c:/R/R-2.6.2/library/t1'

*I have made registry changes also as per the link :
https://stat.ethz.ch/pipermail/r-devel/2008-January/048059.html
*
*I can successfully make the package on Linux. *

But when I try to R CMD INSTALL on windows( package made in linux) I get the
same error of
rm: failed to get attributes of `/': No such file or directory
make[2]: *** [c:/R/R-2.6.2/library/t1/data] Error 1

I am attaching the .tar file made on windows2000


Thank you
Best Regards
Vidhu


__
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] Simple regex problem

2008-05-10 Thread John Kane
I am cleaning up some character data to convert to
dates using chron. The regex that I am using work fine
but there should be a better way to do this. Can
anyone suggest a cleaner bit of code than the gsub,
sub approach? Thanks

#Test Run on dates.
xx - c(May  1, 2007,
May  2, 2007,
May  3, 2007,
May  4, 2007,
May  5, 2007,
May  6, 2007,
May  7, 2007,
May  8, 2007,
May  9, 2007,
May 10, 2007,
May 11, 2007,
May 12, 2007)
yy - gsub( +, /, xx) ; yy
zz - sub(,, , yy) ; zz
library(chron)
ttdates - chron(zz, format = c(dates = mon/d/y))

__
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-pkgs] AER: Applied Econometrics with R

2008-05-10 Thread Achim Zeileis

The package AER accompanying the forthcoming book Applied
Econometrics with R by Christian Kleiber and me in the
Springer useR! series has (finally!) been released to CRAN:
  http://CRAN.R-project.org/package=AER

It contains some new R functionality
  o tobit regression convenience interface (to survival)
  o instrumental variables regression (two-stage least squares)
  o (over-) dispersion test (via auxiliary regression)
but the main feature are ~100 data sets taken from popular
econometrics text books and the data archives of JAE (Journal
of Applied Econometrics) and JBES (Journal of Business and
Economic Statistics). Extensive examples are provided with
the data sets, reproducing many of the analyses in the
books/papers they were taken from. In particular, all data
sets from the following books with many of the associated
examples are provided:
  o Econometrics (Baltagi, 2002)
  o Econometric Analysis (Greene, 2003)
  o Introduction to Econometrics (Stock  Watson, 2007)

Until the book becomes available in autumn 2008, we will add
vignettes to the package reproducing the examples from our
book.

Best wishes,
Z

___
R-packages mailing list
[EMAIL PROTECTED]
https://stat.ethz.ch/mailman/listinfo/r-packages

__
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] Compact Indicator Matrices

2008-05-10 Thread amarkos
An indicator matrix is a binary matrix with orthogonal columns whose
rows sum to 1. A row of this matrix could be [0 1 0 0]. My problem is
to group the similar rows (profiles) so that to create a compact form
of the matrix.

Is there an R function that deals with this problem or do I have to
write it from scratch?

Thanks,
Angelos Markos
Dr. Applied Informatics,
University of Macedonia, Greece

__
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 needed with rbftrain

2008-05-10 Thread Invernomuto

Hello everybody,

I'm new to R. I'm trying to set up a Rbf network using the rbftrain function
but I get an error I can't understand.

this is what I type:

rbftrain(input,3,output,visual=F)

where input is a matrix with 198 rows and 6 columns and output is a matrix
with 198 rows and one column. Both matrices are missing values free. This is
what I get from R:

Error in kmeans(inp[, i], neurons) : 
  more cluster centers than distinct data points.

I don't understand this. Moreover, I can actually train a rbf network with 2
neurons but not with 3 neurons. I'm sure I have far more than 3 distinct
data point both in input and in output so I don't get the meaning.

Can you please help me? Thank you so much everybody.

Invernomuto
-- 
View this message in context: 
http://www.nabble.com/help-needed-with-rbftrain-tp17161948p17161948.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] For Social Network Analysis-Graph Analysis - How to convert 2 mode data to 1 mode data?

2008-05-10 Thread Gabor Csardi
Solomon, if i understand two-mode networks properly (they're bipartite, right?),
then this is not hard to do with igraph. Basically, for each vertex create an 
order=2 neighborhood, and then create a graph from the adjacency list,
it is something like this:

two.to.one - function(g, keep) {
  neis - neighborhood(g, order=2)
  neis - lapply(seq(neis), function(x) neis[[x]][ neis[[x]] != x-1]) ## drop 
self-loops
  neis - lapply(neis, function(x) x[ x %in% keep ])  ## keep 
only these
  neis - lapply(seq(neis), function(x) t(cbind(x-1, neis[[x]]))) ## create 
edge lists
  neis[-keep-1] - NULL   ## these 
are not needed
  neis - matrix(unlist(neis), byrow=TRUE, nc=2)  ## a 
single edge list
  neis - neis[ neis[,1]  neis[,2], ]## count 
an edge once only
  mode(neis) - character
  g2 - graph.edgelist(neis, dir=FALSE)
  V(g2)$id - V(g2)$name  ## 'id' 
is used in Pajek
  g2
}

It does not check that the graph is indeed two-mode, and it keeps the 
vertices given in the 'keep' argument. 'keep' is made of igraph vertex ids.
You can use it like this:

g - graph.ring(10)
keep - seq(0,8,by=2) ## we keep the 'even' vertices

g2 - two.to.one(g, keep)
write.graph(two.to.one(g, keep), format=pajek, file=/tmp/a.net)

I haven't tested it much. We'll have a better function in the next igraph 
version.
Gabor

On Fri, May 09, 2008 at 03:37:05PM -0400, Messing, Solomon O. wrote:
 Hi,
 
  
 
 Does anyone know of a package in R that has a function to convert
 network data (e.g. an adjacency matrix or ) from 2-mode to 1-mode?  I am
 conducting social network analysis.  I know that Pajek has this function
 under Net -- Transform -- 2-mode to 1-mode -- Rows.  I have searched
 the documentation under packages 'sna', 'network', 'igraph', and
 'dynamicgraph' but I was not able to identify a comparable function.  
 
  
 
 I would just export my data to Pajek and import it to R, but I'm going
 to have to generate hundreds of these graphs, so it would take quite a
 bit of time to do it this way.  
 
  
 
 Thanks,
 
  
 
 Solomon
 
  
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor [EMAIL PROTECTED]UNIL DGM

__
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] Simple regex problem

2008-05-10 Thread Ted Harding
On 10-May-08 16:49:20, John Kane wrote:
 I am cleaning up some character data to convert to
 dates using chron. The regex that I am using work fine
 but there should be a better way to do this. Can
 anyone suggest a cleaner bit of code than the gsub,
 sub approach? Thanks
 
#Test Run on dates.
 xx - c(May  1, 2007,
 May  2, 2007,
 May  3, 2007,
 May  4, 2007,
 May  5, 2007,
 May  6, 2007,
 May  7, 2007,
 May  8, 2007,
 May  9, 2007,
 May 10, 2007,
 May 11, 2007,
 May 12, 2007)
 yy - gsub( +, /, xx) ; yy
 zz - sub(,, , yy) ; zz

You can do it in one stroke with
gsub(,*[ ]+, /, xx)
 [1] May/1/2007  May/2/2007  May/3/2007  May/4/2007
 [5] May/5/2007  May/6/2007  May/7/2007  May/8/2007 
 [9] May/9/2007  May/10/2007 May/11/2007 May/12/2007

 library(chron)
 ttdates - chron(zz, format = c(dates = mon/d/y))

Best wishes,
Ted


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 10-May-08   Time: 18:14:33
-- XFMail --

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


Re: [R] Simple regex problem

2008-05-10 Thread Gabor Grothendieck
Try this (no gsub required):

as.chron(as.Date(xx, %b %d, %Y))

On Sat, May 10, 2008 at 12:49 PM, John Kane [EMAIL PROTECTED] wrote:
 I am cleaning up some character data to convert to
 dates using chron. The regex that I am using work fine
 but there should be a better way to do this. Can
 anyone suggest a cleaner bit of code than the gsub,
 sub approach? Thanks

 #Test Run on dates.
 xx - c(May  1, 2007,
 May  2, 2007,
 May  3, 2007,
 May  4, 2007,
 May  5, 2007,
 May  6, 2007,
 May  7, 2007,
 May  8, 2007,
 May  9, 2007,
 May 10, 2007,
 May 11, 2007,
 May 12, 2007)
 yy - gsub( +, /, xx) ; yy
 zz - sub(,, , yy) ; zz
 library(chron)
 ttdates - chron(zz, format = c(dates = mon/d/y))

 __
 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] Error while making R package

2008-05-10 Thread Gabor Grothendieck
There isn't enough information there to really know but I would at least
try this:

- upgrade to R 2.7
- make sure you are using the most recent version of rtools from
Duncan Murdoch's site
- remove the data directory in your package since its the last thing
referred to prior to the
errors
- if that still has a problem remove any vignettes too
- if you still have a problem remove all non-R code

On Thu, May 1, 2008 at 4:20 PM, Vidhu Choudhary
[EMAIL PROTECTED] wrote:
 Hi All,
 I am trying to make R package using R 2.6.2
 And I am getting following error.

 When I give R CMD check t1\

 -- Making package t1 
  adding build stamp to DESCRIPTION
  making DLL ...
 making CGHseg_rewrite.d from CGHseg_rewrite.c
 making rowMedians.d from rowMedians.c
 making runavg.d from runavg.c
 gcc-sjlj  -std=gnu99  -Ic:/R/R-2.6.2/include -O3 -Wall  -c
 CGHseg_rewrite.c -o CGHseg_rewrite.o
 gcc-sjlj  -std=gnu99  -Ic:/R/R-2.6.2/include -O3 -Wall  -c rowMedians.c
 -o rowMedians.o
 gcc-sjlj  -std=gnu99  -Ic:/R/R-2.6.2/include -O3 -Wall  -c runavg.c -o
 runavg.o
 windres --preprocessor=gcc-sjlj -E -xc -DRC_INVOKED -I
 c:/R/R-2.6.2/include  -i t1_res.rc -o t1_res.o
 gcc-sjlj  -std=gnu99  -shared -s  -o t1.dll t1.def CGHseg_rewrite.o
 rowMedians.o runavg.o t1_res.o  -Lc:/R/R-2.6.2/bin-lR
  ... DLL made
  installing DLL
  installing R files
  installing data files
 rm: failed to get attributes of `/': No such file or directory
 make[2]: *** [C:/Vidhu/CGH/RPackage/t1.Rcheck/t1/data] Error 1
 make[1]: *** [all] Error 2
 make: *** [pkg-t1] Error 2
 *** Installation of t1 failed ***


 Can you please suggest what could be the probable cause of the error

 Thank you
 Vidhu

__
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] Random number generation

2008-05-10 Thread Dennis Fisher
Colleagues,

I have encountered behavior of random number generation that eludes me.

I generate a random integer in a particular range using the following  
code:
sample(1000:, size=1)

This code exists within a script that starts with the command:
remove(list=ls())

Each time that I run the script, it yields the same random number:   
6420.

I thought that the problem might result from deleting the random  
seed.  However, list=ls() does not include .RandomSeed.

To my surprise, I can't replicate the problem with a 2-line script:
remove(list-ls())
sample(1000:, size=1)

Also, the same problem occurs if I use runif instead of sample.

Thoughts?

Dennis

Dennis Fisher MD
P  (The P Less Than Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-415-564-2220
www.PLessThan.com


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

2008-05-10 Thread Branimir Hackenberger
After some investigation I found out that constrained ordination is working
fine under R version 6.5.0 and 6.5.1 but not under any of newer versions. Is
it posible to repair/make something in for example newest version of R 7.0
lito enble correct using of constrained ordination under BiodiversityRGUI
environment?

 

 


[[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] substitute in graphics - Uwe's help desk

2008-05-10 Thread Gustave Lefou
Thank to both of you.

I found an interesting document by Uwe Ligges in Rnews December 2002 (Vol
2/3)

The following seems encouraging

x=seq(1,180,by=1)
beta=10
eta=5
plot(x,log(x),type=p,xlab=x,ylab=h(x),main=substitute(Failure rate 
* eta==myeta * , * beta   ,list(myeta=eta,mybeta=beta)) )

but then it fails :

x=seq(1,180,by=1)
beta=10
eta=5
plot(x,log(x),type=p,xlab=x,ylab=h(x),main=substitute(Failure rate
from W( * eta==myeta * , * beta==mybeta , )
,list(myeta=eta,mybeta=beta)) )

Any idea ?

Thank you very much

2008/5/9 Henrique Dallazuanna [EMAIL PROTECTED]:

 Try this:

 plot(x, log(x),
  xlab = x, ylab = h(x),
  main = bquote(Failure~rate~from~W(eta == .(eta), beta == .(beta)))


 On Fri, May 9, 2008 at 11:31 AM, Gustave Lefou [EMAIL PROTECTED]
 wrote:

 Hello,

 I have to do a few graphics of the same function and this function is
 parametrized by two arguments.

 What I would like is to be able to change the value of these two arguments
 without changing the plot command. So as to copy paste.

 I tried the following :

 x=1:100
 eta=10
 beta=5
 plot(x,h(x),xlab=x,ylab=h(x),main=substitute( expression(
 paste(Failure
 rate from,W(eta==myeta,beta==mybeta) ) ) ,list(myeta=eta,mybeta=beta) )
 )

 But it doesn't work. It's written expression ( Failure rate from
 W(eta=10,)
 ... on the plot with eta as a greek letter.

 Thank you very much !

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




 --
 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] Error while making R package

2008-05-10 Thread Duncan Murdoch

On 10/05/2008 4:54 PM, Duncan Murdoch wrote:

On 09/05/2008 11:58 AM, Vidhu Choudhary wrote:



rm: failed to get attributes of `/': No such file or directory


I believe that's a sign of using a bad toolset.  Make sure if you have 
Cygwin installed, it comes *after* the Rtools on your path.  It contains 
some incompatible tools.


No, sorry, I forgot:  that's caused by a Cygwin uninstall bug.  See this 
message:


http://finzi.psych.upenn.edu/R/R-devel/archive/27028.html

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

2008-05-10 Thread Gavin Simpson
Branimir,

You would be better off addressing these issues with the package
maintainer. See the details for the package on CRAN for example to find
out the email address of the maintainer.

You could always use vegan the old-fashioned way and type the relevant
commands at the prompt. If your species data are in 'spp' and the
constraints in env, then it can be little more than

require(vegan)
mod - cca(spp ~ ., data = env) ## for CCA or
mod2 - rda(spp ~ ., data = env) ## for RDA

Then see the helpfiles to see how to fit a model with a minimal set of
constraints.

G

On Sat, 2008-05-10 at 20:09 +0200, Branimir Hackenberger wrote:
 After some investigation I found out that constrained ordination is working
 fine under R version 6.5.0 and 6.5.1 but not under any of newer versions. Is
 it posible to repair/make something in for example newest version of R 7.0
 lito enble correct using of constrained ordination under BiodiversityRGUI
 environment?
 
  
 
 
 
 
   [[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.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%

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


[R] subset rows in two dataframes

2008-05-10 Thread partofy
Dear list:

I have two dataframes, say dat1 and dat2. Each has several variables but
3 of each are common in both, (say v1, v2 and v3). v1 and v2 are
factores while v3 is numeric. Now, I need a subset to extract the rows
in which v1, v2 and v3 are the same in both dataframes.
I tried:

subset(dat1, dat1$v1 %in% dat2$v1  dat1$v2 %in% dat2$v2  dat1$v3 %in%
dat2$v3)

I dont know why, but this is not working as I was expecting. Any
suggestion to improve my code?

Thanks in advance

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


Re: [R] subset rows in two dataframes

2008-05-10 Thread jim holtman
This seems to work for me:

 set.seed(1)
 df1 - data.frame(v1=factor(sample(1:4,20,TRUE)), 
 v2=factor(sample(1:3,20,TRUE)), v3=sample(1:3,20,TRUE))
 df2 - data.frame(v1=factor(sample(1:2,20,TRUE)), 
 v2=factor(sample(1:2,20,TRUE)), v3=sample(1:2,20,TRUE))
 subset(df1, (df1$v1 %in% df2$v1)  (df1$v2 %in% df2$v2)  (df1$v3 %in% 
 df2$v3))
   v1 v2 v3
2   2  1  2
5   1  1  2
11  1  2  2
14  2  1  1


Exactly what problems are you having?  A sample of your actual data
would be useful.

On Sat, May 10, 2008 at 6:31 PM,  [EMAIL PROTECTED] wrote:
 Dear list:

 I have two dataframes, say dat1 and dat2. Each has several variables but
 3 of each are common in both, (say v1, v2 and v3). v1 and v2 are
 factores while v3 is numeric. Now, I need a subset to extract the rows
 in which v1, v2 and v3 are the same in both dataframes.
 I tried:

 subset(dat1, dat1$v1 %in% dat2$v1  dat1$v2 %in% dat2$v2  dat1$v3 %in%
 dat2$v3)

 I dont know why, but this is not working as I was expecting. Any
 suggestion to improve my code?

 Thanks in advance

 Justin
 --

  [EMAIL PROTECTED]

 --

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




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

What is the problem you are trying to solve?

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


Re: [R] subset rows in two dataframes

2008-05-10 Thread partofy
Thanks for your reply.
In fact I dont get none error message, I just simply found that some
rows do not match in both dataframes. I thought it was some evident
problem with my code, but it seems it is not. I'll try to check and if I
can, I'll post a reproducible example.

Justin 



On Sat, 10 May 2008 18:42:51 -0400, jim holtman [EMAIL PROTECTED]
said:
 This seems to work for me:
 
  set.seed(1)
  df1 - data.frame(v1=factor(sample(1:4,20,TRUE)), 
  v2=factor(sample(1:3,20,TRUE)), v3=sample(1:3,20,TRUE))
  df2 - data.frame(v1=factor(sample(1:2,20,TRUE)), 
  v2=factor(sample(1:2,20,TRUE)), v3=sample(1:2,20,TRUE))
  subset(df1, (df1$v1 %in% df2$v1)  (df1$v2 %in% df2$v2)  (df1$v3 %in% 
  df2$v3))
v1 v2 v3
 2   2  1  2
 5   1  1  2
 11  1  2  2
 14  2  1  1
 
 
 Exactly what problems are you having?  A sample of your actual data
 would be useful.
 
 On Sat, May 10, 2008 at 6:31 PM,  [EMAIL PROTECTED] wrote:
  Dear list:
 
  I have two dataframes, say dat1 and dat2. Each has several variables but
  3 of each are common in both, (say v1, v2 and v3). v1 and v2 are
  factores while v3 is numeric. Now, I need a subset to extract the rows
  in which v1, v2 and v3 are the same in both dataframes.
  I tried:
 
  subset(dat1, dat1$v1 %in% dat2$v1  dat1$v2 %in% dat2$v2  dat1$v3 %in%
  dat2$v3)
 
  I dont know why, but this is not working as I was expecting. Any
  suggestion to improve my code?
 
  Thanks in advance
 
  Justin
  --
 
   [EMAIL PROTECTED]
 
  --
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 
 -- 
 Jim Holtman
 Cincinnati, OH
 +1 513 646 9390
 
 What is the problem you are trying to solve?
-- 
  
  [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] predict lmer

2008-05-10 Thread John Maindonald
The following function is designed to work with a logit link.  It can
easily be generalized to work with any link.  The SEs and CIs are
evaluated accounting for all sources of random variation. The plot
may not be much help unless there is just one explanatory variate.

`ciplot` -
  function(obj=glmm2, data=data.site, xcol=2, nam=litter){
cilim - function(obj, xcol){
  b - fixef(obj)
  vcov - summary(obj)@vcov
  X - unique(model.matrix(obj))
  hat - X%*%b
  pval - exp(hat)/(1+exp(hat))   # NB, designed for logit link
  U - chol(as.matrix(summary(obj)@vcov))
  se - sqrt(apply(X%*%t(U), 1, function(x)sum(x^2)))
  list(hat=hat, se=se, x=X[,xcol])
   }
limfo - cilim(obj, xcol)
hat - limfo$hat
se - limfo$se
x - limfo$x
upper - hat+2*se
lower - hat-2*se
ord - order(x)
plot(x, hat, yaxt=n, type=l, xlab=nam, ylab=)
rug(x)
lines(x[ord], lower[ord])
lines(x[ord], upper[ord])
ploc - c(0.01, 0.05, 0.1, 0.2, 0.5, 0.8, 0.9)
axis(2, at=log(ploc/(1-ploc)), labels=paste(ploc), las=2)
}

## Usage
glmm2 - lmer(rcr ~ litter + (1 | Farm), family=binomial,  
data=data.site)
ciplot(obj=glmm2)

John Maindonald email: [EMAIL PROTECTED]
phone : +61 2 (6125)3473fax  : +61 2(6125)5549
Centre for Mathematics  Its Applications, Room 1194,
John Dedman Mathematical Sciences Building (Building 27)
Australian National University, Canberra ACT 0200.


On 8 May 2008, at 8:00 PM, [EMAIL PROTECTED] wrote:
 From: May, Roel [EMAIL PROTECTED]
 Date: 8 May 2008 12:23:15 AM
 To: r-help@r-project.org
 Subject: [R] predict lmer


 Hi,

 I am using lmer to analyze habitat selection in wolverines using the
 following model:

 (me.fit.of -
 lmer(USED~1+STEP+ALT+ALT2+relM+relM:ALT+(1|ID)+(1| 
 ID:TRKPT2),data=vdata,
 control=list(usePQL=TRUE),family=poisson,method=Laplace))

 Here, the habitat selection is calaculated using a so-called discrete
 choice model where each used location has a certain number of
 alternatives which the animal could have chosen. These sets of  
 locations
 are captured using the TRKPT2 random grouping. However, these sets are
 also clustered over the different individuals (ID). USED is my binary
 dependent variable which is 1 for used locations and zero for unused
 locations. The other are my predictors.

 I would like to predict the model fit at different values of the
 predictors, but does anyone know whether it is possible to do this? I
 have looked around at the R-sites and in help but it seems that there
 doesn't exist a predict function for lmer???

 I hope someone can help me with this; point me to the right  
 functions or
 tell me to just forget it

 Thanks in advance!

 Cheers Roel

 Roel May
 Norwegian Institute for Nature Research
 Tungasletta 2, NO-7089 Trondheim, Norway


[[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] Creating data.frames dynamically

2008-05-10 Thread Worik R
I have time series data in named vectors.  They are all the same length for
the same dates.

The dates are in a separate vector.

I want to create a vector of numeric data for every named series, associated
with the dates in a data.frame.

So if...

Names - c(a, b, c)

d - data.frame(dates=Dates, a=vector(mode=numeric, length=length(Dates),
b=vector(mode=numeric, length=length(Dates), c=vector(mode=numeric,
length=length(Dates))

Then I copy the processed data into d

for(i in SomeVectorOfFactors){
for(N in Names){
d[[N]][i] - FunctionCallOfSomeSort(i)
}
}


I want to create the data.frame, d, in the same style I access it.

d - data.frame(dates=Dates, [[Names]]=vectors(.))

Then it is much simpler to add new columns.

Worik ST

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