Re: [R] Learning R

2009-11-29 Thread Meyners, Michael, LAUSANNE, AppliedMathematics
Julia, see 

http://www.r-project.org/ -> Documentation -> Manuals (-> An introduction to R) 
(or use: http://cran.r-project.org/manuals.html)

for a starting point. In addition, you might want to check the annotated list 
of books to see which one might best fit your needs:

http://www.r-project.org/doc/bib/R-books.html

You might also want to browse through the FAQs at some stage, you can learn a 
lot of useful things there. Or look additionally into the Wiki, if that's more 
your style of learning. You see, plenty of options from which you'd need to 
select the one that best meets your requirements. 

HTH, Michael


> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Julia Cains
> Sent: Montag, 30. November 2009 08:23
> To: r-help@r-project.org
> Subject: [R] Learning R
> 
> Dear R helpers,
> 
> Almost 15 days back I have become member of this very active 
> and wonderful group. So far I have been only raising  queries 
> and in turn got them solved too and I really thank for the 
> spirit this group member show when it comes to the guidance.
> 
> I wish to learn R language and I have given 2 months time for 
> this. Can anyone please guide me as how do I begin i.e. from 
> basics to advance.
> 
> R is such a vast thing to learn, so I wish to learn it step 
> by step without getting lost at any stage.
> 
> Please guide me where do I start and upgrade myself to higher 
> level step by step.
> 
> Regards
> 
> Julia
> 
> 
> 
> 
> 
> 
> 
> Only a man of Worth sees Worth in other men
> 
> 
> 
> 
> 
> 
>   
>   [[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] Continuous legend colors

2009-11-29 Thread Tim Clark
Thanks Jim, that is exactly what I was looking for!

Tim


Tim Clark
Department of Zoology 
University of Hawaii


--- On Sun, 11/29/09, Jim Lemon  wrote:

> From: Jim Lemon 
> Subject: Re: [R] Continuous legend colors
> To: "Tim Clark" 
> Cc: r-help@r-project.org
> Date: Sunday, November 29, 2009, 8:13 PM
> On 11/30/2009 03:22 PM, Tim Clark
> wrote:
> > Dear List,
> >
> > I am trying to get a basic plot to show a continuous
> range of fill colors.  It is probably easiest to
> demonstrate.  I would like a legend like in the
> following example:
> >
> >
> Satellite.Palette<-colorRampPalette(c("blue3","cyan","aquamarine","yellow","orange","red"))
> > require(fields)
> > image.plot(volcano, col = Satellite.Palette (500),
> legend.lab="Scale")
> > contour(volcano, levels = seq(90, 200, by = 5), add =
> TRUE)
> >
> >
> > However, I am using the basic plot function.  So
> far I have figured out how to remove any space between the
> colors using the y.intersp call in legend().  Now I
> need to somehow plot the legend so that it 1) fits on the
> plotting region, 2) has fewer labels, and 3) doesn't have
> black lines between each color.  The example I am
> trying to get to work is:
> >
> > Sat.Pal<-Satellite.Palette (101)
> > x<-rnorm(100, mean = 50, sd = 50)
> > y<-rnorm(100, mean = 50, sd = 50)
> > z<-seq(1,100, by=1)
> > plot(x,y,pch=16,col=Sat.Pal[z])
> >
> > legend("topleft",
> > legend=seq(0,100, by=1),
> > fill=Sat.Pal[seq(1,101, by=1)],
> > bty="n",
> > y.intersp=.5)
> >
> >
> > I would appreciate any help or suggestions on how to
> get this to produce a legend with "continuous" colors.
> >
> >    
> Hi Tim,
> Have a look at the "color.legend" function in the plotrix
> package.
> 
> 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] Learning R

2009-11-29 Thread Julia Cains
Dear R helpers,

Almost 15 days back I have become member of this very active and wonderful 
group. So far I have been only raising  queries and in turn got them solved too 
and I really thank for the spirit this group member show when it comes to the 
guidance.

I wish to learn R language and I have given 2 months time for this. Can anyone 
please guide me as how do I begin i.e. from basics to advance.

R is such a vast thing to learn, so I wish to learn it step by step without 
getting lost at any stage.

Please guide me where do I start and upgrade myself to higher level step by 
step.

Regards

Julia







Only a man of Worth sees Worth in other men






  
[[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] Little help needed

2009-11-29 Thread dovii

So, I need some serious help with an R project.  The project essentially
consists of some problems that have to be analyzed to decide the correct
statistical test to use, and then correctly use R to answer them.  The use
of an instant messaging service for this would probably be great.  I am
willing to pay for this help, and paypal would probably be the best option. 
If anyone is willing to help me out email me at dovii...@yahoo.com.  Monday
night would probably be the best option for this as well, so get back to me
soon. 
-- 
View this message in context: 
http://n4.nabble.com/Little-help-needed-tp931076p931076.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] updating subset of data.frame

2009-11-29 Thread Rnewb

i have a data frame and a numeric vector indexed as a subset of the rows in
the data.frame.  what command can i use to assign the values in the vector
to the appropriate rows of the data.frame?  here's my failed attempt.  what
i would want is data[1,'z'] == 2, data[5,'z'] == -4, data[8,'z'] == -5,
data[9,'z'] == 5, and for the other values of 'z' to remain 0.

> data
 x   y z
1   -6   4 0
2   -3  19 0
3   15  40 0
40  17 0
51  12 0
6   17  45 0
74  19 0
8  -13 -16 0
9   -7   5 0
10  -5  22 0
> vec
 1  5  8  9 
 2 -4 -5  5 
> data['z']=vec
Error in `[<-.data.frame`(`*tmp*`, "z", value = c(2, -4, -5, 5)) : 
  replacement has 4 rows, data has 10
> 

thanks,
Rnewb
-- 
View this message in context: 
http://n4.nabble.com/updating-subset-of-data-frame-tp931035p931035.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] how to put ggobi display into a GUI window setup by gWidgets

2009-11-29 Thread jerry83

Hi John,

Thanks A LOT for your reply and the code. What I want to do is to include the 
ggobi display window to the widget window setup by me. I tried add before but 
it said can not do it for GGobiScatterplotDisplay. Do you have any idea about 
add displays?

Thanks again for your help.
 





From: jverzaniNWBKZ [via R] 

Sent: Sun, November 29, 2009 5:19:43 PM
Subject: Re: [R] how to put ggobi display into a GUI window setup by gWidgets

jerry83  yahoo.com> writes: 


> 
> 
> Hi, 
> 
> I want to put a ggobi display into a GUI window setup by gWidgets, but error 
> occur said it is not a S4 object. 
> 
> Does anyone have any idea about how to put it in or maybe it can not be put 
> into a widget at all? 
> 
> Thanks A LOT! 


To embed a GTK widget into gWidgets isn't too hard, just call the add method. 
I'm not sure how  to get the GTK object you want from the ggobi 
interface. Below is an example that you might be able to modify: 

## 
library(RGtk2) 
library(rggobi) 
library(gWidgets) 
options(guiToolkit="RGtk2") 

## ggoobi object 
x <- ggobi(mtcars) 

## grab child from main window. Modify (how?) to get 
## other widgets 
toplevel <- ggobi_gtk_main_window(x) 
child <- toplevel[[1]]  # toplevel has only one child 
toplevel$remove(child)  # remove child if keeping toplevel 
toplevel$destroy()      # or destroy if not 

## add to a gWidget instance using gWidgetsRGtk2: 
w <- gwindow("A gwidget's window") 
g <- ggroup(cont = w, expand=TRUE) 
add(g, child, expand=TRUE) 

--John 

__ 
[hidden email] mailing list 
https://stat.ethz.ch/mailman/listinfo/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 message @ 
http://n4.nabble.com/how-to-put-ggobi-display-into-a-GUI-window-setup-by-gWidgets-tp930529p930927.html
 
To unsubscribe from how to put ggobi display into a GUI window setup by 
gWidgets, click here. 




-- 
View this message in context: 
http://n4.nabble.com/how-to-put-ggobi-display-into-a-GUI-window-setup-by-gWidgets-tp930529p931023.html
Sent from the R help mailing list archive at Nabble.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.


Re: [R] Assign palette (e.g. rainbow) to a series of points on 1 plot

2009-11-29 Thread Frostygoat
Thanks for the suggestion David. With mapply the lines are correctly
plotted but they are all red, the points are colored, but along the x
axis, not along the individual lines.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lm: eval(parse(text=)) works on one side y/x but not on both?

2009-11-29 Thread Matthieu Stigler
Yes, was wondering that other code line did not change so much :-)

Thanks a lot!

2009/11/30 Gabor Grothendieck :
>
>
> On Sun, Nov 29, 2009 at 9:16 AM, Gabor Grothendieck
>  wrote:
>>
>> By the way, if you really do want to create the formula anyways then:
>>
>>    ix <- 1:2
>>    left <- paste(names(freeny)[ix], collapse = ",")
>>    fo <- as.formula(paste("cbind(", left, ") ~ ."))
>>    lm(fo, freeny)
>>
>> or possibly replace last line with:
>>
>>    eval(substitute(lm(fo, freeny))
>>
>> which will cause the formula to appear in the lm output.
>
> This last line should have been:
>
> This last line should have been:
>
>  eval(substitute(lm(fo, freeny), list(fo = fo)))
>
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Continuous legend colors

2009-11-29 Thread Jim Lemon

On 11/30/2009 03:22 PM, Tim Clark wrote:

Dear List,

I am trying to get a basic plot to show a continuous range of fill colors.  It 
is probably easiest to demonstrate.  I would like a legend like in the 
following example:

Satellite.Palette<-colorRampPalette(c("blue3","cyan","aquamarine","yellow","orange","red"))
require(fields)
image.plot(volcano, col = Satellite.Palette (500), legend.lab="Scale")
contour(volcano, levels = seq(90, 200, by = 5), add = TRUE)


However, I am using the basic plot function.  So far I have figured out how to 
remove any space between the colors using the y.intersp call in legend().  Now 
I need to somehow plot the legend so that it 1) fits on the plotting region, 2) 
has fewer labels, and 3) doesn't have black lines between each color.  The 
example I am trying to get to work is:

Sat.Pal<-Satellite.Palette (101)
x<-rnorm(100, mean = 50, sd = 50)
y<-rnorm(100, mean = 50, sd = 50)
z<-seq(1,100, by=1)
plot(x,y,pch=16,col=Sat.Pal[z])

legend("topleft",
legend=seq(0,100, by=1),
fill=Sat.Pal[seq(1,101, by=1)],
bty="n",
y.intersp=.5)


I would appreciate any help or suggestions on how to get this to produce a legend with 
"continuous" colors.

   

Hi Tim,
Have a look at the "color.legend" function in the plotrix package.

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.


Re: [R] sequence of commands in R

2009-11-29 Thread Jim Lemon

On 11/30/2009 07:17 AM, Manuel Jesús López Rodríguez wrote:

Dear all,
I would like to know how could I execute a sequence or orders with just a 
function, i.e, that just typing the function name, R gives me all the 
parameters I want (for instance, if I want to see the summary, the standard 
deviation, the number of valid cases, etc of a dataframe just with one 
function). I have tried with the following, but just compute the second 
argument of the body, i.e., the summary:

resumen<-function(x) {
apply(x,2,sd,na.rm=TRUE)
summary(x)
}

   

Hi Manuel,
This looks very much like one of the "alternative summary" functions. 
Three, all named "describe", can be found in the Hmisc, psych and 
prettyR packages.


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.


Re: [R] Kohonen Package

2009-11-29 Thread Peter Ehlers

This turns out to be easy. What you need are the
locations where to put the labels and those are given in
the som object. Using your code:

mysom <- som(wines.sc, grid=somgrid(5, 5, "hexagonal"))
plot(mysom, type="dist.neighbours" )

# check what's contained in mysom:
str(mysom)

# we need the $grid$pts matrix of (x,y)-locations:
text(mysom$grid$pts, labels=letters)

# Your labels are too long to fit easily,
# so abbreviate:
mylabels <- abbreviate(colnames(wines), minlength=3)
plot(mysom, type="dist.neighbours" )
text(mysom$grid$pts, labels=mylabels)

 -Peter Ehlers

Brock Tibert wrote:
Many thanks, Peter, Gavin.  That is exactly what it was...and old version.  I was running R 2.7 (needed it to integrate with SPSS 17). 

I know I am a pain, but one last question.  Is it possible to overlay a value label onto the maps?  In some of the SOMs we have worked through in class, we saw examples that overlay the observation's label onto the map so we could see where each observation fell.  


Again, many, many, many thanks.  In just working through this one example, I 
have learned a ton about R.

- Brock



--- On Sun, 11/29/09, Gavin Simpson  wrote:


From: Gavin Simpson 
Subject: Re: [R] Kohonen Package
To: "Peter Ehlers" 
Cc: "Brock Tibert" , r-help@r-project.org
Date: Sunday, November 29, 2009, 6:21 AM
On Sat, 2009-11-28 at 17:16 -0700,
Peter Ehlers wrote:

I haven't used pkg:kohonen, so this is just guessing:

1. are you using an old version of the package?

I deleted the original email, so I'll reply here instead.
The example
provided by the OP works for me with on R 2.10-patched
and:


packageDescription("kohonen")$Version

[1] "2.0.5"

Looking at the CHANGES file in the package,
"dist.neighbours" was added
in version 2.0.5, so I suspect the OP was using an older
version, but
reading a newer version of the help as a PDF.


2. don't call the output of function som() 'som'. As
people around here might say: would you call your
iguana 'iguana'?

Indeed:

##install.packages("fortunes") ## uncomment if not
installed
require("fortunes")
fortune("dog")

HTH

G


3. have you used str() on your object to check what
it really contains? I would guess that it should be
of class som and have a component 'distances'.

If none of that helps then it's beyond me.

   -Peter Ehlers


Brock Tibert wrote:

Hi All,

I am still learning R, but making, IMO, great

strides.  I learned about Kohonen/Self-Organizing Maps
in class and I would like to try to replicate some of the
things we have seen in class.

Below is my code.  I am trying to create a

u-matrix.  In the documentation on page 9 it appears
the type of plot, dist.neighbours should do the trick,
however, I am getting an error:

(Error in match.arg(type) : 'arg' should be one

of "codes", "changes", "counts", "mapping", "property",
"quality")

Since I am new to R, I figure I am missing

something obvious.  Any help you can provide will be
greatly appreciated!

Thanks in advance,

Brock

library(kohonen)

data("wines")
wines.sc <- scale(wines)

som <- som(wines.sc, grid=somgrid(5, 5,

"hexagonal"))

plot(som)
plot(som, type="dist.neighbours" )

__
R-help@r-project.org

mailing list

https://stat.ethz.ch/mailman/listinfo/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.
--
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 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] updating subset of data.frame

2009-11-29 Thread Jorge Ivan Velez
Hi Rnewb,

Take a look at ?"%in%" .

HTH,
Jorge


On Sun, Nov 29, 2009 at 11:06 PM, Rnewb <> wrote:

>
> i have a data frame and a numeric vector indexed as a subset of the rows in
> the data.frame.  what command can i use to assign the values in the vector
> to the appropriate rows of the data.frame?  here's my failed attempt.  what
> i would want is data[1,'z'] == 2, data[5,'z'] == -4, data[8,'z'] == -5,
> data[9,'z'] == 5, and for the other values of 'z' to remain 0.
>
> > data
> x   y z
> 1   -6   4 0
> 2   -3  19 0
> 3   15  40 0
> 40  17 0
> 51  12 0
> 6   17  45 0
> 74  19 0
> 8  -13 -16 0
> 9   -7   5 0
> 10  -5  22 0
> > vec
>  1  5  8  9
>  2 -4 -5  5
> > data['z']=vec
> Error in `[<-.data.frame`(`*tmp*`, "z", value = c(2, -4, -5, 5)) :
>  replacement has 4 rows, data has 10
> >
>
> thanks,
> Rnewb
> --
> View this message in context:
> http://n4.nabble.com/updating-subset-of-data-frame-tp931051p931051.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] Question about output from optim

2009-11-29 Thread Ben Bolker
Sébastien Bihorel  free.fr> writes:

> 
> Dear R-users,
> 
> I am trying to port to R something that I wrote in Matlab to perform model
> parameter optimization using the Nelder-Mead simplex method (fminsearch). I
> read the help on ?optim (which seems to be the way to go) as well as a bunch
> of posts on the topic, but I would like to make sure about something before
> I spend to much time trying to reproduce something that is not possible. The
> Matlab fminsearch has some nice features allowing the user to pass the
> optimization status (i.e., iteration number, objective function value,
> parameter estimate, algorithm porcedure,etc...) at each iteration to a
> custom function. In turn, this allows to save the data to file or print
> something to the shell.
> 
> Did anybody manage to get optim similarly output the optimization status at
> each iteration to a function?
> 
> The control=(trace=...) argument seems only to return partial data to the
> shell. Some post on the list also suggested to include some code inside the
> objective function, but this implies the execution of the code at each
> function evaluation rather than at each iteration.
> 
> Any feedback on the topic would be appreciated.
> 
> Sebastien
> 


  I think that what you see is more or less what you get with optim()
in this case. As I've mentioned in an earlier thread, I've translated
Nelder-Mead from _Numerical Recipes_ code into R, which would allow
you to instrument it however you wanted.  (Indeed, I translated it in
order to allow me to create a picture of N-M updating that showed
which points were being visited and which updating rules executed.)
I could send it if you wanted.  The output-function hook is a nice
idea, though -- might be worth mentioning to John Nash, who is working
on a project (optimx on R-forge) to extend R's optimization capabilities.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Iteration idioms & laziness

2009-11-29 Thread David Duffy

Duncan Murdoch murdoch at stats.uwo.ca wrote:


> On 27/11/2009 3:36 PM, Alexander Søndergaard wrote:
> I'm new to R. Having a functional background, I was wondering what's
> the idiomatic way to iterate. It seems that for loops are the default
> given there's no tail-call optimization.
>
> I'm curious to know whether there is a way to transform the following
> toy snippet into something that doesn't eat up gigabytes of memory
> (like it's for loop counterpart) using laziness:
>
> Reduce('+', seq(1,1e6))

I believe the iterators and foreach packages give ways to iterate
without creating the whole array, so they might do what you want.


The OP may also be interested in the jit package, which currently 
just covers (see http://www.milbo.users.sonic.net/ra) loops, but 
might eventually extend to TCO.


David Duffy.

--
| David Duffy (MBBS PhD) ,-_|\
| email: dav...@qimr.edu.au  ph: INT+61+7+3362-0217 fax: -0101  / *
| Epidemiology Unit, Queensland Institute of Medical Research   \_,-._/
| 300 Herston Rd, Brisbane, Queensland 4029, Australia  GPG 4D0B994A v__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Continuous legend colors

2009-11-29 Thread Tim Clark
Dear List,

I am trying to get a basic plot to show a continuous range of fill colors.  It 
is probably easiest to demonstrate.  I would like a legend like in the 
following example:

Satellite.Palette 
<-colorRampPalette(c("blue3","cyan","aquamarine","yellow","orange","red"))
require(fields)
image.plot(volcano, col = Satellite.Palette (500), legend.lab="Scale")
contour(volcano, levels = seq(90, 200, by = 5), add = TRUE)


However, I am using the basic plot function.  So far I have figured out how to 
remove any space between the colors using the y.intersp call in legend().  Now 
I need to somehow plot the legend so that it 1) fits on the plotting region, 2) 
has fewer labels, and 3) doesn't have black lines between each color.  The 
example I am trying to get to work is:

Sat.Pal<-Satellite.Palette (101)
x<-rnorm(100, mean = 50, sd = 50)
y<-rnorm(100, mean = 50, sd = 50)
z<-seq(1,100, by=1)
plot(x,y,pch=16,col=Sat.Pal[z])

legend("topleft",
legend=seq(0,100, by=1),
fill=Sat.Pal[seq(1,101, by=1)],
bty="n",
y.intersp=.5)


I would appreciate any help or suggestions on how to get this to produce a 
legend with "continuous" colors.

Thanks,

Tim





Tim Clark
Department of Zoology 
University of Hawaii

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


[R] updating subset of data.frame

2009-11-29 Thread Rnewb

i have a data frame and a numeric vector indexed as a subset of the rows in
the data.frame.  what command can i use to assign the values in the vector
to the appropriate rows of the data.frame?  here's my failed attempt.  what
i would want is data[1,'z'] == 2, data[5,'z'] == -4, data[8,'z'] == -5,
data[9,'z'] == 5, and for the other values of 'z' to remain 0. 

> data 
 x   y z 
1   -6   4 0 
2   -3  19 0 
3   15  40 0 
40  17 0 
51  12 0 
6   17  45 0 
74  19 0 
8  -13 -16 0 
9   -7   5 0 
10  -5  22 0 
> vec 
 1  5  8  9 
 2 -4 -5  5 
> data['z']=vec 
Error in `[<-.data.frame`(`*tmp*`, "z", value = c(2, -4, -5, 5)) : 
  replacement has 4 rows, data has 10 
> 

thanks, 
Rnewb
-- 
View this message in context: 
http://n4.nabble.com/updating-subset-of-data-frame-tp931051p931051.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] Question about output from optim

2009-11-29 Thread Sébastien Bihorel
Dear R-users,

I am trying to port to R something that I wrote in Matlab to perform model
parameter optimization using the Nelder-Mead simplex method (fminsearch). I
read the help on ?optim (which seems to be the way to go) as well as a bunch
of posts on the topic, but I would like to make sure about something before
I spend to much time trying to reproduce something that is not possible. The
Matlab fminsearch has some nice features allowing the user to pass the
optimization status (i.e., iteration number, objective function value,
parameter estimate, algorithm porcedure,etc...) at each iteration to a
custom function. In turn, this allows to save the data to file or print
something to the shell.

Did anybody manage to get optim similarly output the optimization status at
each iteration to a function?

The control=(trace=...) argument seems only to return partial data to the
shell. Some post on the list also suggested to include some code inside the
objective function, but this implies the execution of the code at each
function evaluation rather than at each iteration.

Any feedback on the topic would be appreciated.

Sebastien

[[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] Assign palette (e.g. rainbow) to a series of points on 1 plot

2009-11-29 Thread David Winsemius


On Nov 29, 2009, at 9:30 PM, Frostygoat wrote:


I have 11 vectors representing insect survival probabilities in
response to different levels of toxins at 10 concentrations

lx100=c(1,1,1,.8,.5,.4,.2,0)
day100=c(0,1,2,3,4,5,6,7,8)

lx90=c(1,1,1,1,.9,.8,.6,.4,.2,.1,0)
day90=c(0,1,2,3,4,5,6,7,8,9,10)

#...and so on10% and a zero (control) series

lx0=c(1,1,1,1,1,1,.9,.9,.8,.8,.6,.5,.4,.3,.2,.1,.1,0)
day0=c(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17)

I want to plot them on one plot with a palette color scheme such as
rainbow or topo.colors, and I want one color per concentration on both
the point and line.  I have found a number of ways to plot them:

1. Plot a blank frame big enough to accommodate the control data and
then add the x,y coords using points.

plot(x=day0,y=lx0, type="n", xlab="Day of adult
life",ylab=lx,lwd=2.2,ylim=c(0.0,1),col=cols)
points(x=day100,y=lx100,type="b",col="#FF8B00")
points(x=day90,y=lx90,type="b",col= "#E8FF00")
...

This is harder than it should be, I tracked down the color names
generated with rainbow(11) and individually name each points command.

2.  Bind the respective x and y coords into 2 respective matrices and
plot.

lxs=matrix(c(lx100,lx90,lx80,lx70,lx60...))
days=matrix(c(day100,day90,day80,day70,day60...))

plot(x=days,y=lxs, col=rainbow(11), type="b")


You have vectors of unequal length which may cause some problems. Have  
you thought of using plot with xlim and ylim and just one series and  
then following that with something like:


> mapply(lines, days, lxs, MoreArgs=list(col=rainbow(3), type="b"))

It seemed to give somewhat sensible results using the series tha tyou  
offered even without the pre-determined x limits.




The points rainbow (not as series) and the lines are red.

I tried various methods of binding data and plotting data frames
without success.




I would appreciate it if someone would kindly put me on the trail.
Thank you for your time.


--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Assign palette (e.g. rainbow) to a series of points on 1 plot

2009-11-29 Thread Frostygoat
I have 11 vectors representing insect survival probabilities in
response to different levels of toxins at 10 concentrations

lx100=c(1,1,1,.8,.5,.4,.2,0)
day100=c(0,1,2,3,4,5,6,7,8)

lx90=c(1,1,1,1,.9,.8,.6,.4,.2,.1,0)
day90=c(0,1,2,3,4,5,6,7,8,9,10)

#...and so on10% and a zero (control) series

lx0=c(1,1,1,1,1,1,.9,.9,.8,.8,.6,.5,.4,.3,.2,.1,.1,0)
day0=c(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17)

I want to plot them on one plot with a palette color scheme such as
rainbow or topo.colors, and I want one color per concentration on both
the point and line.  I have found a number of ways to plot them:

1. Plot a blank frame big enough to accommodate the control data and
then add the x,y coords using points.

plot(x=day0,y=lx0, type="n", xlab="Day of adult
life",ylab=lx,lwd=2.2,ylim=c(0.0,1),col=cols)
points(x=day100,y=lx100,type="b",col="#FF8B00")
points(x=day90,y=lx90,type="b",col= "#E8FF00")
...

This is harder than it should be, I tracked down the color names
generated with rainbow(11) and individually name each points command.

2.  Bind the respective x and y coords into 2 respective matrices and
plot.

lxs=matrix(c(lx100,lx90,lx80,lx70,lx60...))
days=matrix(c(day100,day90,day80,day70,day60...))

plot(x=days,y=lxs, col=rainbow(11), type="b")

The points rainbow (not as series) and the lines are red.

I tried various methods of binding data and plotting data frames
without success.

I would appreciate it if someone would kindly put me on the trail.
Thank you for your time.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Kohonen Package

2009-11-29 Thread Brock Tibert
Many thanks, Peter, Gavin.  That is exactly what it was...and old version.  I 
was running R 2.7 (needed it to integrate with SPSS 17). 

I know I am a pain, but one last question.  Is it possible to overlay a value 
label onto the maps?  In some of the SOMs we have worked through in class, we 
saw examples that overlay the observation's label onto the map so we could see 
where each observation fell.  

Again, many, many, many thanks.  In just working through this one example, I 
have learned a ton about R.

- Brock



--- On Sun, 11/29/09, Gavin Simpson  wrote:

> From: Gavin Simpson 
> Subject: Re: [R] Kohonen Package
> To: "Peter Ehlers" 
> Cc: "Brock Tibert" , r-help@r-project.org
> Date: Sunday, November 29, 2009, 6:21 AM
> On Sat, 2009-11-28 at 17:16 -0700,
> Peter Ehlers wrote:
> > I haven't used pkg:kohonen, so this is just guessing:
> > 
> > 1. are you using an old version of the package?
> 
> I deleted the original email, so I'll reply here instead.
> The example
> provided by the OP works for me with on R 2.10-patched
> and:
> 
> > packageDescription("kohonen")$Version
> [1] "2.0.5"
> 
> Looking at the CHANGES file in the package,
> "dist.neighbours" was added
> in version 2.0.5, so I suspect the OP was using an older
> version, but
> reading a newer version of the help as a PDF.
> 
> > 
> > 2. don't call the output of function som() 'som'. As
> > people around here might say: would you call your
> > iguana 'iguana'?
> 
> Indeed:
> 
> ##install.packages("fortunes") ## uncomment if not
> installed
> require("fortunes")
> fortune("dog")
> 
> HTH
> 
> G
> 
> > 
> > 3. have you used str() on your object to check what
> > it really contains? I would guess that it should be
> > of class som and have a component 'distances'.
> > 
> > If none of that helps then it's beyond me.
> > 
> >   -Peter Ehlers
> > 
> > 
> > Brock Tibert wrote:
> > > Hi All,
> > > 
> > > I am still learning R, but making, IMO, great
> strides.  I learned about Kohonen/Self-Organizing Maps
> in class and I would like to try to replicate some of the
> things we have seen in class.
> > > 
> > > Below is my code.  I am trying to create a
> u-matrix.  In the documentation on page 9 it appears
> the type of plot, dist.neighbours should do the trick,
> however, I am getting an error:
> > > (Error in match.arg(type) : 'arg' should be one
> of "codes", "changes", "counts", "mapping", "property",
> "quality")
> > > 
> > > Since I am new to R, I figure I am missing
> something obvious.  Any help you can provide will be
> greatly appreciated!
> > > 
> > > Thanks in advance,
> > > 
> > > Brock
> > > 
> > > library(kohonen)
> > > 
> > > data("wines")
> > > wines.sc <- scale(wines)
> > > 
> > > som <- som(wines.sc, grid=somgrid(5, 5,
> "hexagonal"))
> > > plot(som)
> > > plot(som, type="dist.neighbours" )
> > > 
> > > __
> > > R-help@r-project.org
> mailing list
> > > https://stat.ethz.ch/mailman/listinfo/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.
> -- 
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
>  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] How do I run to or more R consoles on Mac OS X?

2009-11-29 Thread Sharpie


chronos.phenomena wrote:
> 
> This is really annoying me... when I click R application icon it brings
> already opened session in the focus and it DOESN'T open new session
> 
> any ideas?
> 

I don't think this is possible with R.app on OS X.  OS X applications do not
spawn separate processes if they are re-launched-- they pass focus to the
one that is already running.

However, you can access R from the OS X terminal and run as many different
sessions as you want.

Hope this helps!

-Charlie
-- 
View this message in context: 
http://n4.nabble.com/How-do-I-run-to-or-more-R-consoles-on-Mac-OS-X-tp930979p930991.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] How do I run to or more R consoles on Mac OS X?

2009-11-29 Thread chronos.phenomena

This is really annoying me... when I click R application icon it brings
already opened session in the focus and it DOESN'T open new session

any ideas?
-- 
View this message in context: 
http://n4.nabble.com/How-do-I-run-to-or-more-R-consoles-on-Mac-OS-X-tp930979p930979.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] kernlab's ksvm method freeze

2009-11-29 Thread Heiko Strathmann
I tried out the code you wrote, it also works for me, but it lacks a
parameter i use in my code.

The problem (at this computer) seems to be this "cross"-parameter of
ksvm - if I, for example, add the parameter cross=10, i get the old
problem:

library("kernlab")
load("freeze_workspace.RDATA")
replicate(10, ksvm(kernel="matrix", kernelMatrix, trainingDataYs, type="C-svc", 
C=2, cross=10))

gets me a frozen R process, CTRL-C does not work anymore, and the only thing 
left is to kill it.

(for cross < 4, the thing still works)

(I also just reinstalled my Ubuntu and R)

Heiko Strathmann


Am Sonntag, den 29.11.2009, 19:52 +0100 schrieb Uwe Ligges:
> 
> Heiko Strathmann wrote:
> > Hello uwe,
> > Thanks for trying out.
> > the freeze happens after about 10 to 20 iterations. Did you try as many?
> 
> I just tried again:
> 
> library("kernlab")
> load("freeze_workspace.RDATA")
> replicate(100, ksvm(kernel="matrix", kernelMatrix, trainingDataYs, 
> type="C-svc", C=2))
> 
> and everything is still fine (same on Linux).
> 
> Uwe Ligges
> 
> 
> 
> > Am Sonntag, den 29.11.2009, 17:22 +0100 schrieb Uwe Ligges:
> >> I just tried
> >>
> >> ksvm(kernel="matrix", kernelMatrix, trainingDataYs, type="C-svc", 
> >> cross=10, C=2)
> >>
> >> several times on both workspaces and both returned some results after a 
> >> couple of seconds under the same versions (R version 2.10.0 and kernlab 
> >> 0.9-9.) under Windows XP.
> >>
> >> There mist be something else going on...
> >>
> >> Best wishes,
> >> Uwe Ligges
> >>
> >>
> >>
> >>
> >>
> >> Heiko Strathmann wrote:
> >>> Hello again,
> >>>
> >>> the freeze seems to depend on the kernel matrix.
> >>> With another kernel matrix of similiar size, gernerated with the same
> >>> kernel, but on another dataset, there is no freeze.
> >>>
> >>> I have put a workspace with the working matrix and one with the freezing
> >>> matrix online for testing (see old email)
> >>> http://www-stud.uni-due.de/~sfhestra/
> >>>
> >>> In my eyes this behavior is really strange, and i have no clue, what to
> >>> do to solve this.
> >>>
> >>> Regards,
> >>> Heiko Strathmann
> >>>
> >>> Am Sonntag, den 29.11.2009, 14:21 +0100 schrieb Heiko Strathmann:
>  Hello,
> 
>  I am using kernlab to do some binary classification on aminoacid
>  strings.
> 
>  I am using a custom kernel, so i use the kernel="matrix" option of the
>  ksvm method.
> 
>  My (normalized) kernel matrix is of size 1309*1309, my results vector
>  has the same length.
> 
>  I am using C-svc.
> 
>  My kernlab call is something similiar to this:
> 
>  ksvm(kernel="matrix", kernelMatrix, trainingDataYs, type="C-svc",
>  cross=10, C=2)
> 
>  To this point, everything works fine.
> 
>  But now, i want to do a search for a good C Parameter, so I call the
>  ksvm method multiple times in a loop, with changing parameters.
>  This loop freezes after a few iterations.
> 
> 
>  The following simple example also freezes after few iterations (the
>  number varies). See that the ksvm call is always the same in every
>  iteration:
> 
>  for (i in c(1:20)) {
>  print(i)
>  ksvm(kernel="matrix", kernelMatrix, trainingDataYs,
>  type="C-svc",
>  cross=10, C=2)
>  }
> 
> 
>  Does anybody have an idea what causes this? I am new to R and kernlab,
>  perhaps i missed something?
> 
>  I put my workspace online, which contains the kernel matrix and the
>  training labels. Simply load workspace, kernlab library and paste the
>  example code to reproduce:
>  http://www-stud.uni-due.de/~sfhestra/
> 
>  I am using R version 2.10.0 and kernlab 0.9-9.
> 
>  Thanks for your help!
> 
>  Regards,
>  Heiko Strathmann
> 
> 
> >>> __
> >>> R-help@r-project.org mailing list
> >>> https://stat.ethz.ch/mailman/listinfo/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] sequence of commands in R

2009-11-29 Thread Don MacQueen
You don't see the standard deviations because 
only the final result (the output of summary() in 
your case) is output by the function, not the 
intermediate results (the results of the apply() 
function in your case).


Try this:

resumen<-function(x) {
print( apply(x,2,sd,na.rm=TRUE))
summary(x)
}

-Don

At 9:17 PM +0100 11/29/09, Manuel Jesús López Rodríguez wrote:

Dear all,
I would like to know how could I execute a 
sequence or orders with just a function, i.e, 
that just typing the function name, R gives me 
all the parameters I want (for instance, if I 
want to see the summary, the standard deviation, 
the number of valid cases, etc of a dataframe 
just with one function). I have tried with the 
following, but just compute the second argument 
of the body, i.e., the summary:


resumen<-function(x) {
apply(x,2,sd,na.rm=TRUE)
summary(x)
}

Thank you very much for your help!!

Manuel



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



--
-
Don MacQueen
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062
m...@llnl.gov

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] sequence of commands in R

2009-11-29 Thread Daniel Nordlund


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On Behalf Of Manuel Jesús López Rodríguez
> Sent: Sunday, November 29, 2009 12:17 PM
> To: r-help@r-project.org
> Subject: [R] sequence of commands in R
> 
> Dear all,
> I would like to know how could I execute a sequence or orders with just a
> function, i.e, that just typing the function name, R gives me all the
> parameters I want (for instance, if I want to see the summary, the
> standard deviation, the number of valid cases, etc of a dataframe just
> with one function). I have tried with the following, but just compute the
> second argument of the body, i.e., the summary:
> 
> resumen<-function(x) {
>   apply(x,2,sd,na.rm=TRUE)
>   summary(x)
>   }
> 
> Thank you very much for your help!!
> 
> Manuel
> 

Manuel,

You will need to print the results you want, or return all your results as a 
list.  Something like:

resumen<-function(x) {
print(apply(x,2,sd,na.rm=TRUE))
print(summary(x))
}

Or

resumen<-function(x) {
return(list(apply(x,2,sd,na.rm=TRUE),
summary(x)))
}

Hope this is helpful,

Dan

Daniel Nordlund
Bothell, WA  USA

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lm: eval(parse(text=)) works on one side y/x but not on both?

2009-11-29 Thread Gabor Grothendieck
On Sun, Nov 29, 2009 at 9:16 AM, Gabor Grothendieck  wrote:

> By the way, if you really do want to create the formula anyways then:
>
>ix <- 1:2
>left <- paste(names(freeny)[ix], collapse = ",")
>fo <- as.formula(paste("cbind(", left, ") ~ ."))
>lm(fo, freeny)
>
> or possibly replace last line with:
>
>eval(substitute(lm(fo, freeny))
>
> which will cause the formula to appear in the lm output.


This last line should have been:

This last line should have been:

 eval(substitute(lm(fo, freeny), list(fo = fo)))

[[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] sequence of commands in R

2009-11-29 Thread Manuel Jesús López Rodríguez
Dear all,
I would like to know how could I execute a sequence or orders with just a 
function, i.e, that just typing the function name, R gives me all the 
parameters I want (for instance, if I want to see the summary, the standard 
deviation, the number of valid cases, etc of a dataframe just with one 
function). I have tried with the following, but just compute the second 
argument of the body, i.e., the summary:

resumen<-function(x) {
apply(x,2,sd,na.rm=TRUE)
summary(x)
}

Thank you very much for your help!!

Manuel



[[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] optim or nlminb for minimization, which to believe?

2009-11-29 Thread Hans W Borchers

Your function named 'gradient' is not the correct gradient. Take as an
example the following point x0, very near to the true minimum,

x0 <- c(-0.2517964, 0.4898680, -0.2517962, 0.4898681, 0.7500995)
 
then you get

> gradient(x0)
[1] -0.0372110470  0.0001816991 -0.0372102284  0.0001820976 
0.0144292657

but the numerical gradient is different:

> library(numDeriv)
> grad(fn, x0)
[1] -6.151645e-07 -5.507219e-07  1.969143e-07 -1.563892e-07
-4.955502e-08

that is the derivative is close to 0 in any direction -- as it should be for
an optimum.

No wonder, optim et al. get confused when applying this 'gradient'.

Regards
Hans Werner


Doran, Harold wrote:
> 
> I have constructed the function mml2 (below) based on the likelihood
> function described in the minimal latex I have pasted below for anyone who
> wants to look at it. This function finds parameter estimates for a basic
> Rasch (IRT) model. Using the function without the gradient, using either
> nlminb or optim returns the correct parameter estimates and, in the case
> of optim, the correct standard errors.
> 
> By correct, I mean they match another software program as well as the
> rasch() function in the ltm package.
> 
> Now, when I pass the gradient to optim, I get a message of successful
> convergence, but the parameter estimates are not correct, but they are
> *very* close to being correct. But, when I use nlminb with the gradient, I
> get a message of false convergence and again, the estimates are off, but
> again very close to being correct.
> 
> This is best illustrated via the examples:
> 
> ### Sample data set
> set.seed(1234)
> tmp <- data.frame(item1 = sample(c(0,1), 20, replace=TRUE), item2 =
> sample(c(0,1), 20, replace=TRUE), item3 = sample(c(0,1), 20,
> replace=TRUE),item4 = sample(c(0,1), 20, replace=TRUE),item5 =
> sample(c(0,1), 20, replace=TRUE))
> 
> ## Use function mml2 (below) with optim  with use of gradient
>> mml2(tmp,Q=10)
> $par
> [1] -0.2438733  0.4889333 -0.2438733  0.4889333  0.7464162
> 
> $value
> [1] 63.86376
> 
> $counts
> function gradient
>   456
> 
> $convergence
> [1] 0
> 
> $message
> NULL
> 
> $hessian
>  [,1] [,2] [,3] [,4] [,5]
> [1,] 4.095479 0.00 0.00 0.00 0.00
> [2,] 0.00 3.986293 0.00 0.00 0.00
> [3,] 0.00 0.00 4.095479 0.00 0.00
> [4,] 0.00 0.00 0.00 3.986293 0.00
> [5,] 0.00 0.00 0.00 0.00 3.800898
> 
> ## Use same function but use nlminb with use of gradient
>> mml2(tmp,Q=10)
> $par
> [1] -0.2456398  0.4948889 -0.2456398  0.4948889  0.7516308
> 
> $objective
> [1] 63.86364
> 
> $convergence
> [1] 1
> 
> $message
> [1] "false convergence (8)"
> 
> $iterations
> [1] 4
> 
> $evaluations
> function gradient
>   414
> 
> 
> ### use nlminb but turn off use of gradient
>> mml2(tmp,Q=10)
> $par
> [1] -0.2517961  0.4898682 -0.2517961  0.4898682  0.7500994
> 
> $objective
> [1] 63.8635
> 
> $convergence
> [1] 0
> 
> $message
> [1] "relative convergence (4)"
> 
> $iterations
> [1] 8
> 
> $evaluations
> function gradient
>   11   64
> 
> ### Use optim and turn off gradient
> 
>> mml2(tmp,Q=10)
> $par
> [1] -0.2517990  0.4898676 -0.2517990  0.4898676  0.7500906
> 
> $value
> [1] 63.8635
> 
> $counts
> function gradient
>   227
> 
> $convergence
> [1] 0
> 
> $message
> NULL
> 
> $hessian
>[,1]   [,2]   [,3]   [,4]   [,5]
> [1,]  3.6311153 -0.3992959 -0.4224747 -0.3992959 -0.3764526
> [2,] -0.3992959  3.5338195 -0.3992959 -0.3960956 -0.3798141
> [3,] -0.4224747 -0.3992959  3.6311153 -0.3992959 -0.3764526
> [4,] -0.3992959 -0.3960956 -0.3992959  3.5338195 -0.3798141
> [5,] -0.3764526 -0.3798141 -0.3764526 -0.3798141  3.3784816
> 
> The parameter estimates with and without the use of the gradient are so
> close that I am inclined to believe that the gradient is correct and maybe
> the problem is elsewhere.
> 
> It seems odd that optim seems to converge but nlminb does not with the use
> of the gradient. But, with the use of the gradient in either case, the
> parameter estimates differ from what I think are the correct values. So,
> at this point I am unclear if the problem is somewhere in the way the
> functions are used or how I am passing the gradient or if the problem lies
> in the way I have constructed the gradient itself.
> 
> Below is the function and also some latex for those interested in looking
> at the likelihood function.
> 
> Thanks for any reactions
> Harold
> 
>> sessionInfo()
> R version 2.10.0 (2009-10-26)
> i386-pc-mingw32
> 
> locale:
> [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
> States.1252
> [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
> [5] LC_TIME=English_United States.1252
> 
> attached base packages:
> [1] stats graphics  grDevices utils datasets  methods   base
> 
> other attached packages:
> [1] ltm_0.9-2  polycor_0.7-7  sfsmisc_1.0-9  mvtnorm_0.9-

Re: [R] Help: Beanplots calculating wrong average

2009-11-29 Thread Tom Wainwright

On 11/26/2009 02:25 AM, Michael Hopgood wrote:

Hi Tom,

Thank you for the friendly and informative answer.  It does explain a lot of
things, actually.  As with any good answer, it inevitably leads to other
questions.  In the first place, I need the arithmetic mean.  It's what we
base our calculations on...

My code is currently this:

Metall<-c("Cu","Cu","Cu","Cu","Cu","Cu","Cu","Cu","Cu","Cr","Cr","Cr","Cr","
Cr","Cr","Cr","Cr","Cr","As","As","As","As","As","As","As","As","As","Pb","P
b","Pb","Pb","Pb","Pb","Pb","Pb","Pb","Zn","Zn","Zn","Zn","Zn","Zn","Zn","Zn
","Zn")
Halt<-c(85,13,13,340,18,13,88,24,12,216,33,21,454,20,18,88,30,21,1254,22,4.2
,1081,35,6,1772,192,7.6,43,20,12,3107,21,12,30,24,19,1109,57,46,269,68,50,58
5,131,52)
beanplot(Halt~Metall, log = "y", yaxt = "n", ylab="Halt
(mg/kg)",cex.lab=1.2)
axis(2,c(1,10,100,1000,1))
polygon(c(0.2966510,0.2966510,1.4832033,1.4832033,3.6160162,3.6160162,4.4921
444,4.4921444,5.6968371,5.6968371),c(2.763021e-01,10,10,80,80,40,40,250,250,
2.763021e-01),col="#66FF0090", border="#66FF0090")
text(5.58,10,"MKM", cex=1.2, font=2)


The polygons convey information on whether each sample is higher than the
soil guideline value.  If I take away, the log scale, the vast difference in
values obscures the polygons...  Ideally I'd like the average beanline to be
the arithmetic mean or to be gone altogether. Can't seem to make beanplot do
this...

Sincerely,
Michael Hopgood



Hi Michael,

I don't know beanplot() well enough to know if it can be forced to do exactly 
what you want.  You should be able to use the "what" argument to suppress the 
mean lines, then you could add your own average lines using lines() or 
segments().  You could of course also modify the code to suit your needs (mybean 
<- beanplot; edit mybean), but it looks pretty complicated.


Tom Wainwright

--
NOAA Northwest Fisheries Science Center
Newport, Oregon
~~~
The contents of this message are mine personally and do not necessarily
reflect any position of the Government or the National Oceanic and
Atmospheric Administration.
~~~

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Does nargin and nargout work with R functions?

2009-11-29 Thread Jason Rupert
This works great. 

Thanks for your help. 



- Original Message 
From: baptiste auguie 
To: Jason Rupert 
Cc: R-help 
Sent: Thu, November 26, 2009 11:08:57 AM
Subject: Re: [R] Does nargin and nargout work with R functions?

Hi,

I think you can use match.call() to retrieve the number of arguments
passed to a function (see below), but I don't think nargout makes
sense in R like it does in Matlab.

foo <- function(...){

  print(match.call())
  nargin <- length(as.list(match.call())) -1
  print(nargin)
}

foo(a=1, b=2)
foo()
foo(1:3, a=2, c=3)

HTH,

baptiste

2009/11/26 Jason Rupert :
> I am porting some MATLAB functions over to R and hopefully into a package, so 
> I am curious if nargin and nargout work with R functions.
>
> Here is kind of an example of where I need to head in order to port 
> "control-1.0.11" from Octave over to R.  The Octave "control-1.0.11" package 
> has the capability to produce bode plots of transfer functions.  I hope to 
> post this package once the port over to R is complete.
>
> Thanks again for all the feedback and insights.
>
> bode<-function(sys, w, outputs, inputs, plot_style)
> {
>
> # ...
>
> if (nargin < 1 || nargin > 5)
> {
>print("This works")
> }
>
> if (nargout < 1)
> {
>   print("This also works")
> }
>
> return(list(mag_r, phase_r, w_r))
>
> }
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Why .Diag and .asSparse are not accessible in R sessions?

2009-11-29 Thread Sharpie


Peng Yu wrote:
> 
> How to control what functions/classes are exported to a given namespace?
> 

Namespace exports are set by package authors in the NAMESPACE file of an R
package.  You could alter the  NAMESPACE and rebuild the package yourself,
but an easier way would be to just use the ":::" operator to access the
functions you require.


-Charlie
-- 
View this message in context: 
http://n4.nabble.com/Why-Diag-and-asSparse-are-not-accessible-in-R-sessions-tp930880p930936.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] How to z-standardize for subgroups?

2009-11-29 Thread Karsten Wolf

Hi Jorge, Chuck and Kane,
thanks for your input!
The following code based on Jorge's answer did the trick to  
standardize for subgroups within multiple columns:


# define a standardize function, but you could also define your custom  
standardize function here

z.mean.sd <- function(data){
	return.values <- (data  - mean(data, na.rm = TRUE)) / (sd(data, na.rm  
= TRUE))

return(return.values)
}

# assume there is some data.frame called sole.data with a group factor  
sole.data$studie already read into R

sole.data <- read.csv2("SoLe.dat")
attach(sole.data)
# assume I have created a subset of the data.frame cor.vars with only  
some of the vars needed to be standardized

cor.vars <- data.frame(var02, var04, var07, var10, var17, var24, var 36)

z.cor.vars <- apply(cor.vars, 2, tapply, sole.data$studie, z.mean.sd)
z.cor.vars <- sapply(z.cor.vars, unlist, USE.NAMES = FALSE)
z.cor.vars

BUT then Chuck's answer was much more elegant than my first woodpecker  
solution


apply(iris[,1:4], 2, function(x){ave(x, iris$Species, FUN = scale)})

could be translated into

apply(sole.data[,c(2,4,7,10,17,24,36)], 2, function(x){ave(x,sole.data 
$studie, FUN=scale)})


Thanks for the beauty of this code with an anonymous function call :)

-karsten



Am 29.11.2009 um 16:47 schrieb Jorge Ivan Velez:


Hi Karsten,

Let me assume your data is called d. If I understood what you are  
trying to do, the following might help:


res <- apply(d, 2, tapply, d$group, scale)
res

See ?apply, ?tapply and ?scale for more information.

HTH,
Jorge


On Sun, Nov 29, 2009 at 10:41 AM, Karsten Wolf <> wrote:
Hi folks,
I have a dataframe df.vars with the follwing structure:


var1   var2   var3   group

Group is a factor.

Now I want to standardize the vars 1-3 (actually - there are many  
more) by class, so I define


z.mean.sd <- function(data){
   return.values <- (data  - mean(data)) / (sd(data))
   return(return.values)
}

now I can call for each var

z.var1 <- by(df.vars$var1, group, z.mean.sd)

which gives me the standardised data for each subgroup in a list  
with the subgroups


z.var1 <- unlist(z.var1)

then gives me the z-standardised data for var1 in one vector. Great!

Now I would like to do this for the whole dataframe, but probably I  
am not thinking vectorwise enough.


z.df.vars <- by(df.vars, group, z.mean.sd)

does not work. I banged my head on other solutions trying out sapply  
and tapply, but did not succeed. Do I need to loop and put  
everything together by hand? But I want to keep the columnnames in  
the vector…


-karsten


-
Karsten D. Wolf
Didactical Design of Interactive
Learning Environments
Universität Bremen - Fachbereich 12
web: http://www.ifeb.uni-bremen.de/wolf/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Why .Diag and .asSparse are not accessible in R sessions?

2009-11-29 Thread Peng Yu
How to control what functions/classes are exported to a given namespace?

On Sun, Nov 29, 2009 at 3:34 PM, baptiste auguie
 wrote:
> Hi,
>
> They're not exported from the stats namespace,
>
> stats:::.Diag
> stats:::.asSparse
>
> ?":::"
>
> HTH,
>
> baptiste
>
> 2009/11/29 Peng Yu :
>> '.Diag' and '.asSparse' are defined in contrast.R. I'm wondering why I
>> don't see them in my R session. Is it because that they start with
>> '.'?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] What are polynomial contrasts?

2009-11-29 Thread Peng Yu
I don't find a good explanation on polynomial contrasts. Could
somebody recommend one to me?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 force regression coeffs for some values in a categorical variable

2009-11-29 Thread David Winsemius
I worry whether you understand what is happening when you lump all the  
"unwanted levels" into a reference level. Be sure to watch the  
intercept as you compare models. It will be some sort of adjusted mean  
for whatever cases are in the reference levels of that and teh  
reference levels of any other factor. It will change as you add or  
remove levels from that status. Just because you get no coefficient  
does not mean those data points are not affecting the predictions you  
will make from the model. The prediction for cases in those reference  
levels will NOT be 0. Nor will the predicted differences between that  
group and others be zero.


--
David.

On Nov 29, 2009, at 4:09 PM, sr danda wrote:

My model has several independent and categorical variables. I would  
not like to subset them as other variables in the data are useful. I  
just wanted to set some coefficients for some levels in a single  
category.
A prototype of it can be something like y + constant *  
(cat.variable1-Level1) ~ x1 + x2 + cat.variable1(if level != level1)  
+ cat.variable2 +


Currently, I am modifying data by creating new variables for each  
level and recoding the original values.


I am wondering if there are any other approaches.

Thanks,
Danda

On Sun, Nov 29, 2009 at 11:48 AM, David Winsemius > wrote:


On Nov 29, 2009, at 11:23 AM, sr danda wrote:

Hi,

I am a new R user. I am using it develop regression models with  
categorical

variables.
Is there a way to force some regression coefficients to be zero for  
some of

the values in a categorical variable (with 12 factor levels)?

I am recoding the values to the default value (1st in the order of  
dummy's).

But I am not sure if this is the correct approach if I want to force
coefficients to be specific values.

It's a bit unclear from your description what you are trying to do  
(and it might help to hear the justification for doing it). If you  
do not want the cases with particular factor levels used in the  
prediction, then subset them out. If you want a group of factor  
levels grouped and and then used as the reference level, then perhaps:


?relevel

That will of course result in the intercept term becoming the  
adjusted mean for those levels, but I'm sure you already knew that.




Thanks for your help.

Regards,
Danda

--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 put ggobi display into a GUI window setup by gWidgets

2009-11-29 Thread j verzani
jerry83  yahoo.com> writes:

> 
> 
> Hi,
> 
> I want to put a ggobi display into a GUI window setup by gWidgets, but error
> occur said it is not a S4 object.
> 
> Does anyone have any idea about how to put it in or maybe it can not be put
> into a widget at all?
> 
> Thanks A LOT!



To embed a GTK widget into gWidgets isn't too hard, just call the add method.
I'm not sure how  to get the GTK object you want from the ggobi 
interface. Below is an example that you might be able to modify:

## 
library(RGtk2)
library(rggobi)
library(gWidgets)
options(guiToolkit="RGtk2")

## ggoobi object
x <- ggobi(mtcars)

## grab child from main window. Modify (how?) to get 
## other widgets
toplevel <- ggobi_gtk_main_window(x)
child <- toplevel[[1]]  # toplevel has only one child
toplevel$remove(child)  # remove child if keeping toplevel
toplevel$destroy()  # or destroy if not

## add to a gWidget instance using gWidgetsRGtk2:
w <- gwindow("A gwidget's window")
g <- ggroup(cont = w, expand=TRUE)
add(g, child, expand=TRUE)

--John

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Orphaned R Packages (maybe this is too inside baseball?)

2009-11-29 Thread Gabor Grothendieck
He is also the author of the rpad package and the email address on that
package on CRAN does correspond to a working web site.

On Sun, Nov 29, 2009 at 4:33 PM, Jason Rupert wrote:

> Dear Uwe,
>
> Thank you very much for your response.
>
> Maybe I should take the follow-up discussion about the open license issues
> off line, as I have do not have a great deal of experience with such things,
> especially with regards to the desired licenses for R packages and the
> existing license for the R "signal" package or the original license of the
> package from which it was ported.
>
> Also, I suppose I should mention that I attempted to contacted the person
> listed as the Author, Tom Short (tsh...@eprisolutions.com), of the
> package, but I received the automated message stated below when I attempted
> to contact him:
> Hi. This is the qmail-send program at yahoo.com.
> I'm afraid I wasn't able to deliver your message to the following
> addresses.
> This is a permanent error; I've given up. Sorry it didn't work out.
>
> Also, I believe the listed maintainer's company (
> http://www.eprisolutions.com/) or at least there website is also defunct.
>
> I am in the process of porting Octave's "control" package over to R, so the
> Bode functionality is available (no timeline for completion at this point,
> but hopefully before the New Year - ha!).  It appears that the "control"
> package when it was part of Octave was using some of the functionality
> within the "signal" package, so the R "control" package would have a similar
> dependency.
>
> Thank you again for your response to this inquiry, as I hope it may help
> with this package and hopefully others that are "orphaned".  I also look to
> any further insights regarding concerns about the open license issues
> (handled either on-list or off-list).
>
> Thanks again and take care,
> Jason
>
> jasonkrup...@yahoo.com
>
>
>
>
>
>
> - Original Message 
> From: Uwe Ligges 
> To: Jason Rupert 
> Cc: R-help@r-project.org
> Sent: Sun, November 29, 2009 10:39:23 AM
> Subject: Re: [R] Orphaned R Packages (maybe this is too inside baseball?)
>
>
>
> Jason Rupert wrote:
> > How do the R "powers that be" handle packages that are orphaned from
> CRAN?
> >
> > Recently, I was looking for a function either part of the base
> functionality or an add-on package that mimicked the "poly" functionality
> from Octave (
> http://n4.nabble.com/Re-R-function-that-duplicates-Octave-s-poly-function-td901174.html
> )
> > Based on that post a helpful R user  strongly  encouraged me to look at
> the "signal" package. cran.es.r-project.org/web/packages/signal/index.html
> > Unfortunately, when clicking through on that link the following is
> received:
> > Package ‘signal’ was removed from the CRAN repository.
> > Formerly available versions can be obtained from the archive.
> >
> > It appears that the "signal" package was part of those contributed to
> 2.8, but was not maintained after that, i.e. is not part of 2.9 or 2.10:
> > http://mira.sunsite.utk.edu/CRAN/bin/windows/contrib/2.8/
> >
> > I'm still pretty new to the package concept in R and how those are
> maintained, updated, deprecated, etc., so any insight about how this and
> other similar packages like this are handled is very helpful.
>
> If an R package is no longer maintained (e.g. if a maintainer does not
> respond any more when asked to fix / adapt the package for a new version of
> R), the package is "orphaned" and is moved after some time from the main
> CRAN repository to the archives.
> Any volunteer is welcome to take over maintainership (given the license
> permits it), fix the open issues and upload a new version to CRAN.
>
> Since signal is a package of interest for me as well, I thought about
> taking over maintainership already, but there may be some open license
> issues and I do not have too much time these days.
>
> Best wishes,
> Uwe Ligges
>
>
>
> >
> > Thanks again for the great insights offered by all those R wonderful R
> users and maintainers and contributors out there.  It is truly great to see
> a community be this productive.
> > P.S.  For the time being, I suppose it is okay to continue to use the
> signal package that was contributed to the 2.8 Version until it no longer
> functions properly as the architecture continues to advance (which is
> great).
> >
> >
> >
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/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.
>

[[alternative HTML version deleted]]

_

Re: [R] How to z-standardize for subgroups?

2009-11-29 Thread Chuck Cleland
On 11/29/2009 4:23 PM, John Kane wrote:
> http://finzi.psych.upenn.edu/R/library/QuantPsyc/html/Make.Z.html
> 
> Make.Z in the QuantPsych package may already do it.

  For a single variable, you could use ave() and scale() together like this:

with(iris, ave(Sepal.Width, Species, FUN = scale))

  To scale more than one variable in a concise call, consider something
along these lines:

apply(iris[,1:4], 2, function(x){ave(x, iris$Species, FUN = scale)})

hope this helps,

Chuck Cleland

> --- On Sun, 11/29/09, Karsten Wolf  wrote:
> 
>> From: Karsten Wolf 
>> Subject: [R] How to z-standardize for subgroups?
>> To: r-help@r-project.org
>> Received: Sunday, November 29, 2009, 10:41 AM
>> Hi folks,
>> I have a dataframe df.vars with the follwing structure:
>>
>>
>> var1   var2   var3   group
>>
>> Group is a factor.
>>
>> Now I want to standardize the vars 1-3 (actually - there
>> are many more) by class, so I define
>>
>> z.mean.sd <- function(data){
>> return.values <- (data  -
>> mean(data)) / (sd(data))
>> return(return.values)
>> }
>>
>> now I can call for each var
>>
>> z.var1 <- by(df.vars$var1, group, z.mean.sd)
>>
>> which gives me the standardised data for each subgroup in a
>> list with the subgroups
>>
>> z.var1 <- unlist(z.var1)
>>
>> then gives me the z-standardised data for var1 in one
>> vector. Great!
>>
>> Now I would like to do this for the whole dataframe, but
>> probably I am not thinking vectorwise enough.
>>
>> z.df.vars <- by(df.vars, group, z.mean.sd)
>>
>> does not work. I banged my head on other solutions trying
>> out sapply and tapply, but did not succeed. Do I need to
>> loop and put everything together by hand? But I want to keep
>> the columnnames in the vector…
>>
>> -karsten
>>
>>
>> -
>> Karsten D. Wolf
>> Didactical Design of Interactive
>> Learning Environments
>> Universität Bremen - Fachbereich 12
>> web: http://www.ifeb.uni-bremen.de/wolf/
>>
>> __
>> R-help@r-project.org
>> mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained,
>> reproducible code.
>>
> 
> __
> Do You Yahoo!?
> Tired of spam?
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

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


Re: [R] Why .Diag and .asSparse are not accessible in R sessions?

2009-11-29 Thread baptiste auguie
Hi,

They're not exported from the stats namespace,

stats:::.Diag
stats:::.asSparse

?":::"

HTH,

baptiste

2009/11/29 Peng Yu :
> '.Diag' and '.asSparse' are defined in contrast.R. I'm wondering why I
> don't see them in my R session. Is it because that they start with
> '.'?
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Orphaned R Packages (maybe this is too inside baseball?)

2009-11-29 Thread Jason Rupert
Dear Uwe, 

Thank you very much for your response. 

Maybe I should take the follow-up discussion about the open license issues off 
line, as I have do not have a great deal of experience with such things, 
especially with regards to the desired licenses for R packages and the existing 
license for the R "signal" package or the original license of the package from 
which it was ported.  

Also, I suppose I should mention that I attempted to contacted the person 
listed as the Author, Tom Short (tsh...@eprisolutions.com), of the package, but 
I received the automated message stated below when I attempted to contact him:
Hi. This is the qmail-send program at yahoo.com.
I'm afraid I wasn't able to deliver your message to the following addresses.
This is a permanent error; I've given up. Sorry it didn't work out.

Also, I believe the listed maintainer's company (http://www.eprisolutions.com/) 
or at least there website is also defunct.  

I am in the process of porting Octave's "control" package over to R, so the 
Bode functionality is available (no timeline for completion at this point, but 
hopefully before the New Year - ha!).  It appears that the "control" package 
when it was part of Octave was using some of the functionality within the 
"signal" package, so the R "control" package would have a similar dependency.  

Thank you again for your response to this inquiry, as I hope it may help with 
this package and hopefully others that are "orphaned".  I also look to any 
further insights regarding concerns about the open license issues (handled 
either on-list or off-list). 

Thanks again and take care, 
Jason 

jasonkrup...@yahoo.com






- Original Message 
From: Uwe Ligges 
To: Jason Rupert 
Cc: R-help@r-project.org
Sent: Sun, November 29, 2009 10:39:23 AM
Subject: Re: [R] Orphaned R Packages (maybe this is too inside baseball?)



Jason Rupert wrote:
> How do the R "powers that be" handle packages that are orphaned from CRAN?  
>
> Recently, I was looking for a function either part of the base functionality 
> or an add-on package that mimicked the "poly" functionality from Octave 
> (http://n4.nabble.com/Re-R-function-that-duplicates-Octave-s-poly-function-td901174.html)
>  
> Based on that post a helpful R user  strongly  encouraged me to look at the 
> "signal" package. cran.es.r-project.org/web/packages/signal/index.html  
> Unfortunately, when clicking through on that link the following is received:
> Package ‘signal’ was removed from the CRAN repository.
> Formerly available versions can be obtained from the archive. 
> 
> It appears that the "signal" package was part of those contributed to 2.8, 
> but was not maintained after that, i.e. is not part of 2.9 or 2.10:
> http://mira.sunsite.utk.edu/CRAN/bin/windows/contrib/2.8/
> 
> I'm still pretty new to the package concept in R and how those are 
> maintained, updated, deprecated, etc., so any insight about how this and 
> other similar packages like this are handled is very helpful. 

If an R package is no longer maintained (e.g. if a maintainer does not respond 
any more when asked to fix / adapt the package for a new version of R), the 
package is "orphaned" and is moved after some time from the main CRAN 
repository to the archives.
Any volunteer is welcome to take over maintainership (given the license permits 
it), fix the open issues and upload a new version to CRAN.

Since signal is a package of interest for me as well, I thought about taking 
over maintainership already, but there may be some open license issues and I do 
not have too much time these days.

Best wishes,
Uwe Ligges



> 
> Thanks again for the great insights offered by all those R wonderful R users 
> and maintainers and contributors out there.  It is truly great to see a 
> community be this productive. 
> P.S.  For the time being, I suppose it is okay to continue to use the signal 
> package that was contributed to the 2.8 Version until it no longer functions 
> properly as the architecture continues to advance (which is great).
> 
> 
> 
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] How to z-standardize for subgroups?

2009-11-29 Thread John Kane
http://finzi.psych.upenn.edu/R/library/QuantPsyc/html/Make.Z.html

Make.Z in the QuantPsych package may already do it.

--- On Sun, 11/29/09, Karsten Wolf  wrote:

> From: Karsten Wolf 
> Subject: [R] How to z-standardize for subgroups?
> To: r-help@r-project.org
> Received: Sunday, November 29, 2009, 10:41 AM
> Hi folks,
> I have a dataframe df.vars with the follwing structure:
> 
> 
> var1   var2   var3   group
> 
> Group is a factor.
> 
> Now I want to standardize the vars 1-3 (actually - there
> are many more) by class, so I define
> 
> z.mean.sd <- function(data){
>     return.values <- (data  -
> mean(data)) / (sd(data))
>     return(return.values)
> }
> 
> now I can call for each var
> 
> z.var1 <- by(df.vars$var1, group, z.mean.sd)
> 
> which gives me the standardised data for each subgroup in a
> list with the subgroups
> 
> z.var1 <- unlist(z.var1)
> 
> then gives me the z-standardised data for var1 in one
> vector. Great!
> 
> Now I would like to do this for the whole dataframe, but
> probably I am not thinking vectorwise enough.
> 
> z.df.vars <- by(df.vars, group, z.mean.sd)
> 
> does not work. I banged my head on other solutions trying
> out sapply and tapply, but did not succeed. Do I need to
> loop and put everything together by hand? But I want to keep
> the columnnames in the vector…
> 
> -karsten
> 
> 
> -
> Karsten D. Wolf
> Didactical Design of Interactive
> Learning Environments
> Universität Bremen - Fachbereich 12
> web: http://www.ifeb.uni-bremen.de/wolf/
> 
> __
> R-help@r-project.org
> mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained,
> reproducible code.
> 

__
Do You Yahoo!?
Tired of spam?
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Why .Diag and .asSparse are not accessible in R sessions?

2009-11-29 Thread Peng Yu
'.Diag' and '.asSparse' are defined in contrast.R. I'm wondering why I
don't see them in my R session. Is it because that they start with
'.'?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 force regression coeffs for some values in a categorical variable

2009-11-29 Thread sr danda
My model has several independent and categorical variables. I would not like
to subset them as other variables in the data are useful. I just wanted to
set some coefficients for some levels in a single category.
A prototype of it can be something like y + constant *
(cat.variable1-Level1) ~ x1 + x2 + cat.variable1(if level != level1) +
cat.variable2 +

Currently, I am modifying data by creating new variables for each level and
recoding the original values.

I am wondering if there are any other approaches.

Thanks,
Danda

On Sun, Nov 29, 2009 at 11:48 AM, David Winsemius wrote:

>
> On Nov 29, 2009, at 11:23 AM, sr danda wrote:
>
>  Hi,
>>
>> I am a new R user. I am using it develop regression models with
>> categorical
>> variables.
>> Is there a way to force some regression coefficients to be zero for some
>> of
>> the values in a categorical variable (with 12 factor levels)?
>>
>> I am recoding the values to the default value (1st in the order of
>> dummy's).
>> But I am not sure if this is the correct approach if I want to force
>> coefficients to be specific values.
>>
>
> It's a bit unclear from your description what you are trying to do (and it
> might help to hear the justification for doing it). If you do not want the
> cases with particular factor levels used in the prediction, then subset them
> out. If you want a group of factor levels grouped and and then used as the
> reference level, then perhaps:
>
> ?relevel
>
> That will of course result in the intercept term becoming the adjusted mean
> for those levels, but I'm sure you already knew that.
>
>
>
>> Thanks for your help.
>>
>> Regards,
>> Danda
>>
>>  --
>
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
>
>

[[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] Has anyone had success with RGTK2/rattle and windows 7 64-bit?

2009-11-29 Thread Uwe Ligges



Graham Williams wrote:

I don't have a Windows 7 to test this on yet - works on Vista and XP. Did
you install the GTK libraries (separately to R)?


I have manually tested on Windows Server 2008 64-bit where it works 
(with most recent 32-bit binary versions of R, rattle and GTK).


Best wishes,
Uwe



Regards,
Graham


2009/11/21 Tetrick, Scott 


I have been unable to get rattle to run in my new Windows7-64 bit
configuration.  For wither Rgtk2 or rattle, I get an error:

Entry point not found

The procedure entry point g_assetion_message_expr could not be located in
the dynamic link library libglib-2.0-0.dll.

Any help is really appreciated.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] kernlab's ksvm method freeze

2009-11-29 Thread David Winsemius
No "freezes" on a Mac using Ligges' 100 replication script. Tried it  
twice. They took around a minute each time.


--
David.

--
David
On Nov 29, 2009, at 1:28 PM, Heiko Strathmann wrote:


Hello uwe,
Thanks for trying out.
the freeze happens after about 10 to 20 iterations. Did you try as  
many?


Am Sonntag, den 29.11.2009, 17:22 +0100 schrieb Uwe Ligges:

I just tried

ksvm(kernel="matrix", kernelMatrix, trainingDataYs, type="C-svc",
cross=10, C=2)

several times on both workspaces and both returned some results  
after a
couple of seconds under the same versions (R version 2.10.0 and  
kernlab

0.9-9.) under Windows XP.

There mist be something else going on...

Best wishes,
Uwe Ligges





Heiko Strathmann wrote:

Hello again,

the freeze seems to depend on the kernel matrix.
With another kernel matrix of similiar size, gernerated with the  
same

kernel, but on another dataset, there is no freeze.

I have put a workspace with the working matrix and one with the  
freezing

matrix online for testing (see old email)
http://www-stud.uni-due.de/~sfhestra/

In my eyes this behavior is really strange, and i have no clue,  
what to

do to solve this.

Regards,
Heiko Strathmann

Am Sonntag, den 29.11.2009, 14:21 +0100 schrieb Heiko Strathmann:

Hello,

I am using kernlab to do some binary classification on aminoacid
strings.

I am using a custom kernel, so i use the kernel="matrix" option  
of the

ksvm method.

My (normalized) kernel matrix is of size 1309*1309, my results  
vector

has the same length.

I am using C-svc.

My kernlab call is something similiar to this:

ksvm(kernel="matrix", kernelMatrix, trainingDataYs, type="C-svc",
cross=10, C=2)

To this point, everything works fine.

But now, i want to do a search for a good C Parameter, so I call  
the

ksvm method multiple times in a loop, with changing parameters.
This loop freezes after a few iterations.


The following simple example also freezes after few iterations (the
number varies). See that the ksvm call is always the same in every
iteration:

for (i in c(1:20)) {
   print(i)
   ksvm(kernel="matrix", kernelMatrix, trainingDataYs,
type="C-svc",
cross=10, C=2)
}


Does anybody have an idea what causes this? I am new to R and  
kernlab,

perhaps i missed something?

I put my workspace online, which contains the kernel matrix and the
training labels. Simply load workspace, kernlab library and paste  
the

example code to reproduce:
http://www-stud.uni-due.de/~sfhestra/

I am using R version 2.10.0 and kernlab 0.9-9.

Thanks for your help!

Regards,
Heiko Strathmann




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


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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Removing objects from a list based on nrow

2009-11-29 Thread Tim Clark
Jim,

Good catch!  I know in my current problem there are objects with less than 3 
rows, but will make sure to modify the function for future use.

Thanks,

Tim


Tim Clark
Department of Zoology 
University of Hawaii


--- On Sun, 11/29/09, Linlin Yan  wrote:

> From: Linlin Yan 
> Subject: Re: [R] Removing objects from a list based on nrow
> To: "jim holtman" 
> Cc: "Tim Clark" , r-help@r-project.org
> Date: Sunday, November 29, 2009, 4:35 AM
> Thank Jim! You are right. I didn't
> notice the case of none of rows
> match the condition.
> 
> On Sun, Nov 29, 2009 at 10:10 PM, jim holtman 
> wrote:
> > One thing to be careful of is if no dataframe have
> less than 3 rows:
> >
> >>
> df1<-data.frame(letter=c("A","B","C","D","E"),number=c(1,2,3,4,5))
> >>
> df2<-data.frame(letter=c("A","B"),number=c(1,2))
> >>
> df3<-data.frame(letter=c("A","B","C","D","E"),number=c(1,2,3,4,5))
> >>
> df4<-data.frame(letter=c("A","B","C","D","E"),number=c(1,2,3,4,5))
> >>
> >> lst<-list(df1,df3,df4)
> >> lst
> > [[1]]
> >  letter number
> > 1      A      1
> > 2      B      2
> > 3      C      3
> > 4      D      4
> > 5      E      5
> >
> > [[2]]
> >  letter number
> > 1      A      1
> > 2      B      2
> > 3      C      3
> > 4      D      4
> > 5      E      5
> >
> > [[3]]
> >  letter number
> > 1      A      1
> > 2      B      2
> > 3      C      3
> > 4      D      4
> > 5      E      5
> >
> >> lst[-which(sapply(lst, nrow) < 3)]
> > list()
> >>
> >
> > Notice the list is now empty.  Instead use:
> >
> >> lst[sapply(lst, nrow) >=3]
> > [[1]]
> >  letter number
> > 1      A      1
> > 2      B      2
> > 3      C      3
> > 4      D      4
> > 5      E      5
> >
> > [[2]]
> >  letter number
> > 1      A      1
> > 2      B      2
> > 3      C      3
> > 4      D      4
> > 5      E      5
> >
> > [[3]]
> >  letter number
> > 1      A      1
> > 2      B      2
> > 3      C      3
> > 4      D      4
> > 5      E      5
> >
> >
> > On Sun, Nov 29, 2009 at 3:43 AM, Linlin Yan 
> wrote:
> >> Try these:
> >> sapply(lst, nrow) # get row numbers
> >> which(sapply(lst, nrow) < 3) # get the index of
> rows which has less than 3 rows
> >> lst <- lst[-which(sapply(lst, nrow) < 3)] #
> remove the rows from the list
> >>
> >> On Sun, Nov 29, 2009 at 4:36 PM, Tim Clark 
> wrote:
> >>> Dear List,
> >>>
> >>> I have a list containing data frames of
> various numbers of rows.  I need to remove any data frame
> that has less than 3 rows.  For example:
> >>>
> >>>
> df1<-data.frame(letter=c("A","B","C","D","E"),number=c(1,2,3,4,5))
> >>>
> df2<-data.frame(letter=c("A","B"),number=c(1,2))
> >>>
> df3<-data.frame(letter=c("A","B","C","D","E"),number=c(1,2,3,4,5))
> >>>
> df4<-data.frame(letter=c("A","B","C","D","E"),number=c(1,2,3,4,5))
> >>>
> >>> lst<-list(df1,df2,df3,df4)
> >>>
> >>> How can I determine that the second object
> (df2) has less than 3 rows and remove it from the list?
> >>>
> >>> Thanks!
> >>>
> >>> Tim
> >>>
> >>>
> >>>
> >>>
> >>> Tim Clark
> >>> Department of Zoology
> >>> University of Hawaii
> >>>
> >>>
> __
> >>> R-help@r-project.org
> mailing list
> >>> https://stat.ethz.ch/mailman/listinfo/r-help
> >>> PLEASE do read the posting guide 
> >>> http://www.R-project.org/posting-guide.html
> >>> and provide commented, minimal,
> self-contained, reproducible code.
> >>>
> >>
> >> __
> >> R-help@r-project.org
> mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide 
> >> http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained,
> reproducible code.
> >>
> >
> >
> >
> > --
> > Jim Holtman
> > Cincinnati, OH
> > +1 513 646 9390
> >
> > What is the problem that 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.


[R] optim or nlminb for minimization, which to believe?

2009-11-29 Thread Doran, Harold
I have constructed the function mml2 (below) based on the likelihood function 
described in the minimal latex I have pasted below for anyone who wants to look 
at it. This function finds parameter estimates for a basic Rasch (IRT) model. 
Using the function without the gradient, using either nlminb or optim returns 
the correct parameter estimates and, in the case of optim, the correct standard 
errors.

By correct, I mean they match another software program as well as the rasch() 
function in the ltm package.

Now, when I pass the gradient to optim, I get a message of successful 
convergence, but the parameter estimates are not correct, but they are *very* 
close to being correct. But, when I use nlminb with the gradient, I get a 
message of false convergence and again, the estimates are off, but again very 
close to being correct.

This is best illustrated via the examples:

### Sample data set
set.seed(1234)
tmp <- data.frame(item1 = sample(c(0,1), 20, replace=TRUE), item2 = 
sample(c(0,1), 20, replace=TRUE), item3 = sample(c(0,1), 20, 
replace=TRUE),item4 = sample(c(0,1), 20, replace=TRUE),item5 = sample(c(0,1), 
20, replace=TRUE))

## Use function mml2 (below) with optim  with use of gradient
> mml2(tmp,Q=10)
$par
[1] -0.2438733  0.4889333 -0.2438733  0.4889333  0.7464162

$value
[1] 63.86376

$counts
function gradient
  456

$convergence
[1] 0

$message
NULL

$hessian
 [,1] [,2] [,3] [,4] [,5]
[1,] 4.095479 0.00 0.00 0.00 0.00
[2,] 0.00 3.986293 0.00 0.00 0.00
[3,] 0.00 0.00 4.095479 0.00 0.00
[4,] 0.00 0.00 0.00 3.986293 0.00
[5,] 0.00 0.00 0.00 0.00 3.800898

## Use same function but use nlminb with use of gradient
> mml2(tmp,Q=10)
$par
[1] -0.2456398  0.4948889 -0.2456398  0.4948889  0.7516308

$objective
[1] 63.86364

$convergence
[1] 1

$message
[1] "false convergence (8)"

$iterations
[1] 4

$evaluations
function gradient
  414


### use nlminb but turn off use of gradient
> mml2(tmp,Q=10)
$par
[1] -0.2517961  0.4898682 -0.2517961  0.4898682  0.7500994

$objective
[1] 63.8635

$convergence
[1] 0

$message
[1] "relative convergence (4)"

$iterations
[1] 8

$evaluations
function gradient
  11   64

### Use optim and turn off gradient

> mml2(tmp,Q=10)
$par
[1] -0.2517990  0.4898676 -0.2517990  0.4898676  0.7500906

$value
[1] 63.8635

$counts
function gradient
  227

$convergence
[1] 0

$message
NULL

$hessian
   [,1]   [,2]   [,3]   [,4]   [,5]
[1,]  3.6311153 -0.3992959 -0.4224747 -0.3992959 -0.3764526
[2,] -0.3992959  3.5338195 -0.3992959 -0.3960956 -0.3798141
[3,] -0.4224747 -0.3992959  3.6311153 -0.3992959 -0.3764526
[4,] -0.3992959 -0.3960956 -0.3992959  3.5338195 -0.3798141
[5,] -0.3764526 -0.3798141 -0.3764526 -0.3798141  3.3784816

The parameter estimates with and without the use of the gradient are so close 
that I am inclined to believe that the gradient is correct and maybe the 
problem is elsewhere.

It seems odd that optim seems to converge but nlminb does not with the use of 
the gradient. But, with the use of the gradient in either case, the parameter 
estimates differ from what I think are the correct values. So, at this point I 
am unclear if the problem is somewhere in the way the functions are used or how 
I am passing the gradient or if the problem lies in the way I have constructed 
the gradient itself.

Below is the function and also some latex for those interested in looking at 
the likelihood function.

Thanks for any reactions
Harold

> sessionInfo()
R version 2.10.0 (2009-10-26)
i386-pc-mingw32

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

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

other attached packages:
[1] ltm_0.9-2  polycor_0.7-7  sfsmisc_1.0-9  mvtnorm_0.9-8  msm_0.9.4  
MASS_7.3-3 MiscPsycho_1.5
[8] statmod_1.4.1

loaded via a namespace (and not attached):
[1] splines_2.10.0  survival_2.35-7 tools_2.10.0


mml2 <- function(data, Q, startVal = NULL, gr = TRUE, ...){
if(!is.null(startVal) && length(startVal) != ncol(data) ){
stop("Length of argument startVal not equal to 
the number of parameters estimated")
}
if(!is.null(startVal)){
startVal <- startVal
} else {
p <- colMeans(data)
startVal <- as.vector(log((1 - p)/p))
}
qq <- gauss.quad.prob(Q, dist = 'normal')
rr1 <- matrix(0, nrow = Q, ncol = nrow(data))
data <- as.matrix(data)
L <- nrow(data)
C <- ncol(data)
fn <- function(b){
   

Re: [R] column of dates into time series

2009-11-29 Thread David Winsemius


On Nov 29, 2009, at 12:41 PM, David Winsemius wrote:



On Nov 29, 2009, at 11:59 AM, DispersionMap wrote:



? like this do you mean...


Yes. Exactly. Unfortunately that data was passed though the summary  
function which has done some odd things to the data, to wit:


> Weeks[Weeks==189]
2007-03-26 2007-07-09 2007-11-05 2008-02-25 2008-09-08 2009-08-10
  189189189189189189


Actually those were not so odd. I was just interpreting them  
incorrectly. Those were the tables of counts (i.e. counts of counts),  
since summary on a factor is just the same as table on a factor, so a  
further table operation was giving me a set of weeks that shared the  
same number of counts in the original dataset (which may not be the  
best thing to work with as an example if it has sum(Weeks) = 34377  
entries):


> wk2 <- Sys.Date() -round(150*runif(150))

> options(width=60)
> summary(wk2)
Min.  1st Qu.   Median Mean
"2009-07-02" "2009-08-10" "2009-09-20" "2009-09-18"
 3rd Qu. Max.
"2009-10-27" "2009-11-28"
> table(summary(cut(wk2, breaks="weeks")))

 1  2  3  4  5  6  7  9 11 12 14
 1  1  2  1  5  2  1  5  2  1  1
> table(table(cut(wk2, breaks="weeks")))

 1  2  3  4  5  6  7  9 11 12 14
 1  1  2  1  5  2  1  5  2  1  1
> summary(cut(wk2, breaks="weeks"))
2009-06-29 2009-07-06 2009-07-13 2009-07-20 2009-07-27
 1  9  5  4 12
2009-08-03 2009-08-10 2009-08-17 2009-08-24 2009-08-31
 6  9  5  5  5
2009-09-07 2009-09-14 2009-09-21 2009-09-28 2009-10-05
 3 14  5  2  6
2009-10-12 2009-10-19 2009-10-26 2009-11-02 2009-11-09
 7 11  9 11  9
2009-11-16 2009-11-23
 9  3
> table(cut(wk2, breaks="weeks"))

2009-06-29 2009-07-06 2009-07-13 2009-07-20 2009-07-27
 1  9  5  4 12
2009-08-03 2009-08-10 2009-08-17 2009-08-24 2009-08-31
 6  9  5  5  5
2009-09-07 2009-09-14 2009-09-21 2009-09-28 2009-10-05
 3 14  5  2  6
2009-10-12 2009-10-19 2009-10-26 2009-11-02 2009-11-09
 7 11  9 11  9
2009-11-16 2009-11-23
 9  3



Can you give us dput on data$Raised.Date? And also explain what  
further hints you still need, now that you have been advised that  
table and order are the functions to do the operations you requested?


--
David.






dput(Weeks)

structure(c(370L, 342L, 333L, 317L, 308L, 298L, 289L, 269L, 265L,
257L, 254L, 253L, 252L, 249L, 243L, 243L, 239L, 239L, 236L, 234L,
233L, 232L, 230L, 230L, 229L, 229L, 229L, 228L, 227L, 226L, 225L,
222L, 218L, 217L, 216L, 215L, 215L, 214L, 214L, 214L, 212L, 211L,
209L, 209L, 208L, 207L, 205L, 205L, 204L, 204L, 203L, 202L, 202L,
201L, 200L, 199L, 197L, 197L, 197L, 197L, 195L, 194L, 194L, 194L,
193L, 193L, 193L, 193L, 192L, 191L, 190L, 190L, 190L, 189L, 189L,
189L, 189L, 189L, 189L, 188L, 188L, 187L, 187L, 186L, 183L, 182L,
182L, 181L, 180L, 180L, 180L, 179L, 179L, 179L, 178L, 178L, 177L,
177L, 177L, 13091L), .Names = c("2007-12-17", "2009-01-05",  
"2008-06-09",

"2008-12-08", "2009-02-09", "2008-12-01", "2008-05-12", "2009-02-16",
"2007-01-22", "2008-06-02", "2007-01-29", "2008-05-19", "2007-06-11",
"2008-06-16", "2008-05-26", "2008-06-23", "2008-11-03", "2009-01-12",
"2008-07-21", "2007-02-05", "2008-02-18", "2008-07-14", "2008-01-14",
"2008-10-27", "2007-12-10", "2008-03-17", "2008-08-04", "2008-11-24",
"2006-12-18", "2007-11-26", "2007-11-12", "2006-11-06", "2007-06-25",
"2006-04-03", "2008-01-07", "2006-04-10", "2008-07-28", "2006-05-08",
"2006-06-05", "2009-02-23", "2007-10-22", "2007-02-19", "2008-06-30",
"2009-02-02", "2007-06-04", "2007-12-03", "2006-11-13", "2007-09-03",
"2006-08-28", "2008-07-07", "2007-05-14", "2006-08-14", "2007-04-16",
"2006-07-31", "2008-12-15", "2006-09-11", "2006-06-12", "2008-01-21",
"2008-04-07", "2009-01-26", "2008-02-11", "2007-04-02", "2007-04-09",
"2008-04-21", "2006-08-07", "2007-11-19", "2008-04-14", "2008-05-05",
"2006-07-24", "2007-05-21", "2006-06-19", "2006-10-09", "2007-02-12",
"2007-03-26", "2007-07-09", "2007-11-05", "2008-02-25", "2008-09-08",
"2009-08-10", "2008-09-15", "2009-06-08", "2006-05-15", "2007-07-02",
"2009-06-01", "2008-11-17", "2006-06-26", "2009-06-29", "2007-08-06",
"2007-08-13", "2009-01-19", "2009-07-13", "2006-04-17", "2007-03-05",
"2007-12-24", "2006-10-16", "2008-08-11", "2006-05-29", "2006-11-27",
"2007-10-29", "(Other)"))




David Winsemius wrote:


How about a representation of the data that one could so something
with? By that I mean either by the "dump" method described in the
Posting Guide or by using dput:

ttt <- c(1,2)



dput(ttt)

c(1, 2)


dump("ttt", stdout() )

ttt <-
c(1, 2)

Did you honestly expect anyone in their right mind to reassemble  
that

data from the console text output???

On

Re: [R] kernlab's ksvm method freeze

2009-11-29 Thread Uwe Ligges



Heiko Strathmann wrote:

Hello uwe,
Thanks for trying out.
the freeze happens after about 10 to 20 iterations. Did you try as many?


I just tried again:

library("kernlab")
load("freeze_workspace.RDATA")
replicate(100, ksvm(kernel="matrix", kernelMatrix, trainingDataYs, 
type="C-svc", C=2))


and everything is still fine (same on Linux).

Uwe Ligges




Am Sonntag, den 29.11.2009, 17:22 +0100 schrieb Uwe Ligges:

I just tried

ksvm(kernel="matrix", kernelMatrix, trainingDataYs, type="C-svc", 
cross=10, C=2)


several times on both workspaces and both returned some results after a 
couple of seconds under the same versions (R version 2.10.0 and kernlab 
0.9-9.) under Windows XP.


There mist be something else going on...

Best wishes,
Uwe Ligges





Heiko Strathmann wrote:

Hello again,

the freeze seems to depend on the kernel matrix.
With another kernel matrix of similiar size, gernerated with the same
kernel, but on another dataset, there is no freeze.

I have put a workspace with the working matrix and one with the freezing
matrix online for testing (see old email)
http://www-stud.uni-due.de/~sfhestra/

In my eyes this behavior is really strange, and i have no clue, what to
do to solve this.

Regards,
Heiko Strathmann

Am Sonntag, den 29.11.2009, 14:21 +0100 schrieb Heiko Strathmann:

Hello,

I am using kernlab to do some binary classification on aminoacid
strings.

I am using a custom kernel, so i use the kernel="matrix" option of the
ksvm method.

My (normalized) kernel matrix is of size 1309*1309, my results vector
has the same length.

I am using C-svc.

My kernlab call is something similiar to this:

ksvm(kernel="matrix", kernelMatrix, trainingDataYs, type="C-svc",
cross=10, C=2)

To this point, everything works fine.

But now, i want to do a search for a good C Parameter, so I call the
ksvm method multiple times in a loop, with changing parameters.
This loop freezes after a few iterations.


The following simple example also freezes after few iterations (the
number varies). See that the ksvm call is always the same in every
iteration:

for (i in c(1:20)) {
print(i)
ksvm(kernel="matrix", kernelMatrix, trainingDataYs,
type="C-svc",
cross=10, C=2)
}


Does anybody have an idea what causes this? I am new to R and kernlab,
perhaps i missed something?

I put my workspace online, which contains the kernel matrix and the
training labels. Simply load workspace, kernlab library and paste the
example code to reproduce:
http://www-stud.uni-due.de/~sfhestra/

I am using R version 2.10.0 and kernlab 0.9-9.

Thanks for your help!

Regards,
Heiko Strathmann



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] KhmaladzeTest - quantreg

2009-11-29 Thread antonella.cann...@virgilio.it
 
Hi,

I've implemented the KhmaladzeTest for my linear quantile regression model for 
the location-scale shift hypotesis as follow:



>formula=r ~ div + pe + por

>Ktest=KhmaladzeTest(formula,nullH="location-scale")



> Ktest

$nullH

[1] "location-scale"



$Tn

[1] 2.125804



$THn

div pe   por 

 0.7972984  1.4432325  0.7107914 



attr(,"class")





Now I have to compare the number 2.125804 with the critical values that I found 
in Koenker and Xiao (2002) which are:

 - 1% critical value 5.350

 - 5% critical value 4.523



So I accept the null.



But if I carry out the test for the location shift hypotesis 



the result is:



$Tn

[1] 3.178942



and I accept the null again! How is it possible??? Is there something wrong in 
my estimation?



Thank you for your help!



Antonella Cannito








  
  






 

 
[[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] kernlab's ksvm method freeze

2009-11-29 Thread Heiko Strathmann
Hello uwe,
Thanks for trying out.
the freeze happens after about 10 to 20 iterations. Did you try as many?

Am Sonntag, den 29.11.2009, 17:22 +0100 schrieb Uwe Ligges:
> I just tried
> 
> ksvm(kernel="matrix", kernelMatrix, trainingDataYs, type="C-svc", 
> cross=10, C=2)
> 
> several times on both workspaces and both returned some results after a 
> couple of seconds under the same versions (R version 2.10.0 and kernlab 
> 0.9-9.) under Windows XP.
> 
> There mist be something else going on...
> 
> Best wishes,
> Uwe Ligges
> 
> 
> 
> 
> 
> Heiko Strathmann wrote:
> > Hello again,
> > 
> > the freeze seems to depend on the kernel matrix.
> > With another kernel matrix of similiar size, gernerated with the same
> > kernel, but on another dataset, there is no freeze.
> > 
> > I have put a workspace with the working matrix and one with the freezing
> > matrix online for testing (see old email)
> > http://www-stud.uni-due.de/~sfhestra/
> > 
> > In my eyes this behavior is really strange, and i have no clue, what to
> > do to solve this.
> > 
> > Regards,
> > Heiko Strathmann
> > 
> > Am Sonntag, den 29.11.2009, 14:21 +0100 schrieb Heiko Strathmann:
> >> Hello,
> >>
> >> I am using kernlab to do some binary classification on aminoacid
> >> strings.
> >>
> >> I am using a custom kernel, so i use the kernel="matrix" option of the
> >> ksvm method.
> >>
> >> My (normalized) kernel matrix is of size 1309*1309, my results vector
> >> has the same length.
> >>
> >> I am using C-svc.
> >>
> >> My kernlab call is something similiar to this:
> >>
> >> ksvm(kernel="matrix", kernelMatrix, trainingDataYs, type="C-svc",
> >> cross=10, C=2)
> >>
> >> To this point, everything works fine.
> >>
> >> But now, i want to do a search for a good C Parameter, so I call the
> >> ksvm method multiple times in a loop, with changing parameters.
> >> This loop freezes after a few iterations.
> >>
> >>
> >> The following simple example also freezes after few iterations (the
> >> number varies). See that the ksvm call is always the same in every
> >> iteration:
> >>
> >> for (i in c(1:20)) {
> >> print(i)
> >> ksvm(kernel="matrix", kernelMatrix, trainingDataYs,
> >> type="C-svc",
> >> cross=10, C=2)
> >> }
> >>
> >>
> >> Does anybody have an idea what causes this? I am new to R and kernlab,
> >> perhaps i missed something?
> >>
> >> I put my workspace online, which contains the kernel matrix and the
> >> training labels. Simply load workspace, kernlab library and paste the
> >> example code to reproduce:
> >> http://www-stud.uni-due.de/~sfhestra/
> >>
> >> I am using R version 2.10.0 and kernlab 0.9-9.
> >>
> >> Thanks for your help!
> >>
> >> Regards,
> >> Heiko Strathmann
> >>
> >>
> > 
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/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] Roman numerical output

2009-11-29 Thread Ben Bolker
Thomas Steiner  gmail.com> writes:

> 
> I have integers and I want R to give them back/output as Roman numerals:
> s=c(7,17)
> format(s,roman=T)


 help.search("roman",agrep=FALSE)
 ?as.roman
 as.roman(c(7,17))

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Roman numerical output

2009-11-29 Thread Thomas Steiner
I have integers and I want R to give them back/output as Roman numerals:
s=c(7,17)
format(s,roman=T)
is obviously wrong. Is there any other way/function to do this?
Thanks,
Thomas

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Spectrum confidence interval

2009-11-29 Thread Uwe Ligges
Late answer, but maybe still helpful (if I am correct this question is 
still unanswered on R-help):




Clément Poirier wrote:

Dear useRs,

I'd like to plot a confidence interval on a periodogram. My problem is 
that spec.pgram(sunspots,ci=0.95,log="yes") gives me a blue error bar on 
the plot, but spec.pgram(sunspots,ci=0.95,log="no") does not. My 
questions are:

1. how should I plot the confidence interval with log="no"?


This is not supported in plot.spec (the plot method for spec objects), 
since handled in the else part after

  if (ci <= 0 || !is.numeric(x$df) || log == "no")




2. how should I get the min and max values of the confidence interval?


Type
 plot.spec

In the code for that function, you will find the function definition of 
spec.ci() which calculates the confidence intervals. Just define that 
function in your workspace and you can go on and add lines to your plot now.


Best wishes,
Uwe Ligges




Many thanks for your help!
Clement Poirier

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] column of dates into time series

2009-11-29 Thread David Winsemius


On Nov 29, 2009, at 11:59 AM, DispersionMap wrote:



? like this do you mean...


Yes. Exactly. Unfortunately that data was passed though the summary  
function which has done some odd things to the data, to wit:


> Weeks[Weeks==189]
2007-03-26 2007-07-09 2007-11-05 2008-02-25 2008-09-08 2009-08-10
   189189189189189189

Can you give us dput on data$Raised.Date? And also explain what  
further hints you still need, now that you have been advised that  
table and order are the functions to do the operations you requested?


--
David.






dput(Weeks)

structure(c(370L, 342L, 333L, 317L, 308L, 298L, 289L, 269L, 265L,
257L, 254L, 253L, 252L, 249L, 243L, 243L, 239L, 239L, 236L, 234L,
233L, 232L, 230L, 230L, 229L, 229L, 229L, 228L, 227L, 226L, 225L,
222L, 218L, 217L, 216L, 215L, 215L, 214L, 214L, 214L, 212L, 211L,
209L, 209L, 208L, 207L, 205L, 205L, 204L, 204L, 203L, 202L, 202L,
201L, 200L, 199L, 197L, 197L, 197L, 197L, 195L, 194L, 194L, 194L,
193L, 193L, 193L, 193L, 192L, 191L, 190L, 190L, 190L, 189L, 189L,
189L, 189L, 189L, 189L, 188L, 188L, 187L, 187L, 186L, 183L, 182L,
182L, 181L, 180L, 180L, 180L, 179L, 179L, 179L, 178L, 178L, 177L,
177L, 177L, 13091L), .Names = c("2007-12-17", "2009-01-05",  
"2008-06-09",

"2008-12-08", "2009-02-09", "2008-12-01", "2008-05-12", "2009-02-16",
"2007-01-22", "2008-06-02", "2007-01-29", "2008-05-19", "2007-06-11",
"2008-06-16", "2008-05-26", "2008-06-23", "2008-11-03", "2009-01-12",
"2008-07-21", "2007-02-05", "2008-02-18", "2008-07-14", "2008-01-14",
"2008-10-27", "2007-12-10", "2008-03-17", "2008-08-04", "2008-11-24",
"2006-12-18", "2007-11-26", "2007-11-12", "2006-11-06", "2007-06-25",
"2006-04-03", "2008-01-07", "2006-04-10", "2008-07-28", "2006-05-08",
"2006-06-05", "2009-02-23", "2007-10-22", "2007-02-19", "2008-06-30",
"2009-02-02", "2007-06-04", "2007-12-03", "2006-11-13", "2007-09-03",
"2006-08-28", "2008-07-07", "2007-05-14", "2006-08-14", "2007-04-16",
"2006-07-31", "2008-12-15", "2006-09-11", "2006-06-12", "2008-01-21",
"2008-04-07", "2009-01-26", "2008-02-11", "2007-04-02", "2007-04-09",
"2008-04-21", "2006-08-07", "2007-11-19", "2008-04-14", "2008-05-05",
"2006-07-24", "2007-05-21", "2006-06-19", "2006-10-09", "2007-02-12",
"2007-03-26", "2007-07-09", "2007-11-05", "2008-02-25", "2008-09-08",
"2009-08-10", "2008-09-15", "2009-06-08", "2006-05-15", "2007-07-02",
"2009-06-01", "2008-11-17", "2006-06-26", "2009-06-29", "2007-08-06",
"2007-08-13", "2009-01-19", "2009-07-13", "2006-04-17", "2007-03-05",
"2007-12-24", "2006-10-16", "2008-08-11", "2006-05-29", "2006-11-27",
"2007-10-29", "(Other)"))




David Winsemius wrote:


How about a representation of the data that one could so something
with? By that I mean either by the "dump" method described in the
Posting Guide or by using dput:

ttt <- c(1,2)



dput(ttt)

c(1, 2)


dump("ttt", stdout() )

ttt <-
c(1, 2)

Did you honestly expect anyone in their right mind to reassemble that
data from the console text output???

On Nov 29, 2009, at 10:46 AM, DispersionMap wrote:



Thanks again David,

Heres what happened:


Weeks<-summary(cut(data$Raised.Date, breaks="weeks"))
Weeks

2007-12-17 2009-01-05 2008-06-09 2008-12-08 2009-02-09 2008-12-01
 370342333317308298
2008-05-12 2009-02-16 2007-01-22 2008-06-02 2007-01-29 2008-05-19
 289269265257254253
2007-06-11 2008-06-16 2008-05-26 2008-06-23 2008-11-03 2009-01-12
 252249243243239239
2008-07-21 2007-02-05 2008-02-18 2008-07-14 2008-01-14 2008-10-27
 236234233232230230
2007-12-10 2008-03-17 2008-08-04 2008-11-24 2006-12-18 2007-11-26
 229229229228227226
2007-11-12 2006-11-06 2007-06-25 2006-04-03 2008-01-07 2006-04-10
 225222218217216215
2008-07-28 2006-05-08 2006-06-05 2009-02-23 2007-10-22 2007-02-19
 215214214214212211
2008-06-30 2009-02-02 2007-06-04 2007-12-03 2006-11-13 2007-09-03
 209209208207205205
2006-08-28 2008-07-07 2007-05-14 2006-08-14 2007-04-16 2006-07-31
 204204203202202201
2008-12-15 2006-09-11 2006-06-12 2008-01-21 2008-04-07 2009-01-26
 200199197197197197
2008-02-11 2007-04-02 2007-04-09 2008-04-21 2006-08-07 2007-11-19
 195194194194193193
2008-04-14 2008-05-05 2006-07-24 2007-05-21 2006-06-19 2006-10-09
 193193192191190190
2007-02-12 2007-03-26 2007-07-09 2007-11-05 2008-02-25 2008-09-08
 190189189189189189
2009-08-10 2008-09-15 2009-06-08 2006-05-15 2007-07-02 2009-06-01
 189188188187187186
2008-1

Re: [R] lm() notation question

2009-11-29 Thread Gabor Grothendieck
See the Details section of ?lm where its all discussed.

On Sun, Nov 29, 2009 at 11:46 AM, Carl Witthoft  wrote:

> Hi,
> A recent thread provided a (working) construct for lm:
>
> lm(as.matrix(freeny[ix]) ~., freeny[-ix])
>
>
> Can someone explain what is meant by the formula in that expression,
> that is,  what does "mymatrix~."  do?  I couldn't find any such example in
> the lm() or formula() help pages.
>
> thanks
> Carl
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] lm() notation question

2009-11-29 Thread Gabor Grothendieck
Sorry. Since . is commonly used but a matrix LHS less so I assumed you were
asking about the matrix part.
Dot means everything not on the LHS of the formula.


On Sun, Nov 29, 2009 at 12:18 PM, Carl Witthoft  wrote:

> As others helpfully pointed out, the meaning of "." in a formula is
> provided in the Details section of ?formula.  (But NOT in ?lm)
>
> Ista Zahn wrote:
>
>> The help page for lm says:
>>
>> "If ‘response’ is a matrix a linear model is fitted separately by
>> least-squares to each column of the matrix."
>>
>> -Ista
>>
>>
>> On Sun, Nov 29, 2009 at 11:46 AM, Carl Witthoft 
>> wrote:
>>
>>> Hi,
>>> A recent thread provided a (working) construct for lm:
>>>
>>> lm(as.matrix(freeny[ix]) ~., freeny[-ix])
>>>
>>>
>>> Can someone explain what is meant by the formula in that expression,
>>> that is,  what does "mymatrix~."  do?  I couldn't find any such example
>>> in
>>> the lm() or formula() help pages.
>>>
>>> thanks
>>> Carl
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/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.
>

[[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] Rules for coding expanded formulas

2009-11-29 Thread Peng Yu
I'm reading Section 2.4.1 Rules for Coding Expanded Formulas in
Statistical Models in S by Chambers and Hastie. It is a little
abstract for me. Could somebody point me some references that have
more examples and more explanations that can help me understand the
rules (in particular, the ones on page 39 and 40)?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lm() notation question

2009-11-29 Thread Ista Zahn
The help page for lm says:

"If ‘response’ is a matrix a linear model is fitted separately by
 least-squares to each column of the matrix."

-Ista

On Sun, Nov 29, 2009 at 11:46 AM, Carl Witthoft  wrote:
> Hi,
> A recent thread provided a (working) construct for lm:
>
> lm(as.matrix(freeny[ix]) ~., freeny[-ix])
>
>
> Can someone explain what is meant by the formula in that expression,
> that is,  what does "mymatrix~."  do?  I couldn't find any such example in
> the lm() or formula() help pages.
>
> thanks
> Carl
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.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.


Re: [R] How to force regression coeffs for some values in a categorical variable

2009-11-29 Thread David Winsemius


On Nov 29, 2009, at 11:23 AM, sr danda wrote:


Hi,

I am a new R user. I am using it develop regression models with  
categorical

variables.
Is there a way to force some regression coefficients to be zero for  
some of

the values in a categorical variable (with 12 factor levels)?

I am recoding the values to the default value (1st in the order of  
dummy's).

But I am not sure if this is the correct approach if I want to force
coefficients to be specific values.


It's a bit unclear from your description what you are trying to do  
(and it might help to hear the justification for doing it). If you do  
not want the cases with particular factor levels used in the  
prediction, then subset them out. If you want a group of factor levels  
grouped and and then used as the reference level, then perhaps:


?relevel

That will of course result in the intercept term becoming the adjusted  
mean for those levels, but I'm sure you already knew that.




Thanks for your help.

Regards,
Danda


--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lm() notation question

2009-11-29 Thread Carl Witthoft
As others helpfully pointed out, the meaning of "." in a formula is 
provided in the Details section of ?formula.  (But NOT in ?lm)


Ista Zahn wrote:

The help page for lm says:

"If ‘response’ is a matrix a linear model is fitted separately by
 least-squares to each column of the matrix."

-Ista

On Sun, Nov 29, 2009 at 11:46 AM, Carl Witthoft  wrote:

Hi,
A recent thread provided a (working) construct for lm:

lm(as.matrix(freeny[ix]) ~., freeny[-ix])


Can someone explain what is meant by the formula in that expression,
that is,  what does "mymatrix~."  do?  I couldn't find any such example in
the lm() or formula() help pages.

thanks
Carl

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] column of dates into time series

2009-11-29 Thread DispersionMap

? like this do you mean...

> dput(Weeks)
structure(c(370L, 342L, 333L, 317L, 308L, 298L, 289L, 269L, 265L, 
257L, 254L, 253L, 252L, 249L, 243L, 243L, 239L, 239L, 236L, 234L, 
233L, 232L, 230L, 230L, 229L, 229L, 229L, 228L, 227L, 226L, 225L, 
222L, 218L, 217L, 216L, 215L, 215L, 214L, 214L, 214L, 212L, 211L, 
209L, 209L, 208L, 207L, 205L, 205L, 204L, 204L, 203L, 202L, 202L, 
201L, 200L, 199L, 197L, 197L, 197L, 197L, 195L, 194L, 194L, 194L, 
193L, 193L, 193L, 193L, 192L, 191L, 190L, 190L, 190L, 189L, 189L, 
189L, 189L, 189L, 189L, 188L, 188L, 187L, 187L, 186L, 183L, 182L, 
182L, 181L, 180L, 180L, 180L, 179L, 179L, 179L, 178L, 178L, 177L, 
177L, 177L, 13091L), .Names = c("2007-12-17", "2009-01-05", "2008-06-09", 
"2008-12-08", "2009-02-09", "2008-12-01", "2008-05-12", "2009-02-16", 
"2007-01-22", "2008-06-02", "2007-01-29", "2008-05-19", "2007-06-11", 
"2008-06-16", "2008-05-26", "2008-06-23", "2008-11-03", "2009-01-12", 
"2008-07-21", "2007-02-05", "2008-02-18", "2008-07-14", "2008-01-14", 
"2008-10-27", "2007-12-10", "2008-03-17", "2008-08-04", "2008-11-24", 
"2006-12-18", "2007-11-26", "2007-11-12", "2006-11-06", "2007-06-25", 
"2006-04-03", "2008-01-07", "2006-04-10", "2008-07-28", "2006-05-08", 
"2006-06-05", "2009-02-23", "2007-10-22", "2007-02-19", "2008-06-30", 
"2009-02-02", "2007-06-04", "2007-12-03", "2006-11-13", "2007-09-03", 
"2006-08-28", "2008-07-07", "2007-05-14", "2006-08-14", "2007-04-16", 
"2006-07-31", "2008-12-15", "2006-09-11", "2006-06-12", "2008-01-21", 
"2008-04-07", "2009-01-26", "2008-02-11", "2007-04-02", "2007-04-09", 
"2008-04-21", "2006-08-07", "2007-11-19", "2008-04-14", "2008-05-05", 
"2006-07-24", "2007-05-21", "2006-06-19", "2006-10-09", "2007-02-12", 
"2007-03-26", "2007-07-09", "2007-11-05", "2008-02-25", "2008-09-08", 
"2009-08-10", "2008-09-15", "2009-06-08", "2006-05-15", "2007-07-02", 
"2009-06-01", "2008-11-17", "2006-06-26", "2009-06-29", "2007-08-06", 
"2007-08-13", "2009-01-19", "2009-07-13", "2006-04-17", "2007-03-05", 
"2007-12-24", "2006-10-16", "2008-08-11", "2006-05-29", "2006-11-27", 
"2007-10-29", "(Other)"))




David Winsemius wrote:
> 
> How about a representation of the data that one could so something  
> with? By that I mean either by the "dump" method described in the  
> Posting Guide or by using dput:
>  > ttt <- c(1,2)
> 
>  > dput(ttt)
> c(1, 2)
> 
>  > dump("ttt", stdout() )
> ttt <-
> c(1, 2)
> 
> Did you honestly expect anyone in their right mind to reassemble that  
> data from the console text output???
> 
> On Nov 29, 2009, at 10:46 AM, DispersionMap wrote:
> 
>>
>> Thanks again David,
>>
>> Heres what happened:
>>
>>> Weeks<-summary(cut(data$Raised.Date, breaks="weeks"))
>>> Weeks
>> 2007-12-17 2009-01-05 2008-06-09 2008-12-08 2009-02-09 2008-12-01
>>   370342333317308298
>> 2008-05-12 2009-02-16 2007-01-22 2008-06-02 2007-01-29 2008-05-19
>>   289269265257254253
>> 2007-06-11 2008-06-16 2008-05-26 2008-06-23 2008-11-03 2009-01-12
>>   252249243243239239
>> 2008-07-21 2007-02-05 2008-02-18 2008-07-14 2008-01-14 2008-10-27
>>   236234233232230230
>> 2007-12-10 2008-03-17 2008-08-04 2008-11-24 2006-12-18 2007-11-26
>>   229229229228227226
>> 2007-11-12 2006-11-06 2007-06-25 2006-04-03 2008-01-07 2006-04-10
>>   225222218217216215
>> 2008-07-28 2006-05-08 2006-06-05 2009-02-23 2007-10-22 2007-02-19
>>   215214214214212211
>> 2008-06-30 2009-02-02 2007-06-04 2007-12-03 2006-11-13 2007-09-03
>>   209209208207205205
>> 2006-08-28 2008-07-07 2007-05-14 2006-08-14 2007-04-16 2006-07-31
>>   204204203202202201
>> 2008-12-15 2006-09-11 2006-06-12 2008-01-21 2008-04-07 2009-01-26
>>   200199197197197197
>> 2008-02-11 2007-04-02 2007-04-09 2008-04-21 2006-08-07 2007-11-19
>>   195194194194193193
>> 2008-04-14 2008-05-05 2006-07-24 2007-05-21 2006-06-19 2006-10-09
>>   193193192191190190
>> 2007-02-12 2007-03-26 2007-07-09 2007-11-05 2008-02-25 2008-09-08
>>   190189189189189189
>> 2009-08-10 2008-09-15 2009-06-08 2006-05-15 2007-07-02 2009-06-01
>>   189188188187187186
>> 2008-11-17 2006-06-26 2009-06-29 2007-08-06 2007-08-13 2009-01-19
>>   183182182181180180
>> 2009-07-13 2006-04-17 2007-03-05 2007-12-24 2006-10-16 2008-08-11
>>   180179179179178178
>> 2006-05-29 2006-11-27 2007-10-29(Other)
>>   177177177  13091
>>
>>
>> As you c

Re: [R] lm() notation question

2009-11-29 Thread David Winsemius


On Nov 29, 2009, at 11:46 AM, Carl Witthoft wrote:


Hi,
A recent thread provided a (working) construct for lm:

lm(as.matrix(freeny[ix]) ~., freeny[-ix])


Can someone explain what is meant by the formula in that expression,
that is,  what does "mymatrix~."  do?


It doesn't say my matrix, it says as.matrix, and that is because  
freeny[iz] is most probably a dataframe.


The lm function is capable of doing manova when given a matrix on the  
LHS of the formula:


http://www.r-project.org/doc/Rnews/Rnews_2007-2.pdf   see page 2 and  
onward of Dalgaard's article.


Toward the end of the Details section of formula help page (easily  
accessed with a click from the lm help page) you will find the  
explanation for the  "~."




I couldn't find any such example in the lm() or formula() help pages.

thanks
Carl

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lm() notation question

2009-11-29 Thread Carl Witthoft

Hi,
A recent thread provided a (working) construct for lm:

lm(as.matrix(freeny[ix]) ~., freeny[-ix])


Can someone explain what is meant by the formula in that expression,
that is,  what does "mymatrix~."  do?  I couldn't find any such example 
in the lm() or formula() help pages.


thanks
Carl

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Orphaned R Packages (maybe this is too inside baseball?)

2009-11-29 Thread Uwe Ligges



Jason Rupert wrote:
How do the R "powers that be" handle packages that are orphaned from CRAN?  

>
Recently, I was looking for a function either part of the base functionality or an add-on package that mimicked the "poly" functionality from Octave (http://n4.nabble.com/Re-R-function-that-duplicates-Octave-s-poly-function-td901174.html) 

Based on that post a helpful R user  strongly  encouraged me to look at the "signal" package. 
cran.es.r-project.org/web/packages/signal/index.html  


Unfortunately, when clicking through on that link the following is received:
Package ‘signal’ was removed from the CRAN repository.
Formerly available versions can be obtained from the archive. 



It appears that the "signal" package was part of those contributed to 2.8, but 
was not maintained after that, i.e. is not part of 2.9 or 2.10:
http://mira.sunsite.utk.edu/CRAN/bin/windows/contrib/2.8/

I'm still pretty new to the package concept in R and how those are maintained, updated, deprecated, etc., so any insight about how this and other similar packages like this are handled is very helpful. 


If an R package is no longer maintained (e.g. if a maintainer does not 
respond any more when asked to fix / adapt the package for a new version 
of R), the package is "orphaned" and is moved after some time from the 
main CRAN repository to the archives.
Any volunteer is welcome to take over maintainership (given the license 
permits it), fix the open issues and upload a new version to CRAN.


Since signal is a package of interest for me as well, I thought about 
taking over maintainership already, but there may be some open license 
issues and I do not have too much time these days.


Best wishes,
Uwe Ligges





Thanks again for the great insights offered by all those R wonderful R users and maintainers and contributors out there.  It is truly great to see a community be this productive. 


P.S.  For the time being, I suppose it is okay to continue to use the signal 
package that was contributed to the 2.8 Version until it no longer functions 
properly as the architecture continues to advance (which is great).




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Iteration idioms & laziness

2009-11-29 Thread Duncan Murdoch

On 27/11/2009 3:36 PM, Alexander Søndergaard wrote:

Hi all,

I'm new to R. Having a functional background, I was wondering what's
the idiomatic way to iterate. It seems that for loops are the default
given there's no tail-call optimization.

I'm curious to know whether there is a way to transform the following
toy snippet into something that doesn't eat up gigabytes of memory
(like it's for loop counterpart) using laziness:

Reduce('+', seq(1,1e6))


I believe the iterators and foreach packages give ways to iterate 
without creating the whole array, so they might do what you want.  But 
is the allocation really a problem on modern computers?  The for loop 
version of your example, i.e.


total <- 0
for (i in seq(1,1e6)) total <- total + i
total

uses about 4 megabytes of memory, not "gigabytes".  If you increase the 
limit from 1e6 to 1e9 you'll get gigabytes, but it'll probably take tens 
of minutes to finish running on a system that can run it:  the big 
problem is the interpreted looping, not the memory use.


R has always followed the strategy of making it easy to jump out to C 
code when speed matters, so the natural idiom for your problem is to use 
sum(), not to program it yourself.  In more complicated examples, or if 
you really do want to sum the integers from 1 to a billion on a system 
with limited memory, you'll have to write the C yourself, but it's not hard.


Duncan Murdoch



Thanks!

Best regards,
A.S.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] How to force regression coeffs for some values in a categorical variable

2009-11-29 Thread sr danda
Hi,

I am a new R user. I am using it develop regression models with categorical
variables.
Is there a way to force some regression coefficients to be zero for some of
the values in a categorical variable (with 12 factor levels)?

I am recoding the values to the default value (1st in the order of dummy's).
But I am not sure if this is the correct approach if I want to force
coefficients to be specific values.

Thanks for your help.

Regards,
Danda

[[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] kernlab's ksvm method freeze

2009-11-29 Thread Uwe Ligges

I just tried

ksvm(kernel="matrix", kernelMatrix, trainingDataYs, type="C-svc", 
cross=10, C=2)


several times on both workspaces and both returned some results after a 
couple of seconds under the same versions (R version 2.10.0 and kernlab 
0.9-9.) under Windows XP.


There mist be something else going on...

Best wishes,
Uwe Ligges





Heiko Strathmann wrote:

Hello again,

the freeze seems to depend on the kernel matrix.
With another kernel matrix of similiar size, gernerated with the same
kernel, but on another dataset, there is no freeze.

I have put a workspace with the working matrix and one with the freezing
matrix online for testing (see old email)
http://www-stud.uni-due.de/~sfhestra/

In my eyes this behavior is really strange, and i have no clue, what to
do to solve this.

Regards,
Heiko Strathmann

Am Sonntag, den 29.11.2009, 14:21 +0100 schrieb Heiko Strathmann:

Hello,

I am using kernlab to do some binary classification on aminoacid
strings.

I am using a custom kernel, so i use the kernel="matrix" option of the
ksvm method.

My (normalized) kernel matrix is of size 1309*1309, my results vector
has the same length.

I am using C-svc.

My kernlab call is something similiar to this:

ksvm(kernel="matrix", kernelMatrix, trainingDataYs, type="C-svc",
cross=10, C=2)

To this point, everything works fine.

But now, i want to do a search for a good C Parameter, so I call the
ksvm method multiple times in a loop, with changing parameters.
This loop freezes after a few iterations.


The following simple example also freezes after few iterations (the
number varies). See that the ksvm call is always the same in every
iteration:

for (i in c(1:20)) {
print(i)
ksvm(kernel="matrix", kernelMatrix, trainingDataYs,
type="C-svc",
cross=10, C=2)
}


Does anybody have an idea what causes this? I am new to R and kernlab,
perhaps i missed something?

I put my workspace online, which contains the kernel matrix and the
training labels. Simply load workspace, kernlab library and paste the
example code to reproduce:
http://www-stud.uni-due.de/~sfhestra/

I am using R version 2.10.0 and kernlab 0.9-9.

Thanks for your help!

Regards,
Heiko Strathmann




__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] column of dates into time series

2009-11-29 Thread David Winsemius
How about a representation of the data that one could so something  
with? By that I mean either by the "dump" method described in the  
Posting Guide or by using dput:

> ttt <- c(1,2)

> dput(ttt)
c(1, 2)

> dump("ttt", stdout() )
ttt <-
c(1, 2)

Did you honestly expect anyone in their right mind to reassemble that  
data from the console text output???


On Nov 29, 2009, at 10:46 AM, DispersionMap wrote:



Thanks again David,

Heres what happened:


Weeks<-summary(cut(data$Raised.Date, breaks="weeks"))
Weeks

2007-12-17 2009-01-05 2008-06-09 2008-12-08 2009-02-09 2008-12-01
  370342333317308298
2008-05-12 2009-02-16 2007-01-22 2008-06-02 2007-01-29 2008-05-19
  289269265257254253
2007-06-11 2008-06-16 2008-05-26 2008-06-23 2008-11-03 2009-01-12
  252249243243239239
2008-07-21 2007-02-05 2008-02-18 2008-07-14 2008-01-14 2008-10-27
  236234233232230230
2007-12-10 2008-03-17 2008-08-04 2008-11-24 2006-12-18 2007-11-26
  229229229228227226
2007-11-12 2006-11-06 2007-06-25 2006-04-03 2008-01-07 2006-04-10
  225222218217216215
2008-07-28 2006-05-08 2006-06-05 2009-02-23 2007-10-22 2007-02-19
  215214214214212211
2008-06-30 2009-02-02 2007-06-04 2007-12-03 2006-11-13 2007-09-03
  209209208207205205
2006-08-28 2008-07-07 2007-05-14 2006-08-14 2007-04-16 2006-07-31
  204204203202202201
2008-12-15 2006-09-11 2006-06-12 2008-01-21 2008-04-07 2009-01-26
  200199197197197197
2008-02-11 2007-04-02 2007-04-09 2008-04-21 2006-08-07 2007-11-19
  195194194194193193
2008-04-14 2008-05-05 2006-07-24 2007-05-21 2006-06-19 2006-10-09
  193193192191190190
2007-02-12 2007-03-26 2007-07-09 2007-11-05 2008-02-25 2008-09-08
  190189189189189189
2009-08-10 2008-09-15 2009-06-08 2006-05-15 2007-07-02 2009-06-01
  189188188187187186
2008-11-17 2006-06-26 2009-06-29 2007-08-06 2007-08-13 2009-01-19
  183182182181180180
2009-07-13 2006-04-17 2007-03-05 2007-12-24 2006-10-16 2008-08-11
  180179179179178178
2006-05-29 2006-11-27 2007-10-29(Other)
  177177177  13091


As you can see its come out a little disorderly though.
I have to plot the number of events under each date in a time series.

How do i order the dates and their counts?


Well, you don't really have dates anymore, do you? You have week  
numbers with labels that look like dates. So ordering them is a piece  
of cake given the laws of mathematics.


Weeks[order(Weeks)]  #untested... no reproducible data

 Aggregating them into counts can be done with  various functions,  
the most basic of which is table:


table(Weeks)

--
David.








David Winsemius wrote:



On Nov 29, 2009, at 7:52 AM, Linlin Yan wrote:


There is no year() function. Maybe you can try format() instead.

On Sun, Nov 29, 2009 at 8:44 PM, DispersionMap 
wrote:

i have a column of dates in this format:

data[,"Raised.Date"] <- as.Date(data[,"Raised.Date"], "%d/%m/%Y");
data[1:10,"Raised.Date"]
[1] "2006-07-07" "2006-07-07" "2006-04-03" "2006-04-03"  
"2006-04-03"

"2006-04-03" "2006-04-03" "2006-04-03" "2006-04-03" "2006-04-03"

I can turn them into months like this...

Month<-months(data[,"Raised.Date"])
Month[1:10]
[1] "July"  "July"  "April" "April" "April" "April" "April" "April"
"April"
"April"


But i also want to turn them into years (and also weeks later on),
so tried
this...


library(chron)
?cut.dates

The argument breaks has several options including one of  c("days",
"weeks", "months", "year")


dts <- Sys.Date() - 1:20



cut(dts, breaks="weeks")

 [1] 2009-11-23 2009-11-23 2009-11-23 2009-11-23 2009-11-23
2009-11-23 2009-11-16 2009-11-16 2009-11-16 2009-11-16
[11] 2009-11-16 2009-11-16 2009-11-16 2009-11-09 2009-11-09  
2009-11-09

2009-11-09 2009-11-09 2009-11-09 2009-11-09
Levels: 2009-11-09 2009-11-16 2009-11-23

I was a bit puzzled when I tried cut.dates as the function which
throws a function not found error.




Year<-year(data[,"Raised.Date"])
Error: could not find function "year"





David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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://n4.nabble.

Re: [R] t-criterion calculation using means and SE

2009-11-29 Thread Uwe Ligges



Антон Морковин wrote:

Dear all,

is there any functions which allow to calculate Student t-criterion using 
means, their SE and sample size? I've seek for, but bulit-in t-criterion works 
only with initial sample...




Not that I know, but then, you can easily calculate the t statistics in 
a one line function and directly compare the values with the quantiles 
of the distribution.


Best wishes,
Uwe Ligges




Best regards,

A.Morkovin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] R 2.10 Line Type Issue...

2009-11-29 Thread Uwe Ligges



David B. Thompson, Ph.D., P.E., D.WRE, CFM wrote:


Morning folks (at least here on the western side of the U.S.)...

This morning I constructed a contour plot of some bivariate 
distributions I'm working with. When I attempted to add a second contour 
to the plot using a dashed line (lty=2), R immediately went off to la-la 
land, requiring a force-quit. I finally tied the problem down to this 
statement:


contour(u,v,ci,levels=c(0.30),add=TRUE,lty=2)



Please specify u, v, ci in order to make your example reproducible for us.

Thanks,
Uwe Ligges



I tried specifying lty="dash" as well without any change. The plot works 
with no lty specification (but produces a solid line, of course).


In researching the issue, I learned that the demo, "demo(graphics)", 
should produce a variety of lines on the first plot. On my system, the 
first plot is completely blank.


My system: PowerMac dual-G5, Leopard 10.5.8, R 2.10 fresh install. I 
attempted re-installing with no change.


Any ideas?

Thanks...

-=d

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Iteration idioms & laziness

2009-11-29 Thread Uwe Ligges



Alexander Søndergaard wrote:

Hi all,

I'm new to R. Having a functional background, I was wondering what's
the idiomatic way to iterate. It seems that for loops are the default
given there's no tail-call optimization.

I'm curious to know whether there is a way to transform the following
toy snippet into something that doesn't eat up gigabytes of memory
(like it's for loop counterpart) using laziness:





Reduce('+', seq(1,1e6))



In this case

  sum(as.numeric(seq(1, 1e6)))

or according to Gauss

  1e6 * (1e6+1) / 2

but for more complicated problems it might be sensible to go the loop 
way ...


Uwe Ligges




Thanks!

Best regards,
A.S.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] KhmaladzeTest in quantreg

2009-11-29 Thread antonella.cann...@virgilio.it
 Hi,
I've implemented the KhmaladzeTest for my linear quantile regression model for 
the location-scale shift hypotesis as follow:

>formula=r ~ div + pe + por
>Ktest=KhmaladzeTest(formula,nullH="location-scale")

> Ktest
$nullH
[1] "location-scale"

$Tn
[1] 2.125804

$THn
div pe   por 
 0.7972984  1.4432325  0.7107914 

attr(,"class")


Now I have to compare the number 2.125804 with the critical values that I found 
in Koenker and Xiao (2002) which are:
 - 1% critical value 5.350
 - 5% critical value 4.523

So I accept the null.

But if I carry out the test for the location shift hypotesis 

the result is:

$Tn
[1] 3.178942

and I accept the null again! How is it possible??? Is there something wrong in 
my estimation?

Thank you for your help!

Antonella Cannito

 
[[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] How to z-standardize for subgroups?

2009-11-29 Thread Jorge Ivan Velez
Hi Karsten,

Let me assume your data is called d. If I understood what you are trying to
do, the following might help:

res <- apply(d, 2, tapply, d$group, scale)
res

See ?apply, ?tapply and ?scale for more information.

HTH,
Jorge


On Sun, Nov 29, 2009 at 10:41 AM, Karsten Wolf <> wrote:

> Hi folks,
> I have a dataframe df.vars with the follwing structure:
>
>
> var1   var2   var3   group
>
> Group is a factor.
>
> Now I want to standardize the vars 1-3 (actually - there are many more) by
> class, so I define
>
> z.mean.sd <- function(data){
>return.values <- (data  - mean(data)) / (sd(data))
>return(return.values)
> }
>
> now I can call for each var
>
> z.var1 <- by(df.vars$var1, group, z.mean.sd)
>
> which gives me the standardised data for each subgroup in a list with the
> subgroups
>
> z.var1 <- unlist(z.var1)
>
> then gives me the z-standardised data for var1 in one vector. Great!
>
> Now I would like to do this for the whole dataframe, but probably I am not
> thinking vectorwise enough.
>
> z.df.vars <- by(df.vars, group, z.mean.sd)
>
> does not work. I banged my head on other solutions trying out sapply and
> tapply, but did not succeed. Do I need to loop and put everything together
> by hand? But I want to keep the columnnames in the vector…
>
> -karsten
>
>
>
> -
> Karsten D. Wolf
> Didactical Design of Interactive
> Learning Environments
> Universität Bremen - Fachbereich 12
> web: http://www.ifeb.uni-bremen.de/wolf/
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] column of dates into time series

2009-11-29 Thread DispersionMap

Thanks again David,

Heres what happened:

> Weeks<-summary(cut(data$Raised.Date, breaks="weeks"))
> Weeks
2007-12-17 2009-01-05 2008-06-09 2008-12-08 2009-02-09 2008-12-01 
   370342333317308298 
2008-05-12 2009-02-16 2007-01-22 2008-06-02 2007-01-29 2008-05-19 
   289269265257254253 
2007-06-11 2008-06-16 2008-05-26 2008-06-23 2008-11-03 2009-01-12 
   252249243243239239 
2008-07-21 2007-02-05 2008-02-18 2008-07-14 2008-01-14 2008-10-27 
   236234233232230230 
2007-12-10 2008-03-17 2008-08-04 2008-11-24 2006-12-18 2007-11-26 
   229229229228227226 
2007-11-12 2006-11-06 2007-06-25 2006-04-03 2008-01-07 2006-04-10 
   225222218217216215 
2008-07-28 2006-05-08 2006-06-05 2009-02-23 2007-10-22 2007-02-19 
   215214214214212211 
2008-06-30 2009-02-02 2007-06-04 2007-12-03 2006-11-13 2007-09-03 
   209209208207205205 
2006-08-28 2008-07-07 2007-05-14 2006-08-14 2007-04-16 2006-07-31 
   204204203202202201 
2008-12-15 2006-09-11 2006-06-12 2008-01-21 2008-04-07 2009-01-26 
   200199197197197197 
2008-02-11 2007-04-02 2007-04-09 2008-04-21 2006-08-07 2007-11-19 
   195194194194193193 
2008-04-14 2008-05-05 2006-07-24 2007-05-21 2006-06-19 2006-10-09 
   193193192191190190 
2007-02-12 2007-03-26 2007-07-09 2007-11-05 2008-02-25 2008-09-08 
   190189189189189189 
2009-08-10 2008-09-15 2009-06-08 2006-05-15 2007-07-02 2009-06-01 
   189188188187187186 
2008-11-17 2006-06-26 2009-06-29 2007-08-06 2007-08-13 2009-01-19 
   183182182181180180 
2009-07-13 2006-04-17 2007-03-05 2007-12-24 2006-10-16 2008-08-11 
   180179179179178178 
2006-05-29 2006-11-27 2007-10-29(Other) 
   177177177  13091


As you can see its come out a little disorderly though.
I have to plot the number of events under each date in a time series.

How do i order the dates and their counts?






David Winsemius wrote:
> 
> 
> On Nov 29, 2009, at 7:52 AM, Linlin Yan wrote:
> 
>> There is no year() function. Maybe you can try format() instead.
>>
>> On Sun, Nov 29, 2009 at 8:44 PM, DispersionMap > > wrote:
>>>
>>> i have a column of dates in this format:
>>>
>>> data[,"Raised.Date"] <- as.Date(data[,"Raised.Date"], "%d/%m/%Y");
>>> data[1:10,"Raised.Date"]
>>> [1] "2006-07-07" "2006-07-07" "2006-04-03" "2006-04-03" "2006-04-03"
>>> "2006-04-03" "2006-04-03" "2006-04-03" "2006-04-03" "2006-04-03"
>>>
>>> I can turn them into months like this...
>>>
>>> Month<-months(data[,"Raised.Date"])
>>> Month[1:10]
>>> [1] "July"  "July"  "April" "April" "April" "April" "April" "April"  
>>> "April"
>>> "April"
>>>
>>>
>>> But i also want to turn them into years (and also weeks later on),  
>>> so tried
>>> this...
> 
> library(chron)
> ?cut.dates
> 
> The argument breaks has several options including one of  c("days",  
> "weeks", "months", "year")
> 
>  > dts <- Sys.Date() - 1:20
> 
>  > cut(dts, breaks="weeks")
>   [1] 2009-11-23 2009-11-23 2009-11-23 2009-11-23 2009-11-23  
> 2009-11-23 2009-11-16 2009-11-16 2009-11-16 2009-11-16
> [11] 2009-11-16 2009-11-16 2009-11-16 2009-11-09 2009-11-09 2009-11-09  
> 2009-11-09 2009-11-09 2009-11-09 2009-11-09
> Levels: 2009-11-09 2009-11-16 2009-11-23
> 
> I was a bit puzzled when I tried cut.dates as the function which  
> throws a function not found error.
> 
> 
>>>
>>> Year<-year(data[,"Raised.Date"])
>>> Error: could not find function "year"
>>
> 
> 
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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://n4.nabble.com/column-of-dates-into-time-series-tp930699p930744.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] How to z-standardize for subgroups?

2009-11-29 Thread Karsten Wolf

Hi folks,
I have a dataframe df.vars with the follwing structure:


var1   var2   var3   group

Group is a factor.

Now I want to standardize the vars 1-3 (actually - there are many  
more) by class, so I define


z.mean.sd <- function(data){
return.values <- (data  - mean(data)) / (sd(data))
return(return.values)
}

now I can call for each var

z.var1 <- by(df.vars$var1, group, z.mean.sd)

which gives me the standardised data for each subgroup in a list with  
the subgroups


z.var1 <- unlist(z.var1)

then gives me the z-standardised data for var1 in one vector. Great!

Now I would like to do this for the whole dataframe, but probably I am  
not thinking vectorwise enough.


z.df.vars <- by(df.vars, group, z.mean.sd)

does not work. I banged my head on other solutions trying out sapply  
and tapply, but did not succeed. Do I need to loop and put everything  
together by hand? But I want to keep the columnnames in the vector…


-karsten


-
Karsten D. Wolf
Didactical Design of Interactive
Learning Environments
Universität Bremen - Fachbereich 12
web: http://www.ifeb.uni-bremen.de/wolf/

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


Re: [R] Plotting observed vs. Predicted values, change of symbols

2009-11-29 Thread David Winsemius

On Nov 29, 2009, at 10:09 AM, oscar linares wrote:

> Dear David,
>
> You are correct, I had a bug, here it is fixed. Note the times vector.
>
> # Need upright in same plots (e.g., dashed line)
> times <- seq(0,20, len=100)
> par(cex.lab=1.2,cex.axis=1.3)
>
> par(mfrow=c(2,1))
> plot(c(datasu$concsu, dataup$concup) ~ c(datasu$time, dataup$time),  
> xlab = "Time (minutes)",
>  ylab = "3H-NE (dpm/ml)", main="3H-NE Post-infusion Plasma  
> Disappearance Curves", ylim=c(0,1000),cex=1.25, pch=16,col=1)
>
> lines(times, predictionssu(fit.wt.su, times))
> lines(times, predictionsup(fit.wt.up, times), lty = "dashed")
>
> plot(c(datasu$concsu, dataup$concup) ~ c(datasu$time, dataup$time),  
> xlab = "Time (minutes)",
>  ylab = "3H-NE (dpm/ml)", log = "y", ylim=c(1,1000),cex=1.25,  
> pch=16,col=1)
>
> lines(times, predictionssu(fit.wt.su, times))
> lines(times, predictionsup(fit.wt.up, times), lty = "dashed")
>

So the plotting section with the requested modifications for the  
plotting character parameter would be:

# plot observed and predicted values supine and upright in
# each plot type (linear and smi-log)

# Need upright in same plots (e.g., dashed line)
par(cex.lab=1.2,cex.axis=1.3)
times <- seq(0,20, len=100)
par(cex.lab=1.2,cex.axis=1.3)
par(mfrow=c(2,1))
plot(c(datasu$concsu, dataup$concup) ~ c(datasu$time, dataup$time),  
xlab =
"Time (minutes)",
 ylab = "3H-NE (dpm/ml)", main="3H-NE Post-infusion Plasma  
Disappearance
Curves", ylim=c(0,1000),cex=1.25, pch=c(rep(2,length(datasu$concsu)),  
rep(17,length(datasu$concsu)) ), col=1)

lines(times, predictionssu(fit.wt.su, times))
lines(times, predictionsup(fit.wt.up, times), lty = "dashed")

plot(c(datasu$concsu, dataup$concup) ~ c(datasu$time, dataup$time),  
xlab =
"Time (minutes)",
 ylab = "3H-NE (dpm/ml)", log = "y", ylim=c(1,1000),cex=1.25,
pch=c(rep(2,length(datasu$concsu)), rep(17,length(datasu 
$concsu)) ),col=1);lines(times, predictionssu(fit.wt.su, times))
lines(times, predictionsup(fit.wt.up, times), lty = "dashed")

>
>
> On Sun, Nov 29, 2009 at 9:23 AM, David Winsemius  > wrote:
>
> On Nov 29, 2009, at 8:51 AM, oscar linares wrote:
>
> Dear Wiz[R]ds,
>
> I am deeply grateful for the help from Duncan Murdoch, Gray Calhoun,  
> and
> others. We are almost there. For whatever reason, I can't change the  
> symbol
> from a circle to a triangle in the upright posture plots.
>
> Any ideas? I have
> included the problem in full.
>
> # tritiated (3H)-Norepinephrine(NE) disappearance from plasma
> # concentrations supine and upright
> # supine
> datasu <- data.frame(
> time=c(0,1,2,4,6,8,10,15,20),
> concsu=c(385.61,265.88,173.87,99.47,66.7,55.27,48.29,39.85,40.66)
> )
> # upright
> dataup <- data.frame(
> time=c(0,1,2,4,6,8,10,15,20),
> concup=c(767.27,529.03,328.13,225.94,164,151.1,132.02,121.15,70.88)
> )
>
> # fit supine
> wt.su<- function(resp, time,A1,a1,A2,a2)
> {
>   pred <- A1*exp(-a1*time)+A2*exp(-a2*time)
>   (resp - pred) / sqrt(pred)
> }
>
> fit.wt.su <- nls( ~ wt.su(concsu, time,A1,a1,A2,a2), data=datasu,
> start=list(A1=500,a1=1,A2=100,a2=0.2),
> trace = TRUE)
>
> summary(fit.wt.su)
>
> # fit upright
> wt.up<- function(resp, time,B1,b1,B2,b2)
> {
>   pred <- B1*exp(-b1*time)+B2*exp(-b2*time)
>   (resp - pred) / sqrt(pred)
> }
>
> fit.wt.up <- nls( ~ wt.up(concup, time,B1,b1,B2,b2), data=dataup,
> start=list(B1=500,b1=1,B2=100,b2=0.1),
> trace = TRUE)
>
> summary(fit.wt.up)
>
> # Function that returns predicted values and graphics
> # by Duncan Murdoch
>
> predictionssu <- function(fit, time) {
>  params <- summary(fit)$coefficients[, 1]
>  A1 <- params["A1"]
>  a1 <- params["a1"]
>  A2 <- params["A2"]
>  a2 <- params["a2"]
>
>  A1*exp(-a1*time)+A2*exp(-a2*time)
> }
>
> predictionsup <- function(fit, time) {
>  params <- summary(fit)$coefficients[, 1]
>  B1 <- params["B1"]
>  b1 <- params["b1"]
>  B2 <- params["B2"]
>  b2 <- params["b2"]
>
>  B1*exp(-b1*time)+B2*exp(-b2*time)
> }
>
> # plot observed and predicted values supine and upright in
> # each plot type (linear and smi-log)
>
> # Need upright in same plots (e.g., dashed line)
> par(cex.lab=1.2,cex.axis=1.3)
>
> par(mfrow=c(2,1))
> plot(c(datasu$concsu, dataup$concup) ~ c(datasu$time, dataup$time),  
> xlab =
> "Time (minutes)",
>ylab = "3H-NE (dpm/ml)", main="3H-NE Post-infusion Plasma  
> Disappearance
> Curves", ylim=c(0,1000),cex=1.25, pch=16,col=1)
>
> lines(times, predictionssu(fit.wt.su, times))
>
> I don't think this is a complete presentation. My system thinks  
> "times" is a function from the chron package, so either you have a  
> numeric object named "times" or you are putting in "times" when you  
> meant "time". I did try dropping the "s" but still get the same   
> error:
> lines(time, predictionssu(fit.wt.su, time))
> Error in -a1 * time : non-numeric argument to binary operator
>
> lines(times, predictionsup(fit.wt.up, times), lty = "dashed")
>
> plot(c(datasu$concsu, dataup$concup) ~ c(datasu$tim

Re: [R] R on Large Data Sets (again)

2009-11-29 Thread Jason Morgan
On 2009.11.29 14:24:40, Prof Brian Ripley wrote:
> >> Windows 64-bit can certainly handle large memory spaces, but unless
> >> something has changed recently it my understanding Revolution
> >> Computing's 64-bit is the only 64-bit version of R available for
> >> Windows (due to the unavailability of adequate open source compilers
> >> for 64-bit Windows).  So 64-bit R will need to be Revolution's
> >> solution or a non-Windows platform.
> 
> Or use a commercial Windows compiler.
> 
> > It appears that GNU does have a project that has had some success at
> > compiling 64 bit Windows applications:
> >
> > http://mingw-w64.sourceforge.net/
> 
> Well, some interesed people have a project to port GCC and binutils: 
> as far as I am aware that is not an official GNU project.
> 
> > Not sure if all of the pieces are there for an R build, though.
> 
> You are welcome to show us how to do it (on the R-devel list): several 
> people have spent man months attempting this (including submitting 
> many patches to that project), and the rw-FAQ did tell you do so in 
> http://cran.r-project.org/bin/windows/base/rw-FAQ.html#How-can-I-compile-R-from-source_003f

Not a chance :)

I got away from Windows 10 years ago for exactly these reasons. I was
just trying help point a poor guy in the right direction.


-- 
Jason W. Morgan
Graduate Student
Department of Political Science
*The Ohio State University*
154 North Oval Mall
Columbus, Ohio 43210

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Removing objects from a list based on nrow

2009-11-29 Thread Linlin Yan
Thank Jim! You are right. I didn't notice the case of none of rows
match the condition.

On Sun, Nov 29, 2009 at 10:10 PM, jim holtman  wrote:
> One thing to be careful of is if no dataframe have less than 3 rows:
>
>> df1<-data.frame(letter=c("A","B","C","D","E"),number=c(1,2,3,4,5))
>> df2<-data.frame(letter=c("A","B"),number=c(1,2))
>> df3<-data.frame(letter=c("A","B","C","D","E"),number=c(1,2,3,4,5))
>> df4<-data.frame(letter=c("A","B","C","D","E"),number=c(1,2,3,4,5))
>>
>> lst<-list(df1,df3,df4)
>> lst
> [[1]]
>  letter number
> 1      A      1
> 2      B      2
> 3      C      3
> 4      D      4
> 5      E      5
>
> [[2]]
>  letter number
> 1      A      1
> 2      B      2
> 3      C      3
> 4      D      4
> 5      E      5
>
> [[3]]
>  letter number
> 1      A      1
> 2      B      2
> 3      C      3
> 4      D      4
> 5      E      5
>
>> lst[-which(sapply(lst, nrow) < 3)]
> list()
>>
>
> Notice the list is now empty.  Instead use:
>
>> lst[sapply(lst, nrow) >=3]
> [[1]]
>  letter number
> 1      A      1
> 2      B      2
> 3      C      3
> 4      D      4
> 5      E      5
>
> [[2]]
>  letter number
> 1      A      1
> 2      B      2
> 3      C      3
> 4      D      4
> 5      E      5
>
> [[3]]
>  letter number
> 1      A      1
> 2      B      2
> 3      C      3
> 4      D      4
> 5      E      5
>
>
> On Sun, Nov 29, 2009 at 3:43 AM, Linlin Yan  wrote:
>> Try these:
>> sapply(lst, nrow) # get row numbers
>> which(sapply(lst, nrow) < 3) # get the index of rows which has less than 3 
>> rows
>> lst <- lst[-which(sapply(lst, nrow) < 3)] # remove the rows from the list
>>
>> On Sun, Nov 29, 2009 at 4:36 PM, Tim Clark  wrote:
>>> Dear List,
>>>
>>> I have a list containing data frames of various numbers of rows.  I need to 
>>> remove any data frame that has less than 3 rows.  For example:
>>>
>>> df1<-data.frame(letter=c("A","B","C","D","E"),number=c(1,2,3,4,5))
>>> df2<-data.frame(letter=c("A","B"),number=c(1,2))
>>> df3<-data.frame(letter=c("A","B","C","D","E"),number=c(1,2,3,4,5))
>>> df4<-data.frame(letter=c("A","B","C","D","E"),number=c(1,2,3,4,5))
>>>
>>> lst<-list(df1,df2,df3,df4)
>>>
>>> How can I determine that the second object (df2) has less than 3 rows and 
>>> remove it from the list?
>>>
>>> Thanks!
>>>
>>> Tim
>>>
>>>
>>>
>>>
>>> Tim Clark
>>> Department of Zoology
>>> University of Hawaii
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
>
> What is the problem that 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] Plotting observed vs. Predicted values, change of symbols

2009-11-29 Thread David Winsemius


On Nov 29, 2009, at 8:51 AM, oscar linares wrote:


Dear Wiz[R]ds,

I am deeply grateful for the help from Duncan Murdoch, Gray Calhoun,  
and
others. We are almost there. For whatever reason, I can't change the  
symbol
from a circle to a triangle in the upright posture plots. Any ideas?  
I have

included the problem in full.

# tritiated (3H)-Norepinephrine(NE) disappearance from plasma
# concentrations supine and upright
# supine
datasu <- data.frame(
time=c(0,1,2,4,6,8,10,15,20),
concsu=c(385.61,265.88,173.87,99.47,66.7,55.27,48.29,39.85,40.66)
)
# upright
dataup <- data.frame(
time=c(0,1,2,4,6,8,10,15,20),
concup=c(767.27,529.03,328.13,225.94,164,151.1,132.02,121.15,70.88)
)

# fit supine
wt.su<- function(resp, time,A1,a1,A2,a2)
{
   pred <- A1*exp(-a1*time)+A2*exp(-a2*time)
   (resp - pred) / sqrt(pred)
}

fit.wt.su <- nls( ~ wt.su(concsu, time,A1,a1,A2,a2), data=datasu,
 start=list(A1=500,a1=1,A2=100,a2=0.2),
 trace = TRUE)

summary(fit.wt.su)

# fit upright
wt.up<- function(resp, time,B1,b1,B2,b2)
{
   pred <- B1*exp(-b1*time)+B2*exp(-b2*time)
   (resp - pred) / sqrt(pred)
}

fit.wt.up <- nls( ~ wt.up(concup, time,B1,b1,B2,b2), data=dataup,
 start=list(B1=500,b1=1,B2=100,b2=0.1),
 trace = TRUE)

summary(fit.wt.up)

# Function that returns predicted values and graphics
# by Duncan Murdoch

predictionssu <- function(fit, time) {
 params <- summary(fit)$coefficients[, 1]
 A1 <- params["A1"]
 a1 <- params["a1"]
 A2 <- params["A2"]
 a2 <- params["a2"]

 A1*exp(-a1*time)+A2*exp(-a2*time)
}

predictionsup <- function(fit, time) {
 params <- summary(fit)$coefficients[, 1]
 B1 <- params["B1"]
 b1 <- params["b1"]
 B2 <- params["B2"]
 b2 <- params["b2"]

 B1*exp(-b1*time)+B2*exp(-b2*time)
}

# plot observed and predicted values supine and upright in
# each plot type (linear and smi-log)

# Need upright in same plots (e.g., dashed line)
par(cex.lab=1.2,cex.axis=1.3)

par(mfrow=c(2,1))
plot(c(datasu$concsu, dataup$concup) ~ c(datasu$time, dataup$time),  
xlab =

"Time (minutes)",
ylab = "3H-NE (dpm/ml)", main="3H-NE Post-infusion Plasma  
Disappearance

Curves", ylim=c(0,1000),cex=1.25, pch=16,col=1)


Try:
  ..., pch=c(rep(2,length(datasu$concsu)), rep(17,length(datasu 
$concsu)) ), ...


(open triangles and filled triangles)




lines(times, predictionssu(fit.wt.su, times))
lines(times, predictionsup(fit.wt.up, times), lty = "dashed")

plot(c(datasu$concsu, dataup$concup) ~ c(datasu$time, dataup$time),  
xlab =

"Time (minutes)",
ylab = "3H-NE (dpm/ml)", log = "y", ylim=c(1,1000),cex=1.25,
pch=16,col=1)

lines(times, predictionssu(fit.wt.su, times))
lines(times, predictionsup(fit.wt.up, times), lty = "dashed")

Deeply grateful in advance...
--
Oscar
Oscar A. Linares, MD
Translational Medicine Unit
LaPlaisance Bay, Bolles Harbor
Monroe, Michigan 48161

Department of Medicine,
University of Toledo College of Medicine
Toledo, OH 43606-3390

Department of Internal Medicine,
The Detroit Medical Center (DMC)
Harper University Hospital
Wayne State University School of Medicine
Detroit, Michigan 48201

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 on Large Data Sets (again)

2009-11-29 Thread Prof Brian Ripley

On Sun, 29 Nov 2009, Jason Morgan wrote:


On 2009.11.28 21:50:09, Daniel Nordlund wrote:

- Is a Unix-like platform a better option than win-64? Again, would
this solve my memory limitation problems?


Possibly, but Win64 should provide plenty of memory (I believe Windows 7
Ultimate can use up to 192 GB of memory). You just have to find the
system that can take that much... With Unix/Linux you can probably cut
back some overhead, and the memory management is most likely better, but
unless you need to go over 192GB of memory, you don't necessarily have
to move to a different platform.

~Jason


Windows 64-bit can certainly handle large memory spaces, but unless
something has changed recently it my understanding Revolution
Computing's 64-bit is the only 64-bit version of R available for
Windows (due to the unavailability of adequate open source compilers
for 64-bit Windows).  So 64-bit R will need to be Revolution's
solution or a non-Windows platform.


Or use a commercial Windows compiler.


It appears that GNU does have a project that has had some success at
compiling 64 bit Windows applications:

http://mingw-w64.sourceforge.net/


Well, some interesed people have a project to port GCC and binutils: 
as far as I am aware that is not an official GNU project.



Not sure if all of the pieces are there for an R build, though.


You are welcome to show us how to do it (on the R-devel list): several 
people have spent man months attempting this (including submitting 
many patches to that project), and the rw-FAQ did tell you do so in 
http://cran.r-project.org/bin/windows/base/rw-FAQ.html#How-can-I-compile-R-from-source_003f



--
Jason W. Morgan
Graduate Student
Department of Political Science
*The Ohio State University*
154 North Oval Mall
Columbus, Ohio 43210


--
Brian D. Ripley,  rip...@stats.ox.ac.uk
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] Plotting observed vs. Predicted values, change of symbols

2009-11-29 Thread David Winsemius


On Nov 29, 2009, at 8:51 AM, oscar linares wrote:


Dear Wiz[R]ds,

I am deeply grateful for the help from Duncan Murdoch, Gray Calhoun,  
and
others. We are almost there. For whatever reason, I can't change the  
symbol

from a circle to a triangle in the upright posture plots.



Any ideas? I have
included the problem in full.

# tritiated (3H)-Norepinephrine(NE) disappearance from plasma
# concentrations supine and upright
# supine
datasu <- data.frame(
time=c(0,1,2,4,6,8,10,15,20),
concsu=c(385.61,265.88,173.87,99.47,66.7,55.27,48.29,39.85,40.66)
)
# upright
dataup <- data.frame(
time=c(0,1,2,4,6,8,10,15,20),
concup=c(767.27,529.03,328.13,225.94,164,151.1,132.02,121.15,70.88)
)

# fit supine
wt.su<- function(resp, time,A1,a1,A2,a2)
{
   pred <- A1*exp(-a1*time)+A2*exp(-a2*time)
   (resp - pred) / sqrt(pred)
}

fit.wt.su <- nls( ~ wt.su(concsu, time,A1,a1,A2,a2), data=datasu,
 start=list(A1=500,a1=1,A2=100,a2=0.2),
 trace = TRUE)

summary(fit.wt.su)

# fit upright
wt.up<- function(resp, time,B1,b1,B2,b2)
{
   pred <- B1*exp(-b1*time)+B2*exp(-b2*time)
   (resp - pred) / sqrt(pred)
}

fit.wt.up <- nls( ~ wt.up(concup, time,B1,b1,B2,b2), data=dataup,
 start=list(B1=500,b1=1,B2=100,b2=0.1),
 trace = TRUE)

summary(fit.wt.up)

# Function that returns predicted values and graphics
# by Duncan Murdoch

predictionssu <- function(fit, time) {
 params <- summary(fit)$coefficients[, 1]
 A1 <- params["A1"]
 a1 <- params["a1"]
 A2 <- params["A2"]
 a2 <- params["a2"]

 A1*exp(-a1*time)+A2*exp(-a2*time)
}

predictionsup <- function(fit, time) {
 params <- summary(fit)$coefficients[, 1]
 B1 <- params["B1"]
 b1 <- params["b1"]
 B2 <- params["B2"]
 b2 <- params["b2"]

 B1*exp(-b1*time)+B2*exp(-b2*time)
}

# plot observed and predicted values supine and upright in
# each plot type (linear and smi-log)

# Need upright in same plots (e.g., dashed line)
par(cex.lab=1.2,cex.axis=1.3)

par(mfrow=c(2,1))
plot(c(datasu$concsu, dataup$concup) ~ c(datasu$time, dataup$time),  
xlab =

"Time (minutes)",
ylab = "3H-NE (dpm/ml)", main="3H-NE Post-infusion Plasma  
Disappearance

Curves", ylim=c(0,1000),cex=1.25, pch=16,col=1)

lines(times, predictionssu(fit.wt.su, times))


I don't think this is a complete presentation. My system thinks  
"times" is a function from the chron package, so either you have a  
numeric object named "times" or you are putting in "times" when you  
meant "time". I did try dropping the "s" but still get the same  error:

lines(time, predictionssu(fit.wt.su, time))
Error in -a1 * time : non-numeric argument to binary operator


lines(times, predictionsup(fit.wt.up, times), lty = "dashed")

plot(c(datasu$concsu, dataup$concup) ~ c(datasu$time, dataup$time),  
xlab =

"Time (minutes)",
ylab = "3H-NE (dpm/ml)", log = "y", ylim=c(1,1000),cex=1.25,
pch=16,col=1)

lines(times, predictionssu(fit.wt.su, times))
lines(times, predictionsup(fit.wt.up, times), lty = "dashed")

Deeply grateful in advance...
--
Oscar
Oscar A. Linares, MD
Translational Medicine Unit
LaPlaisance Bay, Bolles Harbor
Monroe, Michigan 48161

Department of Medicine,
University of Toledo College of Medicine
Toledo, OH 43606-3390

Department of Internal Medicine,
The Detroit Medical Center (DMC)
Harper University Hospital
Wayne State University School of Medicine
Detroit, Michigan 48201

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


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lm: eval(parse(text=)) works on one side y/x but not on both?

2009-11-29 Thread Gabor Grothendieck
By the way, if you really do want to create the formula anyways then:

   ix <- 1:2
   left <- paste(names(freeny)[ix], collapse = ",")
   fo <- as.formula(paste("cbind(", left, ") ~ ."))
   lm(fo, freeny)

or possibly replace last line with:

   eval(substitute(lm(fo, freeny))

which will cause the formula to appear in the lm output.


On Sun, Nov 29, 2009 at 9:05 AM, Gabor Grothendieck  wrote:

> Try this:
>
> ix <- 1:2
> lm(as.matrix(freeny[ix]) ~., freeny[-ix])
>
>
>
> On Sun, Nov 29, 2009 at 8:56 AM, Matthieu Stigler <
> matthieu.stig...@gmail.com> wrote:
>
>> Thanks for answering so fast!!
>>
>>>
>>>   lm(freeny)
>>>
>> :-)
>> Ok that's working for the one equation case :-) Was example case...
>>
>> But now I want to have not only first column of freeny on the left but
>> both first? And I don't know their names a priori...
>>
>> Thanks!
>>
>>>
>>> On Sun, Nov 29, 2009 at 8:49 AM, Matthieu Stigler <
>>> matthieu.stig...@gmail.com > wrote:
>>>
>>>Hi
>>>
>>>My goal is to do a (multiple) regression, just knowing that my Y
>>>variables will be the say k first variables of a matrix/data
>>>frame. I thought I should do it with eval(parse)) but encounter a
>>>strange problem.
>>>
>>>See:
>>>lm(y~.-y, data=freeny) #that's what I want to do in the one
>>>equation case
>>>#Problem is I don't know name of the variable... only that it is
>>>the first one...
>>>#so idea is to just take first name
>>>a<-colnames(freeny)
>>>#and then use eval(parse(text=a[1]))
>>>
>>>#it works if I replace y on either the left or right side:
>>>lm(eval(parse(text=a[1]))~.-y, data=freeny) #does the same
>>>lm(y~.-eval(parse(text=a[1])), data=freeny)
>>>
>>>#but not if I do this call twice:
>>>lm(eval(parse(text=a[1]))~.-eval(parse(text=a[1])), data=freeny)
>>>#variable I wanted to remove (y) ist still there
>>>
>>>Do you understand why I can call eval(parse) only once? Should I
>>>try a update workaround? Or have idea of any other solution? Maybe
>>>there is something much simpler I'm missing:-(
>>>
>>>Thanks a lot!!!
>>>
>>>Matthieu Stigler
>>>
>>>__
>>>R-help@r-project.org  mailing list
>>>
>>>https://stat.ethz.ch/mailman/listinfo/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] lm: eval(parse(text=)) works on one side y/x but not on both?

2009-11-29 Thread Matthieu Stigler

Gabor Grothendieck a écrit :

Try this:

ix <- 1:2
lm(as.matrix(freeny[ix]) ~., freeny[-ix])


clean and clever!!! Thanks a lot!! You really simplified the code!!!

Just for curiosity, do you see why parse(eval)) was not working twice in 
same formula?


thanks a lot!!

Matthieu


On Sun, Nov 29, 2009 at 8:56 AM, Matthieu Stigler 
mailto:matthieu.stig...@gmail.com>> wrote:


Thanks for answering so fast!!


  lm(freeny)

:-)
Ok that's working for the one equation case :-) Was example case...

But now I want to have not only first column of freeny on the left
but both first? And I don't know their names a priori...

Thanks!


On Sun, Nov 29, 2009 at 8:49 AM, Matthieu Stigler
mailto:matthieu.stig...@gmail.com>
>> wrote:

   Hi

   My goal is to do a (multiple) regression, just knowing that
my Y
   variables will be the say k first variables of a matrix/data
   frame. I thought I should do it with eval(parse)) but
encounter a
   strange problem.

   See:
   lm(y~.-y, data=freeny) #that's what I want to do in the one
   equation case
   #Problem is I don't know name of the variable... only that
it is
   the first one...
   #so idea is to just take first name
   a<-colnames(freeny)
   #and then use eval(parse(text=a[1]))

   #it works if I replace y on either the left or right side:
   lm(eval(parse(text=a[1]))~.-y, data=freeny) #does the same
   lm(y~.-eval(parse(text=a[1])), data=freeny)

   #but not if I do this call twice:
   lm(eval(parse(text=a[1]))~.-eval(parse(text=a[1])),
data=freeny)
   #variable I wanted to remove (y) ist still there

   Do you understand why I can call eval(parse) only once?
Should I
   try a update workaround? Or have idea of any other
solution? Maybe
   there is something much simpler I'm missing:-(

   Thanks a lot!!!

   Matthieu Stigler

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

   https://stat.ethz.ch/mailman/listinfo/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] Removing objects from a list based on nrow

2009-11-29 Thread jim holtman
One thing to be careful of is if no dataframe have less than 3 rows:

> df1<-data.frame(letter=c("A","B","C","D","E"),number=c(1,2,3,4,5))
> df2<-data.frame(letter=c("A","B"),number=c(1,2))
> df3<-data.frame(letter=c("A","B","C","D","E"),number=c(1,2,3,4,5))
> df4<-data.frame(letter=c("A","B","C","D","E"),number=c(1,2,3,4,5))
>
> lst<-list(df1,df3,df4)
> lst
[[1]]
  letter number
1  A  1
2  B  2
3  C  3
4  D  4
5  E  5

[[2]]
  letter number
1  A  1
2  B  2
3  C  3
4  D  4
5  E  5

[[3]]
  letter number
1  A  1
2  B  2
3  C  3
4  D  4
5  E  5

> lst[-which(sapply(lst, nrow) < 3)]
list()
>

Notice the list is now empty.  Instead use:

> lst[sapply(lst, nrow) >=3]
[[1]]
  letter number
1  A  1
2  B  2
3  C  3
4  D  4
5  E  5

[[2]]
  letter number
1  A  1
2  B  2
3  C  3
4  D  4
5  E  5

[[3]]
  letter number
1  A  1
2  B  2
3  C  3
4  D  4
5  E  5


On Sun, Nov 29, 2009 at 3:43 AM, Linlin Yan  wrote:
> Try these:
> sapply(lst, nrow) # get row numbers
> which(sapply(lst, nrow) < 3) # get the index of rows which has less than 3 
> rows
> lst <- lst[-which(sapply(lst, nrow) < 3)] # remove the rows from the list
>
> On Sun, Nov 29, 2009 at 4:36 PM, Tim Clark  wrote:
>> Dear List,
>>
>> I have a list containing data frames of various numbers of rows.  I need to 
>> remove any data frame that has less than 3 rows.  For example:
>>
>> df1<-data.frame(letter=c("A","B","C","D","E"),number=c(1,2,3,4,5))
>> df2<-data.frame(letter=c("A","B"),number=c(1,2))
>> df3<-data.frame(letter=c("A","B","C","D","E"),number=c(1,2,3,4,5))
>> df4<-data.frame(letter=c("A","B","C","D","E"),number=c(1,2,3,4,5))
>>
>> lst<-list(df1,df2,df3,df4)
>>
>> How can I determine that the second object (df2) has less than 3 rows and 
>> remove it from the list?
>>
>> Thanks!
>>
>> Tim
>>
>>
>>
>>
>> Tim Clark
>> Department of Zoology
>> University of Hawaii
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that 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] R on Large Data Sets (again)

2009-11-29 Thread Uwe Ligges



Jason Morgan wrote:

On 2009.11.28 21:50:09, Daniel Nordlund wrote:

- Is a Unix-like platform a better option than win-64? Again, would
this solve my memory limitation problems?

Possibly, but Win64 should provide plenty of memory (I believe Windows 7
Ultimate can use up to 192 GB of memory). You just have to find the
system that can take that much... With Unix/Linux you can probably cut
back some overhead, and the memory management is most likely better, but
unless you need to go over 192GB of memory, you don't necessarily have
to move to a different platform.

~Jason

Windows 64-bit can certainly handle large memory spaces, but unless
something has changed recently it my understanding Revolution
Computing's 64-bit is the only 64-bit version of R available for
Windows (due to the unavailability of adequate open source compilers
for 64-bit Windows).  So 64-bit R will need to be Revolution's
solution or a non-Windows platform.


It appears that GNU does have a project that has had some success at
compiling 64 bit Windows applications:

http://mingw-w64.sourceforge.net/

Not sure if all of the pieces are there for an R build, though.


Last time we tried, it was not sufficient.

Best wishes,
Uwe Ligges

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lm: eval(parse(text=)) works on one side y/x but not on both?

2009-11-29 Thread Gabor Grothendieck
Try this:

ix <- 1:2
lm(as.matrix(freeny[ix]) ~., freeny[-ix])


On Sun, Nov 29, 2009 at 8:56 AM, Matthieu Stigler <
matthieu.stig...@gmail.com> wrote:

> Thanks for answering so fast!!
>
>>
>>   lm(freeny)
>>
> :-)
> Ok that's working for the one equation case :-) Was example case...
>
> But now I want to have not only first column of freeny on the left but both
> first? And I don't know their names a priori...
>
> Thanks!
>
>>
>> On Sun, Nov 29, 2009 at 8:49 AM, Matthieu Stigler <
>> matthieu.stig...@gmail.com > wrote:
>>
>>Hi
>>
>>My goal is to do a (multiple) regression, just knowing that my Y
>>variables will be the say k first variables of a matrix/data
>>frame. I thought I should do it with eval(parse)) but encounter a
>>strange problem.
>>
>>See:
>>lm(y~.-y, data=freeny) #that's what I want to do in the one
>>equation case
>>#Problem is I don't know name of the variable... only that it is
>>the first one...
>>#so idea is to just take first name
>>a<-colnames(freeny)
>>#and then use eval(parse(text=a[1]))
>>
>>#it works if I replace y on either the left or right side:
>>lm(eval(parse(text=a[1]))~.-y, data=freeny) #does the same
>>lm(y~.-eval(parse(text=a[1])), data=freeny)
>>
>>#but not if I do this call twice:
>>lm(eval(parse(text=a[1]))~.-eval(parse(text=a[1])), data=freeny)
>>#variable I wanted to remove (y) ist still there
>>
>>Do you understand why I can call eval(parse) only once? Should I
>>try a update workaround? Or have idea of any other solution? Maybe
>>there is something much simpler I'm missing:-(
>>
>>Thanks a lot!!!
>>
>>Matthieu Stigler
>>
>>__
>>R-help@r-project.org  mailing list
>>
>>https://stat.ethz.ch/mailman/listinfo/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] GMM estimation

2009-11-29 Thread Arne Henningsen
Hi Zi!

On 11/28/09, Yi Du  wrote:
> I'd like to resort generalized methods of moment to estimate a regression
> model but I can't understand the help file of gmm package. If the regression
> model is y, the instrumental variable is x, how can I write the code?
>
> By the way, I use systemfit's 3sls with method3sls='GMM', but I can't get
> the suitable results.

The argument "method3sls" of systemfit is only relevant for
three-stage least-squares estimations (i.e. argument "method" is
"3SLS"). Currently, systemfit cannot estimate models by GMM.

Best,
Arne

-- 
Arne Henningsen
http://www.arne-henningsen.name

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 on Large Data Sets (again)

2009-11-29 Thread Jason Morgan
On 2009.11.28 21:50:09, Daniel Nordlund wrote:
> > > - Is a Unix-like platform a better option than win-64? Again, would
> > > this solve my memory limitation problems?
> > 
> > Possibly, but Win64 should provide plenty of memory (I believe Windows 7
> > Ultimate can use up to 192 GB of memory). You just have to find the
> > system that can take that much... With Unix/Linux you can probably cut
> > back some overhead, and the memory management is most likely better, but
> > unless you need to go over 192GB of memory, you don't necessarily have
> > to move to a different platform.
> > 
> > ~Jason
> 
> Windows 64-bit can certainly handle large memory spaces, but unless
> something has changed recently it my understanding Revolution
> Computing's 64-bit is the only 64-bit version of R available for
> Windows (due to the unavailability of adequate open source compilers
> for 64-bit Windows).  So 64-bit R will need to be Revolution's
> solution or a non-Windows platform.

It appears that GNU does have a project that has had some success at
compiling 64 bit Windows applications:

http://mingw-w64.sourceforge.net/

Not sure if all of the pieces are there for an R build, though.

-- 
Jason W. Morgan
Graduate Student
Department of Political Science
*The Ohio State University*
154 North Oval Mall
Columbus, Ohio 43210

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lm: eval(parse(text=)) works on one side y/x but not on both?

2009-11-29 Thread Matthieu Stigler

Thanks for answering so fast!!


   lm(freeny)

:-)
Ok that's working for the one equation case :-) Was example case...

But now I want to have not only first column of freeny on the left but 
both first? And I don't know their names a priori...


Thanks!


On Sun, Nov 29, 2009 at 8:49 AM, Matthieu Stigler 
mailto:matthieu.stig...@gmail.com>> wrote:


Hi

My goal is to do a (multiple) regression, just knowing that my Y
variables will be the say k first variables of a matrix/data
frame. I thought I should do it with eval(parse)) but encounter a
strange problem.

See:
lm(y~.-y, data=freeny) #that's what I want to do in the one
equation case
#Problem is I don't know name of the variable... only that it is
the first one...
#so idea is to just take first name
a<-colnames(freeny)
#and then use eval(parse(text=a[1]))

#it works if I replace y on either the left or right side:
lm(eval(parse(text=a[1]))~.-y, data=freeny) #does the same
lm(y~.-eval(parse(text=a[1])), data=freeny)

#but not if I do this call twice:
lm(eval(parse(text=a[1]))~.-eval(parse(text=a[1])), data=freeny)
#variable I wanted to remove (y) ist still there

Do you understand why I can call eval(parse) only once? Should I
try a update workaround? Or have idea of any other solution? Maybe
there is something much simpler I'm missing:-(

Thanks a lot!!!

Matthieu Stigler

__
R-help@r-project.org  mailing list
https://stat.ethz.ch/mailman/listinfo/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] R on Large Data Sets (again)

2009-11-29 Thread Duncan Murdoch

On 28/11/2009 6:53 PM, Lars Bishop wrote:

Dear R users,

I’ve search the R site for help on this topic but it is hard to find a
precise answer for my questions.

Which are the best options to overcome the RAM memory limitation problems
when using R on “large” data sets (such as 2 or 3 million records)?


There are several packages for handling datasets without keeping them in 
RAM:  bigmemory, ff, etc.  You may find that you need to write functions 
to handle your data a block at a time, or you may find they have already 
been written, e.g. biglm.  You can also keep your data in a database and 
just retrieve it a block at a time for processing.




-  Is the free available version of R (as opposed to the one
provided by REvolution Computing) compatible with a windows 64-bit machine?
And if I increase the RAM memory enough on win-64, would this virtually
solve my memory limitation problems?


It is compatible with Win64, but it is a 32 bit application.  It 
benefits from running on 64 bit Windows (because Windows can get out of 
the way and give it most of 4 GB to work in), but not as much as a true 
64 bit application.  So it probably doesn't solve your problem.




-  Is a Unix-like platform a better option than win-64? Again, would
this solve my memory limitation problems?


There are builds available for 64 bit Linux and MacOS (and maybe 
others); they'd likely help more than running 32 bit R in Win64.  I 
don't know how they compare to running Revolution's 64 bit R in Win64.


Duncan Murdoch





-  Any better option?
Thanks in advance for your help,
Lars.

[[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] lm: eval(parse(text=)) works on one side y/x but not on both?

2009-11-29 Thread Gabor Grothendieck
Try this:

   lm(freeny)

On Sun, Nov 29, 2009 at 8:49 AM, Matthieu Stigler <
matthieu.stig...@gmail.com> wrote:

> Hi
>
> My goal is to do a (multiple) regression, just knowing that my Y variables
> will be the say k first variables of a matrix/data frame. I thought I should
> do it with eval(parse)) but encounter a strange problem.
>
> See:
> lm(y~.-y, data=freeny) #that's what I want to do in the one equation case
> #Problem is I don't know name of the variable... only that it is the first
> one...
> #so idea is to just take first name
> a<-colnames(freeny)
> #and then use eval(parse(text=a[1]))
>
> #it works if I replace y on either the left or right side:
> lm(eval(parse(text=a[1]))~.-y, data=freeny) #does the same
> lm(y~.-eval(parse(text=a[1])), data=freeny)
>
> #but not if I do this call twice:
> lm(eval(parse(text=a[1]))~.-eval(parse(text=a[1])), data=freeny)
> #variable I wanted to remove (y) ist still there
>
> Do you understand why I can call eval(parse) only once? Should I try a
> update workaround? Or have idea of any other solution? Maybe there is
> something much simpler I'm missing:-(
>
> Thanks a lot!!!
>
> Matthieu Stigler
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] kernlab's ksvm method freeze

2009-11-29 Thread Heiko Strathmann
Hello again,

the freeze seems to depend on the kernel matrix.
With another kernel matrix of similiar size, gernerated with the same
kernel, but on another dataset, there is no freeze.

I have put a workspace with the working matrix and one with the freezing
matrix online for testing (see old email)
http://www-stud.uni-due.de/~sfhestra/

In my eyes this behavior is really strange, and i have no clue, what to
do to solve this.

Regards,
Heiko Strathmann

Am Sonntag, den 29.11.2009, 14:21 +0100 schrieb Heiko Strathmann:
> Hello,
> 
> I am using kernlab to do some binary classification on aminoacid
> strings.
> 
> I am using a custom kernel, so i use the kernel="matrix" option of the
> ksvm method.
> 
> My (normalized) kernel matrix is of size 1309*1309, my results vector
> has the same length.
> 
> I am using C-svc.
> 
> My kernlab call is something similiar to this:
> 
> ksvm(kernel="matrix", kernelMatrix, trainingDataYs, type="C-svc",
> cross=10, C=2)
> 
> To this point, everything works fine.
> 
> But now, i want to do a search for a good C Parameter, so I call the
> ksvm method multiple times in a loop, with changing parameters.
> This loop freezes after a few iterations.
> 
> 
> The following simple example also freezes after few iterations (the
> number varies). See that the ksvm call is always the same in every
> iteration:
> 
> for (i in c(1:20)) {
> print(i)
> ksvm(kernel="matrix", kernelMatrix, trainingDataYs,
> type="C-svc",
> cross=10, C=2)
> }
> 
> 
> Does anybody have an idea what causes this? I am new to R and kernlab,
> perhaps i missed something?
> 
> I put my workspace online, which contains the kernel matrix and the
> training labels. Simply load workspace, kernlab library and paste the
> example code to reproduce:
> http://www-stud.uni-due.de/~sfhestra/
> 
> I am using R version 2.10.0 and kernlab 0.9-9.
> 
> Thanks for your help!
> 
> Regards,
> Heiko Strathmann
> 
>

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


[R] Plotting observed vs. Predicted values, change of symbols

2009-11-29 Thread oscar linares
Dear Wiz[R]ds,

I am deeply grateful for the help from Duncan Murdoch, Gray Calhoun, and
others. We are almost there. For whatever reason, I can't change the symbol
from a circle to a triangle in the upright posture plots. Any ideas? I have
included the problem in full.

# tritiated (3H)-Norepinephrine(NE) disappearance from plasma
# concentrations supine and upright
# supine
datasu <- data.frame(
time=c(0,1,2,4,6,8,10,15,20),
concsu=c(385.61,265.88,173.87,99.47,66.7,55.27,48.29,39.85,40.66)
)
# upright
dataup <- data.frame(
time=c(0,1,2,4,6,8,10,15,20),
concup=c(767.27,529.03,328.13,225.94,164,151.1,132.02,121.15,70.88)
)

# fit supine
wt.su<- function(resp, time,A1,a1,A2,a2)
{
pred <- A1*exp(-a1*time)+A2*exp(-a2*time)
(resp - pred) / sqrt(pred)
}

fit.wt.su <- nls( ~ wt.su(concsu, time,A1,a1,A2,a2), data=datasu,
  start=list(A1=500,a1=1,A2=100,a2=0.2),
  trace = TRUE)

summary(fit.wt.su)

# fit upright
wt.up<- function(resp, time,B1,b1,B2,b2)
{
pred <- B1*exp(-b1*time)+B2*exp(-b2*time)
(resp - pred) / sqrt(pred)
}

fit.wt.up <- nls( ~ wt.up(concup, time,B1,b1,B2,b2), data=dataup,
  start=list(B1=500,b1=1,B2=100,b2=0.1),
  trace = TRUE)

summary(fit.wt.up)

# Function that returns predicted values and graphics
# by Duncan Murdoch

predictionssu <- function(fit, time) {
  params <- summary(fit)$coefficients[, 1]
  A1 <- params["A1"]
  a1 <- params["a1"]
  A2 <- params["A2"]
  a2 <- params["a2"]

  A1*exp(-a1*time)+A2*exp(-a2*time)
}

predictionsup <- function(fit, time) {
  params <- summary(fit)$coefficients[, 1]
  B1 <- params["B1"]
  b1 <- params["b1"]
  B2 <- params["B2"]
  b2 <- params["b2"]

  B1*exp(-b1*time)+B2*exp(-b2*time)
}

# plot observed and predicted values supine and upright in
# each plot type (linear and smi-log)

# Need upright in same plots (e.g., dashed line)
par(cex.lab=1.2,cex.axis=1.3)

par(mfrow=c(2,1))
plot(c(datasu$concsu, dataup$concup) ~ c(datasu$time, dataup$time), xlab =
"Time (minutes)",
 ylab = "3H-NE (dpm/ml)", main="3H-NE Post-infusion Plasma Disappearance
Curves", ylim=c(0,1000),cex=1.25, pch=16,col=1)

lines(times, predictionssu(fit.wt.su, times))
lines(times, predictionsup(fit.wt.up, times), lty = "dashed")

plot(c(datasu$concsu, dataup$concup) ~ c(datasu$time, dataup$time), xlab =
"Time (minutes)",
 ylab = "3H-NE (dpm/ml)", log = "y", ylim=c(1,1000),cex=1.25,
pch=16,col=1)

lines(times, predictionssu(fit.wt.su, times))
lines(times, predictionsup(fit.wt.up, times), lty = "dashed")

Deeply grateful in advance...
-- 
Oscar
Oscar A. Linares, MD
Translational Medicine Unit
LaPlaisance Bay, Bolles Harbor
Monroe, Michigan 48161

Department of Medicine,
University of Toledo College of Medicine
Toledo, OH 43606-3390

Department of Internal Medicine,
The Detroit Medical Center (DMC)
Harper University Hospital
Wayne State University School of Medicine
Detroit, Michigan 48201

[[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] lm: eval(parse(text=)) works on one side y/x but not on both?

2009-11-29 Thread Matthieu Stigler

Hi

My goal is to do a (multiple) regression, just knowing that my Y 
variables will be the say k first variables of a matrix/data frame. I 
thought I should do it with eval(parse)) but encounter a strange problem.


See:
lm(y~.-y, data=freeny) #that's what I want to do in the one equation case
#Problem is I don't know name of the variable... only that it is the 
first one...

#so idea is to just take first name
a<-colnames(freeny)
#and then use eval(parse(text=a[1]))

#it works if I replace y on either the left or right side:
lm(eval(parse(text=a[1]))~.-y, data=freeny) #does the same
lm(y~.-eval(parse(text=a[1])), data=freeny)

#but not if I do this call twice:
lm(eval(parse(text=a[1]))~.-eval(parse(text=a[1])), data=freeny)
#variable I wanted to remove (y) ist still there

Do you understand why I can call eval(parse) only once? Should I try a 
update workaround? Or have idea of any other solution? Maybe there is 
something much simpler I'm missing:-(


Thanks a lot!!!

Matthieu Stigler

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] column of dates into time series

2009-11-29 Thread David Winsemius


On Nov 29, 2009, at 7:52 AM, Linlin Yan wrote:


There is no year() function. Maybe you can try format() instead.

On Sun, Nov 29, 2009 at 8:44 PM, DispersionMap > wrote:


i have a column of dates in this format:

data[,"Raised.Date"] <- as.Date(data[,"Raised.Date"], "%d/%m/%Y");
data[1:10,"Raised.Date"]
[1] "2006-07-07" "2006-07-07" "2006-04-03" "2006-04-03" "2006-04-03"
"2006-04-03" "2006-04-03" "2006-04-03" "2006-04-03" "2006-04-03"

I can turn them into months like this...

Month<-months(data[,"Raised.Date"])
Month[1:10]
[1] "July"  "July"  "April" "April" "April" "April" "April" "April"  
"April"

"April"


But i also want to turn them into years (and also weeks later on),  
so tried

this...


library(chron)
?cut.dates

The argument breaks has several options including one of  c("days",  
"weeks", "months", "year")


> dts <- Sys.Date() - 1:20

> cut(dts, breaks="weeks")
 [1] 2009-11-23 2009-11-23 2009-11-23 2009-11-23 2009-11-23  
2009-11-23 2009-11-16 2009-11-16 2009-11-16 2009-11-16
[11] 2009-11-16 2009-11-16 2009-11-16 2009-11-09 2009-11-09 2009-11-09  
2009-11-09 2009-11-09 2009-11-09 2009-11-09

Levels: 2009-11-09 2009-11-16 2009-11-23

I was a bit puzzled when I tried cut.dates as the function which  
throws a function not found error.





Year<-year(data[,"Raised.Date"])
Error: could not find function "year"





David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] kernlab's ksvm method freeze

2009-11-29 Thread Heiko Strathmann
Hello,

I am using kernlab to do some binary classification on aminoacid
strings.

I am using a custom kernel, so i use the kernel="matrix" option of the
ksvm method.

My (normalized) kernel matrix is of size 1309*1309, my results vector
has the same length.

I am using C-svc.

My kernlab call is something similiar to this:

ksvm(kernel="matrix", kernelMatrix, trainingDataYs, type="C-svc",
cross=10, C=2)

To this point, everything works fine.

But now, i want to do a search for a good C Parameter, so I call the
ksvm method multiple times in a loop, with changing parameters.
This loop freezes after a few iterations.


The following simple example also freezes after few iterations (the
number varies). See that the ksvm call is always the same in every
iteration:

for (i in c(1:20)) {
print(i)
ksvm(kernel="matrix", kernelMatrix, trainingDataYs,
type="C-svc",
cross=10, C=2)
}


Does anybody have an idea what causes this? I am new to R and kernlab,
perhaps i missed something?

I put my workspace online, which contains the kernel matrix and the
training labels. Simply load workspace, kernlab library and paste the
example code to reproduce:
http://www-stud.uni-due.de/~sfhestra/

I am using R version 2.10.0 and kernlab 0.9-9.

Thanks for your help!

Regards,
Heiko Strathmann

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] column of dates into time series

2009-11-29 Thread Linlin Yan
There is no year() function. Maybe you can try format() instead.

On Sun, Nov 29, 2009 at 8:44 PM, DispersionMap  wrote:
>
> i have a column of dates in this format:
>
> data[,"Raised.Date"] <- as.Date(data[,"Raised.Date"], "%d/%m/%Y");
> data[1:10,"Raised.Date"]
> [1] "2006-07-07" "2006-07-07" "2006-04-03" "2006-04-03" "2006-04-03"
> "2006-04-03" "2006-04-03" "2006-04-03" "2006-04-03" "2006-04-03"
>
> I can turn them into months like this...
>
> Month<-months(data[,"Raised.Date"])
> Month[1:10]
> [1] "July"  "July"  "April" "April" "April" "April" "April" "April" "April"
> "April"
>
>
> But i also want to turn them into years (and also weeks later on), so tried
> this...
>
> Year<-year(data[,"Raised.Date"])
> Error: could not find function "year"
>
>
> thanks.
> --
> View this message in context: 
> http://n4.nabble.com/column-of-dates-into-time-series-tp930699p930699.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.


[R] column of dates into time series

2009-11-29 Thread DispersionMap

i have a column of dates in this format:

data[,"Raised.Date"] <- as.Date(data[,"Raised.Date"], "%d/%m/%Y"); 
data[1:10,"Raised.Date"]
[1] "2006-07-07" "2006-07-07" "2006-04-03" "2006-04-03" "2006-04-03"
"2006-04-03" "2006-04-03" "2006-04-03" "2006-04-03" "2006-04-03"

I can turn them into months like this...

Month<-months(data[,"Raised.Date"])
Month[1:10]
[1] "July"  "July"  "April" "April" "April" "April" "April" "April" "April"
"April"


But i also want to turn them into years (and also weeks later on), so tried
this...

Year<-year(data[,"Raised.Date"])
Error: could not find function "year"


thanks.
-- 
View this message in context: 
http://n4.nabble.com/column-of-dates-into-time-series-tp930699p930699.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] calling R from sas

2009-11-29 Thread Peter Flom
Arnab Maity  wrote
>
> 
>
>I like to call R from SAS. Could you please help me?
>

There are two methods that I know of:
1) Phil Rack has written a program called A Bridge to R see: 
http://minequest.com/WordPress/?p=102
2) If you have SAS/IML licensed, you can link to R through IML studio. I 
believe this is described in the documentation for IML studio

HTH

Peter


Peter L. Flom, PhD
Statistical Consultant
Website: www DOT peterflomconsulting DOT com
Writing; http://www.associatedcontent.com/user/582880/peter_flom.html
Twitter:   @peterflom

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


  1   2   >