Re: [R] creating a variable using concatenation

2010-03-31 Thread David Winsemius


On Mar 30, 2010, at 11:15 PM, Steve Chen wrote:


You can try this:

library(tutoR)


That's an interesting set of goals:
Package to mask common functions so that inputs in error are  
explained and able to be corrected, prior to execution. 'assist'  
offers step-by-step assistance to correctly call a function such as  
'par'. 'eg' picks out Examples first and foremost in help. With  
'deskcheck', execution is initiated and the 'debug' flag utilized, to  
help deskcheck a function.



plot(eval.string(toplot))


Can't say as I learned very much about R by reading the code for  
eval.string, but the idea of having a learning-mode for R that would  
clue in the newbs among us when we committed common errors, rather  
than wrapping things up in a GUI, has a certain intriguing aspect to  
it. Is there a literature regarding how well such a strategy plays out  
in practice?


--
David.





Steve Chen

On 2010/3/31 上午 09:24, zubin wrote:

A general problem i run into, i know there must be a simple solution.

I like to create a variable by appending a 1 for example, (i need to
loop later on from 1 to X, thus the reason for this).   So i assign  
the
variable vplot with this value, however it has quotes and when i  
use it
in a barplot, it throws an error.  but the tcenter$X1 does exist,  
its an
element of a data frame.  So if i type directly it works, but i  
like to
do this programmatically, as i have to generate a bunch of these  
plots

and need to loop.

So how do i concatenate to create a variable, then reference that
variable in a function call?


R  x- data.frame(1,2,3,4,5,6,7,8)
R  x
  X1 X2 X3 X4 X5 X6 X7 X8
1  1  2  3  4  5  6  7  8
R  x$X1
[1] 1

R  i=1
R  toplot- paste(x$X,i,sep=)
R  toplot
[1] x$X1

okay lets test:

 R  plot(x$X1)
-it works i see the plot

however this DOES not work

R  plot(toplot)

Error in plot.window(...) : need finite 'ylim' values
In addition: Warning messages:
1: In xy.coords(x, y, xlabel, ylabel, log) : NAs introduced by  
coercion

2: In min(x) : no non-missing arguments to min; returning Inf
3: In max(x) : no non-missing arguments to max; returning -Inf


Thus, that's my problem, i know it must be simple -  the variable  
is equal to x$X1 but it does not work in a function call?  i tried  
many functions - always some type of error.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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
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] Predict function in ARIMA/GARCH- Real time forecastinng

2010-03-31 Thread RAGHAVENDRA PRASAD
Hi,

I m working on time series forecasting.I was checking ARIMA and
GARCH model for forecasting.Is there any possibility that we can include
test data as input for predict function.I am working on real time
forecasting where i would be getting real time feeds using which i need
forecast.As of now in Predict function we can use how many periods ahead we
need the forecast.As of now we cannot use Predict function for real time
forecasting.Is there any work around so that we can input the test data as
one of the input to Predict function so that it can be used in real time
scenarios?

Regards,
Raghav

[[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] nlsList{nlme} control of min and max parameter bounds?

2010-03-31 Thread Dieter Menne


Steve Oswald wrote:
 
 I'm analysing growth rates using a gompertz (logistic) curve and am
 attempting
 to fit parameters for all of my study birds using nlsList.
 
 I've been looking for an option in nlsList to set min and max limits for
 parameter values during estimation, although I have failed to find any
 under
 'control'. 
 

If you want to constrain to positive parameters only, as in pharmacology,
fitting the logs of the parameters might help. For more general constraints,
check the examples in optim.

Dieter





Hi All


I'm analysing growth rates using a gompertz (logistic) curve and am
attempting
to fit parameters for all of my study birds using nlsList.


I've been looking for an option in nlsList to set min and max limits for
parameter values during estimation, although I have failed to find any under
'control'. Other users seem to have reported that using control in the port
algorithm (as in an nls fit) failed to work and it didn't work in my case
either. Is there such a control for nlsList?


I did fashion a selfStart function with a work-around loop in it. This
subsetted the data by ID and performed separate nls fits with parameters
constrained by the port algorithm. My objective was to use nlsList as an
object
for an nlme fit, so I was thinking of pasting together the details of the
fits
from my slefStart function into an object of class nlsList lmList but
wasn't sure if this would work or was even appropriate.


Thanks for your help


Steve


Dr. Steve Oswald


Penn State Berks

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



-- 
View this message in context: 
http://n4.nabble.com/nlsList-nlme-control-of-min-and-max-parameter-bounds-tp1746242p1746347.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] Install package of BRugs?

2010-03-31 Thread Dieter Menne


Hua Li wrote:
 
 I'm trying to install the package BRugs and could not find it on the
 install package list. Then I tried the suggestion to run the following
 command in R
 
 install.packages(BRugs)
 
 

Use R2WinBUGS instead

http://cran.at.r-project.org/web/packages/R2WinBUGS/index.html

Dieter

-- 
View this message in context: 
http://n4.nabble.com/Install-package-of-BRugs-tp1745751p1746351.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] Install package of BRugs?

2010-03-31 Thread Uwe Ligges



On 30.03.2010 22:01, David Winsemius wrote:


On Mar 30, 2010, at 3:42 PM, Hua Li wrote:


Hi All,

I'm trying to install the package BRugs and could not find it on the
install package list. Then I tried the suggestion to run the following
command in R

install.packages(BRugs)

but get the following error message:

Loading required package: BRugs
Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE,
logical.return = TRUE, :
there is no package called 'BRugs'

and the command of

library(BRugs)

results in the following
Error in library(BRugs) : there is no package called 'BRugs'

So how can I install BRugs at this point? I'm using R 2.8.1 on Windows
XP profession x64 edition.



The glaringly obvious search strategy:

r-project brugs

 on google provides this as the first hit:

http://cran.r-project.org/web/packages/BRugs/



BRugs is hosted on CRAN extras (Brian Ripley's special cases repository) 
due to license specific issues.


Please update your R and try  install.packages(BRugs)  again, you will 
get it from CRAN extras which is a default repository under Windows 
(unless you deselected it).


Uwe Ligges












Thanks a lot!

Hua

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

2010-03-31 Thread Uwe Ligges



On 31.03.2010 08:36, Dieter Menne wrote:



Hua Li wrote:


I'm trying to install the package BRugs and could not find it on the
install package list. Then I tried the suggestion to run the following
command in R

install.packages(BRugs)




Use R2WinBUGS instead

http://cran.at.r-project.org/web/packages/R2WinBUGS/index.html

Dieter




Dieter,

thanks for the pointer, but I highly recommend *not* to use R2WinBUGS if 
you are under Windows but use BRugs which has a much cleaner interface 
and .


It is hosted on CRAN extras (Brian Ripley's special cases repository) 
due to license specific issues.


Please update your R and try  install.packages(BRugs)  again, you will 
get it from CRAN extras which is a default repository under Windows 
(unless you deselected it).


Best wishes,
Uwe

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

2010-03-31 Thread Dieter Menne


Uwe Ligges-3 wrote:
 
 
 
 Use R2WinBUGS instead
 Dieter,
 
 thanks for the pointer, but I highly recommend *not* to use R2WinBUGS if 
 you are under Windows but use BRugs which has a much cleaner interface 
 and .
 

Ahem... yes. I am aware of this, and I had mixed things up! 

Dieter

-- 
View this message in context: 
http://n4.nabble.com/Install-package-of-BRugs-tp1745751p1746371.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] decomposing the error term into time-specific indiviual specific effect + transitory term

2010-03-31 Thread serdal
hi all!

i am a beginner in R so i need a command that i couldnt find on the net.

i need to transform the error term and i should decompose it  into
time-specific, indiviual specific effect and transitory term like here (åit
=ui + vt + wit)

the individual effect in my model is called stno and time effect is called
year, can somebody send me the command to decompose (without forgetting
that i am a beginner)?

Thank you very much!

[[alternative HTML version deleted]]

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


Re: [R] is and the story of a typo

2010-03-31 Thread Ted Harding
On 30-Mar-10 23:23:09, Jim Lemon wrote:
 Hi all,
 The gurus may pour scorn on me for not knowing this, but I happened
 to  mistype if as is in the heat of debugging a function. As I
 scanned the debugged function with some satisfaction, I noticed the
 error. How could this have worked? I assume that is is a generic
 function that calls one of the is.* functions to evaluate whatever
 is passed. It appears that this particular typo causes is to work
 out and report the contents of its argument. Ho hum. As I did not
 test the FALSE result, I never would have noticed that it was not
 the conditional statement I expected until it evaluated something
 that should have been FALSE.
 
 Jim

Hi Jim,

  is: ?is

  is(is)

  is(is(is))

  is(is(is(is)))

  identical(is(is(is)),is(is(is(is

Ted.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 31-Mar-10   Time: 09:21:29
-- XFMail --

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


Re: [R] MySQL and RODBC - limitations

2010-03-31 Thread jorgusch

Thanks guys - that is better.
You all rock!
-- 
View this message in context: 
http://n4.nabble.com/MySQL-and-RODBC-limitations-tp1692743p1746457.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] Weird R behaviour?

2010-03-31 Thread Gianluca Baio
Dear list,
I have observed a weird behaviour from R --- apologies if I am missing
something obvious!

df3f826f28
df3f826f28
Say you type in R:

c.preec - 10074
c.gd - 2200
p1 - .2
c.neo - p1*9451 + (1-p1)*3883
n.preec - 3710
n.gd - 2650
n.neo - 2120
n.pcos - 53000
unit.met - 94
cost.met - 94*n.pcos

effect - seq(0,1,.01)
gross.save - ((n.preec*effect*c.preec) + (n.gd*effect*c.gd) +
(n.neo*effect*c.neo))
save.nhs - gross.save - cost.met

e.star - .4
s.star - save.nhs[which(effect==e.star)]/100

Now, R should return
 which(effect==e.star) = 41

and therefore compute the variable s.star.
All well and trivial; but if you try and set
e.star - .7

R returns
which(effect==e.star) = integer(0)

so apparently there is no element in the vector e.star that is equal to .7.
Of course, there should be, since effect - seq(0,1,.01), and in fact if you
ask R to show you the vector effect, you do get
[1] 0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10 0.11 0.12 0.13
0.14
[16] 0.15 0.16 0.17 0.18 0.19 0.20 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28
0.29
[31] 0.30 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.40 0.41 0.42 0.43
0.44
[46] 0.45 0.46 0.47 0.48 0.49 0.50 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58
0.59
[61] 0.60 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 *0.70* 0.71 0.72 0.73
0.74
[76] 0.75 0.76 0.77 0.78 0.79 0.80 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88
0.89
[91] 0.90 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.00

Can anyone think of why this happens?
Many thanks
Gianluca

[[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] Weird R behaviour?

2010-03-31 Thread Benilton Carvalho
FAQ 7.31: Why doesn't R think these numbers are equal?

http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f

b

On Wed, Mar 31, 2010 at 10:10 AM, Gianluca Baio gianl...@statistica.it wrote:
 Dear list,
 I have observed a weird behaviour from R --- apologies if I am missing
 something obvious!

 df3f826f28
 df3f826f28
 Say you type in R:

c.preec - 10074
c.gd - 2200
p1 - .2
c.neo - p1*9451 + (1-p1)*3883
n.preec - 3710
n.gd - 2650
n.neo - 2120
n.pcos - 53000
unit.met - 94
cost.met - 94*n.pcos

effect - seq(0,1,.01)
gross.save - ((n.preec*effect*c.preec) + (n.gd*effect*c.gd) +
 (n.neo*effect*c.neo))
save.nhs - gross.save - cost.met

e.star - .4
s.star - save.nhs[which(effect==e.star)]/100

 Now, R should return
 which(effect==e.star) = 41

 and therefore compute the variable s.star.
 All well and trivial; but if you try and set
e.star - .7

 R returns
which(effect==e.star) = integer(0)

 so apparently there is no element in the vector e.star that is equal to .7.
 Of course, there should be, since effect - seq(0,1,.01), and in fact if you
 ask R to show you the vector effect, you do get
 [1] 0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10 0.11 0.12 0.13
 0.14
 [16] 0.15 0.16 0.17 0.18 0.19 0.20 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28
 0.29
 [31] 0.30 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.40 0.41 0.42 0.43
 0.44
 [46] 0.45 0.46 0.47 0.48 0.49 0.50 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58
 0.59
 [61] 0.60 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 *0.70* 0.71 0.72 0.73
 0.74
 [76] 0.75 0.76 0.77 0.78 0.79 0.80 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88
 0.89
 [91] 0.90 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.00

 Can anyone think of why this happens?
 Many thanks
 Gianluca

        [[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] Create a new variable

2010-03-31 Thread Petr PIKAL
Hi

r-help-boun...@r-project.org napsal dne 30.03.2010 18:46:35:

 Hello,
 
 Thomas Jensen wrote:
  Dear R-list,
  
  Sorry for spamming the list lately, I am just learning the more 
advanced
  aspects of R! 
  
  I have some data that looks like this:
  
  Out Country1 Country 2 Country 3 ... CountryN
  1   1   1   1  1
  0   1   1   0  1
  1   1   0   1  0
  
 
 Don't paste data like this to the list. Use ?dput to create an easy to 
 use data.frame that users of the list can input with one R command.  You 

 will most likely get help very quickly at that point since our data will 

 match your's exactly.
 
  I want to create a new variable that counts the number of zeros in 
every
  row whenever Out is equal to 1, and else it is a zero, so it would 
look
  like this:
  
  new_var
  0 
  0
  2
  
  I have tried the following:
  
  for (i in length(Out)){
  if (Out == 1) {new_var - sum(dat[i,] != 1)}
  else {new_var - 0}
  }
  
  but this gives me an error message.
 
 I have not tested any of this, but I'm guessing something like the 
 following would work.  Assume your data.frame is called df.
 
 #NOT TESTED
 tmp - apply(df, 1, function(x) sum(x == 0))
 df$new_var - ifelse(df$Out == 1, tmp, 0)

Maybe this can work too

df$new_var - rowSums(df[, -1] ==0) * (df$Out==1)

Regards
Petr

 
 See ?apply and ?ifelse .
 
 
 
 
  
  Best, 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.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Odp: (no subject)

2010-03-31 Thread Petr PIKAL
Hi
r-help-boun...@r-project.org napsal dne 31.03.2010 06:15:38:

 
 
 
 
 
 
 Hi r-users,
  
 I would like to display my legend with fill box and line symbol.  The 
first 
 color will be in the box and the second colour will just be a line.
  
 legend(topright, c(observed,gamma sum fit), col= c
 (greenyellow,red),pch=c(15, NA),lty = c(0,1),lwd=2)
  
 Is it possible?

Did you try it?

Regards
Petr

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

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

2010-03-31 Thread Julia Cains

Dear R users,

I am working on the Value at Risk (VaR) for the Operational risk. For a given 
loss data, we try to fit some statistical distributions using 
Kolmogorov-Smirnov (KS) test and A-D test and then for fitted distribution 
using the estimated parameters, the losses are simulated and the VaR is arrived 
at. 

The typical problem faced by the banks is the paucity of Internal loss data and 
thus banks depend on the external loss data obtained from external sources. 
This external data is normally of higher magnitude than the internal loss data 
of the bank. Thus using regression technique, this external data is scaled and 
then the internal data and the scaled external data is combined. Then we try to 
fit some statistical distribution to this combined data. However, at times it 
becomes very difficult to fit any distribution to this particular combined data 
as the data becomes Bimodal.

The paper by G. Dionne and Hela Dahen  What about underevaluating Operational 
Value at Risk in the Banking sector? suggests that we fit two distributions 

(1) to the internal data (called body part) with Upper cap or upper bound to 
the loss data and 

(2) to the external data with Lower bound (called Tail part). 

Thus, now I am dealing with two truncated distributions (i) having a lower loss 
bound (say 5000$ i.e. bank records only those losses exceeding 5,000$) and 
having an Upper bound of say 500,000$; and (ii) having lower loss bound of say 
500,000$ and no upper limit.

My question is 

(1) Is there any R package which helps to estimate the parameters of various 
Truncated distributions?

(2) How to fit the truncated distributions to loss data in the sense how do we 
use KS and AD tests?

Extremely sorry for writing such a long mail.

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] (no subject)

2010-03-31 Thread Jim Lemon

On 03/31/2010 03:15 PM, Roslina Zakaria wrote:







Hi r-users,

I would like to display my legend with fill box and line symbol.  The first 
color will be in the box and the second colour will just be a line.

legend(topright, c(observed,gamma sum fit), col= 
c(greenyellow,red),pch=c(15, NA),lty = c(0,1),lwd=2)


Hi Rosalina,
I think what you're trying to do requires the argument:

pt.cex=2

in the call to legend

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] Simplifying particular piece of code

2010-03-31 Thread Sergey Goriatchev
Hello, everyone

I have a piece of code that looks like this:

mrets - merge(mrets, BMM.SR=apply(mrets, 1, MyFunc, ret=BMM.AV120,
stdev=BMM.SD120))
mrets - merge(mrets, GM1.SR=apply(mrets, 1, MyFunc, ret=GM1.AV120,
stdev=GM1.SD120))
mrets - merge(mrets, IYC.SR=apply(mrets, 1, MyFunc, ret=IYC.AV120,
stdev=IYC.SD120))
mrets - merge(mrets, FCA.SR=apply(mrets, 1, MyFunc, ret=FCA.AV120,
stdev=FCA.SD120))
mrets - merge(mrets, IMM.SR=apply(mrets, 1, MyFunc, ret=IMM.AV120,
stdev=IMM.SD120))
mrets - merge(mrets, BME.SR=apply(mrets, 1, MyFunc, ret=BME.AV120,
stdev=BME.SD120))
mrets - merge(mrets, CRT.SR=apply(mrets, 1, MyFunc, ret=CRT.AV120,
stdev=CRT.SD120))
mrets - merge(mrets, GTF.SR=apply(mrets, 1, MyFunc, ret=GTF.AV120,
stdev=GTF.SD120))
mrets - merge(mrets, ERU.SR=apply(mrets, 1, MyFunc, ret=ERU.AV120,
stdev=ERU.SD120))
mrets - merge(mrets, ERE.SR=apply(mrets, 1, MyFunc, ret=ERE.AV120,
stdev=ERE.SD120))
mrets - merge(mrets, EPT.SR=apply(mrets, 1, MyFunc, ret=EPT.AV120,
stdev=EPT.SD120))
mrets - merge(mrets, EVA.SR=apply(mrets, 1, MyFunc, ret=EVA.AV120,
stdev=EVA.SD120))
mrets - merge(mrets, EMT.SR=apply(mrets, 1, MyFunc, ret=EMT.AV120,
stdev=EMT.SD120))
mrets - merge(mrets, EMM.SR=apply(mrets, 1, MyFunc, ret=EMM.AV120,
stdev=EMM.SD120))
mrets - merge(mrets, EMV.SR=apply(mrets, 1, MyFunc, ret=EMV.AV120,
stdev=EMV.SD120))
mrets - merge(mrets, ETM.SR=apply(mrets, 1, MyFunc, ret=ETM.AV120,
stdev=ETM.SD120))

Is there a way to simplify this, some sort of loop?
mrets is a zoo object.
.AV120 and .SD120 are columns in this object.
I need the exact .SR column names.

This does not work:
SRnames - paste(colnames.mrets, .SR, sep=)
AVnames - paste(colnames.mrets, .AV120, sep=)
SDnames - paste(colnames.mrets, .SD120, sep=)

for(i in seq(SRnames)){
mrets - merge(mrets, SRnames[i]=apply(mrets, 1, MyFunc,
ret=AVnames[i], stdev=SDnames[i]))
}


Help much appreciated.

Regards,
Sergey


--
Simplicity is the last step of art./Bruce Lee
The more you know, the more you know you don't know. /Myself

I'm not young enough to know everything. /Oscar Wilde
Experience is one thing you can't get for nothing. /Oscar Wilde
When you are finished changing, you're finished. /Benjamin Franklin
Luck is where preparation meets opportunity. /George Patten

Kniven skärpes bara mot stenen.

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

2010-03-31 Thread Gustaf Rydevik
How about this (not tested, since you did not provide example data nor
function code):

---

SRnames - paste(colnames.mrets, .SR, sep=)
AVnames - paste(colnames.mrets, .AV120, sep=)
SDnames - paste(colnames.mrets, .SD120, sep=)
names.matrix-cbind(SRnames,AVnames,SDnames)

mrets.list-apply(names.matrix,1,function(.names){
apply(mrets,1,MyFunc,ret=.names[2],stdev=.names[3]}
)
names(mrets.list)-names.matrix[,1]
mrets-do.call(merge,mrets.list)

-
?
/Gustaf

On Wed, Mar 31, 2010 at 12:10 PM, Sergey Goriatchev serg...@gmail.com wrote:
 Hello, everyone

 I have a piece of code that looks like this:

 mrets - merge(mrets, BMM.SR=apply(mrets, 1, MyFunc, ret=BMM.AV120,
 stdev=BMM.SD120))
 mrets - merge(mrets, GM1.SR=apply(mrets, 1, MyFunc, ret=GM1.AV120,
 stdev=GM1.SD120))
 mrets - merge(mrets, IYC.SR=apply(mrets, 1, MyFunc, ret=IYC.AV120,
 stdev=IYC.SD120))
 mrets - merge(mrets, FCA.SR=apply(mrets, 1, MyFunc, ret=FCA.AV120,
 stdev=FCA.SD120))
 mrets - merge(mrets, IMM.SR=apply(mrets, 1, MyFunc, ret=IMM.AV120,
 stdev=IMM.SD120))
 mrets - merge(mrets, BME.SR=apply(mrets, 1, MyFunc, ret=BME.AV120,
 stdev=BME.SD120))
 mrets - merge(mrets, CRT.SR=apply(mrets, 1, MyFunc, ret=CRT.AV120,
 stdev=CRT.SD120))
 mrets - merge(mrets, GTF.SR=apply(mrets, 1, MyFunc, ret=GTF.AV120,
 stdev=GTF.SD120))
 mrets - merge(mrets, ERU.SR=apply(mrets, 1, MyFunc, ret=ERU.AV120,
 stdev=ERU.SD120))
 mrets - merge(mrets, ERE.SR=apply(mrets, 1, MyFunc, ret=ERE.AV120,
 stdev=ERE.SD120))
 mrets - merge(mrets, EPT.SR=apply(mrets, 1, MyFunc, ret=EPT.AV120,
 stdev=EPT.SD120))
 mrets - merge(mrets, EVA.SR=apply(mrets, 1, MyFunc, ret=EVA.AV120,
 stdev=EVA.SD120))
 mrets - merge(mrets, EMT.SR=apply(mrets, 1, MyFunc, ret=EMT.AV120,
 stdev=EMT.SD120))
 mrets - merge(mrets, EMM.SR=apply(mrets, 1, MyFunc, ret=EMM.AV120,
 stdev=EMM.SD120))
 mrets - merge(mrets, EMV.SR=apply(mrets, 1, MyFunc, ret=EMV.AV120,
 stdev=EMV.SD120))
 mrets - merge(mrets, ETM.SR=apply(mrets, 1, MyFunc, ret=ETM.AV120,
 stdev=ETM.SD120))

 Is there a way to simplify this, some sort of loop?
 mrets is a zoo object.
 .AV120 and .SD120 are columns in this object.
 I need the exact .SR column names.

 This does not work:
 SRnames - paste(colnames.mrets, .SR, sep=)
 AVnames - paste(colnames.mrets, .AV120, sep=)
 SDnames - paste(colnames.mrets, .SD120, sep=)

 for(i in seq(SRnames)){
 mrets - merge(mrets, SRnames[i]=apply(mrets, 1, MyFunc,
 ret=AVnames[i], stdev=SDnames[i]))
 }


 Help much appreciated.

 Regards,
 Sergey


 --
 Simplicity is the last step of art./Bruce Lee
 The more you know, the more you know you don't know. /Myself

 I'm not young enough to know everything. /Oscar Wilde
 Experience is one thing you can't get for nothing. /Oscar Wilde
 When you are finished changing, you're finished. /Benjamin Franklin
 Luck is where preparation meets opportunity. /George Patten

 Kniven skärpes bara mot stenen.

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




-- 
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
skype:gustaf_rydevik

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

2010-03-31 Thread vibha patel
Hello,

I am searching large multivariate time series datasets to use with R.

Can any one help me???


Regards,
Vibha

[[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] Generative Topographic Map

2010-03-31 Thread mauede
I tried to use R version of package 
I noticed the original MatLab Pckage is much better documented. 
I had a look at the R demo code gtm_demo and found that variable Y is used in 
advanced of being created:
I wrote my own few lines as follows:
 inDir -  C:/Documents and Settings/Monville/Alanine Dipeptide/DBP1/DHA

 setwd(inDir)
 T - read.table(DHA_TNH.txt)  
 L - 3
 X - matrix(nrow=nrow(T),ncol=3,byrow=TRUE)
 MU - matrix(nrow=round(nrow(T)/5), ncol=L)

 for(i in 1:ncol(X)) {
   for(j in 1:nrow(X)) {
  X[j,i] - RANDU()
   }
 }

 for(i in 1:ncol(MU)) {
  for(j in 1:nrow(MU)) {
 MU[j,i] - RANDU()
  }
 }
 sigma -1

 FI - gtm_gbf(MU,sigma,X)
 W - gtm_ri(T,FI)
 Y= FI%*%W
 b = gtm_bi(Y)
 lambda - 0.001
 for (m in 1:15) {
trnResult = gtm_trn(T, FI, W, lambda, 1, b, 2,quiet = TRUE, minSing = 0.01)
W = trnResult$W
b = trnResult$beta
Y = FI %*% W
 }

I ran the above script on my own data representing 1969 samples of 7 dihedral 
angles of a folding molecule (attached.
Upon running the 1st iteration of the training function gtm_trn I get the 
following error that I cannot interpret.
Any help and/or suggestion is welcome:

  trnResult = gtm_trn(T, FI, W, lambda, 1, b, 2,quiet = TRUE, minSing = 1.)
Error in gtmGlobalR %*% T : 
  requires numeric/complex matrix/vector arguments
In addition: Warning messages:
1: In chol.default(A, pivot = TRUE) : matrix not positive definite
2: In gtm_trn(T, FI, W, lambda, 1, b, 2, quiet = TRUE, minSing = 1) :
  Using 7 out of 395 eigenvalues

Thank you in advance,
Maura





e tutti i telefonini TIM!
Vai su 
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Value-at-Risk Portfolio(both equity and option)

2010-03-31 Thread zhang

Thank you very much. It is very helpful. As far as I understand, not easy to
have a function to combine both the equity part and the option part?
-- 
View this message in context: 
http://n4.nabble.com/Value-at-Risk-Portfolio-both-equity-and-option-tp1745179p1746520.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] Error singular gradient matrix at initial parameter estimates in nls

2010-03-31 Thread Prof. John C Nash

If you have a perfect fit, you have zero residuals. But in the nls manual page 
we have:


Warning:

 *Do not use ‘nls’ on artificial zero-residual data.*


So this is a case of complaining that your diesel car is broken because you ignored the 
Diesel fuel only sign on the filler cap and put in gasoline.


However I've not been happy with this choice in the code of nls -- it's been there a long 
time -- and my own codes from 1974 onwards have always handled zero residual cases. I do 
believe that the code could at least give a better diagnostic message. Zero residuals -- 
perfect fits -- arise when one is interested more or less in an interpolating function 
rather than doing statistics, and I can understand the reluctance of statisticians to 
countenance such a use of nls.


And Bert's comment on overparametrization is almost certainly valid also.

JN

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] interpretation of p values for highly correlated logistic analysis

2010-03-31 Thread claus orourke
Dear list,

I want to perform a logistic regression analysis with multiple
categorical predictors (i.e., a logit) on some data where there is a
very definite relationship between one predicator and the
response/independent variable. The problem I have is that in such a
case the p value goes very high (while I as a naive newbie would
expect it to crash towards 0).

I'll illustrate my problem with some toy data. Say I have the
following data as an input frame:

   roman animal colour
1  alphadog black
2   betacat white
3  alphadog black
4  alphacat black
5   betadog white
6  alphacat black
7  gammadog white
8  alphacat black
9  gammadog white
10  betacat white
11 alphadog black
12 alphacat black
13 gammadog white
14 alphacat black
15  betadog white
16  betacat black
17 alphacat black
18  betadog white

In this toy data you can see that roman:alpha and roman:beta are
pretty good predictors of colour

Let's say I perform logistic analysis directly on the raw data with
colour as a response variable:

 options(contrasts=c(contr.treatment,contr.poly))
 anal1 - glm(data$colour~data$roman+data$animal,family=binomial)

then I find that my P values for each individual level coefficient approach 1:

Coefficients:
Estimate Std. Error z value Pr(|z|)
(Intercept)   -41.65   19609.49  -0.0020.998
data$romanbeta 42.35   19609.49   0.0020.998
data$romangamma43.74   31089.48   0.0010.999
data$animaldog 20.48   13866.00   0.0010.999

while I expect the p value for roman:beta to be quite low because it
is a good predictor of colour:white

On the other hand, if I then run an anova with a Chi-sq test on the
result model, I find as I would expect that 'roman' is a good
predictor of colour.

 anova(anal1,test=Chisq)
Analysis of Deviance Table

Model: binomial, link: logit

Response: data$colour

Terms added sequentially (first to last)


Df Deviance Resid. Df Resid. Dev P(|Chi|)
NULL   1724.7306
data$roman   2  19.323915 5.4067 6.366e-05 ***
data$animal  1   1.587614 3.81910.2077
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Can anyone please explain why my p value is so high for the individual levels?

Sorry for what is likely a stupid question.

Claus

p.s., when I run logistic analysis on data that is more 'randomised'
everything comes out as I expect.

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

2010-03-31 Thread koj

Dear all,

I use the package RCOM to manipulate Excel-Files (Windows). 

After opening the Excel-File and formatting the cells I want to save the
file automatically without request. If I use y[[Save]] - TRUE it opens
the saving dialog and I have to select the destination for saving. But I
simply want to overwrite the existing file without any other workings. 

Thany your very much in advance.

Jens.
-- 
View this message in context: 
http://n4.nabble.com/RCOM-Save-tp1746602p1746602.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] RCOM Save

2010-03-31 Thread Henrique Dallazuanna
Try adding this:

y[[DisplayAlerts]] - FALSE

On Wed, Mar 31, 2010 at 8:28 AM, koj jens.k...@gmx.li wrote:

 Dear all,

 I use the package RCOM to manipulate Excel-Files (Windows).

 After opening the Excel-File and formatting the cells I want to save the
 file automatically without request. If I use y[[Save]] - TRUE it opens
 the saving dialog and I have to select the destination for saving. But I
 simply want to overwrite the existing file without any other workings.

 Thany your very much in advance.

 Jens.
 --
 View this message in context: 
 http://n4.nabble.com/RCOM-Save-tp1746602p1746602.html
 Sent from the R help mailing list archive at Nabble.com.

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




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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ggplot2: Adding points to a density plot

2010-03-31 Thread Johannes Graumann
Hi,

Consider something like
 library(ggplot2)
 movies$decade - round_any(movies$year, 10)
 m - qplot(rating,data=movies,colour=factor(decade),geom=density)
 m
(modified from ?stat_density).

I'd like to add on the line y=0 a dot for the median of each decade 
category (using the same colour coding as the fill). I'm failing miserably 
at all my
 m + geom_point
based approaches and would appreciate if someone could show me the ggplot2 
way of achieving this.

Thanks, Joh

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] interpretation of p values for highly correlated lo gistic analysis

2010-03-31 Thread Ben Bolker
claus orourke claus.orourke at gmail.com writes:

  look up Hauck-Donner effect ...

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Printing the function t.test() in R

2010-03-31 Thread Luwis Tapiwa Diya
Dear R Users,

I have a question, how does one print an r function like t.test in R (to get
the whole function and not just a summary of the environment)?   For example
if I type the following:

 t.test
function (x, ...)
UseMethod(t.test)
environment: namespace:stats
 print(t.test)
function (x, ...)
UseMethod(t.test)
environment: namespace:stats

I don't get the entire function printed.

Kind regards,


-- 
Luwis Diya,
Leuven Biostatistics and Statistical Bioinformatics Centre (L-BioStat),
Kapucijnenvoer 35 blok d - bus 7001,
3000 Leuven,
Belgium

Tel: +32 16 336886 or +32 16 336892
Fax: +32 16 337015

[[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] Value-at-Risk Portfolio(both equity and option)

2010-03-31 Thread Cedrick Johnson
One thing that comes to mind immediately is the 'blotter' package
which I believe is designed to handle and track multiple instruments.

A sloppy temporary solution I guess would be to do some type of lookup
or a flag that denotes which instrument is an option and apply the VaR
methodology appropriately. I am not in front of my desktop for now,
else I would dig around the blotter code to evaluate a proposal to
handle the scenario you mention.

Perhaps some people who have done more work with these types of issues
can shed more light on this.

Hth
-c

On 3/31/10, zhang yn19...@msn.com wrote:

 Thank you very much. It is very helpful. As far as I understand, not easy to
 have a function to combine both the equity part and the option part?
 --
 View this message in context:
 http://n4.nabble.com/Value-at-Risk-Portfolio-both-equity-and-option-tp1745179p1746520.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.


-- 
Sent from my mobile device

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Printing the function t.test() in R

2010-03-31 Thread Eik Vettorazzi

Hi Luwis,
this task is solved in the R Help Desk, see R News 6/4 
http://cran.r-project.org/doc/Rnews/Rnews_2006-4.pdf


in short t.test is a S3-method and you can have a look at implemented 
methods with


methods(t.test)

and then use e.g.

getAnywhere(t.test.default)

hth.

Luwis Tapiwa Diya schrieb:

Dear R Users,

I have a question, how does one print an r function like t.test in R (to get
the whole function and not just a summary of the environment)?   For example
if I type the following:

  

t.test


function (x, ...)
UseMethod(t.test)
environment: namespace:stats
  

print(t.test)


function (x, ...)
UseMethod(t.test)
environment: namespace:stats

I don't get the entire function printed.

Kind regards,


  


--
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/7410-58243
F ++49/40/7410-57790



--
Pflichtangaben gemäß Gesetz über elektronische Handelsregister und 
Genossenschaftsregister sowie das Unternehmensregister (EHUG):

Universitätsklinikum Hamburg-Eppendorf
Körperschaft des öffentlichen Rechts
Gerichtsstand: Hamburg

Vorstandsmitglieder:
Prof. Dr. Jörg F. Debatin (Vorsitzender)
Dr. Alexander Kirstein
Joachim Prölß
Prof. Dr. Dr. Uwe Koch-Gromus
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] time series datasets

2010-03-31 Thread Cedrick Johnson
What kind of time series data? Finance? Econometrics?

The 'quantmod' package allows for downloading of stock and FRED data
online for analysis. I believe PerformanceAnalytics also has some
datasets as well.

-c

On 3/31/10, vibha patel vibhapatel...@gmail.com wrote:
 Hello,

 I am searching large multivariate time series datasets to use with R.

 Can any one help me???


 Regards,
 Vibha

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


-- 
Sent from my mobile device

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Printing the function t.test() in R

2010-03-31 Thread David Winsemius


On Mar 31, 2010, at 8:35 AM, Luwis Tapiwa Diya wrote:


Dear R Users,

I have a question, how does one print an r function like t.test in R  
(to get
the whole function and not just a summary of the environment)?   For  
example

if I type the following:


t.test

function (x, ...)
UseMethod(t.test)
environment: namespace:stats

print(t.test)

function (x, ...)
UseMethod(t.test)
environment: namespace:stats

I don't get the entire function printed.


 methods(t.test)
[1] t.test.default* t.test.formula*

   Non-visible functions are asterisked
# Noting the asterisk, one need to use getAnywhere()

 getAnywhere(t.test.default)
A single object matching ‘t.test.default’ was found
It was found in the following places
  registered S3 method for t.test from namespace stats
  namespace:stats
with value

function (x, y = NULL, alternative = c(two.sided, less, greater),
mu = 0, paired = FALSE, var.equal = FALSE, conf.level = 0.95,
...)
### snipped the code -

There was an R-News a couple of years back by (if memory serves)  
Ligges describing various methods for getting at source. Yes, there it  
is:
Ligges, U. (2006): R Help Desk: Accessing the Sources. R News 6 (4),   
43-45. http://cran.r-project.org/doc/Rnews/Rnews_2006-4.pdf


--

David Winsemius, MD
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] Problem comparing hazard ratios

2010-03-31 Thread Michal Figurski

Thank you, gentlemen.

I greatly appreciate your help.

--
Michal J. Figurski, PhD
HUP, Pathology  Laboratory Medicine
Biomarker Research Laboratory
3400 Spruce St. 7 Maloney
Philadelphia, PA 19104
tel. (215) 662-3413

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] position of mismatches in all.equal()?

2010-03-31 Thread Ivan Calandra

Dear R users,

I would like to compare two dataframes, actually their categorical 
variables (as factors) only (there are 12, from column 1 to 12).
The reason I do that is that I got 2 datasets from two different methods 
and I would like to be sure that each method used the same data (3D 
images) to extract 2 different sets of 3D parameters. Is it clear so far?


So I thought about using all.equal() like this:

test1 - data.frame(num=1:10, let1=letters[1:10], let2=letters[1:10])
test2 - data.frame(num=1:10, let1=letters[1:10], let2=letters[c(1:6, 6, 
8:10)])


Since I want to compare only some columns, I do this:
 all.equal(test1[,1:2], test2[,1:2])
[1] TRUE
 all.equal(test1[,1:3], test2[,1:3])
[1] Component 3: Attributes:  Component 2: Lengths (10, 9) differ 
(string compare on first 9) 

[2] Component 3: Attributes:  Component 2: 3 string mismatches 
[3] Component 3: 1 string mismatch

If I get TRUE, then everythin's fine. But if not, I just know from the 
output in which column(s) are the mismatches and how many (here 1).
But my datasets are 2000+ rows, and I would like to know the row 
number(s) where mismatches occur.


How can I do that?

Thank you for your help!
Regards,
Ivan

--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php

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


Re: [R] Error singular gradient matrix at initial parameter estimates in nls

2010-03-31 Thread Corrado

Dear JN, Bert,

1) It is not a perfect fit. I do not think I have ever said that. I said 
that an external algorithms fits the model without any problems: with ~ 
500,000 data points and 19 paramters (ki in the original equation), it 
fits the model in less than 1 second. The data are not artificial data. 
The variables are independent (pi in the original model). The solution 
is unique and the rapidity of convergence is practically independent 
from the selection of start conditions (with a reasonable selection of 
start conditions at least). The resulting residuals are approximately 
normally distributed with mean 0 and sd ~ 4.23.


2) I agree with the comment of Bert on over-parametrization, but again 
the model is not overparamterised, and it is identifiable (in part 
answered already in (1))


Regards


Prof. John C Nash wrote:
If you have a perfect fit, you have zero residuals. But in the nls 
manual page we have:



Warning:

 *Do not use ‘nls’ on artificial zero-residual data.*


So this is a case of complaining that your diesel car is broken 
because you ignored the Diesel fuel only sign on the filler cap and 
put in gasoline.


However I've not been happy with this choice in the code of nls -- 
it's been there a long time -- and my own codes from 1974 onwards have 
always handled zero residual cases. I do believe that the code could 
at least give a better diagnostic message. Zero residuals -- perfect 
fits -- arise when one is interested more or less in an interpolating 
function rather than doing statistics, and I can understand the 
reluctance of statisticians to countenance such a use of nls.


And Bert's comment on overparametrization is almost certainly valid also.

JN




--
Corrado Topi
PhD Researcher
Global Climate Change and Biodiversity
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.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] ggplot2: Adding points to a density plot

2010-03-31 Thread Dennis Murphy
Hi:

Try this:

library(ggplot2)
movmed - ddply(movies, .(decade), summarise, med = median(rating))
m + geom_point(data = movmed, aes(x = med), y = 0, size = 2)

HTH,
Dennis

On Wed, Mar 31, 2010 at 4:46 AM, Johannes Graumann johannes_graum...@web.de
 wrote:

 Hi,

 Consider something like
  library(ggplot2)
  movies$decade - round_any(movies$year, 10)
  m - qplot(rating,data=movies,colour=factor(decade),geom=density)
  m
 (modified from ?stat_density).

 I'd like to add on the line y=0 a dot for the median of each decade
 category (using the same colour coding as the fill). I'm failing
 miserably
 at all my
  m + geom_point
 based approaches and would appreciate if someone could show me the ggplot2
 way of achieving this.

 Thanks, Joh

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] regular expression help to extract specific strings from text

2010-03-31 Thread Tony B
Dear all,

Lets say I have the following:

 x - c(Eve: Going to try something new today..., Adam: Hey @Eve, how are 
 you finding R? #rstats, Eve: @Adam, It's awesome, so much better at 
 statistics that #Excel ever was! @Cain  @Able disagree though :(, Adam: 
 @Eve I'm sure they'll sort it out :), blahblah)
 x
[1] Eve: Going to try something new
today...
[2] Adam: Hey @Eve, how are you finding R?
#rstats
[3] Eve: @Adam, It's awesome, so much better at statistics that
\n#Excel ever was! @Cain  @Able disagree though :(
[4] Adam: @Eve I'm sure they'll sort it
out :)
[5] blahblah

I would like to come up with a data frame which looks like this
(pulling out the usernames and #tags):

 data.frame(Msg = x, Source = c(Eve, Adam, Eve, Adam, NA), Mentions = 
 c(NA, Eve, Adam, Cain, Able, Eve, NA), HashTags = c(NA, rstats, 
 Excel, NA, NA))

The best I can do so far is:

source - lapply(x, function (x) {
   tmp - strsplit(x, :, fixed = TRUE)
   if(length(tmp[[1]])  2) {
 tmp - c(NA, tmp)
   }
   return(tmp[[1]][1])
 } )
source - unlist(source)

[1] Eve  Adam Eve  Adam NA

I can't work out how to extract the usernames starting with '@' or the
#tags. I can identify them using gsub and replace them, but I don't
know how to just extract those terms only, e.g. sort of the opposite
of the following

 gsub(@([A-Za-z0-9_]+), @[...], x)
[1] Eve: Going to try something new today...
[2] Adam: Hey @[...], how are you finding R? #rstats
[3] Eve: @[...], It's awesome, so much better at statistics that
#Excel ever was! @[...]  @[...] disagree though :(
[4] Adam: @[...] I'm sure they'll sort it out :)
[5] blahblah

and

 gsub(#([A-Za-z0-9_]+), #[...], x)
[1] Eve: Going to try something new today...
[2] Adam: Hey @Eve, how are you finding R? #[...]
[3] Eve: @Adam, It's awesome, so much better at statistics that
#[...] ever was! @Cain  @Able disagree though :(
[4] Adam: @Eve I'm sure they'll sort it out :)
[5] blahblah

I hope that makes sense, and thank you kindly in advance for your
time.
Tony Breyal

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


Re: [R] for loop; lm() regressions; list of vectors - lapply - accolades and square brackets??

2010-03-31 Thread Driss Agramelal
Hello and thank you both for your answers!

Dennis, I tried to simply run

lm(a ~ b)

after re-importing a as a matrix, but I get the following error message:

Error in model.frame.default(formula = a ~ b, drop.unused.levels = TRUE) :
  invalid type (list) for variable 'a'

so maybe I have to specify something in the arguments? What do you think?

David,

I tried your syntax as well, and received quasi-the same error statement:

 for(i in seq_along(a)) print(r - lm(a[i] ~ b) )
Error in model.frame.default(formula = a[i] ~ b, drop.unused.levels = TRUE)
:
  invalid type (list) for variable 'a[i]'

I am not too familiar with the use of accolades, square brackets and
parentheses, the order in which they have to come
in the function and the role they play, but I think they might be
important...

I also tried to use lapply; it works wonderfully for a basic function
like:

lapply(a, mean)

I get a list of results with names and values..perfect! But with the lm()
function... I just
don't know how to write the arguments... tried several options without
success...

Any idea that could help me solve this only seemingly easy task would be
most welcome!!

Many Thanks,

Driss Agramelal



2010/3/30 David Winsemius dwinsem...@comcast.net


 On Mar 30, 2010, at 12:42 PM, Driss Agramelal wrote:

  ##  Hello everyone,
 ##
 ##  I am trying to execute 150 times a lm regression using the 'for' loop,
 with 150 vectors for y,
 ##
 ##  and always the same vector for x.
 ##
 ##  I have an object with 150 elements named a,
 ##
 ##  and a vector of 60 values named b.
 ##
 ##  Each element in a has 60 values plus a header.
 ##
 ##  When I type:

 r - lm(i ~ b)

 for(i in a) print(r)



 Try instead something like this untested modification:

  for(i in seq_along(a)) print(r - lm(a[i] ~ b) )



 ##  I get 150 times the lm results of the first element of a regressed
 with b,
 ##
 ##  whereas I would like to have 150 different regression results from
 each
 element in a...
 ##
 ##  Can someone please help me with the syntax of my loop please?
 ##
 ##  Many Thanks,
 ##
 ##  Driss Agramelal
 ##
 ##  Switzerland
 ##

[[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
 West Hartford, CT



Hi:

Did you try

lm(a ~ b)  ?

According to the lm() help page, if a is a matrix, lm will regress each
column of the
matrix on the right hand side of the formula. Sounds like what you want...

HTH,
Dennis

[[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] Installing JGR and rJava

2010-03-31 Thread gerald . jean

Hello,

I am running:

R version 2.10.0 (2009-10-26)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

on a 64-bit RedHat box.

To encourage collegues to use R, I am trying to install JGR, which
depends on rJava, on the above machine.  At first I received and error
saying Java was not available.  My IT support, I am not admin. on this
machine, installed Java (1.6.0_19) and JDK (1.6.0_19) and successfully ran:

R CMD javareconf

now, I am getting the following error:

---
.
.
.
checking Java support in R... present:
interpreter : '/usr/java/../bin/java'
archiver: '/usr/java/../bin/jar'
compiler: '/usr/java/../bin/javac'
header prep.: ''
cpp flags   : ''
java libs   : '-L/usr/java/jdk1.6.0_19/jre/lib/amd64/server
-L/usr/java/jdk1.6.0_19/jre/lib/amd64 -L/usr/java/jdk1.6.0
_19/jre/../lib/amd64 -L -L/usr/java/packages/lib/amd64 -L/usr/lib64
-L/lib64 -L/lib -L/usr/lib -ljvm'
configure: error: One or more Java configuration variables are not set.
Make sure R is configured with full Java support (including JDK). Run
R CMD javareconf
as root to add Java support to R.

If you don't have root privileges, run
R CMD javareconf -e
to set all Java-related variables and then install rJava.

as I said previously R CMD javareconf was ran.  As suggested by the error
message I also tried to run:

R CMD javareconf -e

although it ran without error it didn't help?  What are these
configuration variables and how do we set them?

Anyone has and idea on how to fix this?

Thanks for your support,

Gérald Jean
Conseiller senior en statistiques,
VP Actuariat et Solutions d'assurances,
Desjardins Groupe d'Assurances Générales
télephone: (418) 835-4900 poste (7639)
télecopieur  : (418) 835-6657
courrier électronique: gerald.j...@dgag.ca

We believe in God, others must bring Data.

W. Edwards Deming


Le message ci-dessus, ainsi que les documents l'accompagnant, sont destinés 
uniquement aux personnes identifiées et peuvent contenir des informations
privilégiées, confidentielles ou ne pouvant être divulguées. Si vous avez reçu 
ce message par erreur, veuillez le détruire.

This communication ( and/or the attachments ) is intended for named recipients 
only and may contain privileged or confidential information which is
not to be disclosed. If you received this communication by mistake please 
destroy all copies.




Faites bonne impression et imprimez seulement au besoin !
Think green before you print !

Le message ci-dessus, ainsi que les documents l'accompagnant, sont destinés 
uniquement aux personnes identifiées et peuvent contenir des informations 
privilégiées, confidentielles ou ne pouvant être divulguées. Si vous avez reçu 
ce message par erreur, veuillez le détruire.

This communication (and/or the attachments) is intended for named recipients 
only and may contain privileged or confidential information which is not to be 
disclosed. If you received this communication by mistake please destroy all 
copies.

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


Re: [R] for loop; lm() regressions; list of vectors - lapply - accolades and square brackets??

2010-03-31 Thread David Winsemius

On Mar 31, 2010, at 9:13 AM, Driss Agramelal wrote:


 Hello and thank you both for your answers!

 Dennis, I tried to simply run

 lm(a ~ b)

 after re-importing a as a matrix, but I get the following error  
 message:

 Error in model.frame.default(formula = a ~ b, drop.unused.levels =  
 TRUE) :
   invalid type (list) for variable 'a'

 so maybe I have to specify something in the arguments? What do you  
 think?

 David,

 I tried your syntax as well, and received quasi-the same error  
 statement:

  for(i in seq_along(a)) print(r - lm(a[i] ~ b) )
 Error in model.frame.default(formula = a[i] ~ b, drop.unused.levels  
 = TRUE) :
   invalid type (list) for variable 'a[i]'

 I am not too familiar with the use of accolades, square brackets and  
 parentheses, the order in which they have to come
 in the function and the role they play, but I think they might be  
 important...

 I also tried to use lapply; it works wonderfully for a basic  
 function like:

 lapply(a, mean)

 I get a list of results with names and values..perfect! But with the  
 lm() function... I just
 don't know how to write the arguments... tried several options  
 without success...

 Any idea that could help me solve this only seemingly easy task  
 would be most welcome!!

Do you think we can figure this out when you have provided no sample  
data and have not provided even the results of str on the data object  
you are working with? Generally one gains insight by parring the  
problem down to smaller test cases and working with them. Perhaps the  
first 5 elements of a rather than all 150?

-- 
David.
 2010/3/30 David Winsemius dwinsem...@comcast.net

 On Mar 30, 2010, at 12:42 PM, Driss Agramelal wrote:

 ##  Hello everyone,
 ##
 ##  I am trying to execute 150 times a lm regression using the 'for'  
 loop,
 with 150 vectors for y,
 ##
 ##  and always the same vector for x.
 ##
 ##  I have an object with 150 elements named a,
 ##
 ##  and a vector of 60 values named b.
 ##
 ##  Each element in a has 60 values plus a header.
 ##
 ##  When I type:

 r - lm(i ~ b)

 for(i in a) print(r)



 Try instead something like this untested modification:

  for(i in seq_along(a)) print(r - lm(a[i] ~ b) )



 ##  I get 150 times the lm results of the first element of a  
 regressed
 with b,
 ##
 ##  whereas I would like to have 150 different regression results  
 from each
 element in a...
 ##
 ##  Can someone please help me with the syntax of my loop please?
 ##
 ##  Many Thanks,
 ##
 ##  Driss Agramelal
 ##
 ##  Switzerland
 ##

[[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
 West Hartford, CT



 Hi:

 Did you try

 lm(a ~ b)  ?

 According to the lm() help page, if a is a matrix, lm will regress  
 each column of the
 matrix on the right hand side of the formula. Sounds like what you  
 want...

 HTH,
 Dennis



David Winsemius, MD
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] Error singular gradient matrix at initial parameter estimates in nls

2010-03-31 Thread Ravi Varadhan
Try the function called `nls.lm' which is contained in the minpack.lm 
package.  See if it solves your problem.

Ravi.  

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On 
Behalf Of Corrado
Sent: Wednesday, March 31, 2010 9:13 AM
Cc: r-help@r-project.org
Subject: Re: [R] Error singular gradient matrix at initial parameter 
estimates in nls

Dear JN, Bert,

1) It is not a perfect fit. I do not think I have ever said that. I said 
that an external algorithms fits the model without any problems: with ~ 
500,000 data points and 19 paramters (ki in the original equation), it 
fits the model in less than 1 second. The data are not artificial data. 
The variables are independent (pi in the original model). The solution 
is unique and the rapidity of convergence is practically independent 
from the selection of start conditions (with a reasonable selection of 
start conditions at least). The resulting residuals are approximately 
normally distributed with mean 0 and sd ~ 4.23.

2) I agree with the comment of Bert on over-parametrization, but again 
the model is not overparamterised, and it is identifiable (in part 
answered already in (1))

Regards


Prof. John C Nash wrote:
 If you have a perfect fit, you have zero residuals. But in the nls 
 manual page we have:

 Warning:

  *Do not use ‘nls’ on artificial zero-residual data.*

 So this is a case of complaining that your diesel car is broken 
 because you ignored the Diesel fuel only sign on the filler cap and 
 put in gasoline.

 However I've not been happy with this choice in the code of nls -- 
 it's been there a long time -- and my own codes from 1974 onwards have 
 always handled zero residual cases. I do believe that the code could 
 at least give a better diagnostic message. Zero residuals -- perfect 
 fits -- arise when one is interested more or less in an interpolating 
 function rather than doing statistics, and I can understand the 
 reluctance of statisticians to countenance such a use of nls.

 And Bert's comment on overparametrization is almost certainly valid also.

 JN



-- 
Corrado Topi
PhD Researcher
Global Climate Change and Biodiversity
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk

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

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


[R] (no subject)

2010-03-31 Thread Terry Therneau
The answer depends on what your goals are.

If you are simply trying to put all the hazard ratios on a similar
scale, then I often use the HR comparing risk of a subject at the 25th
percentile to one at the 75th percentile.  This has already been
suggested by David W.

But this is not perfect.  The key issue is that a definition of
important is slippery.  Is a risk factor that increases your death
rate 3-fold but only appears in 10% of the subjects more or less
important than one that confers a 50% increase of risk but in 1/2 the
subjects?  (Smoking confers a major increase in the risk of a rare
disease -lung cancer- and a more modest increase in the risk of heart
disease.  The second generates more excess deaths than the first.  Which
to highlight is an old debate in public health.)

Frank's answer went more to the issue of statistical importance, which
is a yet another dimension.

Terry T.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ggplot2: Adding points to a density plot

2010-03-31 Thread Johannes Graumann
Thanks a lot! This got me started!

Joh

Dennis Murphy wrote:

 Hi:
 
 Try this:
 
 library(ggplot2)
 movmed - ddply(movies, .(decade), summarise, med = median(rating))
 m + geom_point(data = movmed, aes(x = med), y = 0, size = 2)
 
 HTH,
 Dennis
 
 On Wed, Mar 31, 2010 at 4:46 AM, Johannes Graumann
 johannes_graum...@web.de
 wrote:
 
 Hi,

 Consider something like
  library(ggplot2)
  movies$decade - round_any(movies$year, 10)
  m - qplot(rating,data=movies,colour=factor(decade),geom=density)
  m
 (modified from ?stat_density).

 I'd like to add on the line y=0 a dot for the median of each decade
 category (using the same colour coding as the fill). I'm failing
 miserably
 at all my
  m + geom_point
 based approaches and would appreciate if someone could show me the
 ggplot2 way of achieving this.

 Thanks, Joh

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

2010-03-31 Thread Ravi Varadhan
Frank,

Is there an article that discusses this idea of bootstrapping the ranks of
the likelihood ratio chi-square 
Statistics to assess relative importance of predictors in time-to-event data
(specifically Cox PH model)? 

Thanks,
Ravi.

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Frank E Harrell Jr
Sent: Tuesday, March 30, 2010 3:57 PM
To: Michal Figurski
Cc: r-help@r-project.org
Subject: Re: [R] Problem comparing hazard ratios

Michal Figurski wrote:
 Dear R-Helpers,
 
 I am a novice in survival analysis. I have the following code:
 for (i in 3:12) print(coxph(Surv(time, status)~a[,i], data=a))
 
 I used it to fit the Cox Proportional Hazard models separately for every 
 available parameter (columns 3:12) in my data set - with intention to 
 compare the Hazard Ratios.
 
 However, some of my variables are in range 0.1 to 1.6, others in range 
 5000 to 9000. How do I compare HRs between such variables?
 
 I have rescaled all the variables to be in 0 to 1 range - is this the 
 proper way to go? Is there a way to somehow calculate the same HRs (as 
 for rescaled parameters) from the HRs for original parameters?
 
 Many thanks in advance.
 

There are a lot of issues related to this that will require a good bit 
of study, both in survival analysis and in regression.  I would start 
with bootstrapping the ranks of the likelihood ratio chi-square 
statistics of the competing biomarkers.

Frank

-- 
Frank E Harrell Jr   Professor and ChairmanSchool of Medicine
  Department of Biostatistics   Vanderbilt University

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

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


Re: [R] Error grid must have equal distances in each direction

2010-03-31 Thread Matthew Dowle
M Joshi,

I don't know but I guess that some might have looked at your previous thread 
on 14 March (also about the geoR package). You received help and good advice 
then, but it doesn't appear that you are following it.  It appears to be a 
similar problem this time.

Also, this list is the wrong place for that question. Please read the 
posting guide to find out the correct place. Its a question about a package.

HTH,
Matthew


maddy madhura1...@gmail.com wrote in message 
news:1269974076132-1745651.p...@n4.nabble.com...

 Hello All,

 Can anyone please help me on this error?

 Error in FUN(X[[1L]], ...) :
  different grid distances detected, but the grid must have equal distances
 in each direction -- try gridtriple=TRUE that avoids numerical errors.

 The program that I am trying to run posted in the previous post of this
 thread.After the rows 1021 of my matrix of size 1024*1024, I start getting
 all the values as 0s.
 How to set the gridtriple as I am using the grf function which does not 
 take
 this parameter as input.

 The maximum vector limit that can be reached in 'R' is 2^30, why does it 
 not
 allow me to create arrays of length even of size 2^17?

 Thanks,
 M Joshi
 -- 
 View this message in context: 
 http://n4.nabble.com/Error-grid-must-have-equal-distances-in-each-direction-tp1695189p1745651.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] regular expression help to extract specific strings from text

2010-03-31 Thread Gabor Grothendieck
strapply in gsubfn can extract matches based on content which seems to
be what you want:

library(gsubfn)

f - function(...) sapply(list(...), paste, collapse = , )

DF - data.frame(x,
Source = strapply(x, ^(\\w+):, c, simplify = f),
Mentions = strapply(x, @(\\w+), c, simplify = f),
HashTags = strapply(x, #(\\w+), c, simplify = f))

DF[DF == ] - NA



On Wed, Mar 31, 2010 at 9:20 AM, Tony B tony.bre...@googlemail.com wrote:
 Dear all,

 Lets say I have the following:

 x - c(Eve: Going to try something new today..., Adam: Hey @Eve, how are 
 you finding R? #rstats, Eve: @Adam, It's awesome, so much better at 
 statistics that #Excel ever was! @Cain  @Able disagree though :(, Adam: 
 @Eve I'm sure they'll sort it out :), blahblah)
 x
 [1] Eve: Going to try something new
 today...
 [2] Adam: Hey @Eve, how are you finding R?
 #rstats
 [3] Eve: @Adam, It's awesome, so much better at statistics that
 \n#Excel ever was! @Cain  @Able disagree though :(
 [4] Adam: @Eve I'm sure they'll sort it
 out :)
 [5] blahblah

 I would like to come up with a data frame which looks like this
 (pulling out the usernames and #tags):

 data.frame(Msg = x, Source = c(Eve, Adam, Eve, Adam, NA), Mentions = 
 c(NA, Eve, Adam, Cain, Able, Eve, NA), HashTags = c(NA, rstats, 
 Excel, NA, NA))

 The best I can do so far is:

 source - lapply(x, function (x) {
   tmp - strsplit(x, :, fixed = TRUE)
   if(length(tmp[[1]])  2) {
     tmp - c(NA, tmp)
   }
   return(tmp[[1]][1])
  } )
 source - unlist(source)

 [1] Eve  Adam Eve  Adam NA

 I can't work out how to extract the usernames starting with '@' or the
 #tags. I can identify them using gsub and replace them, but I don't
 know how to just extract those terms only, e.g. sort of the opposite
 of the following

 gsub(@([A-Za-z0-9_]+), @[...], x)
 [1] Eve: Going to try something new today...
 [2] Adam: Hey @[...], how are you finding R? #rstats
 [3] Eve: @[...], It's awesome, so much better at statistics that
 #Excel ever was! @[...]  @[...] disagree though :(
 [4] Adam: @[...] I'm sure they'll sort it out :)
 [5] blahblah

 and

 gsub(#([A-Za-z0-9_]+), #[...], x)
 [1] Eve: Going to try something new today...
 [2] Adam: Hey @Eve, how are you finding R? #[...]
 [3] Eve: @Adam, It's awesome, so much better at statistics that
 #[...] ever was! @Cain  @Able disagree though :(
 [4] Adam: @Eve I'm sure they'll sort it out :)
 [5] blahblah

 I hope that makes sense, and thank you kindly in advance for your
 time.
 Tony Breyal

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] library sets: A EMPTY does not work; gset_intersection(A,EMPTY) works

2010-03-31 Thread Czerminski, Ryszard
When using generalized sets from sets library

A  EMPTY does not work, but gset_intersection(A,EMPTY) works: example
code below

Is it a bug?

Best regards,
Ryszard

library(sets)
support - universe - c('a','b','c','d')
A - gset(support=support, memberships=c(0.2, 0.2, 0.9, 0),
universe=universe)
class(A)
A
E - A - A # create empty set
I - gset_intersection(A, E) #  this WORKS
class(I); I
I - A  E #  this DOES NOT WORK

# ---

 support - universe - c('a','b','c','d')
 A - gset(support=support, memberships=c(0.2, 0.2, 0.9, 0),
universe=universe)
 class(A)
[1] gset cset
 A
{a [0.2], b [0.2], c [0.9]}
 E - A - A
 I - gset_intersection(A, E) #  this WORKS
 class(I); I
[1] set  gset cset
{}
 I - A  E #  this DOES NOT WORK
Error in A  E :
  operations are possible only for numeric or logical types
In addition: Warning message:
Incompatible methods (Ops.gset, Ops.set) for 


--
Confidentiality Notice: This message is private and may ...{{dropped:8}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] regular expression help to extract specific strings from text

2010-03-31 Thread hadley wickham
On Wed, Mar 31, 2010 at 8:20 AM, Tony B tony.bre...@googlemail.com wrote:
 Dear all,

 Lets say I have the following:

 x - c(Eve: Going to try something new today..., Adam: Hey @Eve, how are 
 you finding R? #rstats, Eve: @Adam, It's awesome, so much better at 
 statistics that #Excel ever was! @Cain  @Able disagree though :(, Adam: 
 @Eve I'm sure they'll sort it out :), blahblah)
 x
 [1] Eve: Going to try something new
 today...
 [2] Adam: Hey @Eve, how are you finding R?
 #rstats
 [3] Eve: @Adam, It's awesome, so much better at statistics that
 \n#Excel ever was! @Cain  @Able disagree though :(
 [4] Adam: @Eve I'm sure they'll sort it
 out :)
 [5] blahblah

 I would like to come up with a data frame which looks like this
 (pulling out the usernames and #tags):

 data.frame(Msg = x, Source = c(Eve, Adam, Eve, Adam, NA), Mentions = 
 c(NA, Eve, Adam, Cain, Able, Eve, NA), HashTags = c(NA, rstats, 
 Excel, NA, NA))

You can do this pretty easily with the stringr package:

library(stringr)
str_extract_all(x, @[a-zA-z]+)
sapply(str_extract_all(x, @[a-zA-z]+), str_c, collapse = , )

Hadley



-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

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


Re: [R] Question about 'logit' and 'mlogit' in Zelig

2010-03-31 Thread Matthew Dowle
Abraham,

This appears to be your 3rd unanswered post to r-help in March, all 3 have 
been about the Zelig package.

Please read the posting guide and find out the correct place to send 
questions about packages.  Then you might get an answer.

HTH
Matthew


Mathew, Abraham T amat...@ku.edu wrote in message 
news:281f7a5fdfef844696011cb21185f8ac0be...@mailbox-11.home.ku.edu...


I'm running a multinomial logit in R using the Zelig packages. According to 
str(trade962a), my dependent variable is a factor with three levels. When I 
run the multinomial logit I get an error message. However, when I run 
'model=logit' it works fine. any ideas on whats wrong?

## MULTINOMIAL LOGIT
anes96two - zelig(trade962a ~ age962 + education962 + personal962 + 
economy962 + partisan962 + employment962 + union962 + home962 + market962 + 
race962 + income962, model=logit, data=data96)
summary(anes96two)

#Error in attr(tt, depFactors)$depFactorVar :
#  $ operator is invalid for atomic vectors


## LOGIT
Call:
zelig(formula = trade962a ~ age962 + education962 + personal962 +
economy962 + partisan962 + employment962 + union962 + home962 +
market962 + race962 + income962, model = logit, data = data96)

Deviance Residuals:
   Min  1Q  Median  3Q Max
-2.021  -1.179   0.764   1.032   1.648

Coefficients:
   Estimate Std. Error z value Pr(|z|)
(Intercept)   -0.697675   0.600991  -1.161   0.2457
age962 0.003235   0.004126   0.784   0.4330
education962  -0.065198   0.038002  -1.716   0.0862 .
personal9620.006827   0.072421   0.094   0.9249
economy962-0.200535   0.084554  -2.372   0.0177 *
partisan9620.092361   0.079005   1.169   0.2424
employment962 -0.009346   0.044106  -0.212   0.8322
union962  -0.016293   0.149887  -0.109   0.9134
home962   -0.150221   0.133685  -1.124   0.2611
market962  0.292320   0.128636   2.272   0.0231 *
race9620.205828   0.094890   2.169   0.0301 *
income962  0.263363   0.048275   5.455 4.89e-08 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

(Dispersion parameter for binomial family taken to be 1)

Null deviance: 1841.2  on 1348  degrees of freedom
Residual deviance: 1746.3  on 1337  degrees of freedom
  (365 observations deleted due to missingness)
AIC: 1770.3

Number of Fisher Scoring iterations: 4




Thanks
Abraham

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] tm package- remove stowords failling

2010-03-31 Thread Welma Pereira
Hi,

I just noticed that by inspecting the matrix term that no all stopwords are
removed, does someone know how to fix that?

library(tm)
data(crude)
d-tm_map(crude, removeWords, stopwords(language='english'))
dt-DocumentTermMatrix(d,control=list(minWordLength=3, minDocFreq=2))
inspect( dt)

I am using R version 2.10, tm package 0.5-3

cheers
Welma

[[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] You are right and the problem is solved. Re: about the possible errors in Rgraphviz Package

2010-03-31 Thread Gabor Grothendieck
Based on your success I thought I would try again. I am not sure why I
had more success this time but this time I got this far even though I
did not change my path at all or make any system changes from what I
had before.  I did reinstall Rgraphviz but used the previously
installed graphviz.   I tried this code taken from the Rgrpahviz
vignette:

 library(Rgraphviz)
Loading required package: graph
Loading required package: grid
 set.seed(123)
 V - letters[1:10]
 M - 1:4
 g1 - randomGraph(V, M, 0.2)
 g1
A graphNEL graph with undirected edges
Number of Nodes = 10
Number of Edges = 16


but when I tried to plot it R crashed.

 plot(g1)

It did produce this message on the Windows console (not the R console):

Error: Layout type: dot not recognized. Use one of:

There was nothing after the of:

 R.version.string
[1] R version 2.10.1 Patched (2010-03-10 r51276)
 win.version()
[1] Windows Vista (build 6002) Service Pack 2
 packageDescription(Rgraphviz)$Version
[1] 1.24.0
 graphvizVersion()
$installed_version
[1] ‘2.20.3’

$build_version
[1] ‘2.20.3’




On Wed, Mar 31, 2010 at 9:56 AM, HU,ZHENGJUN h...@ufl.edu wrote:
 Hi Martin,

  It is really a 'PATH' problem. After adding C:\Program
 Files\Graphviz2.20\bin to the 'PATH' environment variable, the Rgraphviz
 package can be loaded without any error messages.

  Sorry that I ONLY set my 'PATH' environment variable correctly for R but
 not for Graphviz.

  Thank you and Duncan so much for your great help.
  Howard


 On Tue Mar 30 18:12:54 EDT 2010, Martin Morgan mtmor...@fhcrc.org wrote:

 On 03/30/2010 03:06 PM, HU,ZHENGJUN wrote:

 Hi Martin,

  I am 100% sure that I set my 'PATH' environment variable correctly
 because all other packages can loaded correctly as well as because R can
 be run correctly under both MS DOS and MS Windows XP. Also, I can create
 some simple R packages correctly.

 The PATH must be set correctly to include graphviz, as in my example
 below. Copy and paste the output of

  strsplit(Sys.getenv(PATH), ;)

 and

  list.files(strsplit(Sys.getenv(PATH), ;)[[1]][[14]], dll)

 Martin


  Thanks.
  Howard


 On Tue Mar 30 16:58:55 EDT 2010, Martin Morgan mtmor...@fhcrc.org
 wrote:

 On 03/30/2010 01:13 PM, HU,ZHENGJUN wrote:

 Hi Martin,

  I uninstalled graphviz-2.26.3.msi and then installed
 graphviz-2.20.3.1.msi. Then installed the
 Rgraphviz package again. As expected, I got the same error messages as
 before:

 Error in inDL(x, as.logical(local), as.logical(now), ...) :
  unable to load shared library
 'C:/PROGRA~1/R/R-210~1.1/library/Rgraphviz/libs/Rgraphviz.dll':
  LoadLibrary failure:  The specified module could not be found.

 'LoadLibrary' is being vague, the 'specified modules' are the DLLs from
 graphviz.

 Have you checked that your 'PATH' environment variable is set correctly?
 In R

   strsplit(Sys.getenv(PATH), ;)
 $PATH
  ...
  [14] C:\\Program Files\\Graphviz2.20\\bin
 ...

 The relevant files in this directory might look like

 list.files(strsplit(Sys.getenv(PATH), ;)[[1]][[14]], dll)

  [1] iconv.dll                      intl.dll
  [3] jpeg62.dll                     libcairo-2.dll
  [5] libcdt-4.dll                   libcgraph-4.dll
  [7] libexpat.dll                   libfontconfig-1.dll
  [9] libfreetype-6.dll              libgdk_pixbuf-2.0-0.dll
 [11] libglib-2.0-0.dll              libgmodule-2.0-0.dll
 [13] libgobject-2.0-0.dll           libgraph-4.dll
 [15] libgvc-4.dll                   libgvplugin_core-5.dll
 [17] libgvplugin_dot_layout-5.dll   libgvplugin_gd-5.dll
 [19] libgvplugin_neato_layout-5.dll libgvplugin_pango-5.dll
 [21] libltdl-3.dll                  libpango-1.0-0.dll
 [23] libpangocairo-1.0-0.dll        libpangoft2-1.0-0.dll
 [25] libpangowin32-1.0-0.dll        libpathplan-4.dll
 [27] libpng12.dll                   libxml2.dll

 Martin


  Thank you.
  Howard


 On Tue Mar 30 15:36:05 EDT 2010, Martin Morgan mtmor...@fhcrc.org
 wrote:

 On 03/30/2010 10:24 AM, HU,ZHENGJUN wrote:

 Hi Duncan,

 (They are pretty hard to find, but I think you can find them on the
 Bioconductor site.)  It is  not enough to install the Rgraphviz
 package, you also need to install Graphviz.

  Yes I did. Before installing the Rgraphviz package successfully,
 (1) I
 downloaded graphviz-2.26.3.msi for MS Windows (XP) and installed it
 successfully and (2) I also installed the packages from
 Bioconductor by:
 (Note: I use MS Windows XP and R 2.10.1 version)

 This is a bioconductor package so please ask on the Bioconductor
 mailing
 list

 http://bioconductor.org/docs/mailList.html

 See the 'README' file in the 'tar.gz' file at


  http://bioconductor.org/packages/release/Software.html
  http://bioconductor.org/packages/2.5/bioc/html/Rgraphviz.html




 http://bioconductor.org/packages/2.5/bioc/src/contrib/Rgraphviz_1.24.0.tar.gz



 which says


 o. install Graphviz ***2.20.3.1*** Windows ***binary*** distribution
 from



 http://www.graphviz.org/pub/graphviz/stable/windows/graphviz-2.20.3.1.msi


 you must use this version 

Re: [R] zero standard errors with geeglm in geepack

2010-03-31 Thread Matthew Dowle
You may not have got an answer because you posted to the wrong place. Its a 
question about a package. Please read the posting guide.

miriza miri...@sfwmd.gov wrote in message 
news:1269886286228-1695430.p...@n4.nabble.com...

 Hi!

 I am using geeglm to fit a Poisson model to a timeseries of count data as
 follows.  Since there are no clusters I use 73 values of 1 for the ids. 
 The
 problem I have is that I am getting standard errors of zero for the
 parameters.  What am I doing wrong?
 Thanks, Michelle
  N_Base
 [1]  95  85 104  88 102 104  91  88  85 115  96  83  91 107  96 116 118 
 103
 89  88 101 117  82  80  83 103 115 119  95  90  82  91 108 115  93  96  72
 [38]  98  95  98  97 104  86 107  92  94  95 100 107  76 104 101  80 102 
 100
 91  96  89  71 109  97 113  99 127 115  91  81  73  69  92  90  78  57
 Year
 [1] 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945
 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960
 1961
 [31] 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975
 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990
 1991
 [61] 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2006

 tes=geese(formula = N_Base ~ Year, id = rep(1, 73), family = poisson,
 corstr = ar1)
 summary(tes)

 Call:
 geese(formula = N_Base ~ Year, id = rep(1, 73), family = poisson,
corstr = ar1)

 Mean Model:
 Mean Link: log
 Variance to Mean Relation: poisson

 Coefficients:
estimate san.se wald p
 (Intercept)   7.1131  0  Inf 0
 Year -0.0013  0  Inf 0

 Scale Model:
 Scale Link:identity

 Estimated Scale Parameters:
estimate san.se wald p
 (Intercept) 1.79  0  Inf 0

 Correlation Model:
 Correlation Structure: ar1
 Correlation Link:  identity

 Estimated Correlation Parameters:
  estimate san.se wald p
 alpha0.187  0  Inf 0

 Returned Error Value:0
 Number of clusters:   1   Maximum cluster size: 73

 -- 
 View this message in context: 
 http://n4.nabble.com/zero-standard-errors-with-geeglm-in-geepack-tp1695430p1695430.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] GEE for a timeseries of count (one cluster)

2010-03-31 Thread Matthew Dowle
Contact the authors of those packages ?

miriza miri...@sfwmd.gov wrote in message 
news:1269981675252-1745896.p...@n4.nabble.com...

 Hi!

 I was wondering if there were any packages that would allow me to fit a 
 GEE
 to a single timeseries of counts so that I could account for 
 autocorrelation
 in the data.  I tried gee, geepack and yags packages, but I do not get
 standard errors for the parameters when using a single cluster.  Any tips?

 Thanks, Michelle
 -- 
 View this message in context: 
 http://n4.nabble.com/GEE-for-a-timeseries-of-count-one-cluster-tp1745896p1745896.html
 Sent from the R help mailing list archive at Nabble.com.


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


Re: [R] for loop; lm() regressions; list of vectors - lapply - accolades and square brackets??

2010-03-31 Thread Peter Ehlers

Driss,

David is right - you should include data/code.

Nevertheless, the error you get suggests that what you
call a matrix is in fact a data.frame; that's usually
a crucial distinction. There are two things you might try:

Dennis' way:

 lm(as.matrix(a) ~ b)

David's way:

 for(i in seq_along(a)) print(r- lm(a[ ,i] ~ b) )

#Note the comma!

 -Peter Ehlers

On 2010-03-31 7:42, David Winsemius wrote:


On Mar 31, 2010, at 9:13 AM, Driss Agramelal wrote:



Hello and thank you both for your answers!

Dennis, I tried to simply run

lm(a ~ b)

after re-importing a as a matrix, but I get the following error
message:

Error in model.frame.default(formula = a ~ b, drop.unused.levels =
TRUE) :
   invalid type (list) for variable 'a'

so maybe I have to specify something in the arguments? What do you
think?

David,

I tried your syntax as well, and received quasi-the same error
statement:


for(i in seq_along(a)) print(r- lm(a[i] ~ b) )

Error in model.frame.default(formula = a[i] ~ b, drop.unused.levels
= TRUE) :
   invalid type (list) for variable 'a[i]'

I am not too familiar with the use of accolades, square brackets and
parentheses, the order in which they have to come
in the function and the role they play, but I think they might be
important...

I also tried to use lapply; it works wonderfully for a basic
function like:

lapply(a, mean)

I get a list of results with names and values..perfect! But with the
lm() function... I just
don't know how to write the arguments... tried several options
without success...

Any idea that could help me solve this only seemingly easy task
would be most welcome!!


Do you think we can figure this out when you have provided no sample
data and have not provided even the results of str on the data object
you are working with? Generally one gains insight by parring the
problem down to smaller test cases and working with them. Perhaps the
first 5 elements of a rather than all 150?



--
Peter Ehlers
University of Calgary

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

2010-03-31 Thread Matthew Dowle
Apparently not, since this your 3rd unanswered thread to r-help this month 
about this package.

Please read the posting guide and find out where you should send questions 
about packages.  Then you might get an answer.


ping chen chen1984...@yahoo.com.cn wrote in message 
news:975148.47160...@web15304.mail.cnb.yahoo.com...
 Hi R-users:

 Can anyone give an example of giving starting values for MCMCglmm?
 I can't find any anywhere.
 I have 1 random effect (physicians, and there are 50 of them)
 and family=ordinal.

 How can I specify starting values for my fixed effects? It doesn't seem to 
 have the option to do so.

 Thanks, Ping




 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] You are right and the problem is solved. Re: about the possible errors in Rgraphviz Package

2010-03-31 Thread Gabor Grothendieck
By the way, just in case you did not read the entire message R crashed
when I tried to run the code from the vignette.

On Wed, Mar 31, 2010 at 10:52 AM, Gabor Grothendieck
ggrothendi...@gmail.com wrote:
 Based on your success I thought I would try again. I am not sure why I
 had more success this time but this time I got this far even though I
 did not change my path at all or make any system changes from what I
 had before.  I did reinstall Rgraphviz but used the previously
 installed graphviz.   I tried this code taken from the Rgrpahviz
 vignette:

 library(Rgraphviz)
 Loading required package: graph
 Loading required package: grid
 set.seed(123)
 V - letters[1:10]
 M - 1:4
 g1 - randomGraph(V, M, 0.2)
 g1
 A graphNEL graph with undirected edges
 Number of Nodes = 10
 Number of Edges = 16


 but when I tried to plot it R crashed.

 plot(g1)

 It did produce this message on the Windows console (not the R console):

 Error: Layout type: dot not recognized. Use one of:

 There was nothing after the of:

 R.version.string
 [1] R version 2.10.1 Patched (2010-03-10 r51276)
 win.version()
 [1] Windows Vista (build 6002) Service Pack 2
 packageDescription(Rgraphviz)$Version
 [1] 1.24.0
 graphvizVersion()
 $installed_version
 [1] ‘2.20.3’

 $build_version
 [1] ‘2.20.3’




 On Wed, Mar 31, 2010 at 9:56 AM, HU,ZHENGJUN h...@ufl.edu wrote:
 Hi Martin,

  It is really a 'PATH' problem. After adding C:\Program
 Files\Graphviz2.20\bin to the 'PATH' environment variable, the Rgraphviz
 package can be loaded without any error messages.

  Sorry that I ONLY set my 'PATH' environment variable correctly for R but
 not for Graphviz.

  Thank you and Duncan so much for your great help.
  Howard


 On Tue Mar 30 18:12:54 EDT 2010, Martin Morgan mtmor...@fhcrc.org wrote:

 On 03/30/2010 03:06 PM, HU,ZHENGJUN wrote:

 Hi Martin,

  I am 100% sure that I set my 'PATH' environment variable correctly
 because all other packages can loaded correctly as well as because R can
 be run correctly under both MS DOS and MS Windows XP. Also, I can create
 some simple R packages correctly.

 The PATH must be set correctly to include graphviz, as in my example
 below. Copy and paste the output of

  strsplit(Sys.getenv(PATH), ;)

 and

  list.files(strsplit(Sys.getenv(PATH), ;)[[1]][[14]], dll)

 Martin


  Thanks.
  Howard


 On Tue Mar 30 16:58:55 EDT 2010, Martin Morgan mtmor...@fhcrc.org
 wrote:

 On 03/30/2010 01:13 PM, HU,ZHENGJUN wrote:

 Hi Martin,

  I uninstalled graphviz-2.26.3.msi and then installed
 graphviz-2.20.3.1.msi. Then installed the
 Rgraphviz package again. As expected, I got the same error messages as
 before:

 Error in inDL(x, as.logical(local), as.logical(now), ...) :
  unable to load shared library
 'C:/PROGRA~1/R/R-210~1.1/library/Rgraphviz/libs/Rgraphviz.dll':
  LoadLibrary failure:  The specified module could not be found.

 'LoadLibrary' is being vague, the 'specified modules' are the DLLs from
 graphviz.

 Have you checked that your 'PATH' environment variable is set correctly?
 In R

   strsplit(Sys.getenv(PATH), ;)
 $PATH
  ...
  [14] C:\\Program Files\\Graphviz2.20\\bin
 ...

 The relevant files in this directory might look like

 list.files(strsplit(Sys.getenv(PATH), ;)[[1]][[14]], dll)

  [1] iconv.dll                      intl.dll
  [3] jpeg62.dll                     libcairo-2.dll
  [5] libcdt-4.dll                   libcgraph-4.dll
  [7] libexpat.dll                   libfontconfig-1.dll
  [9] libfreetype-6.dll              libgdk_pixbuf-2.0-0.dll
 [11] libglib-2.0-0.dll              libgmodule-2.0-0.dll
 [13] libgobject-2.0-0.dll           libgraph-4.dll
 [15] libgvc-4.dll                   libgvplugin_core-5.dll
 [17] libgvplugin_dot_layout-5.dll   libgvplugin_gd-5.dll
 [19] libgvplugin_neato_layout-5.dll libgvplugin_pango-5.dll
 [21] libltdl-3.dll                  libpango-1.0-0.dll
 [23] libpangocairo-1.0-0.dll        libpangoft2-1.0-0.dll
 [25] libpangowin32-1.0-0.dll        libpathplan-4.dll
 [27] libpng12.dll                   libxml2.dll

 Martin


  Thank you.
  Howard


 On Tue Mar 30 15:36:05 EDT 2010, Martin Morgan mtmor...@fhcrc.org
 wrote:

 On 03/30/2010 10:24 AM, HU,ZHENGJUN wrote:

 Hi Duncan,

 (They are pretty hard to find, but I think you can find them on the
 Bioconductor site.)  It is  not enough to install the Rgraphviz
 package, you also need to install Graphviz.

  Yes I did. Before installing the Rgraphviz package successfully,
 (1) I
 downloaded graphviz-2.26.3.msi for MS Windows (XP) and installed it
 successfully and (2) I also installed the packages from
 Bioconductor by:
 (Note: I use MS Windows XP and R 2.10.1 version)

 This is a bioconductor package so please ask on the Bioconductor
 mailing
 list

 http://bioconductor.org/docs/mailList.html

 See the 'README' file in the 'tar.gz' file at


  http://bioconductor.org/packages/release/Software.html
  http://bioconductor.org/packages/2.5/bioc/html/Rgraphviz.html




 

Re: [R] library sets: A EMPTY does not work; gset_intersection(A,EMPTY) works

2010-03-31 Thread Peter Ehlers

Unless I'm missing something, I don't see any method
in pkg:sets for intersection other than gset_intersection.
So you're using the base R function `` whose help page
tells you that its arguments should be vectors. Yours
aren't.

 -Peter Ehlers

On 2010-03-31 8:50, Czerminski, Ryszard wrote:

When using generalized sets from sets library

A  EMPTY does not work, but gset_intersection(A,EMPTY) works: example
code below

Is it a bug?

Best regards,
Ryszard

library(sets)
support- universe- c('a','b','c','d')
A- gset(support=support, memberships=c(0.2, 0.2, 0.9, 0),
universe=universe)
class(A)
A
E- A - A # create empty set
I- gset_intersection(A, E) #  this WORKS
class(I); I
I- A  E #  this DOES NOT WORK

# ---


support- universe- c('a','b','c','d')
A- gset(support=support, memberships=c(0.2, 0.2, 0.9, 0),

universe=universe)

class(A)

[1] gset cset

A

{a [0.2], b [0.2], c [0.9]}

E- A - A
I- gset_intersection(A, E) #  this WORKS
class(I); I

[1] set  gset cset
{}

I- A  E #  this DOES NOT WORK

Error in A  E :
   operations are possible only for numeric or logical types
In addition: Warning message:
Incompatible methods (Ops.gset, Ops.set) for 


--
Confidentiality Notice: This message is private and may ...{{dropped:8}}

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




--
Peter Ehlers
University of Calgary

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

2010-03-31 Thread Gustaf Rydevik
On Wed, Mar 31, 2010 at 5:11 PM, Sergey Goriatchev serg...@gmail.com wrote:
 but

 data - merge(data,data.list)

 works.

 Neither data or data.list is a list, so do.call does not work.
 I am very weak on lists, never used them before

 Best,
 Sergey

Hej Sergey,

Ok; I was wondering if the apply thing would work. Cool that merge
would be clever enough to append a matrix. I'm guessing that you've
got what you needed then? For reference,  (and for the general list) I
had changed the  code  before Sergeys response, replacing apply() with
lapply(). That code follows below.
Best regards,
Gustaf


-
cnames - c(BMM, GM1, IYC, FCA, IMM, BME, CRT, GTF,
ERU, ERE, EPT, EVA, EMT, EMM, EMV, ETM)
AVnames - paste(cnames, .AV120, sep=)
SDnames - paste(cnames, .SD120, sep=)
a - zoo(matrix(rep(seq(from=160, to=10, by=-10), 1000), ncol=16, byrow=TRUE))
colnames(a) - AVnames
b - zoo(matrix(rep(2, 16000), ncol=16))
colnames(b) - SDnames
data - merge(a, b)
MyFunc - function(x, ret, stdev){
   if(any(is.na(c(x[ret], x[stdev]{
   return(NA)
   }else{
   return(x[ret]/x[stdev])
   }
}
names.df-data.frame(rbind(SRnames,AVnames,SDnames))
func - function(.names){
   apply(data, 1, MyFunc, ret=.names[2], stdev=.names[3])
}
data.list-lapply(names.df, func)
mrets-do.call(merge,c(list(data),data.list))









On Wed, Mar 31, 2010 at 12:33, Gustaf Rydevik gustaf.ryde...@gmail.com wrote:
 How about this (not tested, since you did not provide example data nor
 function code):

 ---

 SRnames - paste(colnames.mrets, .SR, sep=)
 AVnames - paste(colnames.mrets, .AV120, sep=)
 SDnames - paste(colnames.mrets, .SD120, sep=)
 names.matrix-cbind(SRnames,AVnames,SDnames)

 mrets.list-apply(names.matrix,1,function(.names){
 apply(mrets,1,MyFunc,ret=.names[2],stdev=.names[3]}
 )
 names(mrets.list)-names.matrix[,1]
 mrets-do.call(merge,mrets.list)

 -
 ?
 /Gustaf

 On Wed, Mar 31, 2010 at 12:10 PM, Sergey Goriatchev serg...@gmail.com wrote:
 Hello, everyone

 I have a piece of code that looks like this:

 mrets - merge(mrets, BMM.SR=apply(mrets, 1, MyFunc, ret=BMM.AV120,
 stdev=BMM.SD120))
 mrets - merge(mrets, GM1.SR=apply(mrets, 1, MyFunc, ret=GM1.AV120,
 stdev=GM1.SD120))
 mrets - merge(mrets, IYC.SR=apply(mrets, 1, MyFunc, ret=IYC.AV120,
 stdev=IYC.SD120))
 mrets - merge(mrets, FCA.SR=apply(mrets, 1, MyFunc, ret=FCA.AV120,
 stdev=FCA.SD120))
 mrets - merge(mrets, IMM.SR=apply(mrets, 1, MyFunc, ret=IMM.AV120,
 stdev=IMM.SD120))
 mrets - merge(mrets, BME.SR=apply(mrets, 1, MyFunc, ret=BME.AV120,
 stdev=BME.SD120))
 mrets - merge(mrets, CRT.SR=apply(mrets, 1, MyFunc, ret=CRT.AV120,
 stdev=CRT.SD120))
 mrets - merge(mrets, GTF.SR=apply(mrets, 1, MyFunc, ret=GTF.AV120,
 stdev=GTF.SD120))
 mrets - merge(mrets, ERU.SR=apply(mrets, 1, MyFunc, ret=ERU.AV120,
 stdev=ERU.SD120))
 mrets - merge(mrets, ERE.SR=apply(mrets, 1, MyFunc, ret=ERE.AV120,
 stdev=ERE.SD120))
 mrets - merge(mrets, EPT.SR=apply(mrets, 1, MyFunc, ret=EPT.AV120,
 stdev=EPT.SD120))
 mrets - merge(mrets, EVA.SR=apply(mrets, 1, MyFunc, ret=EVA.AV120,
 stdev=EVA.SD120))
 mrets - merge(mrets, EMT.SR=apply(mrets, 1, MyFunc, ret=EMT.AV120,
 stdev=EMT.SD120))
 mrets - merge(mrets, EMM.SR=apply(mrets, 1, MyFunc, ret=EMM.AV120,
 stdev=EMM.SD120))
 mrets - merge(mrets, EMV.SR=apply(mrets, 1, MyFunc, ret=EMV.AV120,
 stdev=EMV.SD120))
 mrets - merge(mrets, ETM.SR=apply(mrets, 1, MyFunc, ret=ETM.AV120,
 stdev=ETM.SD120))

 Is there a way to simplify this, some sort of loop?
 mrets is a zoo object.
 .AV120 and .SD120 are columns in this object.
 I need the exact .SR column names.

 This does not work:
 SRnames - paste(colnames.mrets, .SR, sep=)
 AVnames - paste(colnames.mrets, .AV120, sep=)
 SDnames - paste(colnames.mrets, .SD120, sep=)

 for(i in seq(SRnames)){
 mrets - merge(mrets, SRnames[i]=apply(mrets, 1, MyFunc,
 ret=AVnames[i], stdev=SDnames[i]))
 }


 Help much appreciated.

 Regards,
 Sergey


 --
 Simplicity is the last step of art./Bruce Lee
 The more you know, the more you know you don't know. /Myself

 I'm not young enough to know everything. /Oscar Wilde
 Experience is one thing you can't get for nothing. /Oscar Wilde
 When you are finished changing, you're finished. /Benjamin Franklin
 Luck is where preparation meets opportunity. /George Patten

 Kniven skärpes bara mot stenen.

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



-- 
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
skype:gustaf_rydevik

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

[R] predict.Arima: warnings from xreg magic

2010-03-31 Thread Johann Hibschman
When I run predict.Arima in my code, I get warnings like:

  Warning message:
  In cbind(intercept = rep(1, n), xreg) :
number of rows of result is not a multiple of vector length (arg 1)

I think this is because I'm not running predict.Arima in the same
environment that I did the fit, so the data object used in the fit is no
longer present.  Looking at the predict.Arima source,

  predict.Arima -
  function (object, n.ahead = 1, newxreg = NULL, se.fit = TRUE, ...)
  {
  myNCOL - function(x) if (is.null(x)) 0 else NCOL(x)
  rsd - object$residuals
  xr - object$call$xreg
  xreg - if (!is.null(xr)) eval.parent(xr) else NULL
  ncxreg - myNCOL(xreg)
  if (myNCOL(newxreg) != ncxreg)
  stop('xreg' and 'newxreg' have different numbers of columns)
  class(xreg) - NULL
  xtsp - tsp(rsd)
  n - length(rsd)
  arma - object$arma
  coefs - object$coef
  narma - sum(arma[1L:4L])
  if (length(coefs)  narma) {
  if (names(coefs)[narma + 1L] == intercept) {
  xreg - cbind(intercept = rep(1, n), xreg)
  newxreg - cbind(intercept = rep(1, n.ahead), newxreg)
  ncxreg - ncxreg + 1L
  }
  ...

It looks to me as if it assumes that object$call$xreg is available in
the current (well, parent) environment.

To add insult to injury, it doesn't look like xreg is used anywhere in
the code; it's calculated, then ignored.

So, here are my questions:

  1. Is this a correct diagnosis?
  2. What can I do about it?
a. Is there a version of arima with less magic?
b. Should I try to populate my environment to look like the calling
   environment?
c. Other?


Thanks,

Johann

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

2010-03-31 Thread Sergey Goriatchev
Thanks for help, Gustaf!

(Kan man säga man tackar oxa?) :-)

On Wed, Mar 31, 2010 at 17:34, Gustaf Rydevik gustaf.ryde...@gmail.com wrote:
 On Wed, Mar 31, 2010 at 5:11 PM, Sergey Goriatchev serg...@gmail.com wrote:
 but

 data - merge(data,data.list)

 works.

 Neither data or data.list is a list, so do.call does not work.
 I am very weak on lists, never used them before

 Best,
 Sergey

 Hej Sergey,

 Ok; I was wondering if the apply thing would work. Cool that merge
 would be clever enough to append a matrix. I'm guessing that you've
 got what you needed then? For reference,  (and for the general list) I
 had changed the  code  before Sergeys response, replacing apply() with
 lapply(). That code follows below.
 Best regards,
 Gustaf


 -
 cnames - c(BMM, GM1, IYC, FCA, IMM, BME, CRT, GTF,
 ERU, ERE, EPT, EVA, EMT, EMM, EMV, ETM)
 AVnames - paste(cnames, .AV120, sep=)
 SDnames - paste(cnames, .SD120, sep=)
 a - zoo(matrix(rep(seq(from=160, to=10, by=-10), 1000), ncol=16, byrow=TRUE))
 colnames(a) - AVnames
 b - zoo(matrix(rep(2, 16000), ncol=16))
 colnames(b) - SDnames
 data - merge(a, b)
 MyFunc - function(x, ret, stdev){
       if(any(is.na(c(x[ret], x[stdev]{
               return(NA)
       }else{
               return(x[ret]/x[stdev])
       }
 }
 names.df-data.frame(rbind(SRnames,AVnames,SDnames))
 func - function(.names){
       apply(data, 1, MyFunc, ret=.names[2], stdev=.names[3])
 }
 data.list-lapply(names.df, func)
 mrets-do.call(merge,c(list(data),data.list))









 On Wed, Mar 31, 2010 at 12:33, Gustaf Rydevik gustaf.ryde...@gmail.com 
 wrote:
 How about this (not tested, since you did not provide example data nor
 function code):

 ---

 SRnames - paste(colnames.mrets, .SR, sep=)
 AVnames - paste(colnames.mrets, .AV120, sep=)
 SDnames - paste(colnames.mrets, .SD120, sep=)
 names.matrix-cbind(SRnames,AVnames,SDnames)

 mrets.list-apply(names.matrix,1,function(.names){
 apply(mrets,1,MyFunc,ret=.names[2],stdev=.names[3]}
 )
 names(mrets.list)-names.matrix[,1]
 mrets-do.call(merge,mrets.list)

 -
 ?
 /Gustaf

 On Wed, Mar 31, 2010 at 12:10 PM, Sergey Goriatchev serg...@gmail.com 
 wrote:
 Hello, everyone

 I have a piece of code that looks like this:

 mrets - merge(mrets, BMM.SR=apply(mrets, 1, MyFunc, ret=BMM.AV120,
 stdev=BMM.SD120))
 mrets - merge(mrets, GM1.SR=apply(mrets, 1, MyFunc, ret=GM1.AV120,
 stdev=GM1.SD120))
 mrets - merge(mrets, IYC.SR=apply(mrets, 1, MyFunc, ret=IYC.AV120,
 stdev=IYC.SD120))
 mrets - merge(mrets, FCA.SR=apply(mrets, 1, MyFunc, ret=FCA.AV120,
 stdev=FCA.SD120))
 mrets - merge(mrets, IMM.SR=apply(mrets, 1, MyFunc, ret=IMM.AV120,
 stdev=IMM.SD120))
 mrets - merge(mrets, BME.SR=apply(mrets, 1, MyFunc, ret=BME.AV120,
 stdev=BME.SD120))
 mrets - merge(mrets, CRT.SR=apply(mrets, 1, MyFunc, ret=CRT.AV120,
 stdev=CRT.SD120))
 mrets - merge(mrets, GTF.SR=apply(mrets, 1, MyFunc, ret=GTF.AV120,
 stdev=GTF.SD120))
 mrets - merge(mrets, ERU.SR=apply(mrets, 1, MyFunc, ret=ERU.AV120,
 stdev=ERU.SD120))
 mrets - merge(mrets, ERE.SR=apply(mrets, 1, MyFunc, ret=ERE.AV120,
 stdev=ERE.SD120))
 mrets - merge(mrets, EPT.SR=apply(mrets, 1, MyFunc, ret=EPT.AV120,
 stdev=EPT.SD120))
 mrets - merge(mrets, EVA.SR=apply(mrets, 1, MyFunc, ret=EVA.AV120,
 stdev=EVA.SD120))
 mrets - merge(mrets, EMT.SR=apply(mrets, 1, MyFunc, ret=EMT.AV120,
 stdev=EMT.SD120))
 mrets - merge(mrets, EMM.SR=apply(mrets, 1, MyFunc, ret=EMM.AV120,
 stdev=EMM.SD120))
 mrets - merge(mrets, EMV.SR=apply(mrets, 1, MyFunc, ret=EMV.AV120,
 stdev=EMV.SD120))
 mrets - merge(mrets, ETM.SR=apply(mrets, 1, MyFunc, ret=ETM.AV120,
 stdev=ETM.SD120))

 Is there a way to simplify this, some sort of loop?
 mrets is a zoo object.
 .AV120 and .SD120 are columns in this object.
 I need the exact .SR column names.

 This does not work:
 SRnames - paste(colnames.mrets, .SR, sep=)
 AVnames - paste(colnames.mrets, .AV120, sep=)
 SDnames - paste(colnames.mrets, .SD120, sep=)

 for(i in seq(SRnames)){
 mrets - merge(mrets, SRnames[i]=apply(mrets, 1, MyFunc,
 ret=AVnames[i], stdev=SDnames[i]))
 }


 Help much appreciated.

 Regards,
 Sergey


 --
 Simplicity is the last step of art./Bruce Lee
 The more you know, the more you know you don't know. /Myself

 I'm not young enough to know everything. /Oscar Wilde
 Experience is one thing you can't get for nothing. /Oscar Wilde
 When you are finished changing, you're finished. /Benjamin Franklin
 Luck is where preparation meets opportunity. /George Patten

 Kniven skärpes bara mot stenen.

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



 --
 Gustaf Rydevik, M.Sci.
 tel: +46(0)703 051 451
 address:Essingetorget 40,112 66 Stockholm, SE
 

Re: [R] library sets: A EMPTY does not work; gset_intersection(A,EMPTY) works

2010-03-31 Thread Peter Ehlers

On 2010-03-31 9:30, Peter Ehlers wrote:

Unless I'm missing something, I don't see any method
in pkg:sets for intersection other than gset_intersection.


Whoops, a bit quick on the draw.
There are of course also set_intersection and cset_intersection,
but not AFAICS any method for ``.

 -Peter Ehlers


So you're using the base R function `` whose help page
tells you that its arguments should be vectors. Yours
aren't.

-Peter Ehlers

On 2010-03-31 8:50, Czerminski, Ryszard wrote:

When using generalized sets from sets library

A EMPTY does not work, but gset_intersection(A,EMPTY) works: example
code below

Is it a bug?

Best regards,
Ryszard

library(sets)
support- universe- c('a','b','c','d')
A- gset(support=support, memberships=c(0.2, 0.2, 0.9, 0),
universe=universe)
class(A)
A
E- A - A # create empty set
I- gset_intersection(A, E) # this WORKS
class(I); I
I- A E # this DOES NOT WORK

# ---


support- universe- c('a','b','c','d')
A- gset(support=support, memberships=c(0.2, 0.2, 0.9, 0),

universe=universe)

class(A)

[1] gset cset

A

{a [0.2], b [0.2], c [0.9]}

E- A - A
I- gset_intersection(A, E) # this WORKS
class(I); I

[1] set gset cset
{}

I- A E # this DOES NOT WORK

Error in A E :
operations are possible only for numeric or logical types
In addition: Warning message:
Incompatible methods (Ops.gset, Ops.set) for 


--

Confidentiality Notice: This message is private and may ...{{dropped:8}}

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






--
Peter Ehlers
University of Calgary

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Boundary kernel for kernel density plot?

2010-03-31 Thread Ravi Kulkarni

Hello,
  Is a kernel called the boundary kernel available for kernel density
plots? 
In the help, I can only see the following kernels: gaussian,
rectangular, triangular, epanechnikov, biweight, cosine or
optcosine.

The boundary kernel apparently improves the estimate in a neighborhood of
zero. 

Thanks,

  Ravi Kulkarni
-- 
View this message in context: 
http://n4.nabble.com/Boundary-kernel-for-kernel-density-plot-tp1746968p1746968.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] position of mismatches in all.equal()?

2010-03-31 Thread Ivan Calandra

I've actually found a solution to my problem.
In case someone could be interested, the which() function seems to do 
the trick:


 test2$let2 - factor(test2$let2, levels=letters[1:10])
 which(test1[,3]!=test2[,3])
[1] 7
 which(test1[,1:3]!=test2[,1:3])
[1] 27



Le 3/31/2010 15:13, Ivan Calandra a écrit :

Dear R users,

I would like to compare two dataframes, actually their categorical 
variables (as factors) only (there are 12, from column 1 to 12).
The reason I do that is that I got 2 datasets from two different 
methods and I would like to be sure that each method used the same 
data (3D images) to extract 2 different sets of 3D parameters. Is it 
clear so far?


So I thought about using all.equal() like this:

test1 - data.frame(num=1:10, let1=letters[1:10], let2=letters[1:10])
test2 - data.frame(num=1:10, let1=letters[1:10], let2=letters[c(1:6, 
6, 8:10)])


Since I want to compare only some columns, I do this:
 all.equal(test1[,1:2], test2[,1:2])
[1] TRUE
 all.equal(test1[,1:3], test2[,1:3])
[1] Component 3: Attributes:  Component 2: Lengths (10, 9) differ 
(string compare on first 9) 

[2] Component 3: Attributes:  Component 2: 3 string mismatches 
[3] Component 3: 1 string mismatch

If I get TRUE, then everythin's fine. But if not, I just know from the 
output in which column(s) are the mismatches and how many (here 1).
But my datasets are 2000+ rows, and I would like to know the row 
number(s) where mismatches occur.


How can I do that?

Thank you for your help!
Regards,
Ivan



--
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calan...@uni-hamburg.de

**
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] library sets: A EMPTY does not work; gset_intersection(A,EMPTY) works

2010-03-31 Thread Czerminski, Ryszard
It seems that A  B works the same way as gset_intersection(A,B)
as long as A and B are not empty...
see below:

fuzzy_logic(Yager, p=2)
support - universe - c('a','b','c','d')
A - gset(support=support, memberships=c(0.2, 0.2, 0.9, 0),
universe=universe)
B - gset(support=support, memberships=c(0.211, 0.222, 0.999, 0),
universe=universe)
A
B
A  B
gset_intersection(A,B)
E - A - A
A  E
gset_intersection(A,E)

 fuzzy_logic(Yager, p=2)
 support - universe - c('a','b','c','d')
 A - gset(support=support, memberships=c(0.2, 0.2, 0.9, 0),
universe=universe)
 B - gset(support=support, memberships=c(0.211, 0.222, 0.999, 0),
universe=universe)
 A
{a [0.2], b [0.2], c [0.9]}
 B
{a [0.211], b [0.222], c [0.999]}
 A  B
{c [0.85]}
 gset_intersection(A,B)
{c [0.85]}
 E - A - A
 A  E
Error in A  E :
  operations are possible only for numeric or logical types
In addition: Warning message:
Incompatible methods (Ops.gset, Ops.set) for 
 gset_intersection(A,E)
{}


--
Confidentiality Notice: This message is private and may contain confidential 
and proprietary information. If you have received this message in error, please 
notify us and remove it from your system and note that you must not copy, 
distribute or take any action in reliance on it. Any unauthorized use or 
disclosure of the contents of this message is not permitted and may be unlawful.

-Original Message-
From: Peter Ehlers [mailto:ehl...@ucalgary.ca] 
Sent: Wednesday, March 31, 2010 11:43 AM
To: Czerminski, Ryszard
Cc: R-help@r-project.org
Subject: Re: [R] library sets: A  EMPTY does not work;
gset_intersection(A,EMPTY) works

On 2010-03-31 9:30, Peter Ehlers wrote:
 Unless I'm missing something, I don't see any method
 in pkg:sets for intersection other than gset_intersection.

Whoops, a bit quick on the draw.
There are of course also set_intersection and cset_intersection,
but not AFAICS any method for ``.

  -Peter Ehlers

 So you're using the base R function `` whose help page
 tells you that its arguments should be vectors. Yours
 aren't.

 -Peter Ehlers

 On 2010-03-31 8:50, Czerminski, Ryszard wrote:
 When using generalized sets from sets library

 A EMPTY does not work, but gset_intersection(A,EMPTY) works: example
 code below

 Is it a bug?

 Best regards,
 Ryszard

 library(sets)
 support- universe- c('a','b','c','d')
 A- gset(support=support, memberships=c(0.2, 0.2, 0.9, 0),
 universe=universe)
 class(A)
 A
 E- A - A # create empty set
 I- gset_intersection(A, E) # this WORKS
 class(I); I
 I- A E # this DOES NOT WORK

 # ---

 support- universe- c('a','b','c','d')
 A- gset(support=support, memberships=c(0.2, 0.2, 0.9, 0),
 universe=universe)
 class(A)
 [1] gset cset
 A
 {a [0.2], b [0.2], c [0.9]}
 E- A - A
 I- gset_intersection(A, E) # this WORKS
 class(I); I
 [1] set gset cset
 {}
 I- A E # this DOES NOT WORK
 Error in A E :
 operations are possible only for numeric or logical types
 In addition: Warning message:
 Incompatible methods (Ops.gset, Ops.set) for 




--

 Confidentiality Notice: This message is private and may
...{{dropped:8}}

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




-- 
Peter Ehlers
University of Calgary

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


Re: [R] Error singular gradient matrix at initial parameter estimates in nls

2010-03-31 Thread Bert Gunter
Corrado:

Over parameterization/non-identifiability is not determined by the ratio of
the number of data values to the number of parameters: if you try to fit a
scatter of a zillion points that lie near a straight line to a model with
curvature -- the 4p logistic function, say -- you're over-parameterized.
Period.

I am not an expert on nonlinear optimization, but I would think that the
correlation matrix of the parameters would be one thing to check; another
would be the change in the fits when some of the model terms are dropped.
But model selection for nonlinear fitting is not a trivial issue, and those
with real expertise, not me, could be more helpful.

The fact that other algorithms converge while R's did not is also not
particularly informative, I believe. This could occur merely due to the
choice of convergence criteria (step size, choice of objective function,
etc.).  Or the convergence could be to a local minimum, not a global one.
Comparison of performance of optimization algorithms is, again, a cottage
industry for which serious expertise is required. (This should not be taken
as a defense of R, either. My optimization ignorance cuts both ways). 

So I do not think your protestations of innocence are necessarily accurate.
Nor, I agree,  are my accusations of guilt. I **still** believe that your
convergence difficulties are due to over-parameterization, and that this is
something that needs to be carefully investigated; but that is a prior, not
a posterior.  Examining lots of plots is probably a good place to begin.

Cheers,
Bert

Bert Gunter
Genentech Nonclinical Biostatistics

 


-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Corrado
Sent: Wednesday, March 31, 2010 6:13 AM
Cc: r-help@r-project.org
Subject: Re: [R] Error singular gradient matrix at initial parameter
estimates in nls

Dear JN, Bert,

1) It is not a perfect fit. I do not think I have ever said that. I said 
that an external algorithms fits the model without any problems: with ~ 
500,000 data points and 19 paramters (ki in the original equation), it 
fits the model in less than 1 second. The data are not artificial data. 
The variables are independent (pi in the original model). The solution 
is unique and the rapidity of convergence is practically independent 
from the selection of start conditions (with a reasonable selection of 
start conditions at least). The resulting residuals are approximately 
normally distributed with mean 0 and sd ~ 4.23.

2) I agree with the comment of Bert on over-parametrization, but again 
the model is not overparamterised, and it is identifiable (in part 
answered already in (1))

Regards


Prof. John C Nash wrote:
 If you have a perfect fit, you have zero residuals. But in the nls 
 manual page we have:

 Warning:

  *Do not use 'nls' on artificial zero-residual data.*

 So this is a case of complaining that your diesel car is broken 
 because you ignored the Diesel fuel only sign on the filler cap and 
 put in gasoline.

 However I've not been happy with this choice in the code of nls -- 
 it's been there a long time -- and my own codes from 1974 onwards have 
 always handled zero residual cases. I do believe that the code could 
 at least give a better diagnostic message. Zero residuals -- perfect 
 fits -- arise when one is interested more or less in an interpolating 
 function rather than doing statistics, and I can understand the 
 reluctance of statisticians to countenance such a use of nls.

 And Bert's comment on overparametrization is almost certainly valid also.

 JN



-- 
Corrado Topi
PhD Researcher
Global Climate Change and Biodiversity
Area 18,Department of Biology
University of York, York, YO10 5YW, UK
Phone: + 44 (0) 1904 328645, E-mail: ct...@york.ac.uk

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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] You are right and the problem is solved. Re: about the possible errors in Rgraphviz Package

2010-03-31 Thread Martin Morgan
On 03/31/2010 08:18 AM, Gabor Grothendieck wrote:
 By the way, just in case you did not read the entire message R crashed

I think you mean that you got an error message, not that R became
unusable? More below...

 when I tried to run the code from the vignette.
 
 On Wed, Mar 31, 2010 at 10:52 AM, Gabor Grothendieck
 ggrothendi...@gmail.com wrote:
 Based on your success I thought I would try again. I am not sure why I
 had more success this time but this time I got this far even though I
 did not change my path at all or make any system changes from what I
 had before.  I did reinstall Rgraphviz but used the previously
 installed graphviz.   I tried this code taken from the Rgrpahviz
 vignette:

 library(Rgraphviz)
 Loading required package: graph
 Loading required package: grid
 set.seed(123)
 V - letters[1:10]
 M - 1:4
 g1 - randomGraph(V, M, 0.2)
 g1
 A graphNEL graph with undirected edges
 Number of Nodes = 10
 Number of Edges = 16


 but when I tried to plot it R crashed.

 plot(g1)

 It did produce this message on the Windows console (not the R console):

 Error: Layout type: dot not recognized. Use one of:

In the past this has come about when accessing incorrect graphviz DLLs.
The gory detail (if I remember correctly) is that a FILE* gets allocated
in Rgraphviz and passed to graphviz, and if there is a compiler mismatch
then there are no guarantees about FILE* representation.

The implication is that your Rgraphviz and graphiz are at least partly
out of sync, but it could also be that I am 'getting lucky'. When you
say (quoting from above)...

 did not change my path at all or make any system changes from what I

the implication is that your PATH was already set to include a
graphviz2.20\\bin directory; I'd encourage you to confirm that.

And recognizing that you might justifiably be willing to put this on the
shelf, you might also use Dependency Walker
(http://www.dependencywalker.com/) to open the Rgraphviz DLL
(R_HOME/libraries/Rgraphviz/libs/Rgraphviz.dll), right click on the
RGRAPHVIZ.DLL showing up in the top left panel, and choose 'Full paths',
and verify that LIBCDT-4.DLL, LIBGRAPH-4.DLL, and LIBGVC-4.DLL all point
to Graphviz2.20\bin.

Martin


 There was nothing after the of:

 R.version.string
 [1] R version 2.10.1 Patched (2010-03-10 r51276)
 win.version()
 [1] Windows Vista (build 6002) Service Pack 2
 packageDescription(Rgraphviz)$Version
 [1] 1.24.0
 graphvizVersion()
 $installed_version
 [1] ‘2.20.3’

 $build_version
 [1] ‘2.20.3’




 On Wed, Mar 31, 2010 at 9:56 AM, HU,ZHENGJUN h...@ufl.edu wrote:
 Hi Martin,

  It is really a 'PATH' problem. After adding C:\Program
 Files\Graphviz2.20\bin to the 'PATH' environment variable, the Rgraphviz
 package can be loaded without any error messages.

  Sorry that I ONLY set my 'PATH' environment variable correctly for R but
 not for Graphviz.

  Thank you and Duncan so much for your great help.
  Howard


 On Tue Mar 30 18:12:54 EDT 2010, Martin Morgan mtmor...@fhcrc.org wrote:

 On 03/30/2010 03:06 PM, HU,ZHENGJUN wrote:

 Hi Martin,

  I am 100% sure that I set my 'PATH' environment variable correctly
 because all other packages can loaded correctly as well as because R can
 be run correctly under both MS DOS and MS Windows XP. Also, I can create
 some simple R packages correctly.

 The PATH must be set correctly to include graphviz, as in my example
 below. Copy and paste the output of

  strsplit(Sys.getenv(PATH), ;)

 and

  list.files(strsplit(Sys.getenv(PATH), ;)[[1]][[14]], dll)

 Martin


  Thanks.
  Howard


 On Tue Mar 30 16:58:55 EDT 2010, Martin Morgan mtmor...@fhcrc.org
 wrote:

 On 03/30/2010 01:13 PM, HU,ZHENGJUN wrote:

 Hi Martin,

  I uninstalled graphviz-2.26.3.msi and then installed
 graphviz-2.20.3.1.msi. Then installed the
 Rgraphviz package again. As expected, I got the same error messages as
 before:

 Error in inDL(x, as.logical(local), as.logical(now), ...) :
  unable to load shared library
 'C:/PROGRA~1/R/R-210~1.1/library/Rgraphviz/libs/Rgraphviz.dll':
  LoadLibrary failure:  The specified module could not be found.

 'LoadLibrary' is being vague, the 'specified modules' are the DLLs from
 graphviz.

 Have you checked that your 'PATH' environment variable is set correctly?
 In R

   strsplit(Sys.getenv(PATH), ;)
 $PATH
  ...
  [14] C:\\Program Files\\Graphviz2.20\\bin
 ...

 The relevant files in this directory might look like

 list.files(strsplit(Sys.getenv(PATH), ;)[[1]][[14]], dll)

  [1] iconv.dll  intl.dll
  [3] jpeg62.dll libcairo-2.dll
  [5] libcdt-4.dll   libcgraph-4.dll
  [7] libexpat.dll   libfontconfig-1.dll
  [9] libfreetype-6.dll  libgdk_pixbuf-2.0-0.dll
 [11] libglib-2.0-0.dll  libgmodule-2.0-0.dll
 [13] libgobject-2.0-0.dll   libgraph-4.dll
 [15] libgvc-4.dll   libgvplugin_core-5.dll
 [17] libgvplugin_dot_layout-5.dll   libgvplugin_gd-5.dll
 [19] libgvplugin_neato_layout-5.dll 

Re: [R] GLM / large dataset question

2010-03-31 Thread Matthew Dowle
Geelman,

This appears to be your first post to this list. Welcome to R. Nearly 2 days 
is quite a long time to wait though, so you are unlikely to get a reply now.

Feedback : the question seems quite vague and imprecise. It depends on which 
R you mean (32bit/64bit) and how much ram you have.  It also depends on your 
data and what you want to do with it. Did you mean 100.000 (i.e. one 
hundred) or 100,000.  Also, '8000 explanatory variables' seems a lot, 
especially to be stored in 'a factor'.  There is no R code in your post so 
we can't tell if you're using glm correctly or not.  You could provide the 
result of object.size(), and dim() on your data rather than explaining it in 
words.

No reply often, but not always, means you haven't followed some detail of 
the posting guide or haven't followed this : 
http://www.catb.org/~esr/faqs/smart-questions.html.

HTH
Matthew

geelman geel...@zonnet.nl wrote in message 
news:mkedkcmimcmgohidffmbieklcaaa.geel...@zonnet.nl...
 LS,

 How large a dataset can glm fit with a binomial link function?  I have a 
 set
 of about 100.000 observations and about 8000 explanatory variables (a 
 factor
 with 8000 levels).

 Is there a way to find out how large datasets R can handle in general?



 Thanks in advance,


 geelman


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

2010-03-31 Thread Jannis

Hi kayj

kayj schrieb:

Also, I do nto know how to combine two plots into one plot?

  

Have a look at ?par . There is some argument add or new (i am not
sure) that you have to set to TRUE after making the first plot and then
you can add a second plot with running plot() once more.


thanks and I appreciate your help

  


You are welcome. You should search the archive of the help list a bit
more extensively before posting as this question has been asked several
times already (this happened to me as well already ;-)).



Best
Jannis

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Off Topic: teenie weenie numbers -- Was: Precision level

2010-03-31 Thread Dimitri Liakhovitski
I spoke with a theoretical physicist and he said he encountered 10^-120.
Has something to do with attempts to describe/explain the universe...
Dimitri

On Fri, Mar 26, 2010 at 2:33 PM, Steve Lianoglou
mailinglist.honey...@gmail.com wrote:
 On Fri, Mar 26, 2010 at 1:11 PM, Barry Rowlingson
 b.rowling...@lancaster.ac.uk wrote:
 On Fri, Mar 26, 2010 at 4:31 PM, Bert Gunter gunter.ber...@gene.com wrote:
 *** COMPLETELY OFF TOPIC ***

 Although machine precision (smallest numerical values that can be exactly
 represented) is important for numerical calculations, what is the smallest
 number that anyone has actually seen describing physical phenomena in
 science? I've seen values of ca. 1e-20 or so routinely used in physics on
 both size (e.g quarks) and time scales (lifetimes of evanescent particles).
 Beyond that about the smallest values I've seen are about 1e-40 or so
 seconds in discussions of Big Bang dynamics. Does anyone know of smaller
 ones (and those I've quoted might certainly be off somewhat).

  Hmmm smaller than 1e40... Well, I think I've seen the charge on an
 electron given as much, much smaller than that...

 Here's another: after ~4 years of graduate school, Citibank is
 starting to send me bank statements using these numbers to quantify
 the amount of $$ I have in the bank ...

 Oh, I just earned $.02 interest? ... thanks for the email
 notification, Citibank!

 Just curious. Hope this abuse of the list is not too egregious. Ignore if
 you think it is.

  It's Casual Friday.

 :-)

 -steve

 --
 Steve Lianoglou
 Graduate Student: Computational Systems Biology
  | Memorial Sloan-Kettering Cancer Center
  | Weill Medical College of Cornell University
 Contact Info: http://cbio.mskcc.org/~lianos/contact

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




-- 
Dimitri Liakhovitski
Ninah.com
dimitri.liakhovit...@ninah.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] Comparing times in two time zones

2010-03-31 Thread James Rome
I have data that is collected in two different time zones
z$OnDateTime - as.POSIXct(runway$OnDateTime, tz = EST5EDT,
format=%m/%d/%Y %H:%M)
is in Eastern time, and
zi$ActualOnLocal - as.POSIXct(oooi$ActualOnLocal, tz=MST7MDT,
format=%m/%d/%Y %H:%M)
is in Mountain.
I converted the runway time to Mountain (I think)
z$OnDateTime = format(runway$OnDateTime, tz=MST7MDT)   

The corresponding times in the two data sets seem identical (within a
few minutes) when printed out:
] z$ActualOnLocal[1:5]
[1] 2008-11-01 07:49:00 MDT 2008-11-03 07:58:00 MST
[3] 2008-11-04 08:04:00 MST 2008-11-05 07:44:00 MST
[5] 2008-11-06 07:32:00 MST
 z$OnDateTime[1:5]
[1] 2008-11-01 07:49:00 2008-11-03 07:57:00 2008-11-04 08:04:00
[4] 2008-11-05 07:43:00 2008-11-06 07:32:00

 But when I do
z$dt= as.numeric(difftime(z$ActualOnLocal, z$OnDateTime, units=mins))
the difference is 120 minutes.

How do I get my date times so that difftime works properly?

Thanks,
Jim Rome

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] library sets: A EMPTY does not work; gset_intersection(A,EMPTY) works

2010-03-31 Thread Peter Ehlers

Ryszard,

You've made me take a closer look and now I do think that
you've found a bug.

After a quick look at the package vignette, I see that the
authors have indeed overloaded  and so it should work for
your example. The problem seems to be the order of the class
attribute which is used to call the relevant 'Ops' function:

class(A)
#[1] gset cset

class(B)
#[1] gset cset

class(E - A - A)
#[1] set  gset cset

If you re-order the class vector, function Ops.gset will be called
to handle A and E:

class(E) - class(E)[c(2,3,1)]
A  E
#{}

I've cc'd David Meyer.

 -Peter Ehlers

On 2010-03-31 10:11, Czerminski, Ryszard wrote:

It seems that A  B works the same way as gset_intersection(A,B)
as long as A and B are not empty...
see below:

fuzzy_logic(Yager, p=2)
support- universe- c('a','b','c','d')
A- gset(support=support, memberships=c(0.2, 0.2, 0.9, 0),
universe=universe)
B- gset(support=support, memberships=c(0.211, 0.222, 0.999, 0),
universe=universe)
A
B
A  B
gset_intersection(A,B)
E- A - A
A  E
gset_intersection(A,E)


fuzzy_logic(Yager, p=2)
support- universe- c('a','b','c','d')
A- gset(support=support, memberships=c(0.2, 0.2, 0.9, 0),

universe=universe)

B- gset(support=support, memberships=c(0.211, 0.222, 0.999, 0),

universe=universe)

A

{a [0.2], b [0.2], c [0.9]}

B

{a [0.211], b [0.222], c [0.999]}

A  B

{c [0.85]}

gset_intersection(A,B)

{c [0.85]}

E- A - A
A  E

Error in A  E :
   operations are possible only for numeric or logical types
In addition: Warning message:
Incompatible methods (Ops.gset, Ops.set) for 

gset_intersection(A,E)

{}


--
Confidentiality Notice: This message is private and may contain confidential 
and proprietary information. If you have received this message in error, please 
notify us and remove it from your system and note that you must not copy, 
distribute or take any action in reliance on it. Any unauthorized use or 
disclosure of the contents of this message is not permitted and may be unlawful.

-Original Message-
From: Peter Ehlers [mailto:ehl...@ucalgary.ca]
Sent: Wednesday, March 31, 2010 11:43 AM
To: Czerminski, Ryszard
Cc: R-help@r-project.org
Subject: Re: [R] library sets: A  EMPTY does not work;
gset_intersection(A,EMPTY) works

On 2010-03-31 9:30, Peter Ehlers wrote:

Unless I'm missing something, I don't see any method
in pkg:sets for intersection other than gset_intersection.


Whoops, a bit quick on the draw.
There are of course also set_intersection and cset_intersection,
but not AFAICS any method for ``.

   -Peter Ehlers


So you're using the base R function `` whose help page
tells you that its arguments should be vectors. Yours
aren't.

-Peter Ehlers

On 2010-03-31 8:50, Czerminski, Ryszard wrote:

When using generalized sets from sets library

A  EMPTY does not work, but gset_intersection(A,EMPTY) works: example
code below

Is it a bug?

Best regards,
Ryszard

library(sets)
support- universe- c('a','b','c','d')
A- gset(support=support, memberships=c(0.2, 0.2, 0.9, 0),
universe=universe)
class(A)
A
E- A - A # create empty set
I- gset_intersection(A, E) #  this WORKS
class(I); I
I- A  E #  this DOES NOT WORK

# ---


support- universe- c('a','b','c','d')
A- gset(support=support, memberships=c(0.2, 0.2, 0.9, 0),

universe=universe)

class(A)

[1] gset cset

A

{a [0.2], b [0.2], c [0.9]}

E- A - A
I- gset_intersection(A, E) #  this WORKS
class(I); I

[1] set gset cset
{}

I- A  E #  this DOES NOT WORK

Error in A  E :
operations are possible only for numeric or logical types
In addition: Warning message:
Incompatible methods (Ops.gset, Ops.set) for 





--


Confidentiality Notice: This message is private and may

...{{dropped:8}}


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








--
Peter Ehlers
University of Calgary

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Bar plots with bars made of stacked text

2010-03-31 Thread Thomas Levine
I would like to make bar plots where the bars are composed of text like this:
http://www.thomaslevine.com/lowres/text_bars.png

Is there a package that will help me with this? Thanks

Tom

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] interpretation of p values for highly correlated logistic analysis

2010-03-31 Thread Stephan Kolassa

Hi Claus,

welcome to the wonderful world of collinearity (or multicollinearity, as 
some call it)! You have a near linear relationship between some of your 
predictors, which can (and in your case does) lead to extreme parameter 
estimates, which in some cases almost cancel out (a coefficient of +/-40 
on a categorical variable in logistic regression is a lot, and the 
intercept and two of the roman parameter estimates almost cancel out) 
but which are rather unstable (hence your high p-values).


Belsley, Kuh and Welsch did some work on condition indices and variance 
decomposition proportions, and variance inflation factors are quite 
popular for diagnosing multicollinearity - google these terms for a bit, 
and enlightenment will surely follow.


What can you do? You should definitely think long and hard about your 
data. Should you be doing separate regressions for some factor levels? 
Should you drop a factor from the analysis? Should you do a categorical 
analogue of Principal Components Analysis on your data before the 
regression? I personally have never done this, but correspondence 
analysis has been recommended as a discrete alternative to PCA on this 
list, see a couple of books by M. J. Greenacre.


Best of luck!
Stephan


claus orourke schrieb:

Dear list,

I want to perform a logistic regression analysis with multiple
categorical predictors (i.e., a logit) on some data where there is a
very definite relationship between one predicator and the
response/independent variable. The problem I have is that in such a
case the p value goes very high (while I as a naive newbie would
expect it to crash towards 0).

I'll illustrate my problem with some toy data. Say I have the
following data as an input frame:

   roman animal colour
1  alphadog black
2   betacat white
3  alphadog black
4  alphacat black
5   betadog white
6  alphacat black
7  gammadog white
8  alphacat black
9  gammadog white
10  betacat white
11 alphadog black
12 alphacat black
13 gammadog white
14 alphacat black
15  betadog white
16  betacat black
17 alphacat black
18  betadog white

In this toy data you can see that roman:alpha and roman:beta are
pretty good predictors of colour

Let's say I perform logistic analysis directly on the raw data with
colour as a response variable:


options(contrasts=c(contr.treatment,contr.poly))
anal1 - glm(data$colour~data$roman+data$animal,family=binomial)


then I find that my P values for each individual level coefficient approach 1:

Coefficients:
Estimate Std. Error z value Pr(|z|)
(Intercept)   -41.65   19609.49  -0.0020.998
data$romanbeta 42.35   19609.49   0.0020.998
data$romangamma43.74   31089.48   0.0010.999
data$animaldog 20.48   13866.00   0.0010.999

while I expect the p value for roman:beta to be quite low because it
is a good predictor of colour:white

On the other hand, if I then run an anova with a Chi-sq test on the
result model, I find as I would expect that 'roman' is a good
predictor of colour.


anova(anal1,test=Chisq)

Analysis of Deviance Table

Model: binomial, link: logit

Response: data$colour

Terms added sequentially (first to last)


Df Deviance Resid. Df Resid. Dev P(|Chi|)
NULL   1724.7306
data$roman   2  19.323915 5.4067 6.366e-05 ***
data$animal  1   1.587614 3.81910.2077
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Can anyone please explain why my p value is so high for the individual levels?

Sorry for what is likely a stupid question.

Claus

p.s., when I run logistic analysis on data that is more 'randomised'
everything comes out as I expect.

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

2010-03-31 Thread Kim Jung Hwa
Hi All,

Can someone help me reshape following data:

Var1 Var2 Val
A X 1
A Y 2
A Z 3
B X 4
B Y 5
B Z 6

to some kind of matrix/tabular format (preferably as a matrix), may be like

Var1 X Y Z
A 1 2 3
B 4 5 6

Any help would be greatly appreciated,
Kim

[[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] reshaping data

2010-03-31 Thread Henrique Dallazuanna
Try this:

 xtabs(Val ~ Var1 + Var2, data = x)

On Wed, Mar 31, 2010 at 3:23 PM, Kim Jung Hwa kimhwamaill...@gmail.com wrote:
 Hi All,

 Can someone help me reshape following data:

 Var1 Var2 Val
 A X 1
 A Y 2
 A Z 3
 B X 4
 B Y 5
 B Z 6

 to some kind of matrix/tabular format (preferably as a matrix), may be like

 Var1 X Y Z
 A 1 2 3
 B 4 5 6

 Any help would be greatly appreciated,
 Kim

        [[alternative HTML version deleted]]

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




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

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

2010-03-31 Thread Stephan Kolassa

Hi Kim,

look at the reshape() command with direction=wide. Or at the reshape 
package.


HTH,
Stephan


Kim Jung Hwa schrieb:

Hi All,

Can someone help me reshape following data:

Var1 Var2 Val
A X 1
A Y 2
A Z 3
B X 4
B Y 5
B Z 6

to some kind of matrix/tabular format (preferably as a matrix), may be like

Var1 X Y Z
A 1 2 3
B 4 5 6

Any help would be greatly appreciated,
Kim

[[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] for loop; lm() regressions; list of vectors - lapply - accolades and square brackets??

2010-03-31 Thread Driss Agramelal
Peter, it works!!! Thanks a lot to all of you!

Yes I mistook a data.frame for a matrix

Now both David's and Dennis' solutions work!

I am really a beginner with R, and I think it's a wonderful tool, but
sometimes
a little difficult to use only learning from the manuals and help files...

I hope I didn't pollute the help list! I am really sorry I didn't provide
more info
from the beginning, and for you to fully understand my question, please
find
my code hereafter, with a 'copy-pastable' sample of my data:

What I did:

## Step 1: Import the data (simplified for example)

a - read.table(clipboard, header = TRUE)
a
 a1  a2  a3  a4  a5
1   0.01181  0.01181  0.01181  0.01181  0.01181
2   0.11266  0.10878  0.11217  0.11255  0.11258
3   0.00655  0.00655  0.00655  0.00655  0.00655
4  -0.02956 -0.03098 -0.03006 -0.03243 -0.03244
5  -0.01788 -0.01788 -0.01788 -0.01788 -0.01788
6  -0.01106  0.00083 -0.01172 -0.00328 -0.00328
7   0.00668  0.00668  0.00668  0.00668  0.00668
8   0.06130  0.05779  0.06310  0.06144  0.06146
9   0.01300  0.01300  0.01300  0.01300  0.01300
10 -0.05749 -0.05764 -0.05771 -0.05970 -0.05972
11 -0.04019 -0.04019 -0.04019 -0.04019 -0.04019
12 -0.01223 -0.01235 -0.01229 -0.00866 -0.00867
13  0.01422  0.01422  0.01422  0.01422  0.01422
14  0.00636  0.00603  0.00633  0.00813  0.00813
15 -0.00715 -0.00715 -0.00715 -0.00715 -0.00715
16 -0.02773 -0.03089 -0.02802 -0.02729 -0.02730
17 -0.02534 -0.02534 -0.02534 -0.02534 -0.02534
18  0.01151  0.00634  0.01120  0.01509  0.01509
19 -0.01103 -0.01314 -0.01112 -0.00894 -0.00895
20 -0.01889 -0.01964 -0.01860 -0.01813 -0.01813
21  0.01498  0.01438  0.01526  0.01548  0.01549
22  0.00731  0.00853  0.00746  0.00699  0.00699
23 -0.02229 -0.02069 -0.02247 -0.02223 -0.02224
24  0.00824  0.00817  0.00786  0.00783  0.00783
25  0.00596  0.00699  0.00613  0.00621  0.00622
26 -0.04201 -0.04241 -0.04212 -0.04271 -0.04272
27  0.03012  0.02972  0.03041  0.03056  0.03056
28 -0.00972 -0.01009 -0.00957 -0.01037 -0.01037
29 -0.02637 -0.02657 -0.02598 -0.02614 -0.02615
30 -0.05003 -0.05134 -0.05025 -0.05054 -0.05055
31 -0.02514 -0.02483 -0.02523 -0.02424 -0.02424
32  0.02797  0.02732  0.02802  0.02663  0.02685
33 -0.00777 -0.00791 -0.00766 -0.00716 -0.00716
34 -0.01836 -0.01830 -0.01855 -0.01820 -0.01842

b - c(read.table(clipboard, header = TRUE))
b
$b
 [1]  0.01181  0.02764  0.00655  0.02275 -0.01788 -0.03519  0.00668  0.00541
 0.01300  0.01528 -0.04019
[12] -0.00838  0.01422 -0.02362 -0.00715 -0.00862 -0.02534 -0.02361 -0.01210
 0.00135  0.00101 -0.00017
[23] -0.02670  0.00799  0.01333 -0.03874  0.04817 -0.00102 -0.02142 -0.04965
-0.02773  0.02451 -0.00953
[34] -0.01985

b - b$b

## Step 2: perform the regressions (David's way)

David - *for(i in seq_along(a)) print(r- lm(a[ ,i] ~ b) )*

Call:
lm(formula = a[, i] ~ b)

Coefficients:
(Intercept)b
  0.00084590.8484054


Call:
lm(formula = a[, i] ~ b)

Coefficients:
(Intercept)b
  0.00045230.8215883


Call:
lm(formula = a[, i] ~ b)

Coefficients:
(Intercept)b
  0.00085730.8513867


Call:
lm(formula = a[, i] ~ b)

Coefficients:
(Intercept)b
   0.001105 0.818247


Call:
lm(formula = a[, i] ~ b)

Coefficients:
(Intercept)b
   0.001108 0.818983

## Step 2: Perform the regressions (Dennis' way)

Dennis - *lm(as.matrix(a) ~ b)*
Dennis

Call:
lm(formula = as.matrix(a) ~ b)

Coefficients:
   a1   a2   a3 a4
a5
(Intercept)  0.0008459  0.0004523  0.0008573  0.0011052  0.0011081
b   0.8484054  0.8215883  0.8513867  0.8182470  0.8189826

## Further steps to come... I am still learning to manipulate my new results
to plot.lm a choosen response, to test for autocorrelation, maybe lag or use
the gls or robust method, etc... I already did most of the analyses in a
test
phase with a single regression, but it will be another story on the entire
sample...! Maybe I will post some more questions if appropriate...(?)

For better comprehension, imagine a1 to a5 are companies, and b is
a benchmark index, and I calculate CAPM betas...

Many thanks, and I pasted Dennis's answer hereafter for it to be on the
forum
as well, since it is a valuable contribution!!

Driss Agramelal
---
Student writing his master's thesis
University of St-Gallen






Hi:

I don't know if this will take care of your problem, but here are several
approaches.
I'm using the melt() function in package plyr to
vectorize the response matrix and create a factor variable from the variable
names.

Approach 1: lmList() in nlme.

library(plyr)
library(nlme)
df - data.frame(x = 1:10, y1 = rnorm(10), y2 = rnorm(10), y3 = rnorm(10))
# melt() creates a grouping 'variable' to distinguish the responses; the
responses
# themselves are put into a variable 'value'
df1 - melt(df, id.vars = 'x')
# Run lmList using variable as the grouping factor...
mods - lmList(value ~ x | variable, 

Re: [R] reshaping data

2010-03-31 Thread Kim Jung Hwa
Thanks Henrique and Stephan for your reply!

Henrique, I'm planning to do some arthitmetic operations on tranformed
(matrix) data and then would like to convert it back to original format (as
a data frame)... is there an equivalent easy command for this too? Thanks,

On Wed, Mar 31, 2010 at 2:26 PM, Henrique Dallazuanna www...@gmail.comwrote:

 Try this:

  xtabs(Val ~ Var1 + Var2, data = x)

 On Wed, Mar 31, 2010 at 3:23 PM, Kim Jung Hwa kimhwamaill...@gmail.com
 wrote:
  Hi All,
 
  Can someone help me reshape following data:
 
  Var1 Var2 Val
  A X 1
  A Y 2
  A Z 3
  B X 4
  B Y 5
  B Z 6
 
  to some kind of matrix/tabular format (preferably as a matrix), may be
 like
 
  Var1 X Y Z
  A 1 2 3
  B 4 5 6
 
  Any help would be greatly appreciated,
  Kim
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 



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


[[alternative HTML version deleted]]

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


Re: [R] reshaping data

2010-03-31 Thread Kim Jung Hwa
Actually, apart from melt() in reshape package.

On Wed, Mar 31, 2010 at 2:37 PM, Kim Jung Hwa kimhwamaill...@gmail.comwrote:

 Thanks Henrique and Stephan for your reply!

 Henrique, I'm planning to do some arthitmetic operations on tranformed
 (matrix) data and then would like to convert it back to original format (as
 a data frame)... is there an equivalent easy command for this too? Thanks,

   On Wed, Mar 31, 2010 at 2:26 PM, Henrique Dallazuanna 
 www...@gmail.comwrote:

 Try this:

  xtabs(Val ~ Var1 + Var2, data = x)

 On Wed, Mar 31, 2010 at 3:23 PM, Kim Jung Hwa kimhwamaill...@gmail.com
 wrote:
  Hi All,
 
  Can someone help me reshape following data:
 
  Var1 Var2 Val
  A X 1
  A Y 2
  A Z 3
  B X 4
  B Y 5
  B Z 6
 
  to some kind of matrix/tabular format (preferably as a matrix), may be
 like
 
  Var1 X Y Z
  A 1 2 3
  B 4 5 6
 
  Any help would be greatly appreciated,
  Kim
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.htmlhttp://www.r-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 



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




[[alternative HTML version deleted]]

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


Re: [R] You are right and the problem is solved. Re: about the possible errors in Rgraphviz Package

2010-03-31 Thread Gabor Grothendieck
I got an error message *AND* R becomes unusable and had to be restarted.

Using dependency walker it seems to be complaining about R.dll so I
copied all of my ...\R\bin\R*.dll files to ..
...\win-library\2.10\Rgraphviz\libs.

Then it complained about IESHIMS.dll so I copied \Program
Files\Internet Explorer\IESHIMS.dll to
...\win-library\2.10\Rgraphviz\libs.

Looking at dependency walker these DLLs: LIBCDT-4.DLL, LIBGRAPH-4.DLL,
and LIBGVC-4.DLL all seem to point to correct place.

I still have this message in dependency walker:
Warning: At least one module has an unresolved import due to a missing
export function in a delay-load dependent module.

There is a red mark beside:
c:\windows\system32\IEFRAME.DLL
but its not missing.

I also tried reinstalling R using the latest R 2.10.1.

I am still getting the same result, namely I can run the indicated
code up to but not including plot(g1) but if I run plot(g1) R crashes
and must be restarted.



On Wed, Mar 31, 2010 at 12:54 PM, Martin Morgan mtmor...@fhcrc.org wrote:
 On 03/31/2010 08:18 AM, Gabor Grothendieck wrote:
 By the way, just in case you did not read the entire message R crashed

 I think you mean that you got an error message, not that R became
 unusable? More below...

 when I tried to run the code from the vignette.

 On Wed, Mar 31, 2010 at 10:52 AM, Gabor Grothendieck
 ggrothendi...@gmail.com wrote:
 Based on your success I thought I would try again. I am not sure why I
 had more success this time but this time I got this far even though I
 did not change my path at all or make any system changes from what I
 had before.  I did reinstall Rgraphviz but used the previously
 installed graphviz.   I tried this code taken from the Rgrpahviz
 vignette:

 library(Rgraphviz)
 Loading required package: graph
 Loading required package: grid
 set.seed(123)
 V - letters[1:10]
 M - 1:4
 g1 - randomGraph(V, M, 0.2)
 g1
 A graphNEL graph with undirected edges
 Number of Nodes = 10
 Number of Edges = 16


 but when I tried to plot it R crashed.

 plot(g1)

 It did produce this message on the Windows console (not the R console):

 Error: Layout type: dot not recognized. Use one of:

 In the past this has come about when accessing incorrect graphviz DLLs.
 The gory detail (if I remember correctly) is that a FILE* gets allocated
 in Rgraphviz and passed to graphviz, and if there is a compiler mismatch
 then there are no guarantees about FILE* representation.

 The implication is that your Rgraphviz and graphiz are at least partly
 out of sync, but it could also be that I am 'getting lucky'. When you
 say (quoting from above)...

 did not change my path at all or make any system changes from what I

 the implication is that your PATH was already set to include a
 graphviz2.20\\bin directory; I'd encourage you to confirm that.

Yes,  My path is:

PATH=C:\Graphviz2.20\bin;...more stuff...


 And recognizing that you might justifiably be willing to put this on the
 shelf, you might also use Dependency Walker
 (http://www.dependencywalker.com/) to open the Rgraphviz DLL
 (R_HOME/libraries/Rgraphviz/libs/Rgraphviz.dll), right click on the
 RGRAPHVIZ.DLL showing up in the top left panel, and choose 'Full paths',
 and verify that LIBCDT-4.DLL, LIBGRAPH-4.DLL, and LIBGVC-4.DLL all point
 to Graphviz2.20\bin.

 Martin


 There was nothing after the of:

 R.version.string
 [1] R version 2.10.1 Patched (2010-03-10 r51276)
 win.version()
 [1] Windows Vista (build 6002) Service Pack 2
 packageDescription(Rgraphviz)$Version
 [1] 1.24.0
 graphvizVersion()
 $installed_version
 [1] ‘2.20.3’

 $build_version
 [1] ‘2.20.3’




 On Wed, Mar 31, 2010 at 9:56 AM, HU,ZHENGJUN h...@ufl.edu wrote:
 Hi Martin,

  It is really a 'PATH' problem. After adding C:\Program
 Files\Graphviz2.20\bin to the 'PATH' environment variable, the Rgraphviz
 package can be loaded without any error messages.

  Sorry that I ONLY set my 'PATH' environment variable correctly for R but
 not for Graphviz.

  Thank you and Duncan so much for your great help.
  Howard


 On Tue Mar 30 18:12:54 EDT 2010, Martin Morgan mtmor...@fhcrc.org wrote:

 On 03/30/2010 03:06 PM, HU,ZHENGJUN wrote:

 Hi Martin,

  I am 100% sure that I set my 'PATH' environment variable correctly
 because all other packages can loaded correctly as well as because R can
 be run correctly under both MS DOS and MS Windows XP. Also, I can create
 some simple R packages correctly.

 The PATH must be set correctly to include graphviz, as in my example
 below. Copy and paste the output of

  strsplit(Sys.getenv(PATH), ;)

 and

  list.files(strsplit(Sys.getenv(PATH), ;)[[1]][[14]], dll)

 Martin


  Thanks.
  Howard


 On Tue Mar 30 16:58:55 EDT 2010, Martin Morgan mtmor...@fhcrc.org
 wrote:

 On 03/30/2010 01:13 PM, HU,ZHENGJUN wrote:

 Hi Martin,

  I uninstalled graphviz-2.26.3.msi and then installed
 graphviz-2.20.3.1.msi. Then installed the
 Rgraphviz package again. As expected, I got the same error messages as
 before:

 Error in inDL(x, 

Re: [R] Off Topic: teenie weenie numbers -- Was: Precision level

2010-03-31 Thread Ted Harding
There is a story (apocryphal?) about Fred Hoyle, many years ago,
having come to the close of a public lecture about his work in
Cosmology (I seem to recall that it was to the British Astronomical
Association, a society of amateur astronomers, and therefore
knowledgeable). He was taking questions.

A member of the audience asked (words to the effect):

  Can Professor Hoyle explain the reasons why he adopted the
  value 10^1000 [or similar] for the [X] constant?

At which Hoyle grinned, and replied

  ten to the thousand, ten to the two thousand, ten to the
   three thousand, what difference does it make?

Ted.


On 31-Mar-10 17:45:54, Dimitri Liakhovitski wrote:
 I spoke with a theoretical physicist and he said he encountered
 10^-120.
 Has something to do with attempts to describe/explain the universe...
 Dimitri
 
 On Fri, Mar 26, 2010 at 2:33 PM, Steve Lianoglou
 mailinglist.honey...@gmail.com wrote:
 On Fri, Mar 26, 2010 at 1:11 PM, Barry Rowlingson
 b.rowling...@lancaster.ac.uk wrote:
 On Fri, Mar 26, 2010 at 4:31 PM, Bert Gunter gunter.ber...@gene.com
 wrote:
 *** COMPLETELY OFF TOPIC ***

 Although machine precision (smallest numerical values that can be
 exactly
 represented) is important for numerical calculations, what is the
 smallest
 number that anyone has actually seen describing physical phenomena
 in
 science? I've seen values of ca. 1e-20 or so routinely used in
 physics on
 both size (e.g quarks) and time scales (lifetimes of evanescent
 particles).
 Beyond that about the smallest values I've seen are about 1e-40 or
 so
 seconds in discussions of Big Bang dynamics. Does anyone know of
 smaller
 ones (and those I've quoted might certainly be off somewhat).

 _Hmmm smaller than 1e40... Well, I think I've seen the charge on an
 electron given as much, much smaller than that...

 Here's another: after ~4 years of graduate school, Citibank is
 starting to send me bank statements using these numbers to quantify
 the amount of $$ I have in the bank ...

 Oh, I just earned $.02 interest? ... thanks for the email
 notification, Citibank!

 Just curious. Hope this abuse of the list is not too egregious.
 Ignore if
 you think it is.

 _It's Casual Friday.

 :-)

 -steve

 --
 Steve Lianoglou
 Graduate Student: Computational Systems Biology
 _| Memorial Sloan-Kettering Cancer Center
 _| Weill Medical College of Cornell University
 Contact Info: http://cbio.mskcc.org/~lianos/contact

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

 
 
 
 -- 
 Dimitri Liakhovitski
 Ninah.com
 dimitri.liakhovit...@ninah.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.


E-Mail: (Ted Harding) ted.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 31-Mar-10   Time: 19:52:35
-- XFMail --

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


Re: [R] reshaping data

2010-03-31 Thread Henrique Dallazuanna
Try:

 as.data.frame(with(x, tapply(Val, list(Var1, Var2), sum)))


On Wed, Mar 31, 2010 at 3:37 PM, Kim Jung Hwa kimhwamaill...@gmail.com wrote:
 Thanks Henrique and Stephan for your reply!

 Henrique, I'm planning to do some arthitmetic operations on tranformed
 (matrix) data and then would like to convert it back to original format (as
 a data frame)... is there an equivalent easy command for this too? Thanks,

 On Wed, Mar 31, 2010 at 2:26 PM, Henrique Dallazuanna www...@gmail.com
 wrote:

 Try this:

  xtabs(Val ~ Var1 + Var2, data = x)

 On Wed, Mar 31, 2010 at 3:23 PM, Kim Jung Hwa kimhwamaill...@gmail.com
 wrote:
  Hi All,
 
  Can someone help me reshape following data:
 
  Var1 Var2 Val
  A X 1
  A Y 2
  A Z 3
  B X 4
  B Y 5
  B Z 6
 
  to some kind of matrix/tabular format (preferably as a matrix), may be
  like
 
  Var1 X Y Z
  A 1 2 3
  B 4 5 6
 
  Any help would be greatly appreciated,
  Kim
 
         [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 



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





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

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

2010-03-31 Thread David Winsemius


On Mar 31, 2010, at 2:37 PM, Kim Jung Hwa wrote:


Thanks Henrique and Stephan for your reply!

Henrique, I'm planning to do some arthitmetic operations on tranformed
(matrix) data and then would like to convert it back to original  
format (as
a data frame)... is there an equivalent easy command for this too?  
Thanks,





Read the xtabs help page more thoroughly.

--
David.


On Wed, Mar 31, 2010 at 2:26 PM, Henrique Dallazuanna www...@gmail.com 
wrote:



Try this:

xtabs(Val ~ Var1 + Var2, data = x)

On Wed, Mar 31, 2010 at 3:23 PM, Kim Jung Hwa kimhwamaill...@gmail.com 


wrote:

Hi All,

Can someone help me reshape following data:

Var1 Var2 Val
A X 1
A Y 2
A Z 3
B X 4
B Y 5
B Z 6

to some kind of matrix/tabular format (preferably as a matrix),  
may be

like


Var1 X Y Z
A 1 2 3
B 4 5 6

Any help would be greatly appreciated,
Kim

  [[alternative HTML version deleted]]

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


and provide commented, minimal, self-contained, reproducible code.





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



[[alternative HTML version deleted]]

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


David Winsemius, MD
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] AHRQ Patient Quality Indicators

2010-03-31 Thread GL

Is anyone aware of R code that mimic's AHRQ's SAS code for their Prevention
Quality Indicators (PQI)? Don't see it anywhere, but wanted to see if anyone
else knew of anything. Many thanks
-- 
View this message in context: 
http://n4.nabble.com/AHRQ-Patient-Quality-Indicators-tp1747243p1747243.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] lattice: how to add points to the plot generated by levelplot()?

2010-03-31 Thread Czerminski, Ryszard
I am using levelplot() function from pkg:lattice and I want to add some
points
to the plot generated by levelplot()
similarly as in basic R graphic sequence: plot(...); points(...),
but it does not work.

I was reading documentation for lattice, but so far without much
success.

I would very much appreciate some tips.

Best regards,
Ryszard


--
Confidentiality Notice: This message is private and may ...{{dropped:11}}

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


Re: [R] Problem comparing hazard ratios

2010-03-31 Thread Frank E Harrell Jr

Ravi Varadhan wrote:

Frank,

Is there an article that discusses this idea of bootstrapping the ranks of
the likelihood ratio chi-square 
Statistics to assess relative importance of predictors in time-to-event data
(specifically Cox PH model)? 


Thanks,
Ravi.


Do require(rms); ?anova.rms and see related articles:

@Article{hal09usi,
  author =   {Hall, Peter and Miller, Hugh},
  title = 		 {Using the bootstrap to quantify the authority of an 
empirical ranking},

  journal =  Annals of Stat,
  year = 2009,
  volume =   37,
  number =   {6B},
  pages ={3929-3959},
  annote = 	 {confidence interval for ranks;genomics;high 
dimension;independent component bootstrap;$m$-out-of-$n$ 
bootstrap;ordering;overlap interval;prediction interval;synchronous 
bootstrap;ordinary bootstrap may not provide accurate confidence 
intervals for ranks;may need a different bootstrap if the number of 
parameters being ranked increases with $n$ or is large;estimating $m$ is 
difficult;in their first example, where $m=0.355n$, the ordinary 
bootstrap provided a lower bound to the lengths of more accurate 
confidence intervals of ranks}

}

@Article{xie09con,
  author =   {Xie, Minge and Singh, Kesar and Zhang, {Cun-Hui}},
  title = 		 {Confidence intervals for population ranks in the presence 
of ties and near ties},

  journal =  JASA,
  year = 2009,
  volume =   104,
  number =   486,
  pages ={775-787},
  annote = 	 {bootstrap ranks;ranking;nonstandard bootstrap 
inference;rank inference;slow convergence rate;smooth ranks in the 
presence of near ties;rank inference for fixed effects risk adjustment 
models}

}



-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Frank E Harrell Jr
Sent: Tuesday, March 30, 2010 3:57 PM
To: Michal Figurski
Cc: r-help@r-project.org
Subject: Re: [R] Problem comparing hazard ratios

Michal Figurski wrote:

Dear R-Helpers,

I am a novice in survival analysis. I have the following code:
for (i in 3:12) print(coxph(Surv(time, status)~a[,i], data=a))

I used it to fit the Cox Proportional Hazard models separately for every 
available parameter (columns 3:12) in my data set - with intention to 
compare the Hazard Ratios.


However, some of my variables are in range 0.1 to 1.6, others in range 
5000 to 9000. How do I compare HRs between such variables?


I have rescaled all the variables to be in 0 to 1 range - is this the 
proper way to go? Is there a way to somehow calculate the same HRs (as 
for rescaled parameters) from the HRs for original parameters?


Many thanks in advance.



There are a lot of issues related to this that will require a good bit 
of study, both in survival analysis and in regression.  I would start 
with bootstrapping the ranks of the likelihood ratio chi-square 
statistics of the competing biomarkers.


Frank




--
Frank E Harrell Jr   Professor and ChairmanSchool of Medicine
 Department of Biostatistics   Vanderbilt University

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

2010-03-31 Thread tj

Hi,

anyone here who knows how to determine if an integer is odd or even in
R?
Thanks.


tj
-- 
View this message in context: 
http://n4.nabble.com/ODD-and-EVEN-numbers-tp1747032p1747032.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] You are right and the problem is solved. Re: about the possible errors in Rgraphviz Package

2010-03-31 Thread HU,ZHENGJUN
Hi Gabor,

  I just used your R code below and the code worked properly 
without any error messages. Attached is the output graph, which 
may be the one you expected.

library(Rgraphviz)
set.seed(123)
V - letters[1:10]
M - 1:4
g1 - randomGraph(V, M, 0.2)
g1
plot(g1)

  Thanks.
  Howard



On Wed Mar 31 11:18:25 EDT 2010, Gabor Grothendieck 
ggrothendi...@gmail.com wrote:

 By the way, just in case you did not read the entire message R 
 crashed
 when I tried to run the code from the vignette.
 
 On Wed, Mar 31, 2010 at 10:52 AM, Gabor Grothendieck
 ggrothendi...@gmail.com wrote:
 Based on your success I thought I would try again. I am not sure 
 why I
 had more success this time but this time I got this far even 
 though I
 did not change my path at all or make any system changes from 
 what I
 had before. ??I did reinstall Rgraphviz but used the 
 previously
 installed graphviz. ?? I tried this code taken from the 
 Rgrpahviz
 vignette:
 
 library(Rgraphviz)
 Loading required package: graph
 Loading required package: grid
 set.seed(123)
 V - letters[1:10]
 M - 1:4
 g1 - randomGraph(V, M, 0.2)
 g1
 A graphNEL graph with undirected edges
 Number of Nodes = 10
 Number of Edges = 16
 
 
 but when I tried to plot it R crashed.
 
 plot(g1)
 
 It did produce this message on the Windows console (not the R 
 console):
 
 Error: Layout type: dot not recognized. Use one of:
 
 There was nothing after the of:
 
 R.version.string
 [1] R version 2.10.1 Patched (2010-03-10 r51276)
 win.version()
 [1] Windows Vista (build 6002) Service Pack 2
 packageDescription(Rgraphviz)$Version
 [1] 1.24.0
 graphvizVersion()
 $installed_version
 [1] ?2.20.3?
 
 $build_version
 [1] ?2.20.3?
 
 
 
 
 On Wed, Mar 31, 2010 at 9:56 AM, HU,ZHENGJUN h...@ufl.edu wrote:
 Hi Martin,
 
 ??It is really a 'PATH' problem. After adding C:\Program
 Files\Graphviz2.20\bin to the 'PATH' environment variable, the 
 Rgraphviz
 package can be loaded without any error messages.
 
 ??Sorry that I ONLY set my 'PATH' environment variable 
 correctly for R but
 not for Graphviz.
 
 ??Thank you and Duncan so much for your great help.
 ??Howard
 
 
 On Tue Mar 30 18:12:54 EDT 2010, Martin Morgan 
 mtmor...@fhcrc.org wrote:
 
 On 03/30/2010 03:06 PM, HU,ZHENGJUN wrote:
 
 Hi Martin,
 
 ??I am 100% sure that I set my 'PATH' environment 
 variable correctly
 because all other packages can loaded correctly as well as 
 because R can
 be run correctly under both MS DOS and MS Windows XP. Also, I 
 can create
 some simple R packages correctly.
 
 The PATH must be set correctly to include graphviz, as in my 
 example
 below. Copy and paste the output of
 
 ??strsplit(Sys.getenv(PATH), ;)
 
 and
 
 ??list.files(strsplit(Sys.getenv(PATH), ;)[[1]][[14]], 
 dll)
 
 Martin
 
 
 ??Thanks.
 ??Howard
 
 
 On Tue Mar 30 16:58:55 EDT 2010, Martin Morgan 
 mtmor...@fhcrc.org
 wrote:
 
 On 03/30/2010 01:13 PM, HU,ZHENGJUN wrote:
 
 Hi Martin,
 
 ??I uninstalled graphviz-2.26.3.msi and then installed
 graphviz-2.20.3.1.msi. Then installed the
 Rgraphviz package again. As expected, I got the same error 
 messages as
 before:
 
 Error in inDL(x, as.logical(local), as.logical(now), ...) :
 ??unable to load shared library
 'C:/PROGRA~1/R/R-210~1.1/library/Rgraphviz/libs/Rgraphviz.dll':
 ??LoadLibrary failure: ??The specified module could 
 not be found.
 
 'LoadLibrary' is being vague, the 'specified modules' are 
 the DLLs from
 graphviz.
 
 Have you checked that your 'PATH' environment variable is 
 set correctly?
 In R
 
 ?? strsplit(Sys.getenv(PATH), ;)
 $PATH
 ??...
 ??[14] C:\\Program Files\\Graphviz2.20\\bin
 ...
 
 The relevant files in this directory might look like
 
 list.files(strsplit(Sys.getenv(PATH), ;)[[1]][[14]], dll)
 
 ??[1] iconv.dll ?? ?? ?? ?? ?? 
 ?? ?? ?? ?? ?? ??intl.dll
 ??[3] jpeg62.dll ?? ?? ?? ?? ?? 
 ?? ?? ?? ?? ?? libcairo-2.dll
 ??[5] libcdt-4.dll ?? ?? ?? ?? ?? 
 ?? ?? ?? ?? libcgraph-4.dll
 ??[7] libexpat.dll ?? ?? ?? ?? ?? 
 ?? ?? ?? ?? libfontconfig-1.dll
 ??[9] libfreetype-6.dll ?? ?? ?? ?? 
 ?? ?? ??libgdk_pixbuf-2.0-0.dll
 [11] libglib-2.0-0.dll ?? ?? ?? ?? ?? 
 ?? ??libgmodule-2.0-0.dll
 [13] libgobject-2.0-0.dll ?? ?? ?? ?? 
 ?? libgraph-4.dll
 [15] libgvc-4.dll ?? ?? ?? ?? ?? 
 ?? ?? ?? ?? libgvplugin_core-5.dll
 [17] libgvplugin_dot_layout-5.dll ?? libgvplugin_gd-5.dll
 [19] libgvplugin_neato_layout-5.dll libgvplugin_pango-5.dll
 [21] libltdl-3.dll ?? ?? ?? ?? ?? 
 ?? ?? ?? ??libpango-1.0-0.dll
 [23] libpangocairo-1.0-0.dll ?? ?? ?? 
 ??libpangoft2-1.0-0.dll
 [25] libpangowin32-1.0-0.dll ?? ?? 

[R] change mbmdr odds ratio

2010-03-31 Thread clee

I am using the package 'mbmdr' based on the model-base multifactor
dimensionality reduction method by Calle et al.  In the paper, mbmdr is used
for a case-control study.  My data is not case-control, i.e. I have a lot
more controls than cases.  Does anyone know if the odds ratio in the fuction
mbmdr is automatically set to 1 OR is it default to the odds of disease
based on the input data OR can it be user defined?  Perhaps I am just blind
or too novice of an R user, but I do not see where that can be specified in
the mbmdr help file.

Thanks in advance!
-- 
View this message in context: 
http://n4.nabble.com/change-mbmdr-odds-ratio-tp1747022p1747022.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] You are right and the problem is solved. Re: about the possible errors in Rgraphviz Package

2010-03-31 Thread HU,ZHENGJUN

Hi Martin,

 It is really a 'PATH' problem. After adding C:\Program 
Files\Graphviz2.20\bin to the 'PATH' environment variable, the 
Rgraphviz package can be loaded without any error messages.


 Sorry that I ONLY set my 'PATH' environment variable correctly 
for R but not for Graphviz.


 Thank you and Duncan so much for your great help.
 Howard


On Tue Mar 30 18:12:54 EDT 2010, Martin Morgan 
mtmor...@fhcrc.org wrote:



On 03/30/2010 03:06 PM, HU,ZHENGJUN wrote:

Hi Martin,

 I am 100% sure that I set my 'PATH' environment variable 
correctly
because all other packages can loaded correctly as well as 
because R can
be run correctly under both MS DOS and MS Windows XP. Also, I 
can create

some simple R packages correctly.


The PATH must be set correctly to include graphviz, as in my 
example

below. Copy and paste the output of

  strsplit(Sys.getenv(PATH), ;)

and

  list.files(strsplit(Sys.getenv(PATH), ;)[[1]][[14]], dll)

Martin



 Thanks.
 Howard


On Tue Mar 30 16:58:55 EDT 2010, Martin Morgan 
mtmor...@fhcrc.org wrote:



On 03/30/2010 01:13 PM, HU,ZHENGJUN wrote:

Hi Martin,

 I uninstalled graphviz-2.26.3.msi and then installed
graphviz-2.20.3.1.msi. Then installed the
Rgraphviz package again. As expected, I got the same error 
messages as

before:

Error in inDL(x, as.logical(local), as.logical(now), ...) :
 unable to load shared library
'C:/PROGRA~1/R/R-210~1.1/library/Rgraphviz/libs/Rgraphviz.dll':
 LoadLibrary failure:  The specified module could not be found.


'LoadLibrary' is being vague, the 'specified modules' are the 
DLLs from

graphviz.

Have you checked that your 'PATH' environment variable is set 
correctly?

In R

   strsplit(Sys.getenv(PATH), ;)
$PATH
 ...
 [14] C:\\Program Files\\Graphviz2.20\\bin
...

The relevant files in this directory might look like


list.files(strsplit(Sys.getenv(PATH), ;)[[1]][[14]], dll)

 [1] iconv.dll  intl.dll
 [3] jpeg62.dll libcairo-2.dll
 [5] libcdt-4.dll   libcgraph-4.dll
 [7] libexpat.dll   libfontconfig-1.dll
 [9] libfreetype-6.dll  libgdk_pixbuf-2.0-0.dll
[11] libglib-2.0-0.dll  libgmodule-2.0-0.dll
[13] libgobject-2.0-0.dll   libgraph-4.dll
[15] libgvc-4.dll   libgvplugin_core-5.dll
[17] libgvplugin_dot_layout-5.dll   libgvplugin_gd-5.dll
[19] libgvplugin_neato_layout-5.dll libgvplugin_pango-5.dll
[21] libltdl-3.dll  libpango-1.0-0.dll
[23] libpangocairo-1.0-0.dlllibpangoft2-1.0-0.dll
[25] libpangowin32-1.0-0.dlllibpathplan-4.dll
[27] libpng12.dll   libxml2.dll

Martin



 Thank you.
 Howard


On Tue Mar 30 15:36:05 EDT 2010, Martin Morgan 
mtmor...@fhcrc.org

wrote:


On 03/30/2010 10:24 AM, HU,ZHENGJUN wrote:

Hi Duncan,

(They are pretty hard to find, but I think you can find 
them on the

Bioconductor site.)  It is  not enough to install the Rgraphviz
package, you also need to install Graphviz.


 Yes I did. Before installing the Rgraphviz package successfully,
(1) I
downloaded graphviz-2.26.3.msi for MS Windows (XP) and 
installed it

successfully and (2) I also installed the packages from
Bioconductor by:
(Note: I use MS Windows XP and R 2.10.1 version)


This is a bioconductor package so please ask on the Bioconductor
mailing
list

http://bioconductor.org/docs/mailList.html

See the 'README' file in the 'tar.gz' file at


  http://bioconductor.org/packages/release/Software.html
  http://bioconductor.org/packages/2.5/bioc/html/Rgraphviz.html



http://bioconductor.org/packages/2.5/bioc/src/contrib/Rgraphviz_1.24.0.tar.gz



which says


o. install Graphviz ***2.20.3.1*** Windows ***binary*** 
distribution

from


http://www.graphviz.org/pub/graphviz/stable/windows/graphviz-2.20.3.1.msi


you must use this version of graphviz. File paths must be 
correct.


Martin




source(http://www.bioconductor.org/biocLite.R;)
biocLite()

 I got those error messages:

Error in inDL(x, as.logical(local), as.logical(now), ...) :
 unable to load shared library
'C:/PROGRA~1/R/R-210~1.1/library/Rgraphviz/libs/Rgraphviz.dll':
  LoadLibrary failure:  The specified module could not be found.

 Obviously, it seems it is the package problem because it 
should go to

'C:/PROGRA~1/R/R-2.10.1/library/Rgraphviz/libs/Rgraphviz.dll'
instead of
'C:/PROGRA~1/R/R-210~1.1/library/Rgraphviz/libs/Rgraphviz.dll'

 Thank you for the reply. Howard


On Tue Mar 30 12:50:44 EDT 2010, Duncan Murdoch 
murd...@stats.uwo.ca

wrote:


On 30/03/2010 10:44 AM, HU,ZHENGJUN wrote:

Hi All,

  I tried to install the package of Rgraphviz in the 
following two

ways successfully:

source(http://bioconductor.org/biocLite.R;)
biocLite(Rgraphviz)

install.packages(pkgs=C:/Progra~1/R/lib_download/Rgraphviz_1.24.0.zip,


lib=C:/Progra~1/R/R-2.10.1/library, repos=NULL)

but when I loaded the package though library(Rgraphviz) or
library(Rgraphviz), and got the same error message below:

Error in inDL(x, as.logical(local), 

[R] How to work with the result of JRip?

2010-03-31 Thread fascob

Hello, 

I want to work with the result of JRip, but I don't know how to access it. 
I produce a rule like below: 

 rule = JRip(Cls ~., data=dd)

The result is: 

JRIP rules:
===

(C7 = 1) = Cls=TRUE (384.0/0.0)
 = Cls=FALSE (1344.0/0.0)
\par
Number of Rules : 2


I want to work with the above rule..for instance I need the number of rules,
the number of Attribute Tests. But I don't know how to receive it.
Do anyone know how we can get it?

I would be glad for the reply.
Thanks,

-- 
View this message in context: 
http://n4.nabble.com/How-to-work-with-the-result-of-JRip-tp1746858p1746858.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] Summing data based on certain conditions

2010-03-31 Thread Steve Murray

Dear all,

I have a dataset of 1073 rows, the first 15 which look as follows:

 data[1:15,]
    date year month day rammday thmmday
1   3/8/1988 1988 3   8    1.43    0.94
2  3/15/1988 1988 3  15    2.86    0.66
3  3/22/1988 1988 3  22    5.06    3.43
4  3/29/1988 1988 3  29   18.76   10.93
5   4/5/1988 1988 4   5    4.49    2.70
6  4/12/1988 1988 4  12    8.57    4.59
7  4/16/1988 1988 4  16   31.18   22.18
8  4/19/1988 1988 4  19   19.67   12.33
9  4/26/1988 1988 4  26    3.14    1.79
10  5/3/1988 1988 5   3   11.51    6.33
11 5/10/1988 1988 5  10    5.64    2.89
12 5/17/1988 1988 5  17   37.46   20.89
13 5/24/1988 1988 5  24    9.86    9.81
14 5/31/1988 1988 5  31   13.00    8.63
15  6/7/1988 1988 6   7    0.43    0.00


I am looking for a way by which I can create monthly totals of rammday 
(rainfall in mm/day; column 5) by doing the following:

For each case where the month value and the year are the same (e.g. 3 and 1988, 
in the first four rows), find the mean of the the corresponding rammday values 
and then times by the number of days in that month (i.e. 31 in this case).

Note however that the number of month values in each case isn't always the same 
(e.g. in this subset of data, there are 4 values for month 3, 5 for month 4 and 
5 for month 5). Also the months will of course recycle for the following years, 
so it's not simply a case of finding a monthly total for *all* the 3s in the 
whole dataset, just those associated with each year in turn.

How would I go about doing this in R?

Any help will be gratefully received.

Many thanks,

Steve


  
_
We want to hear all your funny, exciting and crazy Hotmail stories. Tell us now

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] You are right and the problem is solved. Re: about the possible errors in Rgraphviz Package

2010-03-31 Thread Martin Morgan
On 03/31/2010 11:44 AM, Gabor Grothendieck wrote:
 I got an error message *AND* R becomes unusable and had to be restarted.
 
 Using dependency walker it seems to be complaining about R.dll so I
 copied all of my ...\R\bin\R*.dll files to ..
 ...\win-library\2.10\Rgraphviz\libs.
 
 Then it complained about IESHIMS.dll so I copied \Program
 Files\Internet Explorer\IESHIMS.dll to
 ...\win-library\2.10\Rgraphviz\libs.
 
 Looking at dependency walker these DLLs: LIBCDT-4.DLL, LIBGRAPH-4.DLL,
 and LIBGVC-4.DLL all seem to point to correct place.
 
 I still have this message in dependency walker:
 Warning: At least one module has an unresolved import due to a missing
 export function in a delay-load dependent module.
 
 There is a red mark beside:
 c:\windows\system32\IEFRAME.DLL
 but its not missing.
 
 I also tried reinstalling R using the latest R 2.10.1.
 
 I am still getting the same result, namely I can run the indicated
 code up to but not including plot(g1) but if I run plot(g1) R crashes
 and must be restarted.

Wow, I didn't mean to put you through such convolutions, and am sorry
that I can't offer an immediate solution. Martin

 
 
 
 On Wed, Mar 31, 2010 at 12:54 PM, Martin Morgan mtmor...@fhcrc.org wrote:
 On 03/31/2010 08:18 AM, Gabor Grothendieck wrote:
 By the way, just in case you did not read the entire message R crashed

 I think you mean that you got an error message, not that R became
 unusable? More below...

 when I tried to run the code from the vignette.

 On Wed, Mar 31, 2010 at 10:52 AM, Gabor Grothendieck
 ggrothendi...@gmail.com wrote:
 Based on your success I thought I would try again. I am not sure why I
 had more success this time but this time I got this far even though I
 did not change my path at all or make any system changes from what I
 had before.  I did reinstall Rgraphviz but used the previously
 installed graphviz.   I tried this code taken from the Rgrpahviz
 vignette:

 library(Rgraphviz)
 Loading required package: graph
 Loading required package: grid
 set.seed(123)
 V - letters[1:10]
 M - 1:4
 g1 - randomGraph(V, M, 0.2)
 g1
 A graphNEL graph with undirected edges
 Number of Nodes = 10
 Number of Edges = 16


 but when I tried to plot it R crashed.

 plot(g1)

 It did produce this message on the Windows console (not the R console):

 Error: Layout type: dot not recognized. Use one of:

 In the past this has come about when accessing incorrect graphviz DLLs.
 The gory detail (if I remember correctly) is that a FILE* gets allocated
 in Rgraphviz and passed to graphviz, and if there is a compiler mismatch
 then there are no guarantees about FILE* representation.

 The implication is that your Rgraphviz and graphiz are at least partly
 out of sync, but it could also be that I am 'getting lucky'. When you
 say (quoting from above)...

 did not change my path at all or make any system changes from what I

 the implication is that your PATH was already set to include a
 graphviz2.20\\bin directory; I'd encourage you to confirm that.
 
 Yes,  My path is:
 
 PATH=C:\Graphviz2.20\bin;...more stuff...
 

 And recognizing that you might justifiably be willing to put this on the
 shelf, you might also use Dependency Walker
 (http://www.dependencywalker.com/) to open the Rgraphviz DLL
 (R_HOME/libraries/Rgraphviz/libs/Rgraphviz.dll), right click on the
 RGRAPHVIZ.DLL showing up in the top left panel, and choose 'Full paths',
 and verify that LIBCDT-4.DLL, LIBGRAPH-4.DLL, and LIBGVC-4.DLL all point
 to Graphviz2.20\bin.

 Martin


 There was nothing after the of:

 R.version.string
 [1] R version 2.10.1 Patched (2010-03-10 r51276)
 win.version()
 [1] Windows Vista (build 6002) Service Pack 2
 packageDescription(Rgraphviz)$Version
 [1] 1.24.0
 graphvizVersion()
 $installed_version
 [1] ‘2.20.3’

 $build_version
 [1] ‘2.20.3’




 On Wed, Mar 31, 2010 at 9:56 AM, HU,ZHENGJUN h...@ufl.edu wrote:
 Hi Martin,

  It is really a 'PATH' problem. After adding C:\Program
 Files\Graphviz2.20\bin to the 'PATH' environment variable, the Rgraphviz
 package can be loaded without any error messages.

  Sorry that I ONLY set my 'PATH' environment variable correctly for R but
 not for Graphviz.

  Thank you and Duncan so much for your great help.
  Howard


 On Tue Mar 30 18:12:54 EDT 2010, Martin Morgan mtmor...@fhcrc.org wrote:

 On 03/30/2010 03:06 PM, HU,ZHENGJUN wrote:

 Hi Martin,

  I am 100% sure that I set my 'PATH' environment variable correctly
 because all other packages can loaded correctly as well as because R can
 be run correctly under both MS DOS and MS Windows XP. Also, I can create
 some simple R packages correctly.

 The PATH must be set correctly to include graphviz, as in my example
 below. Copy and paste the output of

  strsplit(Sys.getenv(PATH), ;)

 and

  list.files(strsplit(Sys.getenv(PATH), ;)[[1]][[14]], dll)

 Martin


  Thanks.
  Howard


 On Tue Mar 30 16:58:55 EDT 2010, Martin Morgan mtmor...@fhcrc.org
 wrote:

 On 03/30/2010 01:13 PM, HU,ZHENGJUN wrote:

 Hi 

Re: [R] ODD and EVEN numbers

2010-03-31 Thread Erik Iverson

See %% under ?Arithmetic

tj wrote:

Hi,

anyone here who knows how to determine if an integer is odd or even in
R?
Thanks.


tj


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lattice: how to add points to the plot generated by levelplot()?

2010-03-31 Thread Erik Iverson



Czerminski, Ryszard wrote:

I am using levelplot() function from pkg:lattice and I want to add some
points
to the plot generated by levelplot()


It's best to include a small example of what you have done so far, and 
what you want to further do.  Actual R code with a small sample dataset 
is great.




similarly as in basic R graphic sequence: plot(...); points(...),
but it does not work.

I was reading documentation for lattice, but so far without much
success.

I would very much appreciate some tips.



Most base graphics functions like point have a grid equivalent.  In this 
case, use grid.points.


 levelplot(runif(100)~runif(100)*runif(100),
   panel = function(...) {
 panel.levelplot(...)
 grid.points(.1, .1, pch = 2)
 })


I found the Lattice book and the R Graphics book invaluable, both are 
worth getting.


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

2010-03-31 Thread David Winsemius


On Mar 31, 2010, at 12:43 PM, tj wrote:



Hi,

anyone here who knows how to determine if an integer is odd or  
even in

R?
Thanks.


 2 %% 2 == 0
[1] TRUE
 3 %% 2 == 0
[1] FALSE

is.even - function(x){ x %% 2 == 0 }

 is.even(2)
[1] TRUE
--
David Winsemius, MD
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] Summing data based on certain conditions

2010-03-31 Thread Bert Gunter
?ave 
or ?tapply

Bert Gunter
Genentech Nonclinical Biostatistics
 
 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Steve Murray
Sent: Wednesday, March 31, 2010 10:20 AM
To: r-help@r-project.org
Subject: [R] Summing data based on certain conditions


Dear all,

I have a dataset of 1073 rows, the first 15 which look as follows:

 data[1:15,]
    date year month day rammday thmmday
1   3/8/1988 1988 3   8    1.43    0.94
2  3/15/1988 1988 3  15    2.86    0.66
3  3/22/1988 1988 3  22    5.06    3.43
4  3/29/1988 1988 3  29   18.76   10.93
5   4/5/1988 1988 4   5    4.49    2.70
6  4/12/1988 1988 4  12    8.57    4.59
7  4/16/1988 1988 4  16   31.18   22.18
8  4/19/1988 1988 4  19   19.67   12.33
9  4/26/1988 1988 4  26    3.14    1.79
10  5/3/1988 1988 5   3   11.51    6.33
11 5/10/1988 1988 5  10    5.64    2.89
12 5/17/1988 1988 5  17   37.46   20.89
13 5/24/1988 1988 5  24    9.86    9.81
14 5/31/1988 1988 5  31   13.00    8.63
15  6/7/1988 1988 6   7    0.43    0.00


I am looking for a way by which I can create monthly totals of rammday
(rainfall in mm/day; column 5) by doing the following:

For each case where the month value and the year are the same (e.g. 3 and
1988, in the first four rows), find the mean of the the corresponding
rammday values and then times by the number of days in that month (i.e. 31
in this case).

Note however that the number of month values in each case isn't always the
same (e.g. in this subset of data, there are 4 values for month 3, 5 for
month 4 and 5 for month 5). Also the months will of course recycle for the
following years, so it's not simply a case of finding a monthly total for
*all* the 3s in the whole dataset, just those associated with each year in
turn.

How would I go about doing this in R?

Any help will be gratefully received.

Many thanks,

Steve


  
_
We want to hear all your funny, exciting and crazy Hotmail stories. Tell us
now

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] strip.custom with strip on left for three conditioning variables

2010-03-31 Thread Pat Schmitz
I want to use a strip.custom as with useOuterStrips for three conditioning
variables.
useOuterStrips restricts this to only two conditioning variables, and I
cannot figure out
how to write strip.custom properly to do this.

library(lattice)

mtcars$HP - equal.count(mtcars$hp)

#with two factors
x2-xyplot(mpg ~ disp | HP + factor(cyl), mtcars)
useOuterStrips(x2)


#with three factors
x3-xyplot(mpg ~ disp | HP + factor(cyl) + factor(carb), mtcars)

update(x3,strip=strip.custom(which.given= 1),
 strip2=strip.custom(which.given= 2),
 strip.left=strip.custom(which.given=3)
)

--
Patrick Schmitz
Graduate Student
Plant Biology
1206 West Gregory Drive
RM 1500

[[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] ODD and EVEN numbers

2010-03-31 Thread Stephan Kolassa

(foo %% 2) == 0

See ?%%

HTH
Stephan


tj schrieb:

Hi,

anyone here who knows how to determine if an integer is odd or even in
R?
Thanks.


tj


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] lattice: how to add points to the plot generated bylevelplot()?

2010-03-31 Thread Bert Gunter
Tip 1: This sort of thing is done with panel functions. ?xyplot and
?panel.xyplot is where to start.

Tip 2: grid functions are generally not necessary, as translations of the
common ones are part of lattice. See ?panel.points

Tip 3: Deepayan's book provides a gentler explanation of these matters with
more examples than R's man pages.

Tip 4: Depending on your needs and predilections, you may prefer to use
ggplot2.

Bert Gunter
Genentech Nonclinical Biostatistics
 
 

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Erik Iverson
Sent: Wednesday, March 31, 2010 12:54 PM
To: Czerminski, Ryszard
Cc: R-help@r-project.org
Subject: Re: [R] lattice: how to add points to the plot generated
bylevelplot()?



Czerminski, Ryszard wrote:
 I am using levelplot() function from pkg:lattice and I want to add some
 points
 to the plot generated by levelplot()

It's best to include a small example of what you have done so far, and 
what you want to further do.  Actual R code with a small sample dataset 
is great.


 similarly as in basic R graphic sequence: plot(...); points(...),
 but it does not work.
 
 I was reading documentation for lattice, but so far without much
 success.
 
 I would very much appreciate some tips.


Most base graphics functions like point have a grid equivalent.  In this 
case, use grid.points.

  levelplot(runif(100)~runif(100)*runif(100),
panel = function(...) {
  panel.levelplot(...)
  grid.points(.1, .1, pch = 2)
  })


I found the Lattice book and the R Graphics book invaluable, both are 
worth getting.

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


  1   2   >