Re: [R] install packages automatically

2007-09-10 Thread Ross Darnell
Try

?update.packages

Ross Darnell

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Wensui Liu
Sent: Tuesday, 11 September 2007 11:45 AM
To: r-help@stat.math.ethz.ch
Subject: [R] install packages automatically

Dear Listers,
I am a little tired of installing all packages I want every time when
I instill a new version of R.
Say, if I have a list of packages I need to use, is it possible to
tell R to install them all for me automatically rather than I install
them one by one?
Thx.

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


Re: [R] lattice panel.lmline problem

2007-09-10 Thread Ross Darnell
Thanks Frede

I didn't know about the "r" type. 

Ross Darnell


-Original Message-
From: Frede Aakmann Tøgersen [mailto:[EMAIL PROTECTED]
Sent: Mon 10-Sep-07 4:45 PM
To: Ross Darnell; r-help@stat.math.ethz.ch
Subject: SV: [R] lattice panel.lmline problem
 
Why not use the more simple

xyplot(total.fat~x|variable,groups=Group,
   data=tmp1,type=c("p","r"))

???

See ?panel.xyplot and especially the type argument of that panel function.




Best regards

Frede Aakmann Tøgersen
Scientist


UNIVERSITY OF AARHUS
Faculty of Agricultural Sciences
Dept. of Genetics and Biotechnology
Blichers Allé 20, P.O. BOX 50
DK-8830 Tjele

Phone:   +45 8999 1900
Direct:  +45 8999 1878

E-mail:  [EMAIL PROTECTED]
Web:   http://www.agrsci.org

This email may contain information that is confidential.
Any use or publication of this email without written permission from Faculty of 
Agricultural Sciences is not allowed.
If you are not the intended recipient, please notify Faculty of Agricultural 
Sciences immediately and delete this email.


 

> -Oprindelig meddelelse-
> Fra: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] På vegne af Ross Darnell
> Sendt: 10. september 2007 07:55
> Til: r-help@stat.math.ethz.ch
> Emne: [R] lattice panel.lmline problem
> 
> I am wanting to generate panels showing scatterplots with the 
> linear fitted line for two groups within each panel superimposed.
> 
> I have two conditioning factors, "variable" and "Group" and I 
> want separate panels for each level of "variable"
> 
> with different symbols and "lmline"s for each level of 
> "Group". However all observations for a group are missing for 
> some variables so I would still like the points and lmline 
> for the observed group plotted for that variable(panel).
> 
>  
> 
> My attempt is 
> 
>  
> 
> print(xyplot(total.fat~x|variable,data=tmp1,subscripts=TRUE,
> 
>  
> scales=list(x=list(relation="free")),xlab="",groups=Group,
> 
>  panel=function(x,y,subscripts,...){
> 
>panel.superpose(x,y,subscripts,...)
> 
>if(length(x[subscripts])!=0)
> 
>  
> {panel.superpose(x,y,panel.groups="panel.lmline",subscripts,...)}}))
> 
>  
> 
> Which gives an error
> 
>  
> 
> Error in lm.fit(x, y, offset = offset, singular.ok = 
> singular.ok, ...) :
> 
> 
> 0 (non-NA) cases
> 
> > 
> 
>  
> 
> Which occurs when the first panel with all values for one 
> group are missing.
> 
> The same error is returned if I replace the last line without the "if"
> statement which obviously means it's ignored.
> 
>  
> 
> Of course I may be taking the wrong tack completely to get 
> the result I need. Any advice would be appreciated
> 
>   
> 
>  
> 
> Ross Darnell
> 
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 


[[alternative HTML version deleted]]

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


[R] lattice panel.lmline problem

2007-09-09 Thread Ross Darnell
I am wanting to generate panels showing scatterplots with the linear
fitted line for two groups within each panel superimposed.

I have two conditioning factors, "variable" and "Group" and I want
separate panels for each level of "variable"

with different symbols and "lmline"s for each level of "Group". However
all observations for a group are missing for some variables so I would
still like the points and lmline for the observed group plotted for that
variable(panel).

 

My attempt is 

 

print(xyplot(total.fat~x|variable,data=tmp1,subscripts=TRUE,

 scales=list(x=list(relation="free")),xlab="",groups=Group,

 panel=function(x,y,subscripts,...){

   panel.superpose(x,y,subscripts,...)

   if(length(x[subscripts])!=0)

 
{panel.superpose(x,y,panel.groups="panel.lmline",subscripts,...)}}))

 

Which gives an error

 

Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) :


0 (non-NA) cases

> 

 

Which occurs when the first panel with all values for one group are
missing.

The same error is returned if I replace the last line without the "if"
statement which obviously means it's ignored.

 

Of course I may be taking the wrong tack completely to get the result I
need. Any advice would be appreciated

  

 

Ross Darnell


[[alternative HTML version deleted]]

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


Re: [R] Question on graphs and simple if statements

2007-09-02 Thread Ross Darnell
The answer to your first question is

curve(ifelse((x>-1)&(x<1),x^2+1,x+2),from=-10,to=10)

Sorry I cannot understand the next part of your query.

Ross Darnell

On Sun, 2007-09-02 at 00:31 -0700, JHawk3 wrote:
> Hi all,
> 
> I'm a relatively new user to the R interface, and am trying to do some basic
> operations. So far I've used the curve() command to plot graphs. This has a
> couple of limitations, namely trying to do piecewise graphs. Basically, I'm
> looking for how to do "if" and "while" loops for making a graph.
> 
> in simple code, something like:
> 
> if x is on the interval [-1,1], x=x^2+1
> otherwise, x=x^2
> 
> something along those lines. I also am wondering if it's possible to graph
> something like this:
> while(n<20)
> {
> curve(1/n^2, -1,1)
> n++
> }
> Along these same lines, is there a way to graph finite series?
> 
> Thank you for your time and your replies.
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] customizing the color and point shape for each line drawn using lattice's xyplot

2007-08-30 Thread Ross Darnell
Then you can regenerate the factor by

common.without.Method4 <- subset(common, Method!=4)

common.without.Method4 <- transform(common.without.Method4,
Method = factor(Method))

Ross Darnell

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Gen
Sent: Friday, 31 August 2007 1:42 AM
To: r-help@stat.math.ethz.ch
Subject: Re: [R] customizing the color and point shape for each line
drawn using lattice's xyplot


Thank you for your suggestion. Unfortunately it does not appear to
matter if
the data is subsetted before the xyplot command or within it.  The
problem
remains. 

I was able to remove method 4 entirely from the key by using your
suggestion
to subset the dataset "common," and then creating a new variable to
assign
labels for just this subset "common.without.Method4$method.not4.f"  The
resulting code was:

xyplot(MeanBxg ~ PercentVarExplained | bdg.f * bdx.f,
data=common.without.Method4, groups=method.not4.f, type="l",
auto.key=T)

This however leads to lack of continuity between plots, as when I
exclude
methods 4 and 6 in my second plot, using the same approach, the color
that
had corresponds to methods 7, 8 and 9 in plot one is automatically
changed
in plot two.  The subsetting may work, so long as I can dictate line
color
and symbol type in each plot. 



Ross Darnell wrote:
> 
> Does this help
> 
> common.without.Method4 <- subset(common, Method!=4)
> xyplot(MeanBxg ~ PercentVarExplained | bdg.f * bdx.f,
> data=common.without.Method4,
> groups=Method.f, type="l",  auto.key=T)
> 
> Ross Darnell
> 
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Gen
> Sent: Thursday, 30 August 2007 2:51 PM
> To: r-help@stat.math.ethz.ch
> Subject: [R] customizing the color and point shape for each line drawn
> using lattice's xyplot
> 
> 
> Description of what I am trying to do:
> I am using the xyplot code below to plot the variable "MeanBxg"
against
> the
> variable "PercentVarExplained" for all 9 possible combinations of
> variables
> "bdg" and "bdx".  Within each of these 9 scenarios I am plotting a
> separate
> line for each of up to 9 different methods that I used to estimate the
> variable MeanBxg. These methods are identified by the numeric variable
> called "Method."  Giving me one plot with 9 figures and each of the
> figures
> contains 9 lines. 
> 
> My problem arises because I would like to repeat the creation of this
> plot 8
> times, in each instance only a subset (eg 6) of the 9 methods are used
> (a
> different subset each time). 
> 
> What I can't figure out:
> I would like to learn how to specify the exact line color that
> corresponds
> to each method such that Method==1 will always be represented by the
> same
> color (in every plot that it appears in).  Where two methods that I
used
> were of the same family of methods (say method==1 and method==2 made
the
> same assumptions about the data)  I would like to, if possible,
> represent
> the two methods using the same color and distinguish them by the
symbol
> used
> to represent points on the line. 
> 
> My code as it currently stands:
> xyplot(MeanBxg ~ PercentVarExplained | bdg.f * bdx.f, data=common,
> groups=common$Method.f, type="l", subset= Method!=4, auto.key=T)
> 
> As the code is, the default colors assigned are repeated causing
> different
> methods to be represented by the same color with no way to distinguish
> them
> (I have not succeeded in plotting lines and points simultaneously).  
> 
> Side question: When I subset the data to particular methods, is there
a
> way
> to remove the excluded methods from the key as well? (in my code
> "Method" is
> a numeric variable, and "Method.f" corresponds to the lengthy
> descriptions
> of each method for the purpose of the key)
> 
> Thank you very much for your help. 
> Genevieve
> 
> 
> 
> -- 
> View this message in context:
>
http://www.nabble.com/customizing-the-color-and-point-shape-for-each-lin
> e-drawn-using-lattice%27s-xyplot-tf4351934.html#a12400517
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
> https://

Re: [R] customizing the color and point shape for each line drawn using lattice's xyplot

2007-08-30 Thread Ross Darnell
Does this help

common.without.Method4 <- subset(common, Method!=4)
xyplot(MeanBxg ~ PercentVarExplained | bdg.f * bdx.f,
data=common.without.Method4,
groups=Method.f, type="l",  auto.key=T)

Ross Darnell

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Gen
Sent: Thursday, 30 August 2007 2:51 PM
To: r-help@stat.math.ethz.ch
Subject: [R] customizing the color and point shape for each line drawn
using lattice's xyplot


Description of what I am trying to do:
I am using the xyplot code below to plot the variable "MeanBxg" against
the
variable "PercentVarExplained" for all 9 possible combinations of
variables
"bdg" and "bdx".  Within each of these 9 scenarios I am plotting a
separate
line for each of up to 9 different methods that I used to estimate the
variable MeanBxg. These methods are identified by the numeric variable
called "Method."  Giving me one plot with 9 figures and each of the
figures
contains 9 lines. 

My problem arises because I would like to repeat the creation of this
plot 8
times, in each instance only a subset (eg 6) of the 9 methods are used
(a
different subset each time). 

What I can't figure out:
I would like to learn how to specify the exact line color that
corresponds
to each method such that Method==1 will always be represented by the
same
color (in every plot that it appears in).  Where two methods that I used
were of the same family of methods (say method==1 and method==2 made the
same assumptions about the data)  I would like to, if possible,
represent
the two methods using the same color and distinguish them by the symbol
used
to represent points on the line. 

My code as it currently stands:
xyplot(MeanBxg ~ PercentVarExplained | bdg.f * bdx.f, data=common,
groups=common$Method.f, type="l", subset= Method!=4, auto.key=T)

As the code is, the default colors assigned are repeated causing
different
methods to be represented by the same color with no way to distinguish
them
(I have not succeeded in plotting lines and points simultaneously).  

Side question: When I subset the data to particular methods, is there a
way
to remove the excluded methods from the key as well? (in my code
"Method" is
a numeric variable, and "Method.f" corresponds to the lengthy
descriptions
of each method for the purpose of the key)

Thank you very much for your help. 
Genevieve



-- 
View this message in context:
http://www.nabble.com/customizing-the-color-and-point-shape-for-each-lin
e-drawn-using-lattice%27s-xyplot-tf4351934.html#a12400517
Sent from the R help mailing list archive at Nabble.com.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Conditional subsetting

2007-08-07 Thread Ross Darnell

Assuming *A* animal can only be in one location at any one time, I don't 
understand how once you have selected the location nearest 12pm how you can 
select based on the type of location?
Do you mean to select on location before timei.e. from the best location 
visited that day which was closest to 12pm?

Perhaps for condition 2  for a animal which.min(time-1200) (replace 1200 with 
properly defined timestamp representing 12:00pm)

Ross Darnell
  


-Original Message-
From: [EMAIL PROTECTED] on behalf of Tim Sippel
Sent: Wed 08-Aug-07 9:37 AM
To: r-help@stat.math.ethz.ch
Subject: [R] Conditional subsetting
 
Hello-

Upon searching the email archives and reading documentation I haven't found
what I'm looking for.  I have a dataset with a time/date stamp on a series
of geographic locations (lat/lon) associated with the movements of animals.
On some days there are numerous locations and some days there is only one
location.  Associated with each location is an indication that the quality
of the location is either "good", "poor", or "unknown".  For each animal, I
want to extract only one location for each day.  And I want the location
extracted to be nearest to 12pm on any given day, and highest quality
possible.  

So the order of priority for my extraction will be: 1. only one location per
animal each day; 2. the location selected be as close to 12pm as possible;
3. the selected location comes from the best locations available (ie. take
from pool of "good" locations first, or select from "poor" locations if a
"good" location isn't available, or "unknown" if nothing else is available).


 

I think aspect of this task that has me particularly stumped is how to
select only one location for each day, and for that location to be a close
to 12pm as possible.  

 

An example of my dataset follows:

 



DeployID

 

Date.Time

 

LocationQuality

Latitude

Longitude


STM05-1

 

28/02/2005 17:35

 

Good

-35.562

177.158


STM05-1

 

28/02/2005 19:44

 

Good

-35.487

177.129


STM05-1

 

28/02/2005 23:01

 

Unknown

-35.399

177.064


STM05-1

 

01/03/2005 07:28

 

Unknown

-34.978

177.268


STM05-1

 

01/03/2005 18:06

 

Poor

-34.799

177.027


STM05-1

 

01/03/2005 18:47

 

Poor

-34.85

177.059


STM05-2

 

28/02/2005 12:49

 

Good

-35.928

177.328


STM05-2

 

28/02/2005 21:23

 

Poor

-35.926

177.314

 

 

 

 

 

 

 

 

 

 

 

 

 

 


 

 

 

 

 

 

 

 

 

 

 

Many thanks for your input.  I'm using R 2.5.1 on Windows XP.  

 

Cheers,

 

Tim Sippel (MSc)

School of Biological Sciences

Auckland University

Private Bag 92019

Auckland 1020

New Zealand

+64-9-373-7599 ext. 84589 (work)

+64-9-373-7668 (Fax)

+64-21-593-001 (mobile)

 


[[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


Re: [R] problem with reading data files with different numbers of lines to skips

2007-08-02 Thread Ross Darnell

You could read the file and test each line (try readline()) but you need some 
rule to distinguish between text lines and data lines. You could then reread 
the file with the number of skip lines defined.

Ross Darnell 

-Original Message-
From: [EMAIL PROTECTED] on behalf of Tom Cohen
Sent: Fri 03-Aug-07 7:14 AM
To: r-help@stat.math.ethz.ch
Subject: [R] problem with reading data files with different numbers of lines
to skips
 
Dear  List, 
   
  I have 30 data files with different numbers of lines (31 and 33) that I want 
to skip before reading the files. If I use the skip option I can only choose 
either to skip 31 or 33 lines. The data files with 31 lines have no blank rows 
between the lines and the header row. How can I read the files without manually 
checking which files have 31 respectively 33 lines ?  The only text line I want 
to keep is the header.
   
  Thamks for your help,
  Tom
   
   
  for (i in 1:num.files) {
   a<-read.table(file=data[i],
  ,header=T,skip=31,sep='\t',na.strings="NA") 
  
  }
   
   
   

   
-
Går det långsamt? Skaffa dig en snabbare bredbandsuppkoppling.

[[alternative HTML version deleted]]



[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Convert string to list?

2007-07-26 Thread Ross Darnell
Manuel

Jim's may be what you want-- a list of numerics with names P, T and Q or
a list of character strings?

> str <- "P = 0.0, T = 0.0, Q = 0.0"

> str(as.vector(unlist(strsplit(str,",")),mode="list"))
List of 3
 $ : chr "P = 0.0"
 $ : chr " T = 0.0"
 $ : chr " Q = 0.0"



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of jim holtman
Sent: Friday, 27 July 2007 11:20 AM
To: Manuel Morales
Cc: r-help
Subject: Re: [R] Convert string to list?

Is this what you want:

> str <- "P = 0.0, T = 0.0, Q = 0.0"
> x <- eval(parse(text=paste('list(', str, ')')))
> str(x)
List of 3
 $ P: num 0
 $ T: num 0
 $ Q: num 0
>


On 7/26/07, Manuel Morales <[EMAIL PROTECTED]> wrote:
> Let's say I have the following string:
>
> str <- "P = 0.0, T = 0.0, Q = 0.0"
>
> I'd like to find a function that generates the following object from
> 'str'.
>
> list(P = 0.0, T = 0.0, Q = 0.0)
>
> Thanks!
>
> --
> http://mutualism.williams.edu
>
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Convert string to list?

2007-07-26 Thread Ross Darnell
Is this what your want?


as.vector(unlist(strsplit(str,",")),mode="list")


Ross Darnell

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Manuel Morales
Sent: Friday, 27 July 2007 10:39 AM
To: r-help
Subject: [R] Convert string to list?

Let's say I have the following string:

str <- "P = 0.0, T = 0.0, Q = 0.0"

I'd like to find a function that generates the following object from
'str'.

list(P = 0.0, T = 0.0, Q = 0.0)

Thanks!

-- 
http://mutualism.williams.edu

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] questions on lme function

2007-07-04 Thread Dr Ross Darnell
Ana

You are estimating a random coefficient model on 5 individuals (mean 
and variance). Are you sure this is wise?

Ross Darnell 

- Original Message -
From: Ana Conesa <[EMAIL PROTECTED]>
Date: Thursday, July 5, 2007 1:21 am
Subject: [R] questions on lme function
> 
> Dear list,
> 
> I am using the lme funcion to fit a mixed model for the time response
> of a number of physiological variables. The random variable would be
> the individual on which physiological variables are measured at
> different time points. I have 4 time points, 5 individuals and 3
> replicates per condition (time/individual),  and I would like to fit
> a quadratic model on time. The model I am using is
> 
> > mm <- lme(myvar ~ time + time2, random= ~ time|individual,
> data=clinical)
> 
> being time2 = time*time
> 
> I have a number of questions
> 
> 1) I am not very sure the random effect is correctly modeled. 
> Would I
> need to include the time2 variable aswell?
> 
> 2) I would like to extract the F statistics of the model, and I do
> not find a function for this. Is this possible?
> 
> 3) depending of the variable I take, I frequently obtain a
> convergence error as a result of the lme funcion. Any ideas on what
> to do to improve convergence?
> 
> Thank you
> 
> Ana Conesa, PhD
> Centro de Investigacion Principe Felipe
> Avda. Autopista Saler 16 46013 Valencia
> http://bioinfo.cipf.es
> 
> __
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.htmland provide commented, minimal, self-contained, 
> reproducible code.
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Log-likelihood function

2007-05-02 Thread Ross Darnell

Alternatively  generate the log-likelihood using the sum(dpois(y,
fitted(model), log = TRUE))


Regards

Ross Darnell


Doxastic wrote:
> 
> You're right.  I do need to learn more.  I never learned null/residual
> deviance.  I know the deviance is equivalent to an anova decompostion. 
> But I've never dealt with it seperated like this.  
> 
> I understand deviance as the difference between two model's log-likelihood
> difference between them and the most complex.  I want to compare two
> models that are not the most complex.  That is why I wanted the
> log-likelihood.  
> 
> I am using the poisson distribution because my response is count data, so
> the link is the log.  If the deviance in R is computed by comparing the
> fitted model against the most saturated (which would make sense).  Then
> yes, I can use that.  I just picked the log-likelihood because I'm
> comparing two models.  And that's the best way.  But, it's equivalent if R
> compares the fitted to the most complex.
> 
> I assumed the deviance print out tested the fitted model against the least
> complex.  This tests whether the current model parameters can be dropped
> (that's what I thought the null deviance meant).  I'm not sure what the
> residaul deviance means though.  
> 
> My main concern is why the likelihood functions differed between SAS and
> R.  If anyone has encountered this or understands why, I would appreciate
> some help.
> 
> 
> 
> Prof Brian Ripley wrote:
>> 
>> I think you need to learn about deviances, which R does print.
>> 
>> Log-likelihoods are only defined up to additive constants.  In this case 
>> the conventional constant differs if you view this as a Poisson or as a 
>> product-multinomial log-linear model, and R gives you the log-likelihood 
>> for a Poisson log-linear model (assuming you specified family=poisson). 
>> However, deviances and differences in log-likelihoods do not depend on 
>> which.
>> 
>> More details and worked examples can be found in MASS (the book, see the 
>> FAQ), including other ways to fit log-linear models in R.
>> 
>> 
>> On Tue, 1 May 2007, someone ashamed of his real name wrote:
>> 
>>> I've computed a loglinear model on a categorical dataset.  I would like
>>> to
>>> test whether an interaction can be dropped by comparing the
>>> log-likelihoods
>>> from two models(the model with the interaction vs. the model without).
>>> Since R does not immediately print the log-likelihood when I use the
>>> "glm"
>>> function, I used SAS initially.  After searching for an extracting
>>> function,
>>> I found one in R.  But, the log-likelihood given by SAS is different
>>> from
>>> the one given by R.  I'm not sure if the "logLik" function in R is
>>> giving me
>>> something I don't want.  Or if I'm misinterpreting the SAS output.  Can
>>> anyone help?
>>>
>> 
>> -- 
>> 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@stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/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/Log-likelihood-function-tf3678882.html#a10283755
Sent from the R help mailing list archive at Nabble.com.

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


[R] Lattice plots of the form xyplot(y1+y2~x)

2006-11-17 Thread Ross Darnell
I would appreciate help trying
to set different plot types  in a lattice plot with multiple responses e.g.

xyplot(y+fval~x)

but  have "y" as points and "fval" as a line.

I have tried

xyplot(y+fval~x,type=c("p","l"))

but this results in both plots having both types.

Thanks

Ross Darnell
University of Queensland, AUSTRALIA

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] MASS4 page 360 cumulative hazard plot

2006-10-15 Thread Ross Darnell
I cannot reproduce Fig. 13.2 in MASS4.

> plot(gehan.surv,fun='cloglog')
Warning message:
2 x values <= 0 omitted from logarithmic plot in: xy.coords(x, y, 
xlabel, ylabel, log)

and the x-axis is badly scaled.

I was wondering if someone can help


Regards
Ross Darnell

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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 and the "[" function

2006-09-05 Thread Ross Darnell
Hi Vincent

This would seem logical but in this case doesn't work.
It doesn't seem to be a Sweave problem (feature) at all  but within R as 
Hadley stated.
Within R try

 > quote(women[1])
women[1]

now try

 > quote("["(women,1))
women[1]

So it's parsed and "normalised" (there's a familiar term); in this case 
to women[1] before its quoted.

Curiously in the "R Language Definition Guide" in 10.4.3  it states

R has three indexing constructs, two of which are syntactically similar 
although with somewhat
different semantics:
object [ arg1, .. , argn ]
object [[ arg1, .. , argn ]]
The object can formally be any valid expression, but it is understood to 
denote or evaluate
to a subsettable object. The arguments generally evaluate to numerical 
or character indices,
but other kinds of arguments are possible (notably drop = FALSE).
Internally, these index constructs are stored as function calls with 
function name "[" respectively
"[[".

So I'm lost now. Can some one hand me a  map and compass?
 




Vincent Goulet wrote:
> Le Mardi 5 Septembre 2006 0:03, hadley wickham a écrit :
>   
>>> <<>>=
>>> str(women)
>>> women$height
>>> women[,1]
>>> "["(women,1)
>>> @
>>>
>>> to show the equivalence of  three methods of extracting an element from
>>> a data.frame.
>>>
>>> However Sweave returns the last of these as
>>>
>>> women[1]
>>>
>>> in the S input chunk
>>>
>>> How can I force it not to do this and return "["(women,1)
>>>   
>> I don't think you can.  Sweave parses your R code and from then on
>> uses the internal R representation.  R normalises the parse tree in
>> certain ways (eg. strips comments, formats source code, and clearly
>> normalises some function calls).  Since sweave uses this, and not the
>> original text, I don't think there is anyway to get around this,
>> unless there is some trick during parsing.
>>
>> (And don't forget women[[1]])
>>
>> Hadley
>> 
>
> So here's a workaround (untested):
>
> <>=
> str(women)
> women$height
> women[,1]
> @
> <>=
> "["(women,1)
> @
> <>=
> "["(women,1)
> @
>
> I often end up doing similar things.
>
> HTHVincent
>
>

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/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] Sweave and the "[" function

2006-09-04 Thread Ross Darnell
I am wanting to use the "[" operator in an S-chunk, e.g.


<<>>=
str(women)
women$height
women[,1]
"["(women,1)
@

to show the equivalence of  three methods of extracting an element from 
a data.frame.

However Sweave returns the last of these as

women[1]

in the S input chunk

How can I force it not to do this and return "["(women,1)

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


[R] Lattice plot of multiply-nested data

2006-05-09 Thread Ross Darnell
I would like to replicate Figure 3.12 from Pinheiro and Bates's "Mixed 
Effects Models in S and S-PLUS"
but I would like to plot both the average line as well as the individual 
sites lines on the same panel.
I did try modifying the panel function but I cannot seem to  get it  as  
described.

I would appreciate any suggestions

Ross Darnell
University of Queensland

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


[R] Coefficients for aliased models

2006-04-24 Thread Ross Darnell
I find the reporting of aliased terms in class lm objects as little 
inconsistent.

The best way to show  this is to give an example.

X <- mvrnorm(10,c(0,0),Sigma=matrix(c(1,0.5,0.5,1),nrow=2))
Xnew <- as.data.frame(cbind(X,X[,2])) # make copy of X[,2]
names(Xnew) <- c("y","X","Xcopy")
model <- lm(y~X+Xcopy,data=Xnew)
coef(model)  # reports NA for Xcopy estimate
summary(model) # ditto
coef(summary(model)) # drops NA for Xcopy estimate

Is this intentional? Is there a way of extracting the coefficient table 
from the summary output with the aliased term included?

Many thanks

Ross Darnell

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


[R] Calculation of r.squared for linear model with offset

2006-04-09 Thread Ross Darnell
R^2 for a model is usually defined as 1-RSS/TSS where TSS is the SS 
about the mean and RSS is the residual SS from the model.

Consider the model in R

z <- runif(20)
y <- z+rnorm(20)
my.model <- lm(y~offset(z))
summary(my.model)$r.squared

Here the RSS is equivalent to the TSS and
gives 0 when it should (IMHO and a few others perhaps) be

1 - RSS/TSS(corrected for the mean only)

RSS = sum(resid(my.model)^2)
TSS = sum((y-mean(y))^2)

Have I missed this somewhere in the FAQ's or elsewhere?

Regards
Ross Darnell

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


[R] Sweave: How can I include S input in paragraph mode

2005-12-01 Thread Ross Darnell
Sweavers

As the title suggests I would appreciate any help to include S code in
ordinary paragraph mode. I can use the textsl font but is isn't the
same.

Thanks

Ross Darnell

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


[R] Translating lme model call to lme4

2005-09-12 Thread Ross Darnell
I would appreciate help translating the following lme model to an lmer 
function.

lme(lognrms ~ Group*Rotation*muscle*side*support*arms,
 random=~1|Subject/Stratum2/rep, data=Data)



Many thanks

Ross Darnell
[EMAIL PROTECTED]

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


[R] anova.lmlist output change

2005-07-13 Thread Ross Darnell
R-colleagues

I have adapted the anova.lmlist function to use the model object name as 
the first column in the output instead of the string "Model n".

If there is general agreement can the change be implemented into the 
stats package?

Regards

Ross Darnell
-- 
University of Queensland, Brisbane QLD 4072 AUSTRALIA
Email: <[EMAIL PROTECTED]>

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


Re: [R] A suggestion for predict function(s)

2005-04-13 Thread Ross Darnell
Liaw, Andy wrote:
I must respectfully disagree.  Why carry extra copies of data arround?  This
is probably OK for small to medium sized data, but definitely not for large
data.
Besides, in your example, it may do different things depending on whether
newdata is supplied:  model.matrix is not necessarily the same as the
original data frame.  You need a bit more work to get the right model.matrix
that correspond to the newdata.  It's not clear to me whether you want to
return model matrix or model frame, but in either case it's not sufficient
to just use `newdata'.
Andy

From: Ross Darnell
Maybe a useful addition to the predict functions would be to 
return the 
values of the predictor variables. It just (unless there are 
problems) 
requires an extra line. I have inserted an example below.

"predict.glm" <-
  function (object, newdata = NULL, type = c("link", "response",
  "terms"), se.fit = FALSE, 
dispersion = NULL, terms = NULL,
na.action = na.pass, ...)
{
  type <- match.arg(type)
  na.act <- object$na.action
  object$na.action <- NULL
  if (!se.fit) {
if (missing(newdata)) {
  pred <- switch(type, link = object$linear.predictors,
 response = object$fitted, terms = 
predict.lm(object,
 se.fit = 
se.fit, scale 
= 1, type = "terms",
 terms = terms))
  if (!is.null(na.act))
pred <- napredict(na.act, pred)
}
else {
  pred <- predict.lm(object, newdata, se.fit, scale = 1,
 type = ifelse(type == "link", 
"response", type),
 terms = terms, na.action = na.action)
  switch(type, response = {
pred <- family(object)$linkinv(pred)
  }, link = , terms = )
}
  }
  else {
if (inherits(object, "survreg"))
  dispersion <- 1
if (is.null(dispersion) || dispersion == 0)
  dispersion <- summary(object, dispersion = 
dispersion)$dispersion
residual.scale <- as.vector(sqrt(dispersion))
pred <- predict.lm(object, newdata, se.fit, scale = 
residual.scale,
   type = ifelse(type == "link", 
"response", type),
   terms = terms, na.action = na.action)
fit <- pred$fit
se.fit <- pred$se.fit
switch(type, response = {
  se.fit <- se.fit * abs(family(object)$mu.eta(fit))
  fit <- family(object)$linkinv(fit)
}, link = , terms = )
if (missing(newdata) && !is.null(na.act)) {
  fit <- napredict(na.act, fit)
  se.fit <- napredict(na.act, se.fit)
}
predictors <- if (missing(newdata)) model.matrix(object) 
else newdata
pred <- list(predictors=predictors,
 fit = fit, se.fit = se.fit,
 residual.scale = residual.scale)
  }
  pred

#__ end of R code

Ross Darnell
--
School of Health and Rehabilitation Sciences
University of Queensland, Brisbane QLD 4072 AUSTRALIA
Email: <[EMAIL PROTECTED]>
Phone: +61 7 3365 6087 Fax: +61 7 3365 4754  Room:822, 
Therapies Bldg.
http://www.shrs.uq.edu.au/shrs/school_staff/ross_darnell.html

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




--
Notice:  This e-mail message, together with any attachment...{{dropped}}
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] A suggestion for predict function(s)

2005-04-12 Thread Ross Darnell
Maybe a useful addition to the predict functions would be to return the 
values of the predictor variables. It just (unless there are problems) 
requires an extra line. I have inserted an example below.

"predict.glm" <-
  function (object, newdata = NULL, type = c("link", "response",
  "terms"), se.fit = FALSE, 
dispersion = NULL, terms = NULL,
na.action = na.pass, ...)
{
  type <- match.arg(type)
  na.act <- object$na.action
  object$na.action <- NULL
  if (!se.fit) {
if (missing(newdata)) {
  pred <- switch(type, link = object$linear.predictors,
 response = object$fitted, terms = predict.lm(object,
 se.fit = se.fit, scale 
= 1, type = "terms",
 terms = terms))
  if (!is.null(na.act))
pred <- napredict(na.act, pred)
}
else {
  pred <- predict.lm(object, newdata, se.fit, scale = 1,
 type = ifelse(type == "link", "response", type),
 terms = terms, na.action = na.action)
  switch(type, response = {
pred <- family(object)$linkinv(pred)
  }, link = , terms = )
}
  }
  else {
if (inherits(object, "survreg"))
  dispersion <- 1
if (is.null(dispersion) || dispersion == 0)
  dispersion <- summary(object, dispersion = dispersion)$dispersion
residual.scale <- as.vector(sqrt(dispersion))
pred <- predict.lm(object, newdata, se.fit, scale = residual.scale,
   type = ifelse(type == "link", "response", type),
   terms = terms, na.action = na.action)
fit <- pred$fit
se.fit <- pred$se.fit
switch(type, response = {
  se.fit <- se.fit * abs(family(object)$mu.eta(fit))
  fit <- family(object)$linkinv(fit)
}, link = , terms = )
if (missing(newdata) && !is.null(na.act)) {
  fit <- napredict(na.act, fit)
  se.fit <- napredict(na.act, se.fit)
}
predictors <- if (missing(newdata)) model.matrix(object) else newdata
pred <- list(predictors=predictors,
 fit = fit, se.fit = se.fit,
 residual.scale = residual.scale)
  }
  pred

#__ end of R code

Ross Darnell
--
School of Health and Rehabilitation Sciences
University of Queensland, Brisbane QLD 4072 AUSTRALIA
Email: <[EMAIL PROTECTED]>
Phone: +61 7 3365 6087 Fax: +61 7 3365 4754  Room:822, Therapies Bldg.
http://www.shrs.uq.edu.au/shrs/school_staff/ross_darnell.html
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Histogram without common borders

2004-07-19 Thread Ross Darnell
Is it possible to produce a histogram directly using the hist()
function with the common borders removed?

It can be done by plotting the histogram object using type 's'teps.

my.hist <- hist(x,plot=FALSE)
plot(my.hist$breaks,c(0,my.hist$counts),type='s')

I would appreciate help

Ross Darnell 
-- 
University of Queensland, Brisbane QLD 4067 AUSTRALIA
Email: <[EMAIL PROTECTED]>
Phone: +61 7 3365 6087 Fax: +61 7 3365 4754
http://www.shrs.uq.edu.au/shrs/school_staff/ross_darnell.html

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] WinMenu's question

2004-06-01 Thread Ross Darnell
I am using the Windows menu functions below which will work on the
first pass, but if I repeat the same script I cannot get the
WinMenuAddItem to work. This is a problem if I change the menu
structure and reread the source code I am forced to quit and restart Rgui.

"try.menu" <- function(){
  OS <- .Platform$OS.type
  GUI <- .Platform$GUI
  if (!(OS == "windows" & GUI == "Rgui")) return("Sorry, you must be running R using 
Rgui.exe on MS Windows")
  try(winMenuDelItem('EMG/Graphics','Plot.trace'))
  try(winMenuDel('EMG/Graphics'))
  try(winMenuDel("EMG"))
  winMenuAdd("EMG")
  winMenuAdd("EMG/Graphics")
  winMenuAddItem("EMG/Graphics","Plot trace","plot.trace()")
}
"plot.trace" <- function(){
  x <- eval(parse(text=trace.dialog()))
  plot(x,type="l")
  invisible()
}


Help much appreciated

Ross Darnell
-- 
University of Queensland, Brisbane QLD 4067 AUSTRALIA
Email: <[EMAIL PROTECTED]>
Phone: +61 7 3365 6087 Fax: +61 7 3365 4754
http://www.shrs.uq.edu.au/shrs/school_staff/ross_darnell.html

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Frequent crash printing graphics windows and wavethresh

2003-12-08 Thread Ross Darnell

I often have R (1.8.1) crash after I generate several graphics windows using
windows() or X11(), print a graphics window and then rerun the same
script. A windows message comes up saying "Program error Rterm.exe .." 
(I can get the same problem using Rgui.)

Xemacs tells me 
"Process R trace trap" at time  and date

The entry in the Dr Watson logs starts with


Application exception occurred:
App:  (pid=134697032)
When: 26/11/2002 @ 21:12:10.057
Exception number: c005 (access violation)


The situation in which I can consistently produce this is when I am
using the wavethresh3 dll and associated functions. I have tried to
generate the same problem without using wavelet functions (just
producing several graphics windows with plots of random numbers) but
cannot reproduce this problem consistently from a new session.

I was wondering if anyone else is experiencing this problem

Regards

Ross Darnell
-- 
University of Queensland, Brisbane QLD 4067 AUSTRALIA
Email: <[EMAIL PROTECTED]>

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] help with nomogram function

2003-11-06 Thread Ross Darnell

Frank Harrell wrote
 
> On Wed, 05 Nov 2003 09:22:34 +1000
> Ross Darnell <[EMAIL PROTECTED]> wrote:
> 
> > I have fitted a logistic regression model
> > 
> > > failed.lr2$call
> > lrm(formula = failed ~ Age + task2 + Age:task2, data = time.long, 
> > na.action = na.omit)
> 
> Use Age*task2 and omit na.action as na.omit is the default
> 
> > 
> > using the Design package functions and would like to generate a
> > nomogram from this model.
> > 
> > the datadist information is generated and stored in
> > 
> > > ddist
> > time.long$Age time.long$task2
> > Low:effect 45
> > Adjust to  56   both.foam
> > High:effect68
> > Low:prediction 21   both.foam
> > High:prediction80   right
> > Low20   both.foam
> > High   80   right
> 
> This looks most strange.  You did not include the original code but I
> suspect you had $ in a term.  $ should not appear in column headings
> above.  Design wants you to use data= or attach, and avoid $ in terms.
> 
> 
> > 
> > Values:
> > 
> > time.long$task2 : both.foam left right 
> > > 
> > 
> > The model fitted and then when I try the nomgram function
> > 
> > > nomogram(failed.lr2)
> > Error in value.chk(at, i, NA, -nint, Limval, type.range = "full") : 
> > variable Age does not have limits defined by datadist
> > > 
> > 
> > I get an error. The NA values in ddist seem to be the problem but I
> > don't understand the datadist information.
> > 

I tried using the data argument in datadist

> names(my.data)
[1] "subject" "Age" "failed"  "task"   
> ddist <- datadist(Age,task,data=my.data)
Error in datadist(Age, task, data = my.data) : 
Object "Age" not found


Strange.

Thanks
Ross Darnell


--

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] help with nomogram function

2003-11-04 Thread Ross Darnell
I have fitted a logistic regression model

> failed.lr2$call
lrm(formula = failed ~ Age + task2 + Age:task2, data = time.long, 
na.action = na.omit)

using the Design package functions and would like to generate a
nomogram from this model.

the datadist information is generated and stored in

> ddist
time.long$Age time.long$task2
Low:effect 45
Adjust to  56   both.foam
High:effect68
Low:prediction 21   both.foam
High:prediction80   right
Low20   both.foam
High   80   right

Values:

time.long$task2 : both.foam left right 
> 

The model fitted and then when I try the nomgram function

> nomogram(failed.lr2)
Error in value.chk(at, i, NA, -nint, Limval, type.range = "full") : 
variable Age does not have limits defined by datadist
> 

I get an error. The NA values in ddist seem to be the problem but I
don't understand the datadist information.

Can anyone help explain why this is failing.

Thanks

Ross Darnell

-- 

University of Queensland, Brisbane QLD 4067 AUSTRALIA
Email: <[EMAIL PROTECTED]>
Phone +61 7 3365 6087
http://www.shrs.uq.edu/shrs/school_staff/ross_darnell.html

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] R workshop, Qld Australia

2003-08-06 Thread Ross Darnell
Need some help with R?

An R workshop, lead by John Maindonald, is planned for the 2nd October
at the University of Southern Queensland, Toowoomba, Australia. The
workshop is being organised by the Queensland branch of the
Statistical Society of Australia as part of their conference.

Anyone interested in attending can find out more by looking at 

http://www.sci.usq.edu.au/staff/dunn/qstatconf/workshops.html

-- 
Ross Darnell
Organising committee
Email: <[EMAIL PROTECTED]>

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Specifying an lme model

2003-07-15 Thread Ross Darnell
Thanks for the help.

Sorry but now comes the second question. What we have now assumes
equal within-subject variances. How can I fit separate (pooled)
within-subject variances for each group (similar to an unequal
variance t-test) and test if this is better than the existing constant
within-subject variance.

Many thanks

Ross
 
Douglas Bates <[EMAIL PROTECTED]> writes:

> Ross Darnell <[EMAIL PROTECTED]> writes:
>
>> I would like some advice on how if possible, to test the following
>> 
>>  I have subjects each measured several times. The subjects are sampled
>>  from 3 subpopulations (groups). The question is "Is the 
>>  between-subject variance the same for the three groups?"
>> 
>> The "null" model is 
>> 
>> lme0 <- lme(y~group,random=~1|subject)
>> 
>> I did think that the model that defined a specific between-subject
>> variance for each group was
>> 
>> update(lme0,.~., weights=varIdent(form=~1|group))
>> 
>> but I am not sure.
>
> I think you have it right.  You should then compare the two fitted
> models using the anova generic, which will provide a likelihood ratio
> test statistic and a p-value based on a chi-squared reference
> distribution.  Regard the p-value as an approximation.
>
>
>

-- 
Ross Darnell
School of Health and Rehabilitation Sciences
University of Queensland, Brisbane QLD 4067 AUSTRALIA
Email: <[EMAIL PROTECTED]>
Phone +61 7 3365 6087
http://www.uq.edu.au/~uqrdarne/

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Specifying an lme model

2003-07-14 Thread Ross Darnell
I would like some advice on how if possible, to test the following

 I have subjects each measured several times. The subjects are sampled
 from 3 subpopulations (groups). The question is "Is the 
 between-subject variance the same for the three groups?"

The "null" model is 

lme0 <- lme(y~group,random=~1|subject)

I did think that the model that defined a specific between-subject
variance for each group was

update(lme0,.~., weights=varIdent(form=~1|group))

but I am not sure.

I would appreciate any help.

Ross Darnell

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] equivalence test

2003-06-26 Thread Ross Darnell
>Hi,
>   is it possible to do an equivalence test on paired quantitative datas 
>in R? Is there a way to calculate sample size for such tests?
>
>I've tried to find some documentation on that subject but I was 
>unsuccessfull. 
>I'll be happy with any links on equivalence test. If such a test does'nt 
>exist in R, i'll do it manually if I find a method to do so.
>
>Best regards
>
>Blaise

The sample size for an equivalence trial with normally distributed
outcomes can be calculated by

n <- 2 * s^2 / delta^2 * (qnorm(alpha/2) + qnorm(beta/2))^2

s = standard deviation
delta = clinically important difference
alpha = Type I error
beta = Type II error


-- 
Ross Darnell

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] RE: Simple NLME problem (I hope)

2003-03-27 Thread Ross Darnell

Date: Wed, 26 Mar 2003 17:35:27 +
From: "Vumani Dlamini" <[EMAIL PROTECTED]>
Subject: [R] Simple NLME problem (I hope)  
To: [EMAIL PROTECTED]
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; format=flowed


"Vumani Dlamini" wrote:
>Dear R-Users:

>I would like to fit a multilevel model using LME such that the parameters 
>after fitting the multilevel in two separate groups and when I use the 
>complete data (with interactions between the grouping variable and the other 
>variables) set are comparable (or the same).

>The problem I am having currently is that I am not sure whether it is 
>possible to let the random error term to vary by group such that the models 
>are comparable. At present only one random error term is estimate and this 
>"sort of" distorts the parameter estimates for the fixed and other random 
>effects.

>Looking forward to your help.

It may be that you want to use the "weights=varIdent(form=~1|groups)"
argument which will fit a variance for each level of the groups
factor.


-- 
Ross Darnell
School of Health and Rehabilitation Sciences
University of Queensland, Brisbane QLD 4067 AUSTRALIA
Email: <[EMAIL PROTECTED]>
Phone +61 7 3365 6087
http://www.uq.edu.au/~uqrdarne/

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Re: Finding missing data patterns

2003-02-02 Thread Ross Darnell

The norm package of Joe Schafer can be used. It has a function called
'prelim' (or very similar) that does this.

Regards
Ross Darnell

Email: <[EMAIL PROTECTED]>

__
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help



[R] tkmenu question

2003-01-29 Thread Ross Darnell

I am learning the tcl/tk package and language and working through an
example (following a Tcl/Tk) tutorial which constructs a menubar and
menu system. My code is below.  I would very much appeciate some help
with two questions.

1. What is the parent for the menus associated with the menubuttons?

2. Why does the toplevel frame shrink if though I define the width of
the menubar frame and set the fill="x"?

Thanks

Ross Darnell


-- 
Email: <[EMAIL PROTECTED]>


require(tcltk) || stop("tcltk support is absent")
# Generate the main frame
.fr <- tktoplevel(width=800,height=500)
tktitle(.fr) <- "My example"
.menubar <- tkframe(.fr, relief="raised", borderwidth=2,
width=500,height=15)
tkpack(.menubar,fill="x") #why does .fr shrink?
# Set up the menu buttons
.menubar.file <- tkmenubutton(.menubar, text="File",
  underline=0,menu=.menubar.file.menu)
.menubar.edit <- tkmenubutton(.menubar, text="Edit",
  underline=0,menu=.menubar.edit.menu)
.menubar.graphics <- tkmenubutton(.menubar, text="Graphics",
  underline=0,menu=.menubar.graphics.menu)
tkpack(.menubar.file, .menubar.edit, .menubar.graphics,fill="x",
   side="left")
# Help menu to the right
.menubar.help <- tkmenubutton(.menubar, text="Help", underline=0)
tkpack(.menubar.help, side="right",fill="x")
# create pulldown menus  what is the parent?
.menubar.file.menu <- tkmenu(.)
tkadd(.menubar.file.menu,"separator")
tkadd(.menubar.file.menu,"command",label="Quit",command="exit")
.menubar.edit.menu <- tkmenu(.)
tkadd(.menubar.edit.menu,"separator")
.menubar.graphics.menu <- tkmenu(.)
tkadd(.menubar.graphics.menu,"separator")

__
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help



[R] Searching for glmmNQ

2003-01-07 Thread Ross Darnell

I cannot find the glmmNQ function in the MASS package (or anywhere else I have tried) 
mentioned on page 296 of MASS4.

I would appreciate directions.
Thanks
-- 
Ross Darnell

__
[EMAIL PROTECTED] mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help