Re: [R] Identify and plotting symbols. [SEC=UNCLASSIFIED]

2007-09-19 Thread Crombie, Joe
Or maybe:

> while(length(ind <- identify(x,y,n = 1, plot = F)))
>   points(x[ind], y[ind], pch = 19)

(highlights each point as you select it, until you click _stop_)

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Crombie, Joe
Sent: Thursday, 20 September 2007 2:11 PM
To: [EMAIL PROTECTED]
Subject: Re: [R] Identify and plotting symbols. [SEC=UNCLASSIFIED]

Rolf turner wrote:

>I have been trying, unsuccessfully, to use identify() to (simply) 
>return a list of the indices of points clicked on and overplot (with 
>say a solid dot) each clicked-on point so that I can see where I've 
>been.  I.e. I don't want to see the indices printed on the screen; I
just want the points I've already selected to be highlighted.
>
>I tried
>
>   ind <- identify(x,y,labels=rep("\021",length(x)),offset=0)


Why not:

ind <- identify(x,y, plot = F)
points(x[ind], y[ind], pch = 19)

Cheers  Joe



Joe Crombie
 
Information and Risk Sciences
Bureau of Rural Science
Canberra  Australia
 
p: +61 2 6272 5906
e: [EMAIL PROTECTED]

--IMPORTANT - This message has been issued by The Department of
Agriculture, Fisheries and Forestry (DAFF). The information transmitted
is for the use of the intended recipient only and may contain
confidential and/or legally privileged material. It is your
responsibility to check any attachments for viruses and defects before
opening or sending them on. 

Any reproduction, publication, communication, re-transmission,
disclosure, dissemination or other use of the information contained in
this e-mail by persons or entities other than the intended recipient is
prohibited. The taking of any action in reliance upon this information
by persons or entities other than the intended recipient is prohibited.
If you have received this e-mail in error please notify the sender and
delete all copies of this transmission together with any attachments. If
you have received this e-mail as part of a valid mailing list and no
longer want to receive a message such as this one advise the sender by
return e-mail accordingly. Only e-mail correspondence which includes
this footer, has been authorised by DAFF
--

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

--IMPORTANT - This message has been issued by The Department of 
Agriculture, Fisheries and Forestry (DAFF). The information transmitted is for 
the use of the intended recipient only and may contain confidential and/or 
legally privileged material. It is your responsibility to check any attachments 
for viruses and defects before opening or sending them on. 

Any reproduction, publication, communication, re-transmission, disclosure, 
dissemination or other use of the information contained in this e-mail by 
persons or entities other than the intended recipient is prohibited. The taking 
of any action in reliance upon this information by persons or entities other 
than the intended recipient is prohibited. If you have received this e-mail in 
error please notify the sender and delete all copies of this transmission 
together with any attachments. If you have received this e-mail as part of a 
valid mailing list and no longer want to receive a message such as this one 
advise the sender by return e-mail accordingly. Only e-mail correspondence 
which includes this footer, has been authorised by DAFF 
--

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

2007-09-19 Thread Patrick Connolly
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, 20 September 2007 11:38 a.m.
> To: Patrick Connolly; [EMAIL PROTECTED]
> Subject: RE: [R] fontsize in mosaic plot lables
> 
> Thanks Patric,
> 
> mosaic{vdc} takes gpar parameters. So cex.axis does not work for 

OK, my mistake.  I was thinking of mosaicplot in the graphics package.

It's a while since I used it, and I seem to remember it was a bit tricky
also, but I did get it to work in the end using mtext which lets you set
the cex.  But that's no use to you.


___
The contents of this e-mail are privileged and/or confidential to the
named recipient and are not to be used by any other person and/or
organisation. If you have received this e-mail in error, please notify
the sender and delete all material pertaining to this e-mail.

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

2007-09-19 Thread Anand Patil
Hi all,


I'd like to distribute an R package that compiles some (small) C functions
every time it's sourced. The relevant code in the top level R script is as
follows:

system("R CMD SHLIB Selma_extensions.c")
if (.Platform$OS.type=="windows") {
slash = '\\'
dyn.load("Selma_extensions.dll")
}
if (.Platform$OS.type=="unix") {
slash = '/'
dyn.load("Selma_extensions.so")
}


This works fine on a Mac, but I tried it under Windows Vista, after
installing RTools and telling it to put itself on the system path, and got
the following:

making Selma_extensions.d from Selma_extensions.c
gcc.exe: installation problem, cannot exec `cc1': No such file or directory
make: *** [Selma_extensions.d] Error 1
Error in dyn.load(x, as.logical(local), as.logical(now)) :
unable to load shared library
'C:/Users/anand/Desktop/Selma/Selma_extensions.dll':
  LoadLibrary failure:  The specified module could not be found.

Can this be fixed without requiring the user to do anything?

Note: The compilation takes so little time relative to the use of the
package that it's no big deal to call SHLIB every time.


Thanks in advance,
Anand Patil

[[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] Identify and plotting symbols. [SEC=UNCLASSIFIED]

2007-09-19 Thread Crombie, Joe
Rolf turner wrote:

>I have been trying, unsuccessfully, to use identify() to (simply) 
>return a list of the indices of points clicked on and overplot (with 
>say a solid dot) each clicked-on point so that I can see where I've 
>been.  I.e. I don't want to see the indices printed on the screen; I
just want the points I've already selected to be highlighted.
>
>I tried
>
>   ind <- identify(x,y,labels=rep("\021",length(x)),offset=0)


Why not:

ind <- identify(x,y, plot = F)
points(x[ind], y[ind], pch = 19)

Cheers  Joe



Joe Crombie
 
Information and Risk Sciences
Bureau of Rural Science
Canberra  Australia
 
p: +61 2 6272 5906
e: [EMAIL PROTECTED]

--IMPORTANT - This message has been issued by The Department of 
Agriculture, Fisheries and Forestry (DAFF). The information transmitted is for 
the use of the intended recipient only and may contain confidential and/or 
legally privileged material. It is your responsibility to check any attachments 
for viruses and defects before opening or sending them on. 

Any reproduction, publication, communication, re-transmission, disclosure, 
dissemination or other use of the information contained in this e-mail by 
persons or entities other than the intended recipient is prohibited. The taking 
of any action in reliance upon this information by persons or entities other 
than the intended recipient is prohibited. If you have received this e-mail in 
error please notify the sender and delete all copies of this transmission 
together with any attachments. If you have received this e-mail as part of a 
valid mailing list and no longer want to receive a message such as this one 
advise the sender by return e-mail accordingly. Only e-mail correspondence 
which includes this footer, has been authorised by DAFF 
--

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

2007-09-19 Thread Gabor Grothendieck
If you are interested in regular expressions you may also be
interested in a solution using the gsubfn package.  Here x
is the input character string, re is Jeffrey's regular expression
and strapply applies the regular expression to x calling the function
which is represented in formula notation using the free variables
year, month and day as the arguments.  backref = -3 says
only pass the 3 backreferences, i.e. the matched portion within
parens, and not the entire string.  The function is set up to take
a vector input for x but since we only have one element we use [[1]].

library(gsubfn)

x <- "2005-09-01"
re <- "([[:digit:]]{4})-([[:digit:]]{2})-([[:digit:]]{2})"

strapply(x, re, ~ c(year = year, month = month, day = day), backref = -3)[[1]]


On 9/19/07, Jeffrey Robert Spies <[EMAIL PROTECTED]> wrote:
> Sub uses POSIX-extended regular expressions.  It searches for the
> first argument, the pattern, and replaces it with the second argument
> in the variable defined by the third argument.  [[:digit:]] is a
> match-any-digit operator; it matches the characters 0-9.  The {#} is
> the interval operator, where what's inside the bracket's is a count.
> So [[:digit:]]{4} means match 4 digits.  All together, ([[:digit:]]
> {4})-([[:digit:]]{2})-([[:digit:]]{2}) means "Match 4 digits followed
> by a dash followed by 2 digits followed by a dash followed by 2 digits.
> By surrounding pieces of the search pattern in parentheses, we create
> back-references, which can be used in the replacement (second
> argument) like variables, \\1 to \\9, in the order that they appear
> in the pattern. When we replace the pattern with '\\1', that means
> return what is in the first set of parentheses, or the first four
> digits before a dash before two digits before a dash before another
> two digits.
>
> Note: most of the time, we'd use single slashes to escape a character
> (i.e. \1), but R needs double slashes (i.e. \\1).
>
> If you're interested in regular expressions, this site is quite
> useful: http://www.cs.utah.edu/dept/old/texinfo/regex/regex_toc.html.
>
> Make sense?
>
> Jeff.
>
> On Sep 18, 2007, at 10:46 AM, Arun Kumar Saha wrote:
>
> > Dear Jeffrey,
> >
> > Your syntax looks very extraordinary to me. I would be very happy
> > if you can explain this notation.
> >
> > Regards,
> >
> > On 9/18/07, Jeffrey Robert Spies <[EMAIL PROTECTED]> wrote:And one
> > using regular expressions:
> >
> > x <- "2005-09-01"
> > pattern <- '([[:digit:]]{4})-([[:digit:]]{2})-([[:digit:]]{2})'
> > y <- sub(pattern, '\\1', x)
> > m <- sub(pattern, '\\2', x)
> > d <- sub(pattern, '\\3', x)
> >
> > -- Jeff.
> >
> > On Sep 18, 2007, at 5:00 AM, Arun Kumar Saha wrote:
> >
> > > Dear all,
> > >
> > > I have a variable 'x' like that:
> > >
> > >> x
> > > [1] "2005-09-01"
> > >
> > > Here, 2005 represents year, 09 month and 01 day.
> > >
> > > Now I want to create three variables naming: y, m, and d such that:
> > >
> > > y = 2005
> > > m = 09
> > > d = 01
> > >
> > > can anyone tell me how to do that?
> > >
> > > Regards,
> > >
> > >   [[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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] R-related: problem with openvt on Ubuntu 7.04

2007-09-19 Thread bbolker

   This is a configuration/OS problem, but it's affecting my use of R ...

  Whenever I try to open _any_ vignette (as far as I can tell)
from within R, I get "Could not get a file descriptor referring to the
console",
coming from /usr/bin/openvt, which is pointed to by /usr/bin/open,
which is called by print.vignette to display the vignette.

   On the other hand, openvt fails in the same way from the command line,
with
_any_ command ("openvt bash"), so I know it's not really an R problem.
Nevertheless, maybe someone has an answer?

   system("evince") or system("acroread") both seem to work fine, so I guess
in a pinch I could hack print.vignette ...

RSiteSearching finds practically nothing and
Googling around finds nothing terribly useful ... 
this is on a fairly standard Ubuntu 7.04 install.

  thanks
Ben Bolker



> sessionInfo()
R version 2.5.1 (2007-06-27) 
i486-pc-linux-gnu 

locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C

attached base packages:
[1] "stats" "graphics"  "grDevices" "utils" "datasets"  "methods"  
[7] "base" 
> vignette()
> library(grid)
> vignette("frame")
> Couldnt get a file descriptor referring to the console
Could not get a file descriptor referring to the console

-- 
View this message in context: 
http://www.nabble.com/R-related%3A-problem-with-openvt-on-Ubuntu-7.04-tf4485216.html#a12790390
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] Factor levels

2007-09-19 Thread Gabor Grothendieck
If you don't know ahead of time how many columns you have and
only that they are a mix of numeric and character (to be converted to
factor) then you can do this:

DF <- read.table(textConnection(Input), header = TRUE, as.is = TRUE)
f <- function(x) if (is.character(x)) factor(x, levels = unique(x)) else x
DF[] <- lapply(DF, f)
DF





On 9/19/07, Sébastien <[EMAIL PROTECTED]> wrote:
> Hi Gabor,
>
> I am coming back to you about the method you described to me a month ago to
> define the level order during a read.table call. I initially thought that I
> would need to apply the 'unique' function on a single column of my dataset,
> so I only used it after the read.table step (to make my life easier)...
> Well, I was wrong: I need to reorder all my columns (just to remind you, I
> don't know the numbers of columns my code has to handle). So, here come
> troubles.
>
> I first tried to apply your code as is, although I thought there might be
> some problems. The class can actually not be recycled, when a list notation
> is used (the help says that "colClasses character. A vector of classes to be
> assumed for the columns. Recycled as necessary..."). See the following
> example:
>
> ##
>
> library(methods)
>
> setClass("my.factor")
>
> setAs("character", "my.factor",
>
>  function(from) factor(from, levels = unique(from)))
>
>
>
> Input<-"a b c d
>
> 1 1 175 n f
>
> 2 2 102 n j
>
> 3 3 187 o n
>
> 4 4 106 u g
>
> 5 5 102 o v
>
> 6 6 133 l x
>
> 7 7 149 w q
>
> 8 8 122 x p
>
> 9 9 151 u r
>
> 10 10 134 e g
>
> 11 11 170 j q
>
> 12 12 103 v n
>
> 13 13 153 n w
>
> 14 14 106 x x
>
> 15 15 185 v x
>
> 16 16 102 s p
>
> 17 17 181 i h
>
> 18 18 192 o k
>
> 19 19 161 d f
>
> 20 20 158 n q
>
> "
>
>
>
> DF <- read.table(textConnection(Input), header = TRUE, colClasses =
> list(c=("my.factor")))
> levels(DF$c) # properly ordered
>
>
> levels(DF$d) # not reordered
>
> ##
>
> I also tried that:
>
> ##
>
> DF <- read.table(textConnection(Input), header = TRUE, colClasses =
> c("my.factor"))
> levels(DF$c)
>
> levels(DF$d)
>
> ##
>
> In this case, the class is definitely recycled as all the columns of DF are
> transformed into factors... Not really useful :)
> I tried to modify the content of the list or my second notation, by
> including "integer" or a second "my.factor"... but I did not have much
> success.
> Any idea how to use the class "my.factor" multiple times ?
>
> Thanks in advance
>
>
> Gabor Grothendieck a écrit :
> Its the same principle. Just change the function to be suitable. This
> one
arranges the levels according to the
> input:

library(methods)
setClass("my.factor")
setAs("character",
> "my.factor",
 function(from) factor(from, levels = unique(from)))

Input <-
> "a b c
1 1 176 w
2 2 141 k
3 3 172 r
4 4 182 s
5 5 123 k
6 6 153 p
7 7 176
> l
8 8 170 u
9 9 140 z
10 10 194 s
11 11 164 j
12 12 100 j
13 13 127 x
14 14
> 137 r
15 15 198 d
16 16 173 j
17 17 113 x
18 18 144 w
19 19 198 q
20 20 122
> f
"
DF <- read.table(textConnection(Input), header = TRUE,
 colClasses =
> list(c = "my.factor"))
str(DF)


On 8/28/07, Sébastien <[EMAIL PROTECTED]>
> wrote:

> Ok, I cannot send to you one of my dataset since they are confidential.
> But
I can produce a dummy "mini" dataset to illustrate my question. Let's
> say I
have a csv file with 3 columns and 20 rows which content is reproduced
> by
the following line.


> mydata<-data.frame(a=1:20,

> b=sample(100:200,20,replace=T),c=sample(letters[1:26],
> 20,
replace = T))

> mydata

>  a b c
1 1 176 w
2 2 141 k
3 3 172 r
4 4 182 s
5 5 123 k
6 6 153 p
7 7 176
> l
8 8 170 u
9 9 140 z
10 10 194 s
11 11 164 j
12 12 100 j
13 13 127 x
14 14
> 137 r
15 15 198 d
16 16 173 j
17 17 113 x
18 18 144 w
19 19 198 q
20 20 122
> f

If I had to read the csv file, I would use something
> like:
mydata<-data.frame(read.table(file="c:/test.csv",header=T))

Now, if
> you look at mydata$c, the levels are alphabetically ordered.

> mydata$c

>  [1] w k r s k p l u z s j j x r d j x w q f
Levels: d f j k l p q r s u w x
> z

What I am trying to do is to reorder the levels as to have them in the
> order
they appear in the table, ie
Levels: w k r s p l u z j x d q f

Again,
> keep in mind that my script should be used on datasets which content
are
> unknown to me. In my example, I have used letters for mydata$c, but my
code
> may have to handle factors of numeric or character values (I need
> to
transform specific columns of my dataset into factors for
> plotting
purposes). My goal is to let the code scan the content of each
> factor of my
data.frame during or after the read.table step and reorder
> their levels
automatically without having to ask the user to hard-code the
> level order.

In a way, my problem is more related to the way the factor
> levels are
ordered than to the read.table function, although I guess there
> is a link...

Gabor Grothendieck a écrit :
Its not clear from your
> description wha

Re: [R] how to find "p" in binomial(n,p)

2007-09-19 Thread Charles C. Berry
On Thu, 20 Sep 2007, Rolf Turner wrote:

>
> On 20/09/2007, at 11:04 AM, Mike Meredith wrote:
>
>>
>> I think the function you need is 'help.search'; try:
>>
>> help.search("binomial")
>>
>> and look for something obvious in the 'stats' package. A good deal
>> quicker
>> and easier than posting to an internet forum!
>>
>
>   I don't think so.  I couldn't find anything useful under help.search
> ("binomial"), and
>   I'm fairly comfortable with R.


After 20-odd years of R, Splus, and S, I'd say I am more enthusiastic than 
'comfortable', but trying 'help.search("binomial")' I get:


Help files with alias or concept or title matching 'binomial' using fuzzy 
matching:

[stuff omitted]

binom.test(stats)   Exact Binomial Test




And after reading the help page:

> binom.test(15,20,conf=.95,alt='less') # Rolf's example

 Exact binomial test

data:  15 and 20
number of successes = 15, number of trials = 20, p-value = 0.994
alternative hypothesis: true probability of success is less than 0.5
95 percent confidence interval:
  0.000 0.8959192

...^... matches Rolf's example

sample estimates:
probability of success
   0.75

> binom.test(4,10,conf=.05,alt='le') # Ted's Example

 Exact binomial test

data:  4 and 10
number of successes = 4, number of trials = 10, p-value = 0.3770
alternative hypothesis: true probability of success is less than 0.5
5 percent confidence interval:
  0.000 0.2224411
...^. matches Ted's Example

sample estimates:
probability of success
0.4

So, it really can be found using 'help.search'.

Although in view of the 'Zen in the Art of Motorcycle Maintenance' effect 
(if it is only obvious if you know something, then it is not really 
obvious) I must note that one must recognize that "Pr(X <= k) <= alpha" is 
the confidence statement.

But of course, if one 'knew something' it is

help.search("beta")

that would be tried. :-)


HTH,

Chuck


>
>   It seems to me that what is required here is to roll your own.
>
>   I defined a function foo():
>
>   foo <- function(p,n,k,alpha){pbinom(k,n,p)-alpha}
>
>   Then I used uniroot to solve foo(p,n,k,alpha) = 0.
>
>   E.g.
>
>   xxx <- uniroot(foo,c(0,1),n=20,k=15,alpha=0.05)
>
>   Then xxx$root is 0.895913.
>
>   Check this out graphically:
>
>   p <- seq(0,1,length=301)
>   y <- foo(p,20,15,0.05)
>   plot(p,y,type="l")
>   abline(h=0)
>   abline(v=xxx$root)
>
>   It looks good.
>
>   cheers,
>
>   Rolf Turner
>> Cheers, Mike.
>>
>>
>> cathelf wrote:
>>>
>>> Dear all,
>>>
>>> I am trying a find the value "p" in binomial.
>>>
>>> X ~ Bin(n,p)
>>>
>>> I want to find the value "p", so that Pr(X <= k) <= alpha
>>>
>>> Here, n, k and alpha are known. n, k are integers. alpha is
>>> between (0,1).
>>>
>>> Thanks a lot!
>>>
>>> Catherine
>>>
>
>
> ##
> Attention:\ This e-mail message is privileged and confidenti...{{dropped}}
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

Charles C. Berry(858) 534-2098
 Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]  UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

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


[R] What is the preferred method to view a pdf (not a vignette) in a package /doc ?

2007-09-19 Thread morphwj
What is the preferred method to view a pdf (not generated by Sweave so not a 
vignette) in a package  /doc ?  Some options are openPDF(Biobase), and the 
README and Help files.

Bill Morphet
ATK, Space Launch Systems
Postflight Evaluation Eng
[[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] Factor levels

2007-09-19 Thread Sébastien
Hi Gabor,

I am coming back to you about the method you described to me a month ago 
to define the level order during a read.table call. I initially thought 
that I would need to apply the 'unique' function on a single column of 
my dataset, so I only used it after the read.table step (to make my life 
easier)... Well, I was wrong: I need to reorder all my columns (just to 
remind you, I don't know the numbers of columns my code has to handle). 
So, here come troubles.

I first tried to apply your code as is, although I thought there might 
be some problems. The class can actually not be recycled, when a list 
notation is used (the help says that "colClasses character. A *vector* 
of classes to be assumed for the columns. Recycled as necessary..."). 
See the following example:

##

library(methods)
 

setClass("my.factor")   
 

setAs("character", 
"my.factor",  

 function(from) factor(from, levels = 
unique(from)))

 

Input<-"a b c 
d   
   

1 1 175 n 
f   
   

2 2 102 n 
j   
   

3 3 187 o 
n   
   

4 4 106 u 
g   
   

5 5 102 o 
v   
   

6 6 133 l 
x   
   

7 7 149 w 
q   
   

8 8 122 x 
p   
   

9 9 151 u 
r   
   

10 10 134 e 
g   
 

11 11 170 j 
q   
 

12 12 103 v 
n   
 

13 13 153 n 
w   
 

14 14 106 x 
x   
 

15 15 185 v 
x   
 

16 16 102 s 
p   
 

17 17 181 i 
h   
 

18 18 192 o 
k   
 

19 19 161 d 
f   
 

20 20 158 n 
q   
 

"   
 


 

DF <- read.table(textConnection(Input), header = TRUE, colClasses = 
list(c=("my.factor")))  
levels(DF$c) # properly ordered 

  

levels(DF$d) # not reordered

##

I also tried that:

##

DF <- read.table(textConnection(Input), header = TRUE, colClasses = 
c("my.factor"))  
levels(DF$c)
 

levels(DF$d)

##

In this case, the class is definitely recycled as all the columns of DF 
are transformed into factors... Not really useful :)
I tried to modify the content of the list or my second notation, by 
including "integer" or a second "my.factor"... but I did not have much 
success.
Any idea how to use the class "my.factor" multiple times ?

Thanks in advance

Gabor Grothendieck a écrit :
> Its the same principle.  Just change the function to be suitable.  This one
> arranges the levels according to the input:
>
> library(methods)
> setClass("my.factor")
> setAs("character", "my.factor",
>  function(from) factor(from, levels = unique(from)))
>
> Input <- "a b c
> 1   1 176 w
> 2   2 141 k
> 3   3 172 r
> 4   4 182 s
> 5   5 123 k
> 6   6 153 p
> 7   7 176 l
> 8   8 170 u
> 9   9 140 z
> 10 10 194 s
> 11 1

Re: [R] Need help on "date"

2007-09-19 Thread Jeffrey Robert Spies
Sub uses POSIX-extended regular expressions.  It searches for the  
first argument, the pattern, and replaces it with the second argument  
in the variable defined by the third argument.  [[:digit:]] is a  
match-any-digit operator; it matches the characters 0-9.  The {#} is  
the interval operator, where what's inside the bracket's is a count.   
So [[:digit:]]{4} means match 4 digits.  All together, ([[:digit:]] 
{4})-([[:digit:]]{2})-([[:digit:]]{2}) means "Match 4 digits followed  
by a dash followed by 2 digits followed by a dash followed by 2 digits.
By surrounding pieces of the search pattern in parentheses, we create  
back-references, which can be used in the replacement (second  
argument) like variables, \\1 to \\9, in the order that they appear  
in the pattern. When we replace the pattern with '\\1', that means  
return what is in the first set of parentheses, or the first four  
digits before a dash before two digits before a dash before another  
two digits.

Note: most of the time, we'd use single slashes to escape a character  
(i.e. \1), but R needs double slashes (i.e. \\1).

If you're interested in regular expressions, this site is quite  
useful: http://www.cs.utah.edu/dept/old/texinfo/regex/regex_toc.html.

Make sense?

Jeff.

On Sep 18, 2007, at 10:46 AM, Arun Kumar Saha wrote:

> Dear Jeffrey,
>
> Your syntax looks very extraordinary to me. I would be very happy  
> if you can explain this notation.
>
> Regards,
>
> On 9/18/07, Jeffrey Robert Spies <[EMAIL PROTECTED]> wrote:And one  
> using regular expressions:
>
> x <- "2005-09-01"
> pattern <- '([[:digit:]]{4})-([[:digit:]]{2})-([[:digit:]]{2})'
> y <- sub(pattern, '\\1', x)
> m <- sub(pattern, '\\2', x)
> d <- sub(pattern, '\\3', x)
>
> -- Jeff.
>
> On Sep 18, 2007, at 5:00 AM, Arun Kumar Saha wrote:
>
> > Dear all,
> >
> > I have a variable 'x' like that:
> >
> >> x
> > [1] "2005-09-01"
> >
> > Here, 2005 represents year, 09 month and 01 day.
> >
> > Now I want to create three variables naming: y, m, and d such that:
> >
> > y = 2005
> > m = 09
> > d = 01
> >
> > can anyone tell me how to do that?
> >
> > Regards,
> >
> >   [[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] Subset any value and blanks

2007-09-19 Thread jim holtman
You can use 'split' to create a list of dataframes and then operate on them:

  Day Month Year Time Hits Misses F.type
1  0101 1999 0600  120 80   0600
2  0101 1999 1015  300 10
3  0101 1999 1216  250 50   1216
4  0101 1999 1649  380  0
5  0101 1999 2132 1100 25   2132
> str(x)
'data.frame':   5 obs. of  7 variables:
 $ Day   : chr  "01" "01" "01" "01" ...
 $ Month : chr  "01" "01" "01" "01" ...
 $ Year  : chr  "1999" "1999" "1999" "1999" ...
 $ Time  : chr  "0600" "1015" "1216" "1649" ...
 $ Hits  : chr  "120" "300" "250" "380" ...
 $ Misses: chr  "80" "10" "50" "0" ...
 $ F.type: chr  "0600" "" "1216" "" ...
> x.split <- split(x, x$F.type == "")
> x.split
$`FALSE`
  Day Month Year Time Hits Misses F.type
1  0101 1999 0600  120 80   0600
3  0101 1999 1216  250 50   1216
5  0101 1999 2132 1100 25   2132

$`TRUE`
  Day Month Year Time Hits Misses F.type
2  0101 1999 1015  300 10
4  0101 1999 1649  380  0
> x.missing <- x.split$"TRUE"
> x.missing
  Day Month Year Time Hits Misses F.type
2  0101 1999 1015  300 10
4  0101 1999 1649  380  0


On 9/19/07, Spilak,Jacqueline [Edm] <[EMAIL PROTECTED]> wrote:
> Hi everyone
> I need help with subseting a data set.  In my dataset there is a
> specific row that will either have a value or be blank.  I would like to
> subset (or split) the dataset into one dataset with the row that has the
> value and another dataset that has just the blanks.  Now the thing is
> that the row that has the value in it, the value is not always the same,
> it is a time stamp of when something happens.
> Example of Dataset
> Day Month   YearTimeHitsMissesF-type
> 01  01  19990600120 800600
> 01  01  19991015300 10
> 01  01  19991216250 501216
> 01  01  19991649380 0
> 01  01  199921321100252132
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>


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

What is the problem you are trying to solve?

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


Re: [R] function on factors - how best to proceed

2007-09-19 Thread Gustaf Rydevik
On 9/19/07, Karin Lagesen <[EMAIL PROTECTED]> wrote:
>
> Sorry about this one being long, and I apologise beforehand if there
> is something obvious here that I have missed. I am new to creating my
> own functions in R, and I am uncertain of how they work.
>
> I have a data set that I have read into a data frame:
>
> > gctable[1:5,]
>  refseq geometry X60_origin X60_terminus  length  kingdom
> 1 NC_009484  cir179   773000 3389227 Bacteria
> 2 NC_009484  cir179   773000 3389227 Bacteria
> 3 NC_009484  cir179   773000 3389227 Bacteria
> 4 NC_009484  cir179   773000 3389227 Bacteria
> 5 NC_009484  cir179   773000 3389227 Bacteria
>   grp feature gene begin dir gc_content replicor LEADLAG
> 1 Alphaproteobacteria CDS  CDS   261   +   0.654244RIGHTLEAD
> 2 Alphaproteobacteria CDS  CDS  1737   -   0.651408RIGHT LAG
> 3 Alphaproteobacteria CDS  CDS  2902   +   0.607843RIGHTLEAD
> 4 Alphaproteobacteria CDS  CDS  3693   +   0.617647RIGHTLEAD
> 5 Alphaproteobacteria CDS  CDS  4227   +   0.699208RIGHTLEAD
> >
>
> Most of these columns are factors.
>
> Now, I have a function that I would like to employ on this data
> frame. Right now I cannot get it to work, and that seems to be due to
> the columns in the data frame being factors. I tested it with a data
> frame created from vectors, and it worked fine.
>
> The function:
>
> percentdistance <- function(origin, terminus, length, begin, replicor){
> print(c(origin, terminus, length, begin, repl))
> d = 0
> if (terminus>origin) {
>   if(replicor=="LEFT") {
> d = -((origin-begin)%%length)
>   }
> else {
> d = (begin-origin)
>   }
> }
> else {
>   if (replicor=="LEFT") {
> d=(origin-begin)
>   }
>   else{
> d = -((begin-origin)%%length)
>   }
> }
> d/length*2
> }
>
> The error I get:
> > percentdistance(gctable$X60_origin, gctable$X60_terminus, gctable$length, 
> > gctable$begin, gctable$replicor)
> [1]  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  
> 87
>[19]  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  
> 87
>[37]  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  
> 87
>[55]  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  
> 87
>[73]  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  
> 87
>[91]  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  
> 87
>   [109]  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  
> 87
>   [127]  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  
> 87
> .[99919]   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2  
>  2   2
> [99937]   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   
> 2
> [99955]   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   
> 2
> [99973]   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   
> 2
> [1]   2   2   2   2   2   2   2   2   2
>  [ reached getOption("max.print") -- omitted 8526091 entries ]]
> Error in if (terminus > origin) { : missing value where TRUE/FALSE needed
> In addition: Warning messages:
> 1: > not meaningful for factors in: Ops.factor(terminus, origin)
> 2: the condition has length > 1 and only the first element will be used in: 
> if (terminus > origin) {
> >
>
> This worked nice when the input were columns from a data frame created
> from vectors.
>
> I have also tried the different apply-functions, although I am
> uncertain of which one would be appropriate here.
>
>
...
>
> Karin
> --
> Karin Lagesen, PhD student
> [EMAIL PROTECTED]
> http://folk.uio.no/karinlag


Hej Karin!

A couple of things:
First, the first warning message tells you that:
1: > not meaningful for factors in: Ops.factor(terminus, origin).

Thus, terminus and origin are factor variables, which cannot be
ordered. You have to convert
them to numerical variables (See the faq for HowTo)

The second warning message tells you that:
 2: the condition has length > 1 and only the first element will be
used in: if (terminus > origin)

You are comparing two vectors,  which generate a vector of TRUE/FALSE values.
The "if" statement need a single TRUE/FALSE value.
Either use a for loop:
for (i in 1:nrow(terminus)) {if terminus[i]> origin[i]...}
or a nested ifelse statement (which is recommendable on such a big data set).


best,

Gustaf


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


Re: [R] how to find "p" in binomial(n,p)

2007-09-19 Thread Rolf Turner

On 20/09/2007, at 11:04 AM, Mike Meredith wrote:

>
> I think the function you need is 'help.search'; try:
>
> help.search("binomial")
>
> and look for something obvious in the 'stats' package. A good deal  
> quicker
> and easier than posting to an internet forum!
>

I don't think so.  I couldn't find anything useful under help.search 
("binomial"), and
I'm fairly comfortable with R.

It seems to me that what is required here is to roll your own.

I defined a function foo():

foo <- function(p,n,k,alpha){pbinom(k,n,p)-alpha}

Then I used uniroot to solve foo(p,n,k,alpha) = 0.

E.g.

xxx <- uniroot(foo,c(0,1),n=20,k=15,alpha=0.05)

Then xxx$root is 0.895913.

Check this out graphically:

p <- seq(0,1,length=301)
y <- foo(p,20,15,0.05)
plot(p,y,type="l")
abline(h=0)
abline(v=xxx$root)

It looks good.

cheers,

Rolf Turner
> Cheers, Mike.
>
>
> cathelf wrote:
>>
>> Dear all,
>>
>> I am trying a find the value "p" in binomial.
>>
>> X ~ Bin(n,p)
>>
>> I want to find the value "p", so that Pr(X <= k) <= alpha
>>
>> Here, n, k and alpha are known. n, k are integers. alpha is  
>> between (0,1).
>>
>> Thanks a lot!
>>
>> Catherine
>>


##
Attention:\ This e-mail message is privileged and confidenti...{{dropped}}

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

2007-09-19 Thread Alexander.Herr
Thanks Patric,

mosaic{vdc} takes gpar parameters. So cex.axis does not work for 

mosaic(Titanic, pop=FALSE,
labeling_args=list(rot_labels=c(bottom=90,top=90),cex.axis=0.5)) 
or
mosaic(Titanic, pop=FALSE,
labeling_args=list(rot_labels=c(bottom=90,top=90)),cex.axis=0.5)

However,
mosaic(Titanic, pop=FALSE,
labeling_args=list(rot_labels=c(bottom=90,top=90),gp_labels=(gpar(fontsi
ze=5

works for all labels.

Is there a way to adjust only one set of axis labels?

Thanx and cheers
Herry

-Original Message-
From: Patrick Connolly [mailto:[EMAIL PROTECTED] 
Sent: Thursday, September 20, 2007 7:15 AM
To: Herr, Alexander Herr - Herry (CSE, Townsville);
[EMAIL PROTECTED]
Subject: RE: [R] fontsize in mosaic plot lables

> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of 
> [EMAIL PROTECTED]
> Sent: Wednesday, 19 September 2007 2:04 p.m.
> To: [EMAIL PROTECTED]
> Subject: [R] fontsize in mosaic plot lables
> 
> Hi List,
> 
> I am trying unsucessfully to modify the fontsize of lables in mosaic:
> 
> 
> require(vcd)
> mosaic(Titanic, pop=FALSE,
> labeling_args=list(rot_labels=c(bottom=90,top=90),
>   set_varnames = c(Sex = "Gender"),
>   gp_text=gpar(fontsize=20))) #can't get it to resize text
> 
> tab <- ifelse(Titanic < 6, NA, Titanic) # it works for labeling_cells 
> labeling_cells(text = tab, margin =
> 0,gp_text=gpar(fontsize=20))(Titanic)
> 
> What am I doing wrong?

The mosaic function isn't part of lattice.  Try cex.axis in a more or
less normal way instead of gpar settings.  

HTH

___
The contents of this e-mail are privileged and/or confidenti...{{dropped}}

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


Re: [R] how to find "p" in binomial(n,p)

2007-09-19 Thread Ted Harding
On 19-Sep-07 23:04:57, Mike Meredith wrote:
> 
> 
> I think the function you need is 'help.search'; try:
> 
> help.search("binomial")
> 
> and look for something obvious in the 'stats' package.
> A good deal quicker and easier than posting to an internet forum!
> 
> Cheers, Mike.

Well ...

  help.search("root")
  ?uniroot
  ?pbinom

n<-10; k<-4; alpha<-0.95;
f<-function(p){ pbinom(k,n,p)-alpha }
uniroot(f,c(0,1))

## $root
## [1] 0.2224413
## $f.root
## [1] -1.588189e-07
## $iter
## [1] 10
## $estim.prec
## [1] 6.103516e-05

#Check:
pbinom(k,n, 0.2224413)
## [1] 0.948


> 
> 
> cathelf wrote:
>> 
>> Dear all,
>> 
>> I am trying a find the value "p" in binomial.
>> 
>> X ~ Bin(n,p)
>> 
>> I want to find the value "p", so that Pr(X <= k) <= alpha 
>> 
>> Here, n, k and alpha are known. n, k are integers. alpha is between
>> (0,1).
>> 
>> Thanks a lot!
>> 
>> Catherine
>> 
> 
> -- 
> View this message in context:
> http://www.nabble.com/how-to-find-%22p%22-in-binomial%28n%2Cp%29-tf44842
> 27.html#a12787900
> 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.


E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
Fax-to-email: +44 (0)870 094 0861
Date: 20-Sep-07   Time: 00:34:22
-- 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] how to find "p" in binomial(n,p)

2007-09-19 Thread Mike Meredith


I think the function you need is 'help.search'; try:

help.search("binomial")

and look for something obvious in the 'stats' package. A good deal quicker
and easier than posting to an internet forum!

Cheers, Mike.


cathelf wrote:
> 
> Dear all,
> 
> I am trying a find the value "p" in binomial.
> 
> X ~ Bin(n,p)
> 
> I want to find the value "p", so that Pr(X <= k) <= alpha 
> 
> Here, n, k and alpha are known. n, k are integers. alpha is between (0,1).
> 
> Thanks a lot!
> 
> Catherine
> 

-- 
View this message in context: 
http://www.nabble.com/how-to-find-%22p%22-in-binomial%28n%2Cp%29-tf4484227.html#a12787900
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] Subset any value and blanks

2007-09-19 Thread Spilak,Jacqueline [Edm]
Hi everyone
I need help with subseting a data set.  In my dataset there is a
specific row that will either have a value or be blank.  I would like to
subset (or split) the dataset into one dataset with the row that has the
value and another dataset that has just the blanks.  Now the thing is
that the row that has the value in it, the value is not always the same,
it is a time stamp of when something happens.
Example of Dataset
Day Month   YearTimeHitsMissesF-type
01  01  19990600120 800600  
01  01  19991015300 10
01  01  19991216250 501216  
01  01  19991649380 0   
01  01  199921321100252132

[[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] Creating Hmisc labels inside a function

2007-09-19 Thread Frank E Harrell Jr
Steve Powell wrote:
> Thanks again Frank for quick reply.
> True, 
> 
> someobject=2
> Test=function(obj,labe)
>{
>label(obj)=labe
>#at this point add the line:
>obj
>}
>  Test(someobject,"somelabel") 
> #returns a label. But if you retype 
> someobject
> #the label has gone. That is what I meant by the label not being permanently
> changed.

Why would that work?  someobject was never changed in any way.  Use 
someobject <- Test(someobject, 'new label') or if that's all you want, 
just label(someobject) <- 'new label'

Frank

> Steve 
>  
> proMENTE social research 
> research | evaluation | training & consulting 
> Kranjčevićeva 35, 71000 Sarajevo 
> mobile: +387 61 215 997 | office: +387 33 556 865 | fax: +387 33 556 866
> skype: stevepowell99 
> www.promente.org  |  www.mojakarijera.com  |  www.psih.org  
> 
> -Original Message-
> From: Frank E Harrell Jr [mailto:[EMAIL PROTECTED] 
> Sent: 17 September 2007 17:18
> To: Steve Powell
> Cc: [EMAIL PROTECTED]
> Subject: Re: [R] Creating Hmisc labels inside a function
> 
> Steve Powell wrote:
>>  
>> Thanks, Frank - it doesn't work though. 
>> Your suggestion was:
>>
> Test=function(obj,labe)
>   {
>   label(obj)=labe
>   #at this point add the line:
>   obj
>   }
>> #...but just returning the object does not permanently change the label:
>> obj
> 
> It does for me.  Please re-run.  -Frank
> 
>  > attributes(Test(1:3, 'some label'))
> $label
> [1] "some label"
> 
> $class
> [1] "labelled"
> 
> You don't need assign.
> Frank
> 
> 
>> That is why I wanted to use assign. But "assign" will not work with 
>> attributes, labels etc. So
>>
>> assign(label(obj),"some label") #doesn't even work outside a function, 
>> at the command prompt.
>>
>> Any more ideas anyone?
>> Best wishes
>> Steve Powell
>>
>>  
>> proMENTE social research
>> research | evaluation | training & consulting Kranjčevićeva 35, 71000 
>> Sarajevo
>> mobile: +387 61 215 997 | office: +387 33 556 865 | fax: +387 33 556 
>> 866
>> skype: stevepowell99
>> www.promente.org  |  www.mojakarijera.com  |  www.psih.org
>>
>> -Original Message-
>> From: Frank E Harrell Jr [mailto:[EMAIL PROTECTED]
>> Sent: 12 September 2007 14:38
>> To: Steve Powell
>> Cc: [EMAIL PROTECTED]
>> Subject: Re: [R] Creating Hmisc labels inside a function
>>
>> Steve Powell wrote:
>>> hello list members,
>>> I am wanting to write a label using the Hmisc package, but inside a 
>>> function. Normally I can do:
>>>
>>> library(Hmisc)
>>> M=2
>>> label(M)="lab"
>>>
>>> #But inside a function the "=" does not work:
>>> Test=function(obj,labe)
>>> {
>>> label(obj)=labe
>> at this point add the line:
>>
>> obj
>>
>>> }
>> The returned object will have what you need.  -Frank
>>
>>> Test(M,"new label")
>>>
>>> I usually use the "assign" function to make assignments inside 
>>> functions, but assign will not work with attributes, labels etc.
>>> Any ideas?
>>> Thanks in advance
>>>
>>> Steve Powell
>>>
>>>  
>>> proMENTE social research
>>> research | evaluation | training & consulting Kranjčevićeva 35, 71000 
>>> Sarajevo
>>> mobile: +387 61 215 997 | office: +387 33 556 865 | fax: +387 33 556
>>> 866
>>> skype: stevepowell99
>>> www.promente.org  |  www.mojakarijera.com  |  www.psih.org
>>>
>>>
>>> Checked by AVG Free Edition. 
>>>
>>> 17:43
>>>
>>> __
>>> R-help@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-help
>>> PLEASE do read the posting guide
>>> http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
>>>
>>
> 
> 


-- 
Frank E Harrell Jr   Professor and Chair   School 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] Identify and plotting symbols.

2007-09-19 Thread Rolf Turner

I have been trying, unsuccessfully, to use identify() to (simply)  
return a list of
the indices of points clicked on and overplot (with say a solid dot)  
each clicked-on
point so that I can see where I've been.  I.e. I don't want to see  
the indices printed
on the screen; I just want the points I've already selected to be  
highlighted.

I tried

ind <- identify(x,y,labels=rep("\021",length(x)),offset=0)

Two problems:

(1) Instead of getting a solid dot --- which I thought I should get  
from "\021", I got a
small rectangle outlined in dotted lines.   (Which I would've  
thought I'd get from
"\177".)

I seem to get the dotted rectangle no matter what 3 digit string I  
use in "\xxx".

(2) Despite setting offset=0 the superimposed symbol is not actually  
superimposed,
but is jittered off the location of the existing point by a small  
amount.

Another minor annoyance is having to use rep("\021",length(x)) rather  
than simply
"\021".  I.e. the vector supplied for labels does not get  
``recycled'' the way col and
pch etc. are recycled.

Is there any way of resolving these difficulties?

cheers,

Rolf Turner

##
Attention:\ This e-mail message is privileged and confidenti...{{dropped}}

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

2007-09-19 Thread stephen bond
is there a straigthforward way to get the holidays for Toronto ? 
like the function for NYSE e.g.

the timeDate class says that setting a finCenter will give the right 
holidays, but how?

thank you very much.
stephen

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

2007-09-19 Thread Patrick Connolly
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of 
> [EMAIL PROTECTED]
> Sent: Wednesday, 19 September 2007 2:04 p.m.
> To: [EMAIL PROTECTED]
> Subject: [R] fontsize in mosaic plot lables
> 
> Hi List,
> 
> I am trying unsucessfully to modify the fontsize of lables in mosaic:
> 
> 
> require(vcd)
> mosaic(Titanic, pop=FALSE,
> labeling_args=list(rot_labels=c(bottom=90,top=90),
>   set_varnames = c(Sex = "Gender"),
>   gp_text=gpar(fontsize=20))) #can't get it to resize text
> 
> tab <- ifelse(Titanic < 6, NA, Titanic)
> # it works for labeling_cells
> labeling_cells(text = tab, margin =
> 0,gp_text=gpar(fontsize=20))(Titanic)
> 
> What am I doing wrong?

The mosaic function isn't part of lattice.  Try cex.axis in a more or
less normal way instead of gpar settings.  

HTH

___
The contents of this e-mail are privileged and/or confidential to the
named recipient and are not to be used by any other person and/or
organisation. If you have received this e-mail in error, please notify
the sender and delete all material pertaining to this e-mail.

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

2007-09-19 Thread Greg Snow
Try:

> lines(spline(x,y, method='n', n=250))

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Nestor Fernandez
> Sent: Wednesday, September 19, 2007 2:09 PM
> To: [EMAIL PROTECTED]
> Subject: [R] Smooth line in graph
> 
> Hi,
> 
> I'm trying to get smooth curves connecting points in a plot 
> using "spline" but I don't get what I whant.
> 
> Eg.:
> x<-1:5
> y <- c(0.31, 0.45, 0.84, 0.43, 0.25)
> plot(x,y)
> lines(spline(x,y))
> 
> Creates a valley between the first and second points, then 
> peaks at 3rd, and another valley between 4th and 5th. I'm 
> trying to get a consistently growing curve up to the 3rth 
> point and then a decrease like with SigmaPlot spline curves 
> or with Excel.
> 
> I tried with different spline arguments and also lowess and 
> loess, with no success. Any ideas?
> 
> Thanks.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Sweave: tables vs matrices

2007-09-19 Thread Markus Jäntti
Gavin Simpson wrote:
> On Fri, 2007-09-14 at 11:24 +0100, Robin Hankin wrote:
>> Hi Gavin
>>
>> thanks for that. . . it does 99% of what I wanted.
>> I'd forgotten about the na.print argument.
>>
>> It's considerably nicer than my other solution
>> which converted to character, then jj[is.na(jj)] <- "-"
>> then noquote(jj).
>>
>> But  sometimes I just need nice LaTeX tables
>> and I can't think of a way to arrange things
>> so that: (i) I have only one set of numbers to maintain,
>> and (ii) an NA appears as a "-" in the LaTeX table.
> 
> Ok, then the xtable package and function is your answer. You can use
> this within Sweave but I think you need to set the output to latex in
> the Sweave chunk?
> 
> Is this closer to what you want?
> 
>> print.xtable(xtable(jj), NA.string = "-")
> % latex table generated in R 2.5.1 by xtable 1.4-6 package
> % Fri Sep 14 11:43:34 2007
> \begin{table}[ht]
> \begin{center}
> \begin{tabular}{rr}
>   \hline
>  & 1 & 2 & 3 & 4 & 5 \\
>   \hline
> 1 & 2.00 & 3.00 & 4.00 & 1.00 & 10.00 \\
>   2 & 0.00 & 5.00 & 7.00 & $-$ & 12.00 \\
>   3 & 3.00 & 7.00 & $-$ & 4.00 & 14.00 \\
>   4 & 2.00 & $-$ & $-$ & 2.00 & 4.00 \\
>   5 & 7.00 & 15.00 & 11.00 & 7.00 & 40.00 \\
>\hline
> \end{tabular}
> \end{center}
> \end{table}
> 

Another approach that I use a lot is to use the latex facilities in Hmisc by 
Frank Harrell.

For example,

\documentclass{article}

\begin{document}
\SweaveOpts{fig=FALSE, results=hide, echo=FALSE}

<<>>=

library(Hmisc)
Z <- matrix(rnorm(20), ncol=4)
rownames(Z) <- letters[1:nrow(Z)]
colnames(Z) <- LETTERS[1:ncol(Z)]

@

<>=
latex(A, dec=3, center='none', table.env=FALSE, file="")

@

<>=

latex(A, dec=1, cgroup=c("Column labels"), n.cgroup=c(ncol(Z)),
   caption="A title", center='centering', file="")


@
\end{document}

Markus

> HTH
> 
> G
> 
>> best wishes
>>
>> rksh
>>
>> On 14 Sep 2007, at 09:52, Gavin Simpson wrote:
>>
>>> On Fri, 2007-09-14 at 09:34 +0100, Robin Hankin wrote:
 Hello everyone


 I am preparing a document using Sweave in which I want my matrices
 to appear as tables.  I am running into problems because as my
 Rnw files stand, I have to  change table entries twice, once for
 the matrix and once for the typeset table.

 I have lots of material like the following.  How can I arrange
 my Rnw file so that  I only have to change one set of figures
 when my numbers change?

 One reason I prefer tables here is that the NA entries
 appear as "-" in the table, but as "NA" in the Schunk.
 Is there a way to make the Schunk  typeset NAs
 as minuses?
>>> See ?print.default and its argument na.print:
>>>
 print.default(jj, na.print = "-")
>>>  [,1] [,2] [,3] [,4] [,5]
>>> [1,]2341   10
>>> [2,]057-   12
>>> [3,]37-4   14
>>> [4,]2--24
>>> [5,]7   15   117   40
>>>
>>> Is that what you meant? It still prints the [1,] bits...
>>>
>>> HTH
>>>
>>> G
>>>


 \begin{table}
 \centering
 \begin{tabular}{||c|}\hline
 \multicolumn{4}{|c|}{brand}&\\ \hline
 A&B&C&D&total\\ \hline
 2   & 3  &  4   & 1& 10   \\
 0   & 5   & 7   & -& 12   \\
 3   & 7   & -   & 4& 14   \\
 2   & -   & -   & 2&  4\\ \hline
 7&15&11&7&40\\ \hline
 \end{tabular}
 \caption{snipped caption}
 \end{table}


 <<>>=
 jj <- matrix(c(2,  3,  4, 1,
 0,  5,  7, NA,
 3,  7, NA, 4,
 2, NA, NA, 2
 ),byrow=TRUE,nrow=4)
 jj <- rbind(jj,apply(jj,2,sum,na.rm=TRUE))
 jj <- cbind(jj,apply(jj,1,sum,na.rm=TRUE))
 jj
 @



>> --
>> Robin Hankin
>> Uncertainty Analyst
>> National Oceanography Centre, Southampton
>> European Way, Southampton SO14 3ZH, UK
>>   tel  023-8059-7743
>>


-- 
Markus Jantti
Abo Akademi University
[EMAIL PROTECTED]
http://www.iki.fi/~mjantti

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

2007-09-19 Thread Katharine Mullen
how about:

require(splines)
x<-1:5
y <- c(0.31, 0.45, 0.84, 0.43, 0.25)
yy <-predict(interpSpline(x, y))
plot(x, y)
lines(yy)



Katharine Mullen
mail: Department of Physics and Astronomy, Faculty of Sciences
Vrije Universiteit Amsterdam, de Boelelaan 1081
1081 HV Amsterdam, The Netherlands
room: T.1.06
tel: +31 205987870
fax: +31 205987992
e-mail: [EMAIL PROTECTED]
homepage: http://www.nat.vu.nl/~kate/


On Wed, 19 Sep 2007, Nestor Fernandez wrote:

> Hi,
>
> I’m trying to get smooth curves connecting points in a plot using
> "spline" but I don’t get what I whant.
>
> Eg.:
> x<-1:5
> y <- c(0.31, 0.45, 0.84, 0.43, 0.25)
> plot(x,y)
> lines(spline(x,y))
>
> Creates a valley between the first and second points, then peaks at 3rd,
> and another valley between 4th and 5th. I’m trying to get a consistently
> growing curve up to the 3rth point and then a decrease like with
> SigmaPlot spline curves or with Excel.
>
> I tried with different spline arguments and also lowess and loess, with
> no success. Any ideas?
>
> Thanks.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] layout function for several plots

2007-09-19 Thread Prof Brian Ripley
On Wed, 19 Sep 2007, Greg Snow wrote:

> Using ann=F just tells R not to put anything in the margins, it does not 
> reduce the size of the margins.  You need to reduce the margin size 
> using par(mar= ...) with appropriate values.  You can then shrink what 
> goes in the margins rather than not plotting it at all (though that is a 
> good first step to make sure everything else works).

However, if you try to plot 9 plots on one device surface, you almost 
certainly need to reduce the pointsize.  par(mfrow=) does that 
automatically, but layout() does not.  If the device you are using does 
not support pointsize, try a global setting of cex.  You could also 
increase the device dimensions, but other settings (e.g. the default line 
width) will not be appropriate unless the intention is to zoom in on 
individual plots.
a

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

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


[R] Smooth line in graph

2007-09-19 Thread Nestor Fernandez
Hi,

I’m trying to get smooth curves connecting points in a plot using 
"spline" but I don’t get what I whant.

Eg.:
x<-1:5
y <- c(0.31, 0.45, 0.84, 0.43, 0.25)
plot(x,y)
lines(spline(x,y))

Creates a valley between the first and second points, then peaks at 3rd, 
and another valley between 4th and 5th. I’m trying to get a consistently 
growing curve up to the 3rth point and then a decrease like with 
SigmaPlot spline curves or with Excel.

I tried with different spline arguments and also lowess and loess, with 
no success. Any ideas?

Thanks.

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


Re: [R] function on factors - how best to proceed

2007-09-19 Thread Gustaf Rydevik
On 9/19/07, Gustaf Rydevik <[EMAIL PROTECTED]> wrote:
> On 9/19/07, Karin Lagesen <[EMAIL PROTECTED]> wrote:
> > "Gustaf Rydevik" <[EMAIL PROTECTED]> writes:
> >
> >
> > > The second warning message tells you that:
> > >  2: the condition has length > 1 and only the first element will be
> > > used in: if (terminus > origin)
> > >
> > > You are comparing two vectors,  which generate a vector of TRUE/FALSE 
> > > values.
> > > The "if" statement need a single TRUE/FALSE value.
> > > Either use a for loop:
> > > for (i in 1:nrow(terminus)) {if terminus[i]> origin[i]...}
> > > or a nested ifelse statement (which is recommendable on such a big data 
> > > set).
> >
> > Thankyou for your reply! I will certainly try the numeric thing.
> >
> > Now, for the vector comparison. I can easily see how you would do a
> > for loop here, but I am unable to see how a nested ifelse statement
> > would work. Could you possibly give me an example?
> >
> > Thankyou again for your help!
> >
> > Karin
> > --
> > Karin Lagesen, PhD student
> > [EMAIL PROTECTED]
> > http://folk.uio.no/karinlag
> >
>
> You replace each instance of "if" with ifelse, inserting a comma after
> the logical test, and instead of the else statement.  The end result
> would become (if I've not made a mistake):
>
> _
> replicator<-rep(c("LEFT","RIGHT"),50)
> terminus<-rnorm(100)
> origin<-rnorm(100)
> begin<-rnorm(100)
> length<-sample(1:100,100,replace=T)
>
> d<-ifelse(terminus>origin,
> +ifelse(replicator=="LEFT",-((origin-begin))%%length),(begin-origin)),
> +ifelse(replicator=="LEFT",(origin-begin),-((begin-origin)%%length))
> +)
>
> /Gustaf
>
>
> --
> Gustaf Rydevik, M.Sci.
> tel: +46(0)703 051 451
> address:Essingetorget 40,112 66 Stockholm, SE
> skype:gustaf_rydevik
>

Sorry, forgot to remove the plusses, and had a parenthesis wrong...

__
replicator<-rep(c("LEFT","RIGHT"),50)
terminus<-rnorm(100)
origin<-rnorm(100)
begin<-rnorm(100)
length<-sample(1:100,100,replace=T)

d<-ifelse(terminus>origin,
  ifelse(replicator=="LEFT",-((origin-begin)%%length),(begin-origin)),
  ifelse(replicator=="LEFT",(origin-begin),-((begin-origin)%%length))
  )
___


best,

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


Re: [R] layout function for several plots

2007-09-19 Thread Greg Snow
Using ann=F just tells R not to put anything in the margins, it does not reduce 
the size of the margins.  You need to reduce the margin size using par(mar= 
...) with appropriate values.  You can then shrink what goes in the margins 
rather than not plotting it at all (though that is a good first step to make 
sure everything else works).

For adding the cross, look at the cnvrt.coords function in the TeachingDemos 
package, will that do what you want? (look at the examples)

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
 
 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of marcg
> Sent: Wednesday, September 19, 2007 5:26 AM
> To: [EMAIL PROTECTED]
> Subject: [R] layout function for several plots
> 
> Dear all
> 
> I try to print 9 plots on a page, arranged as the code shows below.
> 
> nf <- layout(matrix(c(1,0,2,0,0,3,0,4,0,5,0,6,0,0,0,0,7,0,8,9), 10,2))
> layout.show(nf)
> 
> but when I try to plot, an error message Fehler in plot.new() 
> : Grafikränder zu groß appears
> 
> to verify p.e. with 
> 
> plot(runif(10:1)) 
> 
> i tried with plot(runif(10:1), ann=F) to produce more space, 
> but neither.
> 
> The second question: how to place a cross in the middle of 
> the plot to delineate in 4 big fields (containing each 5 plots)
> 
> Thanks a lot
> 
> 
> --
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> --
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

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


Re: [R] How to pass a string as an argument to a function?

2007-09-19 Thread Gang Chen
Yes, as.formula is the magic tool! Thanks a lot...

Gang

On Sep 19, 2007, at 2:00 PM, Vladimir Eremeev wrote:

>
> lme(as.formula(paste("y~",ww)),random=~1|subj,model)
>
>
> Gang Chen-3 wrote:
>>
>> I want to pass a predefined string ww ("fa*fb+fc") to function lme so
>> that I can run
>>
>>> lme(y ~  fa*fb+fc, random = ~1|subj, model)
>>
>> There must be a simple way to do this. Any help?
>>
>> Thanks,
>> Gang

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


Re: [R] How to pass a string as an argument to a function?

2007-09-19 Thread Vladimir Eremeev

lme(as.formula(paste("y~",ww)),random=~1|subj,model)


Gang Chen-3 wrote:
> 
> I want to pass a predefined string ww ("fa*fb+fc") to function lme so  
> that I can run
> 
>  > lme(y ~  fa*fb+fc, random = ~1|subj, model)
> 
> There must be a simple way to do this. Any help?
> 
> Thanks,
> Gang
> 

-- 
View this message in context: 
http://www.nabble.com/How-to-pass-a-string-as-an-argument-to-a-function--tf4482519.html#a12782865
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] Robust or Sandwich estimates in lmer2

2007-09-19 Thread Abdus Sattar
Hi Doran, 

My interests to estimate fixed effects parameters in a mixed model (not the 
random effects parameters) and, in addition, in the model there are some 
nuisace parameters. For this estimation I am using pseudo-maximum likelihood 
methods. First I am estimating nuisance parameters then using these estimates 
in my likelihood function to get the estimates of fixed effects parameters 
using lmer2. Therefore, to get the correct estimates of the standard errors, I 
need robust (or sandwich) estiamtes of the SE. Thank you and thanks to Thomas 
his remarks, 

Sattar


- Original Message 
From: Thomas Lumley <[EMAIL PROTECTED]>
To: "Doran, Harold" <[EMAIL PROTECTED]>
Cc: Sundar Dorai-Raj <[EMAIL PROTECTED]>; Abdus Sattar <[EMAIL PROTECTED]>; 
[EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Wednesday, September 19, 2007 1:13:20 PM
Subject: Re: [R] Robust or Sandwich estimates in lmer2


On Wed, 19 Sep 2007, Doran, Harold wrote:

> This has come up before and I'll again ask the question "why would you
> want robust standard errors in lmer"?

And I'll again answer: using lmer() does not automatically guarantee correct 
model specification, either for the correlation structure or for the marginal 
variance.

  -thomas


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


  


ttp://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7 


[[alternative HTML version deleted]]

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


[R] How to pass a string as an argument to a function?

2007-09-19 Thread Gang Chen
I want to pass a predefined string ww ("fa*fb+fc") to function lme so  
that I can run

 > lme(y ~  fa*fb+fc, random = ~1|subj, model)

I've tried something like

 > lme(y ~  paste(ww), random = ~1|subj, model)

and

 > lme(y ~  sprintf(ww), random = ~1|subj, model)

but both give me the following error:

Error in model.frame(formula, rownames, variables, varnames, extras,  
extranames,  :
 variable lengths differ (found for 'ww')

There must be a simple way to do this. Any help?

Thanks,
Gang

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Row-by-row regression on matrix

2007-09-19 Thread Charles C. Berry


> system.time( lm( t(y) ~ x ) )
user  system elapsed
   0.008   0.000   0.010



On Wed, 19 Sep 2007, 
[EMAIL PROTECTED] wrote:

> Folks,
>
> I have a 3000 x 4 matrix (y), which I need to regress row-by-row against a
> 4-vector (x) to create a
> matrix lm.y of intercepts and slopes. To illustrate:
>
> y <- matrix(rnorm(12000), ncol = 4)
> x <- c(1/12, 3/12, 6/12, 1)
>
> system.time(lm.y <- t(apply(y, 1, function(z) lm(z ~ x)$coefficient)))
> [1] 44.72 18.00 69.52NANA
>
> Takes more than a minute to do (and I need to do many similar regressions
> a day).
>
> Is there a more efficient way of handling this?
>
> I'm running R 2.4.1 on Windows XP Service Pack 2 on a Intel Xeon dual-core
> 2.66GHz with 3GB RAM.
>
> Thanks very much,
>
> Murali
>
>
> ---
> This message (including any attachments) is confidential and...{{dropped}}
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

Charles C. Berry(858) 534-2098
 Dept of Family/Preventive Medicine
E mailto:[EMAIL PROTECTED]  UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

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

2007-09-19 Thread Thomas Lumley
On Wed, 19 Sep 2007, Doran, Harold wrote:

> This has come up before and I'll again ask the question "why would you
> want robust standard errors in lmer"?

And I'll again answer: using lmer() does not automatically guarantee correct 
model specification, either for the correlation structure or for the marginal 
variance.

  -thomas


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

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Row-by-row regression on matrix

2007-09-19 Thread Chuck Cleland
[EMAIL PROTECTED] wrote:
> Folks,
> 
> I have a 3000 x 4 matrix (y), which I need to regress row-by-row against a 
> 4-vector (x) to create a
> matrix lm.y of intercepts and slopes. To illustrate:
> 
> y <- matrix(rnorm(12000), ncol = 4)
> x <- c(1/12, 3/12, 6/12, 1)
> 
> system.time(lm.y <- t(apply(y, 1, function(z) lm(z ~ x)$coefficient)))
> [1] 44.72 18.00 69.52NANA
> 
> Takes more than a minute to do (and I need to do many similar regressions 
> a day). 
> 
> Is there a more efficient way of handling this?
> 
> I'm running R 2.4.1 on Windows XP Service Pack 2 on a Intel Xeon dual-core 
> 2.66GHz with 3GB RAM.
> 
> Thanks very much,
> 
> Murali

 y <- matrix(rnorm(12000), ncol = 4)
 x <- c(1/12, 3/12, 6/12, 1)

 system.time(lm.y1 <- t(coef(lm(t(y) ~ x
   user  system elapsed
   0.030.000.04

 system.time(lm.y2 <- t(apply(y, 1, function(z) lm(z ~ x)$coefficient)))
   user  system elapsed
  19.700.05   20.45

 all.equal(lm.y1, lm.y2)
[1] TRUE

> 
> ---
> This message (including any attachments) is confidential and...{{dropped}}
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code. 

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

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


Re: [R] Row-by-row regression on matrix

2007-09-19 Thread Sundar Dorai-Raj

[EMAIL PROTECTED] said the following on 9/19/2007 9:50 AM:
> Folks,
> 
> I have a 3000 x 4 matrix (y), which I need to regress row-by-row against a 
> 4-vector (x) to create a
> matrix lm.y of intercepts and slopes. To illustrate:
> 
> y <- matrix(rnorm(12000), ncol = 4)
> x <- c(1/12, 3/12, 6/12, 1)
> 
> system.time(lm.y <- t(apply(y, 1, function(z) lm(z ~ x)$coefficient)))
> [1] 44.72 18.00 69.52NANA
> 
> Takes more than a minute to do (and I need to do many similar regressions 
> a day). 
> 
> Is there a more efficient way of handling this?
> 
> I'm running R 2.4.1 on Windows XP Service Pack 2 on a Intel Xeon dual-core 
> 2.66GHz with 3GB RAM.
> 
> Thanks very much,
> 
> Murali
> 

Yes. Try,

set.seed(1)
y <- matrix(rnorm(12000), ncol = 4)
x <- c(1/12, 3/12, 6/12, 1)
system.time(lm.y <- t(apply(y, 1, function(z) lm(z ~ x)$coefficient)))

##   user  system elapsed
##   1.100.00   38.69

system.time(lm.y2 <- t(coef(lm(t(y) ~ x

##   user  system elapsed
##   0.020.000.04

all.equal(lm.y, lm.y2)
## [1] TRUE

HTH,

--sundar

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] micEcon: selection(,method="ml") . Predict method?

2007-09-19 Thread Werner Wernersen
Hi,

as I read, maximum likelihood is the better method for
estimating selection-biased models. But I also want to
predict from that model. Is there any predict method
for the selection function when using maximum
likelihood estimation in micEcon? I couldn't find any.

Many thanks,
  Werner

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] By() with method = spearman

2007-09-19 Thread Sundar Dorai-Raj
Hi, Harold,

In cases like this I usually add some print info to the function. E.g.

tmp$Grade <- factor(tmp$Grade)
lapply(split(tmp, f = tmp$Grade),
function(x) {
  z <- x[,c("mtsc07","DCBASmathscoreSPRING")]
  print(levels(factor(z$Grade)))
  print(summary(z))
  print(mean(is.na(rowSums(z
  cor(z, use='complete', method='spearman')
})

My guess is that one level produces no data when using "complete". I can 
reproduce the error with:

na <- rep(NA, 10)
z <- matrix(c(1:10, na, na, 1:10), 20, 2)
cor(z, use = "complete", method = "spearman")

HTH,

--sundar

Doran, Harold said the following on 9/19/2007 9:30 AM:
> I still get an error
> 
>> tmp$Grade <- factor(tmp$Grade)
>> lapply(split(tmp, f = tmp$Grade),
> function(x){cor(x[,c("mtsc07","DCBASmathscoreSPRING")], use='complete',
> + method='spearman')})
> 
> Error in cor(x[, c("mtsc07", "DCBASmathscoreSPRING")], use = "complete",
> : 
> 'x' is empty 
> 
> I noticed tmp$Grade (my index variable) was numeric. So, I coerced it
> into a factor. I get the same error message, however.
> 
> Notice, however, that this code works correctly
> 
> lapply(split(tmp, f = tmp$Grade),
> function(x){cor(x[,c("mtsc07","DCBASmathscoreSPRING")], use='complete',
> method='pearson')})
> 
> The only differece is that method is changed to pearson.
> 
>> -Original Message-
>> From: Chuck Cleland [mailto:[EMAIL PROTECTED] 
>> Sent: Wednesday, September 19, 2007 12:22 PM
>> To: Doran, Harold
>> Subject: Re: [R] By() with method = spearman
>>
>> Doran, Harold wrote:
>>> Thanks, Chuck. Seems odd though, doesn't it? There must be 
>> something 
>>> with my data set. But, I don't have any clue what it might 
>> be since I 
>>> can compute pearson using by() and I can subset and 
>> actually compute 
>>> spearman using just cor()
>> Harold:
>>   What happens when you approach the problem with split() and 
>> lapply() instead of by()?  For example:
>>
>> lapply(split(iris, f = iris$Species),
>> function(x){cor(x[,c("Sepal.Length","Sepal.Width")], use='complete',
>> method='spearman')})
>>
>> $setosa
>>  Sepal.Length Sepal.Width
>> Sepal.Length1.000   0.7553375
>> Sepal.Width 0.7553375   1.000
>>
>> $versicolor
>>  Sepal.Length Sepal.Width
>> Sepal.Length 1.000.517606
>> Sepal.Width  0.5176061.00
>>
>> $virginica
>>  Sepal.Length Sepal.Width
>> Sepal.Length1.000   0.4265165
>> Sepal.Width 0.4265165   1.000
>>
>> hope this helps,
>>
>> Chuck
>>
 -Original Message-
 From: Chuck Cleland [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, September 19, 2007 12:14 PM
 To: Doran, Harold
 Cc: r-help@r-project.org
 Subject: Re: [R] By() with method = spearman

 Doran, Harold wrote:
> I have a data set where I want the correlations between 2 
>> variables 
> conditional on a students grade level.
>
> This code works just fine.
>
> by(tmp[,c('mtsc07', 'DCBASmathscoreSPRING')], tmp$Grade, cor, 
> use='complete', method='pearson')
>
> However, this generates an error
>
> by(tmp[,c('mtsc07', 'DCBASmathscoreSPRING')], tmp$Grade, cor, 
> use='complete', method='spearman') Error in FUN(data[x, ],
 ...) : 'x' 
> is empty
>
> I can subset the data by grade and compute spearman rho as
>
> tmp5 <- subset(tmp, Grade == 5)
> cor(tmp5[,c('mtsc07', 'DCBASmathcountSPRING')], use='complete',
> method='spearman')
>
> But doing this iteratively is inefficient.
>
> I don't see anything in the help man for by() or cor() that
 tells me
> what the problem is. I might be missing it though. Any thoughts?
   It works as expected using the iris data:

 by(iris[,c('Sepal.Length', 'Sepal.Width')], iris$Species, cor,
use='complete', method='spearman')

 iris$Species: setosa
  Sepal.Length Sepal.Width
 Sepal.Length1.000   0.7553375
 Sepal.Width 0.7553375   1.000
 --
 ---

 iris$Species: versicolor
  Sepal.Length Sepal.Width
 Sepal.Length 1.000.517606
 Sepal.Width  0.5176061.00
 --
 ---

 iris$Species: virginica
  Sepal.Length Sepal.Width
 Sepal.Length1.000   0.4265165
 Sepal.Width 0.4265165   1.000

> sessionInfo()
 R version 2.5.1 Patched (2007-09-16 r42884)
 i386-pc-mingw32

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

 attached base packages:
 [1] "s

Re: [R] By() with method = spearman

2007-09-19 Thread Ivar Herfindal
Hello

It seems like method="pearson" accept missing values, that is, none 
complete cases, and only generate correlation coefficients of NA, while 
using method="spearman" gives and error message. try e.g.
 
testdata <- cbind.data.frame(gr=rep(letters[1:4], each=5), aa=rnorm(20), 
bb=rnorm(20))
testdata[1:5, 2] <- NA
by(testdata[,c("aa", "bb")], testdata$gr, cor, use="complete", 
method="pearson")
# provides result for every group, but NA for group a

by(testdata[,c("aa", "bb")], testdata$gr, cor, use="complete", 
method="spearman")
# gives:
Error in FUN(data[x, ], ...) : 'x' is empty

I guess a deeper look into cor would reveal what is actually going on 
with spearman vs pearson vs kendall (kendall also provides error message).
Anyway, this leads me to believe that you may have groups with no 
complete pairs.

Sincerely

Ivar

Doran, Harold skrev:
> I still get an error
>
>   
>> tmp$Grade <- factor(tmp$Grade)
>> lapply(split(tmp, f = tmp$Grade),
>> 
> function(x){cor(x[,c("mtsc07","DCBASmathscoreSPRING")], use='complete',
> + method='spearman')})
>
> Error in cor(x[, c("mtsc07", "DCBASmathscoreSPRING")], use = "complete",
> : 
> 'x' is empty 
>
> I noticed tmp$Grade (my index variable) was numeric. So, I coerced it
> into a factor. I get the same error message, however.
>
> Notice, however, that this code works correctly
>
> lapply(split(tmp, f = tmp$Grade),
> function(x){cor(x[,c("mtsc07","DCBASmathscoreSPRING")], use='complete',
> method='pearson')})
>
> The only differece is that method is changed to pearson.
>
>   
>> -Original Message-
>> From: Chuck Cleland [mailto:[EMAIL PROTECTED] 
>> Sent: Wednesday, September 19, 2007 12:22 PM
>> To: Doran, Harold
>> Subject: Re: [R] By() with method = spearman
>>
>> Doran, Harold wrote:
>> 
>>> Thanks, Chuck. Seems odd though, doesn't it? There must be 
>>>   
>> something 
>> 
>>> with my data set. But, I don't have any clue what it might 
>>>   
>> be since I 
>> 
>>> can compute pearson using by() and I can subset and 
>>>   
>> actually compute 
>> 
>>> spearman using just cor()
>>>   
>> Harold:
>>   What happens when you approach the problem with split() and 
>> lapply() instead of by()?  For example:
>>
>> lapply(split(iris, f = iris$Species),
>> function(x){cor(x[,c("Sepal.Length","Sepal.Width")], use='complete',
>> method='spearman')})
>>
>> $setosa
>>  Sepal.Length Sepal.Width
>> Sepal.Length1.000   0.7553375
>> Sepal.Width 0.7553375   1.000
>>
>> $versicolor
>>  Sepal.Length Sepal.Width
>> Sepal.Length 1.000.517606
>> Sepal.Width  0.5176061.00
>>
>> $virginica
>>  Sepal.Length Sepal.Width
>> Sepal.Length1.000   0.4265165
>> Sepal.Width 0.4265165   1.000
>>
>> hope this helps,
>>
>> Chuck
>>
>> 
 -Original Message-
 From: Chuck Cleland [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, September 19, 2007 12:14 PM
 To: Doran, Harold
 Cc: r-help@r-project.org
 Subject: Re: [R] By() with method = spearman

 Doran, Harold wrote:
 
> I have a data set where I want the correlations between 2 
>   
>> variables 
>> 
> conditional on a students grade level.
>
> This code works just fine.
>
> by(tmp[,c('mtsc07', 'DCBASmathscoreSPRING')], tmp$Grade, cor, 
> use='complete', method='pearson')
>
> However, this generates an error
>
> by(tmp[,c('mtsc07', 'DCBASmathscoreSPRING')], tmp$Grade, cor, 
> use='complete', method='spearman') Error in FUN(data[x, ],
>   
 ...) : 'x' 
 
> is empty
>
> I can subset the data by grade and compute spearman rho as
>
> tmp5 <- subset(tmp, Grade == 5)
> cor(tmp5[,c('mtsc07', 'DCBASmathcountSPRING')], use='complete',
> method='spearman')
>
> But doing this iteratively is inefficient.
>
> I don't see anything in the help man for by() or cor() that
>   
 tells me
 
> what the problem is. I might be missing it though. Any thoughts?
>   
   It works as expected using the iris data:

 by(iris[,c('Sepal.Length', 'Sepal.Width')], iris$Species, cor,
use='complete', method='spearman')

 iris$Species: setosa
  Sepal.Length Sepal.Width
 Sepal.Length1.000   0.7553375
 Sepal.Width 0.7553375   1.000
 --
 ---

 iris$Species: versicolor
  Sepal.Length Sepal.Width
 Sepal.Length 1.000.517606
 Sepal.Width  0.5176061.00
 --
 ---

 iris$Species: virginica
  Sepal.Length Sepal.Width
 Sepal.Length1.0

Re: [R] Robust or Sandwich estimates in lmer2

2007-09-19 Thread Doran, Harold
This has come up before and I'll again ask the question "why would you
want robust standard errors in lmer"? Traditional econometric thinking
suggests that there is model mispecification if OLS is used and there is
a violation to the assumption of independence. So, one may still get the
point estimates via OLS but then get robust standard errors. This makes
sense.

But, mixed models are designed to account for violations to the iid
assumption via correctly specified random effects. So, if your lmer
model is correctly specified, the standard errors should yield an
accurate estimate of the true sampling variance.

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Sundar Dorai-Raj
> Sent: Wednesday, September 19, 2007 11:42 AM
> To: Abdus Sattar
> Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: [R] Robust or Sandwich estimates in lmer2
> 
> Abdus Sattar said the following on 9/19/2007 7:03 AM:
> > Dear R-Users:
> > 
> > I am trying to find the robust (or sandwich) estimates of 
> the standard error of fixed effects parameter estimates using 
> the package "lmer2". In model-1, I used "robust=TRUE" on the 
> other, in model-2, I used "robust=FALSE". Both models giving 
> me the same estimates. So my question is, does the robust 
> option works in lmer2 to get the robust estimates of the 
> standard error? If anybody could offer me a suggestion I 
> would greatly appreciate it. Thank you.  
> > 
> > Model-1:
> > 
> >> p.mle<-lmer2(ddimer~race+steroid+psi+sofa+apache + 
> (apache|subject), 
> >> method="ML", data=final, robust=TRUE, cluster="id", 
> weights=final$w)
> >> beta=fixef(p.mle)
> >> Vcov=vcov(p.mle, useScale=FALSE)
> >> se=sqrt(diag(Vcov))
> >> beta
> >  (Intercept) race  steroid  psi 
> sofa   apache 
> >  5.826489820 -0.001920670 -0.242040171  0.005293996  0.075468340  
> > 0.009245152
> >> se
> > [1] 0.108325229 0.058921371 0.055975547 0.001285687 0.018119089 
> > 0.002559902
> > 
> > Model-2:
> > 
> >> p.mle<-lmer2(ddimer~race+steroid+psi+sofa+apache + 
> (apache|subject), 
> >> method="ML", data=final, robust=FALSE, cluster="id", 
> weights=final$w)
> >> beta=fixef(p.mle)
> >> Vcov=vcov(p.mle, useScale=FALSE)
> >> se=sqrt(diag(Vcov))
> >> beta
> >  (Intercept) race  steroid  psi 
> sofa   apache 
> >  5.826489820 -0.001920670 -0.242040171  0.005293996  0.075468340  
> > 0.009245152
> >> se
> > [1] 0.108325229 0.058921371 0.055975547 0.001285687 0.018119089 
> > 0.002559902
> > 
> > 
> > Best Regards,
> > 
> > Sattar
> > 
> > 
> 
> The help page to ?lmer2 in the lme4 package makes no mention 
> of "cluster" or "robust" arguments. To me, that would mean 
> these arguments are ignored.
> 
> HTH,
> 
> --sundar
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] Row-by-row regression on matrix

2007-09-19 Thread murali . menon
Folks,

I have a 3000 x 4 matrix (y), which I need to regress row-by-row against a 
4-vector (x) to create a
matrix lm.y of intercepts and slopes. To illustrate:

y <- matrix(rnorm(12000), ncol = 4)
x <- c(1/12, 3/12, 6/12, 1)

system.time(lm.y <- t(apply(y, 1, function(z) lm(z ~ x)$coefficient)))
[1] 44.72 18.00 69.52NANA

Takes more than a minute to do (and I need to do many similar regressions 
a day). 

Is there a more efficient way of handling this?

I'm running R 2.4.1 on Windows XP Service Pack 2 on a Intel Xeon dual-core 
2.66GHz with 3GB RAM.

Thanks very much,

Murali


---
This message (including any attachments) is confidential and...{{dropped}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] By() with method = spearman

2007-09-19 Thread Doran, Harold
I still get an error

> tmp$Grade <- factor(tmp$Grade)
> lapply(split(tmp, f = tmp$Grade),
function(x){cor(x[,c("mtsc07","DCBASmathscoreSPRING")], use='complete',
+ method='spearman')})

Error in cor(x[, c("mtsc07", "DCBASmathscoreSPRING")], use = "complete",
: 
'x' is empty 

I noticed tmp$Grade (my index variable) was numeric. So, I coerced it
into a factor. I get the same error message, however.

Notice, however, that this code works correctly

lapply(split(tmp, f = tmp$Grade),
function(x){cor(x[,c("mtsc07","DCBASmathscoreSPRING")], use='complete',
method='pearson')})

The only differece is that method is changed to pearson.

> -Original Message-
> From: Chuck Cleland [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, September 19, 2007 12:22 PM
> To: Doran, Harold
> Subject: Re: [R] By() with method = spearman
> 
> Doran, Harold wrote:
> > Thanks, Chuck. Seems odd though, doesn't it? There must be 
> something 
> > with my data set. But, I don't have any clue what it might 
> be since I 
> > can compute pearson using by() and I can subset and 
> actually compute 
> > spearman using just cor()
> 
> Harold:
>   What happens when you approach the problem with split() and 
> lapply() instead of by()?  For example:
> 
> lapply(split(iris, f = iris$Species),
> function(x){cor(x[,c("Sepal.Length","Sepal.Width")], use='complete',
> method='spearman')})
> 
> $setosa
>  Sepal.Length Sepal.Width
> Sepal.Length1.000   0.7553375
> Sepal.Width 0.7553375   1.000
> 
> $versicolor
>  Sepal.Length Sepal.Width
> Sepal.Length 1.000.517606
> Sepal.Width  0.5176061.00
> 
> $virginica
>  Sepal.Length Sepal.Width
> Sepal.Length1.000   0.4265165
> Sepal.Width 0.4265165   1.000
> 
> hope this helps,
> 
> Chuck
> 
> >> -Original Message-
> >> From: Chuck Cleland [mailto:[EMAIL PROTECTED]
> >> Sent: Wednesday, September 19, 2007 12:14 PM
> >> To: Doran, Harold
> >> Cc: r-help@r-project.org
> >> Subject: Re: [R] By() with method = spearman
> >>
> >> Doran, Harold wrote:
> >>> I have a data set where I want the correlations between 2 
> variables 
> >>> conditional on a students grade level.
> >>>
> >>> This code works just fine.
> >>>
> >>> by(tmp[,c('mtsc07', 'DCBASmathscoreSPRING')], tmp$Grade, cor, 
> >>> use='complete', method='pearson')
> >>>
> >>> However, this generates an error
> >>>
> >>> by(tmp[,c('mtsc07', 'DCBASmathscoreSPRING')], tmp$Grade, cor, 
> >>> use='complete', method='spearman') Error in FUN(data[x, ],
> >> ...) : 'x' 
> >>> is empty
> >>>
> >>> I can subset the data by grade and compute spearman rho as
> >>>
> >>> tmp5 <- subset(tmp, Grade == 5)
> >>> cor(tmp5[,c('mtsc07', 'DCBASmathcountSPRING')], use='complete',
> >>> method='spearman')
> >>>
> >>> But doing this iteratively is inefficient.
> >>>
> >>> I don't see anything in the help man for by() or cor() that
> >> tells me
> >>> what the problem is. I might be missing it though. Any thoughts?
> >>   It works as expected using the iris data:
> >>
> >> by(iris[,c('Sepal.Length', 'Sepal.Width')], iris$Species, cor,
> >>use='complete', method='spearman')
> >>
> >> iris$Species: setosa
> >>  Sepal.Length Sepal.Width
> >> Sepal.Length1.000   0.7553375
> >> Sepal.Width 0.7553375   1.000
> >> --
> >> ---
> >>
> >> iris$Species: versicolor
> >>  Sepal.Length Sepal.Width
> >> Sepal.Length 1.000.517606
> >> Sepal.Width  0.5176061.00
> >> --
> >> ---
> >>
> >> iris$Species: virginica
> >>  Sepal.Length Sepal.Width
> >> Sepal.Length1.000   0.4265165
> >> Sepal.Width 0.4265165   1.000
> >>
> >>> sessionInfo()
> >> R version 2.5.1 Patched (2007-09-16 r42884)
> >> i386-pc-mingw32
> >>
> >> locale:
> >> LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
> >> States.1252;LC_MONETARY=English_United
> >> States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
> >>
> >> attached base packages:
> >> [1] "stats" "graphics"  "grDevices" "utils" "datasets"
> >> "methods"   "base"
> >>
> >> other attached packages:
> >>  lattice
> >> "0.16-5"
> >>
> >>> Thanks,
> >>> Harold
> >>>
> >>>
>  sessionInfo()
> >>> R version 2.5.0 (2007-04-23)
> >>> i386-pc-mingw32
> >>>
> >>> locale:
> >>> LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
> >>> States.1252;LC_MONETARY=English_United
> >>> States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
> >>>
> >>> attached base packages:
> >>> [1] "stats" "graphics"  "grDevices" "utils" "datasets"
> >>> "methods"   "base" 
> >>>
> >>> other attached packages:
> >>>  lattice
> >>> "0.15-4" 
> >>>
> >>>
> >>>   [[alternative HTML version deleted]]
> >>>
> >>> ___

Re: [R] Robust or Sandwich estimates in lmer2

2007-09-19 Thread Sundar Dorai-Raj
Abdus Sattar said the following on 9/19/2007 7:03 AM:
> Dear R-Users:
> 
> I am trying to find the robust (or sandwich) estimates of the standard error 
> of fixed effects parameter estimates using the package "lmer2". In model-1, I 
> used "robust=TRUE" on the other, in model-2, I used "robust=FALSE". Both 
> models giving me the same estimates. So my question is, does the robust 
> option works in lmer2 to get the robust estimates of the standard error? If 
> anybody could offer me a suggestion I would greatly appreciate it. Thank you. 
>  
> 
> Model-1:
> 
>> p.mle<-lmer2(ddimer~race+steroid+psi+sofa+apache + (apache|subject), 
>> method="ML", data=final, robust=TRUE, cluster="id", weights=final$w)
>> beta=fixef(p.mle)
>> Vcov=vcov(p.mle, useScale=FALSE)
>> se=sqrt(diag(Vcov))
>> beta
>  (Intercept) race  steroid  psi sofa   apache 
>  5.826489820 -0.001920670 -0.242040171  0.005293996  0.075468340  0.009245152 
>> se
> [1] 0.108325229 0.058921371 0.055975547 0.001285687 0.018119089 0.002559902
> 
> Model-2:
> 
>> p.mle<-lmer2(ddimer~race+steroid+psi+sofa+apache + (apache|subject), 
>> method="ML", data=final, robust=FALSE, cluster="id", weights=final$w)
>> beta=fixef(p.mle)
>> Vcov=vcov(p.mle, useScale=FALSE)
>> se=sqrt(diag(Vcov))
>> beta
>  (Intercept) race  steroid  psi sofa   apache 
>  5.826489820 -0.001920670 -0.242040171  0.005293996  0.075468340  0.009245152 
>> se
> [1] 0.108325229 0.058921371 0.055975547 0.001285687 0.018119089 0.002559902
> 
> 
> Best Regards, 
> 
> Sattar
> 
> 

The help page to ?lmer2 in the lme4 package makes no mention of 
"cluster" or "robust" arguments. To me, that would mean these arguments 
are ignored.

HTH,

--sundar

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] By() with method = spearman

2007-09-19 Thread Doran, Harold
Thanks, Chuck. Seems odd though, doesn't it? There must be something
with my data set. But, I don't have any clue what it might be since I
can compute pearson using by() and I can subset and actually compute
spearman using just cor() 

> -Original Message-
> From: Chuck Cleland [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, September 19, 2007 12:14 PM
> To: Doran, Harold
> Cc: r-help@r-project.org
> Subject: Re: [R] By() with method = spearman
> 
> Doran, Harold wrote:
> > I have a data set where I want the correlations between 2 variables 
> > conditional on a students grade level.
> > 
> > This code works just fine.
> > 
> > by(tmp[,c('mtsc07', 'DCBASmathscoreSPRING')], tmp$Grade, cor, 
> > use='complete', method='pearson')
> > 
> > However, this generates an error
> > 
> > by(tmp[,c('mtsc07', 'DCBASmathscoreSPRING')], tmp$Grade, cor, 
> > use='complete', method='spearman') Error in FUN(data[x, ], 
> ...) : 'x' 
> > is empty
> > 
> > I can subset the data by grade and compute spearman rho as
> > 
> > tmp5 <- subset(tmp, Grade == 5)
> > cor(tmp5[,c('mtsc07', 'DCBASmathcountSPRING')], use='complete',
> > method='spearman')
> > 
> > But doing this iteratively is inefficient.
> > 
> > I don't see anything in the help man for by() or cor() that 
> tells me 
> > what the problem is. I might be missing it though. Any thoughts?
> 
>   It works as expected using the iris data:
> 
> by(iris[,c('Sepal.Length', 'Sepal.Width')], iris$Species, cor,
>use='complete', method='spearman')
> 
> iris$Species: setosa
>  Sepal.Length Sepal.Width
> Sepal.Length1.000   0.7553375
> Sepal.Width 0.7553375   1.000
> --
> ---
> 
> iris$Species: versicolor
>  Sepal.Length Sepal.Width
> Sepal.Length 1.000.517606
> Sepal.Width  0.5176061.00
> --
> ---
> 
> iris$Species: virginica
>  Sepal.Length Sepal.Width
> Sepal.Length1.000   0.4265165
> Sepal.Width 0.4265165   1.000
> 
> > sessionInfo()
> R version 2.5.1 Patched (2007-09-16 r42884)
> i386-pc-mingw32
> 
> locale:
> LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
> States.1252;LC_MONETARY=English_United
> States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
> 
> attached base packages:
> [1] "stats" "graphics"  "grDevices" "utils" "datasets"
> "methods"   "base"
> 
> other attached packages:
>  lattice
> "0.16-5"
> 
> > Thanks,
> > Harold
> > 
> > 
> >> sessionInfo()
> > R version 2.5.0 (2007-04-23)
> > i386-pc-mingw32
> > 
> > locale:
> > LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
> > States.1252;LC_MONETARY=English_United
> > States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
> > 
> > attached base packages:
> > [1] "stats" "graphics"  "grDevices" "utils" "datasets"
> > "methods"   "base" 
> > 
> > other attached packages:
> >  lattice
> > "0.15-4" 
> > 
> > 
> > [[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. 
> 
> --
> Chuck Cleland, Ph.D.
> NDRI, Inc.
> 71 West 23rd Street, 8th floor
> New York, NY 10010
> tel: (212) 845-4495 (Tu, Th)
> tel: (732) 512-0171 (M, W, F)
> fax: (917) 438-0894
> 

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] layout function for several plots

2007-09-19 Thread R Help
I can't read what your error message, but on mine I get the error:
"Error in plot.new(): margins too large", which is happening because
the default margins do not have enough space.  You can reduce the
margins with using par

par(mar=c(0,0,0,0))

Which will let plot.new() work.  I hope this helps.

Sam

On 9/19/07, marcg <[EMAIL PROTECTED]> wrote:
> Dear all
>
> I try to print 9 plots on a page, arranged as the code shows below.
>
> nf <- layout(matrix(c(1,0,2,0,0,3,0,4,0,5,0,6,0,0,0,0,7,0,8,9), 10,2))
> layout.show(nf)
>
> but when I try to plot, an error message
> Fehler in plot.new() : Grafikränder zu groß
> appears
>
> to verify p.e. with
>
> plot(runif(10:1))
>
> i tried with plot(runif(10:1), ann=F) to produce more space, but neither.
>
> The second question: how to place a cross in the middle of the plot to 
> delineate in 4 big fields (containing each 5 plots)
>
> Thanks a lot
>
>
> --
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
> --
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] By() with method = spearman

2007-09-19 Thread Chuck Cleland
Doran, Harold wrote:
> I have a data set where I want the correlations between 2 variables
> conditional on a students grade level.
> 
> This code works just fine.
> 
> by(tmp[,c('mtsc07', 'DCBASmathscoreSPRING')], tmp$Grade, cor,
> use='complete', method='pearson')
> 
> However, this generates an error
> 
> by(tmp[,c('mtsc07', 'DCBASmathscoreSPRING')], tmp$Grade, cor,
> use='complete', method='spearman')
> Error in FUN(data[x, ], ...) : 'x' is empty
> 
> I can subset the data by grade and compute spearman rho as
> 
> tmp5 <- subset(tmp, Grade == 5)
> cor(tmp5[,c('mtsc07', 'DCBASmathcountSPRING')], use='complete',
> method='spearman')
> 
> But doing this iteratively is inefficient.
> 
> I don't see anything in the help man for by() or cor() that tells me
> what the problem is. I might be missing it though. Any thoughts?

  It works as expected using the iris data:

by(iris[,c('Sepal.Length', 'Sepal.Width')], iris$Species, cor,
   use='complete', method='spearman')

iris$Species: setosa
 Sepal.Length Sepal.Width
Sepal.Length1.000   0.7553375
Sepal.Width 0.7553375   1.000
-

iris$Species: versicolor
 Sepal.Length Sepal.Width
Sepal.Length 1.000.517606
Sepal.Width  0.5176061.00
-

iris$Species: virginica
 Sepal.Length Sepal.Width
Sepal.Length1.000   0.4265165
Sepal.Width 0.4265165   1.000

> sessionInfo()
R version 2.5.1 Patched (2007-09-16 r42884)
i386-pc-mingw32

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

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

other attached packages:
 lattice
"0.16-5"

> Thanks,
> Harold
> 
> 
>> sessionInfo()
> R version 2.5.0 (2007-04-23) 
> i386-pc-mingw32 
> 
> locale:
> LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
> States.1252;LC_MONETARY=English_United
> States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
> 
> attached base packages:
> [1] "stats" "graphics"  "grDevices" "utils" "datasets"
> "methods"   "base" 
> 
> other attached packages:
>  lattice 
> "0.15-4" 
> 
> 
>   [[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. 

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

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

2007-09-19 Thread Wiebke Timm
Hi!

When I apply the lars (least-angle-regression) method to my data  
(3655 features, only 355 data points, no I did not mistype), I  
observe a strange behaviour:

1) The beta values tend to grow into real high values quite fast up  
to a point where they overflow and get negative. The overflow is not  
a problem, I don't need the last part of the analysis anyway, but why  
do they just shoot up to high values like that...? Any explanation?

2) The Cp values... they start at about -360 and grow linearly with  
increasing steps. This is totally strange since they ought to be an  
"overly optimistic estimation of the generalization error" according  
to Hastie's book.

3) Lastly, I get a curve for the r^2 correlation values, that grows  
up to a plateau where they are 1 (until they reach the point where  
betas overflow, then it gets negative, but forget about that). This  
is classic overfitting happening. The calculation IS right though,  
since using the components and betas from one of those r^2=1 steps  
gives a correlation of like 0.96 with nu-SVR too. The generalization  
is pretty bad though.

The funny thing: I observe qualitatively the same when starting with  
359 of these features and do a lars on them.

So, questions I have:
* Regarding to point 1 and 2, does anybody have an explanation for  
the described behaviour? I can't seem to find one myself...
* Did anybody try lars on data with such a bad feature to data points  
ratio before? What were the experiences?
* Why does it overfit so bad?

I have also tried the crossvalidation selection (cv.lars) but it does  
not give me the selected features or betas, just the r^2 and RSS  
values from its runs...


Thanks for any thoughts on this!

Ciao!
Wiebke

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] By() with method = spearman

2007-09-19 Thread Doran, Harold
I have a data set where I want the correlations between 2 variables
conditional on a students grade level.

This code works just fine.

by(tmp[,c('mtsc07', 'DCBASmathscoreSPRING')], tmp$Grade, cor,
use='complete', method='pearson')

However, this generates an error

by(tmp[,c('mtsc07', 'DCBASmathscoreSPRING')], tmp$Grade, cor,
use='complete', method='spearman')
Error in FUN(data[x, ], ...) : 'x' is empty

I can subset the data by grade and compute spearman rho as

tmp5 <- subset(tmp, Grade == 5)
cor(tmp5[,c('mtsc07', 'DCBASmathcountSPRING')], use='complete',
method='spearman')

But doing this iteratively is inefficient.

I don't see anything in the help man for by() or cor() that tells me
what the problem is. I might be missing it though. Any thoughts?

Thanks,
Harold


> sessionInfo()
R version 2.5.0 (2007-04-23) 
i386-pc-mingw32 

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

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

other attached packages:
 lattice 
"0.15-4" 


[[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] glmpath error

2007-09-19 Thread Prof Brian Ripley
On Wed, 19 Sep 2007, Duncan Murdoch wrote:

> On 9/19/2007 7:46 AM, Tirthadeep wrote:
>> Then what is the solution?
>
> The same method you used for the other columns:
>
> train.data[,21]

However, the error message is about the first argument (x) and not NULL 
for the second argument (and applying $ to a matrix will give a warning in 
recent versions of R).

I think it most likely that train.data is a data frame, in which case the 
problem lies in the first argument.  glmpath makes no attempt to coerce 
its arguments to the desired form, so you do need to supply exactly what 
the help page says.  (Although it does not say x should be numeric, it 
does need to be.)

>
> Duncan Murdoch
>
>>
>>
>>
>>
>> Duncan Murdoch-2 wrote:
>>>
>>> Tirthadeep wrote:
 Hi,

 I am using glampath package for L1 regularized logistic regression. I got
 the following error messege.


> model.fit <- glmpath(train.data[,1:20], train.data$RES, family=binomial)
>
 Error in one %*% x : requires numeric matrix/vector arguments

 where train.data is a 700X21 matrix and 21st column in response (RES).

>>> If it is a matrix, then train.data$RES won't work.  That column
>>> selection method only works for data frames,
>>> because they are lists, and matrices aren't.
>>>
>>> Duncan Murdoch
 Please clarify!!!

 Thanks

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

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

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


[R] ChiSquare-Test

2007-09-19 Thread Birgit Lemcke
Hello all you helpful people out there!

I am stil R Beginner using R 2.5.1 on a Apple Power Book G4 with Mac  
OS X 10.4.10 .
I have two tabels like this:

MalTabChi
   X1 X4 X6 X8  X10  X14  X21  X24   X29  X38  X43 X50  
X67  X76  X78 X80 X82 X84
Anth_cap   1  1  1  1651   45124   12   6   
5652   4   1   1
Anth_crin 12  1  1  2   7651   45   2562   25  56   
56  3452  23   1   2
Anth_eck  12  1 12  175   12514   452  56
452  34   1  12
Anth_gram  2  1  1  1651   2525   23   25  45
5   452  23   1  12
Anth_insi  2  1  1  2   63514 222  45   
45   45   12   3   1  23
Anth_laxi 12  1  1 127   4515   245   235  46   
56  3452  23   1  12
Anth_sing  1  1  2  17 234514   129 2345   12  46
45   23   2   1   1
Aski_albo_ari  3  1  1  2652   46 2   34   15  34
553   4   1   1
Aski_alt  13  1  1  26524 23   15  46
552  34   3   1
Aski_and   1  1  2  26525   1  36
453   3   3   1
Aski_capi  3  1  1  2   63525 235  45
453   3   1   1.

FemTabChi
 X1 X4   X6 X8  X10  X14 X21 X24   X29  X38  X43 X50   
X67 X76  X78 X80 X82 X84
Anth_cap 1  11  244   1   5 6   142   6
56   52  23   1   1
Anth_crin1  11  2   475   1  45 612   
455  342   3   1  23
Anth_eck 1  11  245   1  45 612  56
46 3452   3   1  12
Anth_gram1  11  2 5   2   5  4   56
56   52   3   1   1
Anth_insi1  11  235   1   426   252
45   52   3   1 234
Anth_laxi1  11  2   475   1  56 6   242
45 345   21  23   1   1
Anth_sing1  11  2   47   24   1   22422
44   52  12   1   1
Aski_albo_ari2  11  245   2   4 2   34   15
45   53   4   1   1
Aski_alt12  11  245   2   4895   15   
465   52   3   3   1
Aski_and 1  11  245   2   5   25951  46
25   52  23   1   1
Aski_capi   23  11  2  2345   2   5  2459  2355   
465  343   3   1   1
Aski_chart  12  11  245   2   4292   15   4
25   52  34   3   1
Aski_deli2  11  245  12   4 625   
465   33   4   1   1..

The variables are factors and I would like to perform a ChiSquare  
Test, comparing for example X1(first Table)
to X1(secondTable)(Null Hypothesis: Variables are equal)
Depending on the variables are the factor levels  1 up to 9.
But as you immediately see, there is often more than one answer per  
species in the variables (Example 129).
My question is now: how can I say to R that these numbers have to be  
treated separately? In the example as a 1, a 2 and a 9 and not as 129)

I really hope you understand what I mean. If not please ask me.

I would be very pleased, if somebody could help me.

Greetings

Birgit




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






[[alternative HTML version deleted]]

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


[R] function on factors - how best to proceed

2007-09-19 Thread Karin Lagesen

Sorry about this one being long, and I apologise beforehand if there
is something obvious here that I have missed. I am new to creating my
own functions in R, and I am uncertain of how they work.

I have a data set that I have read into a data frame:

> gctable[1:5,]
 refseq geometry X60_origin X60_terminus  length  kingdom
1 NC_009484  cir179   773000 3389227 Bacteria
2 NC_009484  cir179   773000 3389227 Bacteria
3 NC_009484  cir179   773000 3389227 Bacteria
4 NC_009484  cir179   773000 3389227 Bacteria
5 NC_009484  cir179   773000 3389227 Bacteria
  grp feature gene begin dir gc_content replicor LEADLAG
1 Alphaproteobacteria CDS  CDS   261   +   0.654244RIGHTLEAD
2 Alphaproteobacteria CDS  CDS  1737   -   0.651408RIGHT LAG
3 Alphaproteobacteria CDS  CDS  2902   +   0.607843RIGHTLEAD
4 Alphaproteobacteria CDS  CDS  3693   +   0.617647RIGHTLEAD
5 Alphaproteobacteria CDS  CDS  4227   +   0.699208RIGHTLEAD
> 

Most of these columns are factors.

Now, I have a function that I would like to employ on this data
frame. Right now I cannot get it to work, and that seems to be due to
the columns in the data frame being factors. I tested it with a data
frame created from vectors, and it worked fine.

The function:

percentdistance <- function(origin, terminus, length, begin, replicor){
print(c(origin, terminus, length, begin, repl))
d = 0
if (terminus>origin) {
  if(replicor=="LEFT") {
d = -((origin-begin)%%length)
  }
else {
d = (begin-origin)
  }
}
else {
  if (replicor=="LEFT") {
d=(origin-begin)
  }
  else{
d = -((begin-origin)%%length)
  }
}
d/length*2
}

The error I get:
> percentdistance(gctable$X60_origin, gctable$X60_terminus, gctable$length, 
> gctable$begin, gctable$replicor)
[1]  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87
   [19]  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87
   [37]  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87
   [55]  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87
   [73]  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87
   [91]  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87
  [109]  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87
  [127]  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87  87
.[99919]   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   
2   2
[99937]   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2
[99955]   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2
[99973]   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2
[1]   2   2   2   2   2   2   2   2   2
 [ reached getOption("max.print") -- omitted 8526091 entries ]]
Error in if (terminus > origin) { : missing value where TRUE/FALSE needed
In addition: Warning messages:
1: > not meaningful for factors in: Ops.factor(terminus, origin) 
2: the condition has length > 1 and only the first element will be used in: if 
(terminus > origin) { 
> 

This worked nice when the input were columns from a data frame created
from vectors.

I have also tried the different apply-functions, although I am
uncertain of which one would be appropriate here.


I would like to use this function to create a new data frame which
would look something like this:

new_frame = (gctable$feature, gctable$gene, gctable$kingdom, gctable$grp, 
gctable$gc_content, percentdistance(gctable))

I am uncertain of how to proceed. Should I deconstruct the data frame
within the function, or should I get just the numbers out of the
factors and input that into the function? Or is my solution way off
from how things are done in R?

Thankyou very much for your help!

Karin
-- 
Karin Lagesen, PhD student
[EMAIL PROTECTED]
http://folk.uio.no/karinlag

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

2007-09-19 Thread Peter Ehlers
Is train.data a *numeric* matrix?

Peter Ehlers

Tirthadeep wrote:
> Then what is the solution?
> 
> 
> 
> 
> Duncan Murdoch-2 wrote:
>> Tirthadeep wrote:
>>> Hi,
>>>
>>> I am using glampath package for L1 regularized logistic regression. I got
>>> the following error messege.
>>>
>>>   
 model.fit <- glmpath(train.data[,1:20], train.data$RES, family=binomial)
 
>>> Error in one %*% x : requires numeric matrix/vector arguments
>>>
>>> where train.data is a 700X21 matrix and 21st column in response (RES).
>>>   
>> If it is a matrix, then train.data$RES won't work.  That column 
>> selection method only works for data frames,
>> because they are lists, and matrices aren't.
>>
>> Duncan Murdoch
>>> Please clarify!!!
>>>
>>> Thanks
>>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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] glmpath error

2007-09-19 Thread Duncan Murdoch
On 9/19/2007 7:46 AM, Tirthadeep wrote:
> Then what is the solution?

The same method you used for the other columns:

train.data[,21]

Duncan Murdoch

> 
> 
> 
> 
> Duncan Murdoch-2 wrote:
>> 
>> Tirthadeep wrote:
>>> Hi,
>>>
>>> I am using glampath package for L1 regularized logistic regression. I got
>>> the following error messege.
>>>
>>>   
 model.fit <- glmpath(train.data[,1:20], train.data$RES, family=binomial)
 
>>> Error in one %*% x : requires numeric matrix/vector arguments
>>>
>>> where train.data is a 700X21 matrix and 21st column in response (RES).
>>>   
>> If it is a matrix, then train.data$RES won't work.  That column 
>> selection method only works for data frames,
>> because they are lists, and matrices aren't.
>> 
>> Duncan Murdoch
>>> Please clarify!!!
>>>
>>> Thanks
>>>
>> 
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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] Memory Issue

2007-09-19 Thread Yoni Stoffman
Hi, 

I'm new to R and there is something I'm missing about how it uses
memory. I'm doing a simple query (using RODBC package) and immediately
set the data.frame to null close the connection/channel and explicitly
call to the garbage collector (gc()) however when I look in the task
monitor I see both "VM size" and ""Mem Usage" increased every time (for
the RGui).

I tried this on different configurations: windowxp64 / windowsxp and R
version 2.4.1 and 2.5.1. 

What I'm doing wrong? 

Thanks, 
Yoni.

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

2007-09-19 Thread Abdus Sattar
Dear R-Users:

I am trying to find the robust (or sandwich) estimates of the standard error of 
fixed effects parameter estimates using the package "lmer2". In model-1, I used 
"robust=TRUE" on the other, in model-2, I used "robust=FALSE". Both models 
giving me the same estimates. So my question is, does the robust option works 
in lmer2 to get the robust estimates of the standard error? If anybody could 
offer me a suggestion I would greatly appreciate it. Thank you.  

Model-1:

> p.mle<-lmer2(ddimer~race+steroid+psi+sofa+apache + (apache|subject), 
> method="ML", data=final, robust=TRUE, cluster="id", weights=final$w)
> beta=fixef(p.mle)
> Vcov=vcov(p.mle, useScale=FALSE)
> se=sqrt(diag(Vcov))
> beta
 (Intercept) race  steroid  psi sofa   apache 
 5.826489820 -0.001920670 -0.242040171  0.005293996  0.075468340  0.009245152 
> se
[1] 0.108325229 0.058921371 0.055975547 0.001285687 0.018119089 0.002559902

Model-2:

> p.mle<-lmer2(ddimer~race+steroid+psi+sofa+apache + (apache|subject), 
> method="ML", data=final, robust=FALSE, cluster="id", weights=final$w)
> beta=fixef(p.mle)
> Vcov=vcov(p.mle, useScale=FALSE)
> se=sqrt(diag(Vcov))
> beta
 (Intercept) race  steroid  psi sofa   apache 
 5.826489820 -0.001920670 -0.242040171  0.005293996  0.075468340  0.009245152 
> se
[1] 0.108325229 0.058921371 0.055975547 0.001285687 0.018119089 0.002559902


Best Regards, 

Sattar


  


, and more!

[[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] Cox regression and p-values

2007-09-19 Thread Terry Therneau
  Fisher's "exact" test is for comparing two proportions, which is a completely 
different problem than Cox regression, and so the test has no relevance to this 
problem.  It has, however, sparked a large literature of debate; already 
alluded 
to by many of the responses.

  The tests in the coxph table are Wald tests, beta/ se(beta).  For large 
sample 
sizes the Wald, score, and likelihood ratio tests will be equivalent, but for 
small samples the prevailing wisdom is that the likelihood ratio tests are the 
most reliable.  To do the LR test, you need to refit the Cox model without the 
variable of interest.  Then compare the two printouts, one for the full model 
and one for the reduced model: both will contain a line "Likelihood ratio test 
= 
xxx on y df" where xxx and y are numbers.  The LR test for the omitted variable 
is the difference in the two "xxx" values, which is chi-squared with degrees of 
freedom equal to the difference in the "y" values.

Terry Therneau



>I might be barking up the wrong tree here, but I want to make sure I
>have a full understanding of this.  What I would like to know is what
>tests are performed to give the p-values for each variable in the table
>that is the result of coxph regression when the variables are
>categorical only.
>More specifically, when expected counts are less than 5 is the Fisher's
>exact test used instead of the Chi^2 test?

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

2007-09-19 Thread marcg
Dear all

I try to print 9 plots on a page, arranged as the code shows below.

nf <- layout(matrix(c(1,0,2,0,0,3,0,4,0,5,0,6,0,0,0,0,7,0,8,9), 10,2))
layout.show(nf)

but when I try to plot, an error message 
Fehler in plot.new() : Grafikränder zu groß
appears

to verify p.e. with 

plot(runif(10:1)) 

i tried with plot(runif(10:1), ann=F) to produce more space, but neither.

The second question: how to place a cross in the middle of the plot to 
delineate in 4 big fields (containing each 5 plots)

Thanks a lot


--

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Running tcltk From a batch file

2007-09-19 Thread Peter Dalgaard
Jonne Zutt wrote:
> Hi Samuel,
>
> An easy solution is the following. Let the R script wait until a certain
> variable (ok_to_quit) got changed.
>
> Hope it helps,
> Jonne.
>
> ## in a file called test.R
> quit <- function() {
>   .Tcl("set ok_to_quit 1")
>   tkdestroy(tt)
> }
>
> require(tcltk)
> tt <<- tktoplevel()
> OK.but <- tkbutton(tt,text="OK",command=quit)
> tkgrid(OK.but)
> tkfocus(tt)
>
> .Tcl("set ok_to_quit 0")
> .Tcl("vwait ok_to_quit")
>
>   
The tkttest demo does this in a somewhat cleaner fashion (avoiding .Tcl).

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

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


Re: [R] apply

2007-09-19 Thread Dimitris Rizopoulos
it also works with vectors, e.g.

x <- c("Ca00Mn48_0.gout", "Ca01Mn47_0.gout", "Ca01Mn47_1.gout", 
"Ca48Mn00_0.gout")
substr(x, 3, 4)


I hope it helps.

Best,
Dimitris


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

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


- Original Message - 
From: "Roger Mason" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, September 19, 2007 3:03 PM
Subject: [R] apply


> Hello,
>
> I have a list of filenames extracted from a data-frame thus:
>
> files <- main$file
>
> e.g. file[[1]] returns
>
> [1] Ca00Mn48_0.gout
> 4702 Levels: Ca00Mn48_0.gout Ca01Mn47_0.gout Ca01Mn47_1.gout
> ... Ca48Mn00_0.gout
>
> I want to extract the substring that contains the two digits after
> "Ca".  This works on individual entries, e.g. substr(files[[1]],3,4)
> returns "00".
>
> I wish to apply substr() to all the entries in files.  All my 
> efforts
> fail.  Could some kind soul explain how to do what I want?
>
> Thanks,
>
> Roger Mason
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 


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

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


Re: [R] Running tcltk From a batch file

2007-09-19 Thread Jonne Zutt
Hi Samuel,

An easy solution is the following. Let the R script wait until a certain
variable (ok_to_quit) got changed.

Hope it helps,
Jonne.

## in a file called test.R
quit <- function() {
  .Tcl("set ok_to_quit 1")
  tkdestroy(tt)
}

require(tcltk)
tt <<- tktoplevel()
OK.but <- tkbutton(tt,text="OK",command=quit)
tkgrid(OK.but)
tkfocus(tt)

.Tcl("set ok_to_quit 0")
.Tcl("vwait ok_to_quit")

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

2007-09-19 Thread Roger Mason
Hello,

I have a list of filenames extracted from a data-frame thus:

files <- main$file

e.g. file[[1]] returns 

[1] Ca00Mn48_0.gout
4702 Levels: Ca00Mn48_0.gout Ca01Mn47_0.gout Ca01Mn47_1.gout
... Ca48Mn00_0.gout

I want to extract the substring that contains the two digits after
"Ca".  This works on individual entries, e.g. substr(files[[1]],3,4)
returns "00".

I wish to apply substr() to all the entries in files.  All my efforts
fail.  Could some kind soul explain how to do what I want?

Thanks,

Roger Mason

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


Re: [R] function on factors - how best to proceed

2007-09-19 Thread Gustaf Rydevik
On 9/19/07, Karin Lagesen <[EMAIL PROTECTED]> wrote:
> "Gustaf Rydevik" <[EMAIL PROTECTED]> writes:
>
>
> > The second warning message tells you that:
> >  2: the condition has length > 1 and only the first element will be
> > used in: if (terminus > origin)
> >
> > You are comparing two vectors,  which generate a vector of TRUE/FALSE 
> > values.
> > The "if" statement need a single TRUE/FALSE value.
> > Either use a for loop:
> > for (i in 1:nrow(terminus)) {if terminus[i]> origin[i]...}
> > or a nested ifelse statement (which is recommendable on such a big data 
> > set).
>
> Thankyou for your reply! I will certainly try the numeric thing.
>
> Now, for the vector comparison. I can easily see how you would do a
> for loop here, but I am unable to see how a nested ifelse statement
> would work. Could you possibly give me an example?
>
> Thankyou again for your help!
>
> Karin
> --
> Karin Lagesen, PhD student
> [EMAIL PROTECTED]
> http://folk.uio.no/karinlag
>

You replace each instance of "if" with ifelse, inserting a comma after
the logical test, and instead of the else statement.  The end result
would become (if I've not made a mistake):

_
replicator<-rep(c("LEFT","RIGHT"),50)
terminus<-rnorm(100)
origin<-rnorm(100)
begin<-rnorm(100)
length<-sample(1:100,100,replace=T)

d<-ifelse(terminus>origin,
+ifelse(replicator=="LEFT",-((origin-begin))%%length),(begin-origin)),
+ifelse(replicator=="LEFT",(origin-begin),-((begin-origin)%%length))
+)

/Gustaf


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


Re: [R] CRAN mirror for R in India: new one at WBUT, how do we get listed in the CRAN website?

2007-09-19 Thread Vladimir Eremeev

http://cran.r-project.org/mirror-howto.html


Arin Basu-3 wrote:
> 
> Dear All,
> 
> Folks at the West Bengal University of Technology has set up a mirror to
> distribute R and associated packages. Here is the URL:
> 
> http://mirror.wbut.ac.in/CRAN
> 
> This will be helpful for R users in South Asia and the adjoining
> countries.
> I have yet to see the site featured in the CRAN list of mirrors. What
> needs
> to be done? For those of you who are impatient and would like to give it a
> try before CRAN folks link to it, here are the details sent to me by
> Indranil Dasgupta, the maintainer of the WBUT mirror site:
> 
> The CRAN mirror's details are as follows:
> 
> 1. URL : http://mirror.wbut.ac.in/CRAN
> 2. HOSTING INSTITUTION : West Bengal University of Technology
> 3. COUNTRY : INDIA
> 4. CITY : KOLKATA (old name - Calcutta, IATA Identifier code - CCU)
> 5. CONTACT EMAIL : [EMAIL PROTECTED]
> 6. UPDATE FREQUENCY : At 1 AM IST (+0530 GMT) every day.
> 
> Enjoy!
> 
> Best,
> Arin Basu
> 
> 

-- 
View this message in context: 
http://www.nabble.com/CRAN-mirror-for-R-in-India%3A-new-one-at-WBUT%2C-how-do-we-get-listed-in-the-CRAN-website--tf4480498.html#a12776013
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] SEM - standardized path coefficients?

2007-09-19 Thread John Fox
Dear Steve,

My intention was to provide this flexibility via the parameters argument to
path.diagram.sem(), but it isn't implemented. Here's a version that should
do what you want:

- snip 

path.diagram.sem <- function (model, out.file, min.rank = NULL, max.rank =
NULL, 
same.rank = NULL, variables = model$var.names, parameters, 
ignore.double = TRUE, edge.labels = c("names", "values"), 
size = c(8, 8), node.font = c("Helvetica", 14), edge.font =
c("Helvetica", 
10), rank.direction = c("LR", "TB"), digits = 2, ...) 
{
if (!missing(out.file)) {
handle <- file(out.file, "w")
on.exit(close(handle))
}
else handle <- stdout()
edge.labels <- match.arg(edge.labels)
rank.direction <- match.arg(rank.direction)
cat(file = handle, paste("digraph \"", deparse(substitute(model)), 
"\" {\n", sep = ""))
cat(file = handle, paste("  rankdir=", rank.direction, ";\n", 
sep = ""))
cat(file = handle, paste("  size=\"", size[1], ",", size[2], 
"\";\n", sep = ""))
cat(file = handle, paste("  node [fontname=\"", node.font[1], 
"\" fontsize=", node.font[2], " shape=box];\n", sep = ""))
cat(file = handle, paste("  edge [fontname=\"", edge.font[1], 
"\" fontsize=", edge.font[2], "];\n", sep = ""))
cat(file = handle, "  center=1;\n")
if (!is.null(min.rank)) {
min.rank <- paste("\"", min.rank, "\"", sep = "")
min.rank <- gsub(",", "\" \"", gsub(" ", "", min.rank))
cat(file = handle, paste("  {rank=min ", min.rank, "}\n", 
sep = ""))
}
if (!is.null(max.rank)) {
max.rank <- paste("\"", max.rank, "\"", sep = "")
max.rank <- gsub(",", "\" \"", gsub(" ", "", max.rank))
cat(file = handle, paste("  {rank=max ", max.rank, "}\n", 
sep = ""))
}
if (!is.null(same.rank)) {
for (s in 1:length(same.rank)) {
same <- paste("\"", same.rank[s], "\"", sep = "")
same <- gsub(",", "\" \"", gsub(" ", "", same))
cat(file = handle, paste("  {rank=same ", same, "}\n", 
sep = ""))
}
}
latent <- variables[-(1:model$n)]
for (lat in latent) {
cat(file = handle, paste("  \"", lat, "\" [shape=ellipse]\n", 
sep = ""))
}
ram <- model$ram
ram[names(model$coeff), 5] <- model$coeff
rownames(ram)[model$fixed] <- ram[model$fixed, 5]
names <- rownames(ram)
values <- round(ram[, 5], digits)
heads <- ram[, 1]
to <- ram[, 2]
from <- ram[, 3]
labels <- if (!missing(parameters)){ 
if (is.numeric(parameters)) round(parameters, digits) 
else parameters
}
else if (edge.labels == "names") names
else values
direction <- ifelse((heads == 2), " dir=both", "")
for (par in 1:nrow(ram)) {
if ((!ignore.double) || (heads[par] == 1)) 
cat(file = handle, paste("  \"", variables[from[par]], 
"\" -> \"", variables[to[par]], "\" [label=\"", 
labels[par], "\"", direction[par], "];\n", sep = ""))
}
cat(file = handle, "}\n")
}

- snip 

E.g., continuing the example in ?path.diagram,

path.diagram(sem.dhp, min.rank='RIQ, RSES, RParAsp, FParAsp, FSES, FIQ', 
max.rank='ROccAsp, REdAsp, FEdAsp, FOccAsp', 
parameters=standardized.coefficients(sem.dhp)$"Std. Estimate")

I'll put the updated path.diagram.sem() in the sem package when I have a
chance.

I hope this helps,
 John


John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox 
 

> -Original Message-
> From: Steve Powell [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, September 19, 2007 3:33 AM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: [R] SEM - standardized path coefficients?
> 
> Dear list members,
> In sem, std.coef() will give me standardized coefficients 
> from a sem model.
> But is there a trick so that path.diagram can use these 
> coefficients rather than unstandardized ones?
> Thanks
> Steve Powell
> 
> 
> From: John Fox 
> Date: Wed 28 Feb 2007 - 14:37:22 GMT
> 
> 
> Dear Tim,
> 
> See ?standardized.coefficients (after loading the sem package).
> 
> Regards,
>  John
> 
> John Fox
> Department of Sociology
> McMaster University
> Hamilton, Ontario
> Canada L8S 4M4
> 905-525-9140x23604
> http://socserv.mcmaster.ca/jfox
> 
> > -Original Message-
> > From: [EMAIL PROTECTED] 
> > [mailto:[EMAIL PROTECTED] On Behalf Of Tim Holland
> > Sent: Wednesday, February 28, 2007 12:35 AM
> > To: [EMAIL PROTECTED]
> > Subject: [R] SEM - standardized path coefficients?
> >
> > Hello -
> >
> > Does anybody know how to get the SEM package in R to return 
> > standardized path coefficients instead of unstandardized ones? Does 
> >

[R] CRAN mirror for R in India: new one at WBUT, how do we get listed in the CRAN website?

2007-09-19 Thread Arin Basu
Dear All,

Folks at the West Bengal University of Technology has set up a mirror to
distribute R and associated packages. Here is the URL:

http://mirror.wbut.ac.in/CRAN

This will be helpful for R users in South Asia and the adjoining countries.
I have yet to see the site featured in the CRAN list of mirrors. What needs
to be done? For those of you who are impatient and would like to give it a
try before CRAN folks link to it, here are the details sent to me by
Indranil Dasgupta, the maintainer of the WBUT mirror site:

The CRAN mirror's details are as follows:

1. URL : http://mirror.wbut.ac.in/CRAN
2. HOSTING INSTITUTION : West Bengal University of Technology
3. COUNTRY : INDIA
4. CITY : KOLKATA (old name - Calcutta, IATA Identifier code - CCU)
5. CONTACT EMAIL : [EMAIL PROTECTED]
6. UPDATE FREQUENCY : At 1 AM IST (+0530 GMT) every day.

Enjoy!

Best,
Arin Basu

[[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] glmpath error

2007-09-19 Thread Tirthadeep

Then what is the solution?




Duncan Murdoch-2 wrote:
> 
> Tirthadeep wrote:
>> Hi,
>>
>> I am using glampath package for L1 regularized logistic regression. I got
>> the following error messege.
>>
>>   
>>> model.fit <- glmpath(train.data[,1:20], train.data$RES, family=binomial)
>>> 
>> Error in one %*% x : requires numeric matrix/vector arguments
>>
>> where train.data is a 700X21 matrix and 21st column in response (RES).
>>   
> If it is a matrix, then train.data$RES won't work.  That column 
> selection method only works for data frames,
> because they are lists, and matrices aren't.
> 
> Duncan Murdoch
>> Please clarify!!!
>>
>> Thanks
>>
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/glmpath-error-tf4480056.html#a12775820
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] Running tcltk From a batch file

2007-09-19 Thread Samuel Kemp
Hi,

I am trying to run some simple tktcl code

## in a file called test.R
require(tcltk)
tt <- tktoplevel()
OK.but <- tkbutton(tt,text="OK",command=function()tkdestroy(tt))
tkgrid(OK.but)
tkfocus(tt)

Using a batch file with the command

Rterm < test.R > testOutput.Rout --slave

The GUI pops up but then disappears. The results in the test.Output.Routfile are

> # Load the tcltk package
> require(tcltk)
Loading required package: tcltk
[1] TRUE
>
> # Create a new toplevel window
> tt <- tktoplevel()
>
> # Create a button whose function (command) is to destroy the window
> OK.but <- tkbutton(tt,text="OK",command=function()tkdestroy(tt))
>
> # Place the button on the window, using the grid manager.
> tkgrid(OK.but)

> tkfocus(tt)

>

Does anyone know how to make the GUI stay open?

Kind regards,

Sam

[[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] layout function for several plots

2007-09-19 Thread marcg
Dear all

I try to print 9 plots on a page, arranged as the code shows below.

nf <- layout(matrix(c(1,0,2,0,0,3,0,4,0,5,0,6,0,0,0,0,7,0,8,9), 10,2))
layout.show(nf)

but when I try to plot, an error message 
Fehler in plot.new() : Grafikränder zu groß
appears

to verify p.e. with 

plot(runif(10:1)) 

i tried with plot(runif(10:1), ann=F) to produce more space, but neither.

The second question: how to place a cross in the middle of the plot to 
delineate in 4 big fields (containing each 5 plots)

Thanks a lot


--

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

2007-09-19 Thread Duncan Murdoch
Tirthadeep wrote:
> Hi,
>
> I am using glampath package for L1 regularized logistic regression. I got
> the following error messege.
>
>   
>> model.fit <- glmpath(train.data[,1:20], train.data$RES, family=binomial)
>> 
> Error in one %*% x : requires numeric matrix/vector arguments
>
> where train.data is a 700X21 matrix and 21st column in response (RES).
>   
If it is a matrix, then train.data$RES won't work.  That column 
selection method only works for data frames,
because they are lists, and matrices aren't.

Duncan Murdoch
> Please clarify!!!
>
> Thanks
>

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

2007-09-19 Thread Tirthadeep


Hi,

I am using glampath package for L1 regularized logistic regression. I got
the following error messege.

> model.fit <- glmpath(train.data[,1:20], train.data$RES, family=binomial)
Error in one %*% x : requires numeric matrix/vector arguments

where train.data is a 700X21 matrix and 21st column in response (RES).

Please clarify!!!

Thanks
-- 
View this message in context: 
http://www.nabble.com/glmpath-error-tf4480056.html#a12774607
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] handling multiple files; was: R advice

2007-09-19 Thread Uwe Ligges
Handling multiple files automatically is easy in R and has been answered 
several times on this list: please pok up the archives as suggested in 
the posting guide to this list which also asks you to use a sensible 
subject line.
Additionally, there is a FAQ entry called "How can I save the result of 
each iteration in a loop into a separate file?". I am sure you can adapt 
it to read files as well.

Uwe Ligges



Daniel White wrote:
>  
> 
> Dear R-help
> 
>  
> 
> As a novice to R I was seeking some advice with respect to using R to
> help solve a problem I have. 
> 
> I have a large number of infiles that need analysed. This can be done, I
> believe, using 2 separate R packages (popgen and ape) with the output
> from 'popgen' being used as input for 'ape'. What I would like to know
> is whether it is possible within R to write some script so that these
> files can be read from a folder outside the R space (say a folder within
> the C drive of my computer) and processed without having to re-initiate
> each individual infile?
> 
> If this is possible I would then work on the problem of trying to link
> the output from the first package with the second.
> 
>  
> 
> Many thanks for any advice given here.
> 
>  
> 
> Dan White 
> 
>  
> 
> 
>   [[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] x and y coordinates (Rfwdmv Package)

2007-09-19 Thread gigis.mail
Hello R users,

before asking my question I'd like to stress that I'm an (absolute)
beginner in using R, but enthused about the incredible possibilities of
it.
So I hope my questions are not too stupid.

Here's my problem:

I have a dataset with skewed distributions. In order to obtain approx
multivariate normality by a Box-Cox-Transformation, I used the "Rfwdmv
Package" to estimate a common value of lambda for all the variables.

Therefore I entered the following R commands:
data(my.dat)
l.mle <- fwdtr(my.dat, lambda = 1/3, one.lambda = TRUE)
l.profile.mle <- profile.fwdtr(l.mle)
fwdtrProfilePlot(l.profile.mle)
fwdtrMlePlot(l.mle).

Everything worked well so far and I obtained the plots in question.

The problem is: In these plots I just can see that lambda is roughly
around 1.4, but it could be 1.35 or 1.45 or somewhat in between. The
same problem occurs with the log-likelihoods and the confidence
intervals.

Now my question is:

Is there a possibility obtaining the EXACT log-likelihoods, confidence
intervals and, first of all, lambda values ?

Or more general: How can I obtain the x (or y) value for a specific
(e.g. maximum) y (or x) of a plot in R ?

I would be very grateful if one could give me a lead.

Thank you very much in advance.

With best regards,

Juergen

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] x and y coordinates (Rfwdmv Package)

2007-09-19 Thread J. Däbritz
Hello R users,

before asking my question I'd like to stress that I'm an (absolute)
beginner in using R, but enthused about the incredible possibilities of
it.
So I hope my questions are not too stupid.

Here's my problem:

I have a dataset with skewed distributions. In order to obtain approx
multivariate normality by a Box-Cox-Transformation, I used the "Rfwdmv
Package" to estimate a common value of lambda for all the variables.

Therefore I entered the following R commands:
data(my.dat)
l.mle <- fwdtr(my.dat, lambda = 1/3, one.lambda = TRUE)
l.profile.mle <- profile.fwdtr(l.mle)
fwdtrProfilePlot(l.profile.mle)
fwdtrMlePlot(l.mle).

Everything worked well so far and I obtained the plots in question.

The problem is: In these plots I just can see that lambda is roughly
around 1.4, but it could be 1.35 or 1.45 or somewhat in between. The
same problem occurs with the log-likelihoods and the confidence
intervals.

Now my question is:

Is there a possibility obtaining the EXACT log-likelihoods, confidence
intervals and, first of all, lambda values ?

Or more general: How can I obtain the x (or y) value for a specific
(e.g. maximum) y (or x) of a plot in R ?

I would be very grateful if one could give me a lead.

Thank you very much in advance.

With best regards,

Juergen

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] independent plotting of predicted terms with gamlss

2007-09-19 Thread Nikolaus Umlauf
Hi!

I want to create a plot of a predicted term similar to the function term.plot()
in the gamlss package. I have tried several options, but I could not work it
out so far...

Thank you for your help!

Nikolaus

here is my example:

library(gamlss)
data(rent)
attach(rent)

# Estimating some model
rent.model <- gamlss(R ~ ps(Fl)+ps(A)+Sp+Sm, family="NO")
summary(rent.model)

# Predicting the values for term A
A_pred <- predict(rent.model, type="terms", what="mu", terms=2, se.fit=TRUE)

# Calculating only the fitted values without se.fit
fitted_A <- A_pred$fit

# This is my problem: I want to plot the fitted smooth function without using
the R function term.plot(), but the function lines() computes an unuseful
graph...
plot(A, fitted_A, type="n")
lines(A, fitted_A)

# I want to create a plot like term.plot() does
term.plot(rent.model, terms=2, se=TRUE)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] recommended package/docs for analyzing multiple choice tests

2007-09-19 Thread Dimitris Rizopoulos
In ltm (version 0.8-1) you may also check the following functions: 
descript(), cronbach.alpha(), mult.choice()

I hope it helps.

Best,
Dimitris

ps, you may find more information about `ltm' as well as sample 
analysis files at the Rwiki page: 
http://wiki.r-project.org/rwiki/doku.php?id=packages:cran:ltm


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

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


- Original Message - 
From: "Doug Holton" <[EMAIL PROTECTED]>
To: 
Sent: Wednesday, September 19, 2007 2:36 AM
Subject: [R] recommended package/docs for analyzing multiple choice 
tests


> Hi,
>  What package would you recommend for analyzing the
> validity/reliability of multiple choice tests.  Doing things such as
> classical test analysis, factor analysis, item response theory.
>
> I've used psychometric (item.exam), MiscPsycho (alpha.Summary), and 
> ltm
> (rcor.test).  MiscPsycho reported the numbers most similar to what I 
> get
> in SPSS: corrected point biserial correlations, cronbach's alpha.  I
> didn't understand what the psychometric package meant by its
> "discrimination" and "item reliability" numbers output by the 
> item.exam
> function.  Perhaps the former is uncorrected point biserial
> correlations?  They were higher values.  I downloaded and inspected
> the source code for both packages.  It was hard to understand what 
> the
> functions were doing without some comments in the code.
>
> Also, would you recommend a book or resource with examples of using 
> R
> for test analysis.
>
> Thank you, it's been great learning R,
> -Doug
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 


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

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


Re: [R] xyplot question

2007-09-19 Thread Wayne.W.Jones
The following link is an excellent reference which gives R code for making 
different plots in R. 

http://addictedtor.free.fr/graphiques/thumbs.php


Is it something like this you want: 

http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=52

The code can be found to do this on the webpage. 

Regards

Wayne



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Raymond Balise
Sent: 18 September 2007 23:52
To: [EMAIL PROTECTED]
Subject: [R] xyplot question


I am tring to add error bars to data in an xyplot.  Below is the
content of a CSV file that I am trying to use and the code which plots
the data points and 45 degree lines in each of the panes of the
trellice.  I want to add error bars that go up and down to the limits
set by the lcl and ucl values in the data set.  How the heck can I
specify the error bars in a lattice plot?

If anyone knows how to do this can you please tell me how to do it and
more importantly point me toward a book/paper that explains how to do
this and has examples. :~)  As always, help is profoundly appreciated.

fig2 = read.xls("figure2.csv")

library(lattice)
library(grid)

with(fig2,
  xyplot(y ~ x |  group * Method,
  xlab = "",
  xlim = c(-5, 1),
  ylab = "",
  ylim = c(-5, 1),
  col = "black",
  groups = group,
  aspect = 1,
  lx = lcl,
  ux = ucl,
  pch = 16 ,
  panel = function(x, y, ...) {
 panel.superpose(x, y, ...)
 panel.abline(0, 1)

 },
 )
)

## some sample data for a CSV file 

Method,group,x,y,lcl,ucl
A,Black,-3.018626791,-1.461326791,-2.068936791,-0.867106791
A,Black,-3.304632403,-2.608322403,-3.463632403,-1.768972403
A,Black,-2.673500283,-2.100820283,-2.708560283,-1.507230283
A,Black,-1.700734807,-0.887104807,-1.275424807,-0.524394807
A,Black,-0.586121342,-0.848638342,-1.169118342,-0.551044342
A,Yellow,-3.136580929,-1.120380929,-1.720710929,-0.550799929
A,Yellow,-2.757574147,-1.021674147,-1.474644147,-0.600298147
A,Yellow,-2.17890461,-0.89563461,-1.34797461,-0.47309861
A,Yellow,-1.812551095,-0.920201095,-1.215711095,-0.639398095
A,Yellow,-1.054284002,-1.195239002,-1.453922002,-0.956836002
A,Green,-1.639312507,-4.174222507,-4.174222507,-4.174222507
A,Green,-1.23917727,-0.30492427,-0.68852327,-0.21611447
A,Green,-0.66966805,-1.13230605,-1.99186605,-0.49901105
A,Green,0.278895635,0.096514635,-0.301298365,0.300602935
A,Green,-0.504911532,-0.894806332,-1.378339332,-0.603663332
A,Blue,-2.969196277,-3.693096277,-3.820696277,-1.384526277
A,Blue,-2.419573959,-2.280913959,-2.894093959,-1.672893959
A,Blue,-1.773659064,-1.850719064,-2.450169064,-1.260569064
A,Blue,-1.510092543,-0.851495543,-1.439472543,-0.411152543
A,Blue,-0.595168746,-0.998596746,-1.208087746,-0.805696746
B,Black,-2.459224263,-1.757114263,-2.364714263,-1.162324263
B,Black,-1.817291831,-1.704651831,-2.557361831,-0.868041831
B,Black,-2.495591512,-2.614881512,-3.456411512,-1.789931512
B,Black,-1.216945891,-0.928095891,-1.315455891,-0.557498891
B,Black,-0.500977651,-0.518668651,-0.817970651,-0.249855651
B,Yellow,-2.473182951,-1.310892951,-1.909672951,-0.741403951
B,Yellow,-2.08297,-0.856005297,-1.252555297,-0.489987297
B,Yellow,-2.249602851,-1.539112851,-2.010652851,-1.093110851
B,Yellow,-1.406241001,-0.872741001,-1.183891001,-0.577481001
B,Yellow,-0.953045757,-0.981668757,-1.241857757,-0.740871757
B,Green,-2.487720209,-4.310240209,-4.310240209,-4.310240209
B,Green,-2.472235352,-0.579902352,-0.963501352,-0.491092552
B,Green,-1.35388464,-0.39377464,-0.99212464,0.00267836
B,Green,-1.20222519,-0.58276419,-1.05847819,-0.30239519
B,Green,-0.155542679,-0.302979679,-0.795866679,-0.000590679
B,Blue,-2.467137219,-2.879317219,-3.541517219,-2.219037219
B,Blue,-2.093208678,-2.467378678,-3.037568678,-1.901558678
B,Blue,-1.968546702,-1.171728702,-1.881726702,-0.642598702
B,Blue,-1.067931387,-1.109401387,-1.445171387,-0.785811387
B,Blue,-0.936799562,-1.166112562,-1.361216562,-0.987562562

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

2007-09-19 Thread Alexandre Courtiol
 Dear all, I try to consider overdispersion in a lmer model. But using
family=quasibinomial rather than family=binomial seems to change the fit but
not the result of an anova test. In addition if we specify test="F" as it is
recomanded for glm using quasibinomial, the test remains a Chisq test. Are
all tests scaled for dispersion, or none? Why is there a difference between
glm and lmer for this? And why summary does not test estimates only in the
quasibinomial case? Thank you.

Here is an simple example using a simulated dataset (with anova tests at the
end):

library(lme4)
Y1<-sample(c(rbinom(90,10,0.1),rbinom(90,10,0.7)))
Y2<-10-Y1
Y<-cbind(Y1,Y2)
Group<-c(rep("A",80),rep("B",50),rep("C",50))
Group<-as.factor(sample(Group))
X<-Y1*rnorm(180,mean=0,sd=10)

mod0<-lmer(Y~X+(1|Group),family=binomial) #model using binomial family
summary(mod0)

Generalized linear mixed model fit using Laplace
Formula: Y ~ X + (1 | Group)
Family: binomial(logit link)
AIC BIC logLik deviance
872.9 882.4 -433.4 866.9
Random effects:
Groups Name Variance Std.Dev.
Group (Intercept) 0.012863 0.11341
number of obs: 180, groups: Group, 3
Estimated scale (compare to 1 ) 2.025698
Fixed effects:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -0.451023 0.082160 -5.490 4.03e-08 ***
X 0.002388 0.001092 2.187 0.0287 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Correlation of Fixed Effects:
(Intr)
X -0.076

mod1<-lmer(Y~X+(1|Group),family=quasibinomial)#model using quasibinomial
family
summary(mod1)
Generalized linear mixed model fit using Laplace
Formula: Y ~ X + (1 | Group)
Family: quasibinomial(logit link)
AIC BIC logLik deviance
872.9 882.4 -433.4 866.9
Random effects:
Groups Name Variance Std.Dev.
Group (Intercept) 0.052785 0.22975
Residual 4.103452 2.02570
number of obs: 180, groups: Group, 3
Fixed effects:
Estimate Std. Error t value
(Intercept) -0.451020 0.166434 -2.710
X 0.002389 0.002212 1.080
Correlation of Fixed Effects:
(Intr)
X -0.076

mod0ML<-lmer(Y~X+(1|Group),family=binomial,type="ML")
mod0NULLML<-lmer(Y~1+(1|Group),family=binomial,type="ML")
anova(mod0ML,mod0NULLML)

mod0NULLML: Y ~ 1 + (1 | Group)
mod0ML: Y ~ X + (1 | Group)
Df AIC BIC logLik Chisq Chi Df Pr(>Chisq)
mod0NULLML 2 875.68 882.07 -435.84
mod0ML 3 872.85 882.43 -433.43 4.8307 1 0.02796 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

mod1ML<-lmer(Y~X+(1|Group),family=quasibinomial,type="ML")
mod1NULLML<-lmer(Y~1+(1|Group),family=quasibinomial,type="ML")
anova(mod1ML,mod1NULLML,test="F")

mod1NULLML: Y ~ 1 + (1 | Group)
mod1ML: Y ~ X + (1 | Group)
Df AIC BIC logLik Chisq Chi Df Pr(>Chisq)# F test does not occur!!!
mod1NULLML 2 875.68 882.07 -435.84
mod1ML 3 872.85 882.43 -433.43 4.8307 1 0.02796 *
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

[[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] SEM - standardized path coefficients?

2007-09-19 Thread Steve Powell
Dear list members,
In sem, std.coef() will give me standardized coefficients from a sem model.
But is there a trick so that path.diagram can use these coefficients rather
than unstandardized ones?
Thanks
Steve Powell


From: John Fox 
Date: Wed 28 Feb 2007 - 14:37:22 GMT


Dear Tim,

See ?standardized.coefficients (after loading the sem package).

Regards,
 John

John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox

> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Tim Holland
> Sent: Wednesday, February 28, 2007 12:35 AM
> To: [EMAIL PROTECTED]
> Subject: [R] SEM - standardized path coefficients?
>
> Hello -
>
> Does anybody know how to get the SEM package in R to return
> standardized path coefficients instead of unstandardized
> ones? Does this involve changing the covariance matrix, or
> is there an argument in the SEM itself that can be changed?
>
> Thank you,
> Tim
>
> [[alternative HTML version deleted]]
>
> __
> [EMAIL PROTECTED] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code. 

Steve Powell

 
proMENTE social research 
research | evaluation | training & consulting 
Kranjčevićeva 35, 71000 Sarajevo 
mobile: +387 61 215 997 | office: +387 33 556 865 | fax: +387 33 556 866
skype: stevepowell99 
www.promente.org  |  www.mojakarijera.com  |  www.psih.org  


Checked by AVG Free Edition. 

18.09.2007
11:53
 

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