Re: [R] Newbie Question: Using R with PHP and MySQL

2007-08-23 Thread Dieter Menne
MASFERFC Team  gmail.com> writes:

> I'm currently running MySQL 5 queries with PHP 5.2.3 and returning results
> to the end-user in web-page tables of ca. 50 rows by 5 columns. I'd like to
> (more or less) simultaneously return to the browser a couple of "canned"
> charts and graphs based on the data. Nothing fancy, two pie charts and two
> simple bar-charts to start. I need to generate these on-the-fly, based on
> the results of the MySQL query, and display them in the web-page, beside the
> table data.
> 
> What's the best reference, if there is one,  for PHP, MySQL, R integration?

It's not the best, but it's simple, works for all our sites and comes with a
sample: package phpSerialize. Graphs are should be written to a file as png and
linked via standard HTML.

Dieter

__
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] Lost in substitute: nlsList and nlme with dynamic formula

2007-08-23 Thread Dieter Menne
DeaR

I am trying to use a dynamically create formula with nlsList and nlme, but I
cannot get the environment of the string-generated formal to work similarly
to the manually entered one.

Any idea?

Dieter

#-
library(nlme)
# Pinheiro/Bates p 280
fm1Indom.lis = nlsList(conc~SSbiexp(time,A1,lrc1,A2,lrc2),
  data=Indometh)
nlme(fm1Indom.lis,random=pdDiag(A1+lrc1+A2~1))
# works...


# Simulating a dynamic formula
form = as.formula("conc~SSbiexp(time,A1,lrc1,A2,lrc2)")
fm2Indom.lis = nlsList(form,data=Indometh)
# still correct

nlme(fm2Indom.lis,random=pdDiag(A1+lrc1+A2~1))
#Error in switch(mode(x), "NULL" = structure(NULL, class = "formula"),  :
#invalid formula


# B.D. Ripley val(subst) workaround
# http://finzi.psych.upenn.edu/R/Rhelp02a/archive/16599.html
fm3Indom.lis = eval(substitute(nlsList(form,data=Indometh)),
  list(form=form))
nlme(fm3Indom.lis,random=pdDiag(A1+lrc1+A2~1))
#.. Same error

__
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] for plots

2007-08-16 Thread Dieter Menne
jim holtman  gmail.com> writes:

> 
> Turn 'Recording" on for the plots.
> 
> windows(record=TRUE)
> 
> or select from the GUI.
> 
> I mean if the object has several plots how can I
> get those?

> > "gam.object <- gam(y ~ s(x,6) + z,data=gam.data)
> > plot(gam.object,se=TRUE)"

Or use something like

par(mfrow=c(3,3)) 

to avoid paging

Dieter

__
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] R graphics display window

2007-08-16 Thread Dieter Menne
Felipe Carrillo  yahoo.com> writes:

> How can the R graphics window be customized
> programmatically? Either minimized,maximized or change
> the size of the default that ships with R.

Assuming Windows as OS (which you forgot to mention)

windows(width = 2, height = 2, pointsize = 12)

Dieter

__
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] lmer coefficient distributions and p values

2007-08-16 Thread Dieter Menne
Daniel Lakeland  street-artists.org> writes:

> 
> We have used the lmer package to fit various models for the various
> experiments that she has done (random effects from multiple
> measurements for each animal or each trial, and fixed effects from
> developmental stage, and genotype etc). The results are fairly clear
> cut to me, and I suggested that she publish the results as coefficient
> estimates for the relevant contrasts, and their standard error
> estimates. However, she has read the statistical guidelines for the
> journal and they insist on p values.
> 
> I personally think that p values, and sharp-null hypothesis tests are
> misguided and should be banned from publications, but it doesn't much
> matter what I think compared to what the editors want.
> 
> Based on searching the archives, and finding this message:
> 
> https://stat.ethz.ch/pipermail/r-help/2006-May/094765.html

.

>From what you describe, using the stable function lme in nlme by the same 
>author
Douglas Bates would do the job better for you. Remember lmer is under
development, which does not mean it's bad, but some nice things like weight are
still missing.
For lme, you have excellent documentation in the book by Pinheiro/Bates.

Dieter

__
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] to combine bwplot + srt option?

2007-08-16 Thread Dieter Menne
KOITA Lassana - STAC/ACE  aviation-civile.gouv.fr> writes:

> Could someone help me to combine bwplot and srt option (exemple srt = 45 
> degree or srt 90 degree)? My graphic contains 146 boxplots, I would like 
> to label all of them. As you know, labels  are not readable.

You cannot, since bwplot is part of lattice and srt is standard R-graphics. I
agree, this can be very confusing, lattice was added later to R and I am happy
we have it now (thanks, Deepayan).

So when you see that the function you are using (bwplot) is documented under
lattice, always use the other options available in this package. These are
mostly documented under xyplot, which is worth a fixed link on the desktop.

Dieter

library(lattice)
bwplot(voice.part ~ height, data = singer,
   horizontal=FALSE,
   scales = list(x = list(rot = 45))) ##<< see xyplot

__
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] Import of Access data via RODBC changes column name ("NO" to "Expr1014") and the content of t he column

2007-08-14 Thread Dieter Menne
Maciej Hoffman-Wecker  bioskin.de> writes:

...
> But I succeeded in developing a tiny example, that reproduces the bug
(wherever it is).
> 
> I generated a small Access data base "test2.mdb" with one table "Tab1" and
following columns:
. 

> > library(RODBC)
> > .con <- odbcConnectAccess("./test2.mdb")
> > (.d <- try(sqlQuery(.con, "select * from Tab1")))

> > (.d <- try(sqlQuery(.con, "select F1 , NO , F2 from Tab1")))
>   F1 Expr1001 F2
> 1  10  1
> 2  20  2
> 3  00  1
> 4  10  0
> > close(.con)

NO is a reserved word in ODBC (or where...). Whenever you see Exprxxx in
columns, put the column name in []
d <- try(sqlQuery(con, "select F1 ,[NO], F2 from Tab1"))

works for me.

Dieter

__
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] Using sunflowerplot to add points in a xyplot panel

2007-08-14 Thread Dieter Menne
Ronaldo Reis Junior  gmail.com> writes:

> 
> Hi,
> 
> I use panel.points to add points to a xyplot graphic. But I like to use the 
> sunflowerplot to plot my points because this is very superimposed. It is 
> possible to use this? I try but it dont work directly. It may be need to put 
> this function inside a panel.??? 

sunflower is "old style R graphics", and xyplot is lattice/trellis. these two
normally don't get along together too well. Paul Murrell's grid which is the
base of lattice, can do some magic to bring them together.

Dieter


## Modfied after Cris Bergstresser and Paul Murrell
##http://finzi.psych.upenn.edu/R/Rhelp02a/archive/73780.html
library(grid);
library(lattice);

sunpanel <- function(x, y, subscripts, ...) {
  pushViewport(viewport(x = 0.5, y = 0.5, just = "center"));
  sunflowerplot(x, y, axes = FALSE, xlab = "", ylab = "");
  popViewport(1);
} 

x = round(runif(100, 1, 5));
y = round(runif(100, 1, 5));
print(xyplot(y ~ x, aspect = "iso", panel = sunpanel));

__
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

2007-08-14 Thread Dieter Menne
Daniel Stahl  operamail.com> writes:

> 
> I would like to do a large number of e.g. 1000 paired ttest using the
by-function.

Technical stuff aside: do you really want to do 1000 paired t-tests?
Followed by a *** pick-nic?

Mmm...

Dieter

__
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] p value statistic for lm object

2007-08-13 Thread Dieter Menne
Arjun Bhandari  adia.ae> writes:

> I conduct a univariate regression with lm function. I would like to get 
> the p value for the regression. Is there a method that would enable me to 
> extract the p value into a variable.

# From lm docs (Sorry, Annette, for misusing your data)
ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
lm.D90 <- lm(ctl ~ trt)
# let's look if it is in lm..
str(lm.D90)
# mmm.. looks like there are no p-test results
# try summary
sum.lm = summary(lm.D90)
sum.lm
# .. coming closer. 
# Colum Pr(>|t|), row trt is what we are looking for
# Let's look into the structure
str(sum.lm)
# $coeffients has the wanted
sum.lm$coefficients
# looks good. We could use this, but better use the accessor function
# Check the documentation, but coef is always a good try
cf =  coef(sum.lm)
#now pick the right column
pslope = cf["trt","Pr(>|t|)"]
pslope ##
# Could also use index, but less safe in general, even if the 
# "Pr(.." is definitively ugly
cf[2,4]
# In general, the $ approach is not recommened, if there is an 
# accessor funtion, use it. The closest (with no p-values) is
confint(lm.D90)
# Which probably tells more than the beloved p-values.
# The better the journal's referees, the more they prefer confints over p

__
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] bayesm - question about 'rscaleUsage function'

2007-08-06 Thread Dieter Menne
  optusnet.com.au> writes:

 
> I get this part of the code, it all makes sense.
> 
> ##
> if(nchar(Sys.getenv("LONG_TEST")) != 0) {R=1000} else {R=5} 
> {
> data(customerSat)
> surveydat = list(k=10,x=as.matrix(customerSat))
> Mcmc1 = list(R=R)
> set.seed(66)
> out=rscaleUsage(Data=surveydat,Mcmc=Mcmc1)
> summary(out$mudraw)
> }
> 
> My question is how do I retrieve the results from this in a matrix format
> 

str() is your friend...

-
if(nchar(Sys.getenv("LONG_TEST")) != 0) {R=1000} else {R=5} 
{
data(customerSat)
surveydat = list(k=10,x=as.matrix(customerSat))
Mcmc1 = list(R=R)
set.seed(66)
out=rscaleUsage(Data=surveydat,Mcmc=Mcmc1)
summary(out$mudraw)
}
> str(out)

List of 6
 $ Sigmadraw : bayesm.var [1:5, 1:100] 7.37 7.04 5.56 5.00 4.50 ...
  ..- attr(*, "class")= chr [1:3] "bayesm.var" "bayesm.mat" "mcmc"
  ..- attr(*, "mcpar")= num [1:3] 1 5 1
 $ mudraw: bayesm.mat [1:5, 1:10] 6.21 6.54 6.49 6.56 6.59 ...
  ..- attr(*, "class")= chr [1:2] "bayesm.mat" "mcmc"
  ..- attr(*, "mcpar")= num [1:3] 1 5 1
 $ taudraw   : bayesm.mat [1:5, 1:1811]  0.1862 -1.4988 -1.0348  0.0754  1.0258 
...
  ..- attr(*, "class")= chr [1:2] "bayesm.mat" "mcmc"
  ..- attr(*, "mcpar")= num [1:3] 1 5 1
 $ sigmadraw : bayesm.mat [1:5, 1:1811] 1.11 1.29 1.47 1.2 1.95 0.72 0.63 0.69
1.2 1.14 ...
  ..- attr(*, "class")= chr [1:2] "bayesm.mat" "mcmc"
  ..- attr(*, "mcpar")= num [1:3] 1 5 1
 $ Lambdadraw: bayesm.mat [1:5, 1:4] 3.35 2.73 2.58 2.49 2.73 ...
  ..- attr(*, "class")= chr [1:2] "bayesm.mat" "mcmc"
  ..- attr(*, "mcpar")= num [1:3] 1 5 1
 $ edraw :Classes 'bayesm.mat', 'mcmc'  atomic [1:5] 0.000 0.001 0.001 0.001
0.001
  .. ..- attr(*, "mcpar")= num [1:3] 1 5 1
> 
Looks like you want sigmadraw (lowercase!)? So try

out$sigmadraw

Dieter

__
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] multiple nls - next fit even after convergence problem

2007-08-04 Thread Dieter Menne
GOUACHE David  arvalisinstitutduvegetal.fr> writes:

... 

> This is my original function :
> 
> comp.fit.2<-function(tab)
> {
>  fit.log<-nls(surf.vert.tot ~ 100/(1+exp(((log(81))/a)*(sum.T.levee-b))),
start=list(

...
> I've thought of just storing the 3 model results in a list, and then going
through each model object,
> but even then, when I have a convergence problem, the function breaks off.

try and catch as Gabor suggested, but nlslist in package nlme does this for you
the easy way.

Dieter

__
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] Invert Likert-Scale Values

2007-08-04 Thread Dieter Menne
Alexis Delevett  yahoo.com> writes:

> I am using R to process some community survey data. Several item responses are
recorded via a 7-point
> Likert-Scale. As I have coded the responses, 1 represents high agreement, and
7 high disagreement. This
> of course impacts the coefficients in a linear regression (of example
agreement to self-perception
> measures on housing satisfaction). For some purposes, in order to make the
coefficients more accessible
> to the reader, I would like to invert the item values, i.e. to arrive at 1 for
high disagreement, and 7 for
> high agreement (such that the linear regression would express something like
"the higher the agreement
> on A, the greater the B).
> 
> Is there an already existing function for this, or do I use a custom replace
loop in R?

It's a rarely used function called '-'

x=c(1,7,3,4)
y=8-x
y

__
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] [R-pkgs] new package plotAndPlayGTK

2007-08-02 Thread Dieter Menne
Felix Andrews  nfrac.org> writes:

> 
> Package plotAndPlayGTK provides a graphical user interface for R
.
>>This package is
> based on RGtk2, and so requires the GTK+ libraries.
> 

Warning for Windows users: When I installed GTK+ from 



(Win2K) the installation erased all my paths settings, leaving only the the GTK
path. I had to restore it via registry manipulation from the old control set.

The plotAndPlayGTK worked after the recovery.

Dieter

__
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] Fitting exponential curve to data points

2007-07-24 Thread Dieter Menne
Andrew Clegg  gmail.com> writes:

> 
> ... If I want to demonstrate that a non-linear curve fits
> better than an exponential, what's the best measure for that? Given
> that neither of nls() or optim() provide R-squared. 

To supplement Karl's comment, try Douglas Bates' (author of nls) comments on the
matter

http://www.ens.gu.edu.au/ROBERTK/R/HELP/00B/0399.HTML

Short summary:
* ... "the lack of automatic ANOVA, R^2 and adj. R^2 from nls is a feature,
not a bug :-)"
* My best advice regarding R^2 statistics with nonlinear models is, as Nancy
Reagan suggested, "Just say no."

Dieter

__
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] custom point shapes

2007-07-20 Thread Dieter Menne
baptiste Auguié  exeter.ac.uk> writes:

> I'm new to R, but a search through the list didn't quite solve this  
> problem: I want to draw a few ellipses (or any custom shape for that  
> matter) at given locations in a graph. I know how to plot points from  
> my data, set the point type "pch" to any built in value, but I do not  
> know how to specify a custom shape.
> A search for drawing ellipses gave me functions to plot one at a  
> given location, possibly using some dataset but only to display a  
> confidence interval or other convex hull. Nothing to use as pch.
> 
> Say I have this data:
> 
> x<-c(1:10)
> y<-x^2
> 
> I would like to plot (x,y) with some ellipses of custom aspect ratio  
> for every point.

If you want to use pch, you are stuck with the existing symbols, and don't have
much freedom in manipulating these. Looks like you are best off with ellipse in
package car that you probably found already.

Dieter

__
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] What is parameter "display" (windows/grDevices)

2007-07-02 Thread Dieter Menne
In the docs of window/grDevices:

>All these devices are implemented as windows devices, the _display_
parameter selects which is actually used.>>

What is the "display" parameter?


Dieter Menne

__
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] Print grid/ggplot to a metafile

2007-06-29 Thread Dieter Menne
Dear UseRs called Hadley, or Paul,

I am trying to print an edited ggplot2/grid graphics to a metafile. With the
commented line below it works, but when I edit the plot by uncommenting the
line, it fails, because it's illegal to have 2 graphics in a metafile. It
works with pdf, but even then I get two plots, which is a nuisance.

I found a workaround by using windows(); savePlot, but it only works in
interactive mode, not when called with something like (Windows)

rterm --no-save < printit.r

Any ideas?

Dieter

#--
library(ggplot2)
win.metafile(file="bar.emf")
mtcars$cyls = factor(mtcars$cyl,
  labels=c("four\ncylinders","six\ncylinders","eight\ncylinders"))
ggplot(mtcars, aes(x=cyls)) + geom_bar()
#grid.gedit("xaxis::labels::label.text",just=c("center","center"))
dev.off()

__
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] eps in odfWeave

2007-06-25 Thread Dieter Menne
Dieter Menne  menne-biomed.de> writes:

> 
> library(odfWeave)
> plotInfo <- getImageDefs()
> plotInfo$type = "eps"
> plotInfo$plotWidth = 4
> plotInfo$plotHeight = 4
> plotInfo$device = "postscript"
> plotInfo$args = list( horizontal = FALSE,onefile = FALSE, paper = "special")
> setImageDefs(plotInfo)
> demoFile <- system.file("examples", "simple.odt", package ="odfWeave")
> odfWeave(demoFile, "c:/simpleOut.odt")
> 
> -
> Error in check(options) : invalid value for 'type' : eps

Sorry, Max, my error (as you noted in private email). From an earlier attempt I
had forgotten to remove the incorrect <<type="eps">> in the code.

Dieter

__
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] eps in odfWeave

2007-06-25 Thread Dieter Menne
Kuhn, Max  pfizer.com> writes:

Thanks, Max.

> What is the version of odfWeave? If you use those specifications in the
> current version (0.5.9):

Yes, version 0.5.9 (it was further below in my message, I forgot to put the
odfWeave flag before it.

I had tried your horizontal... suggestions before, because these came up nicely
in the error message, but the error remained the same, so I removed them. Here
another try for copy/paste, with a traceback. 

The convert problem is a well known Imagemagick problem; clashes with "convert"
in the Windows directory. Workaround is to put the Imagemagick path before the
Windows/system32 path.

Dieter


library(odfWeave)
plotInfo <- getImageDefs()
plotInfo$type = "eps"
plotInfo$plotWidth = 4
plotInfo$plotHeight = 4
plotInfo$device = "postscript"
plotInfo$args = list(
horizontal = FALSE,
onefile = FALSE,
paper = "special")
setImageDefs(plotInfo)
demoFile <- system.file("examples", "simple.odt", package ="odfWeave")
odfWeave(demoFile, "c:/simpleOut.odt")

-
Error in check(options) : invalid value for 'type' : eps
>
>
> traceback()
5: stop(gettextf("invalid value for '%s' : %s", opt, oldval), domain = NA)
4: check(options)
3: SweaveParseOptions(chunkopts, drobj$options, driver$checkopts)
2: Sweave(file = rnwFileName, output = "content_1.xml", quiet = 
!control$verbose,
   driver = RweaveOdf(), control = control)
1: odfWeave(demoFile, "c:/simpleOut.odt")

__
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] eps in odfWeave

2007-06-25 Thread Dieter Menne
Dear Weavers,

Does someone have an example of using eps or any other vector graphics with
odfWeave? It tried the example below (and commented variants) with
simple.odt in the examples directory, and got an error.

Dieter


#---
library(odfWeave)
plotInfo <- getImageDefs()
plotInfo$type = "eps"
#plotInfo$device = "postscript"
setImageDefs(plotInfo)
odfWeave("simple.odt", "simpleOut.odt")
#-

#  Writing to file content_1.xml
#  Processing code chunks ...
#1 : term hide(label=loadLibs)
#2 : term xml(label=showOutputList)
#Error in check(options) : invalid value for 'type' : eps

Version: 0.5.9
Date: 2007-20-06

platform   i386-pc-mingw32
arch   i386
os mingw32
system i386, mingw32
status
major  2
minor  5.0
year   2007
month  04
day23
svn rev41293
language   R
version.string R version 2.5.0 (2007-04-23)

__
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] Setting up a blank table with column names in the hard drive

2007-06-23 Thread Dieter Menne
Yuchen Luo  gmail.com> writes:

> This should be a very common operation and I believe there should be a nice
> way in R to handle it.  I couldn't find it in the manual or by searching on
> line. I am wondering if I could ask for some help in this community.
> 
> I am trying to record the results of my program to a csv file in the hard
> drive so as to save memory space and also to read the results in excel after
> running the program.  Every loop of my program will result in a list with
> element belonging to different class. For example, things like
> 
> a1 <- list(name="Fred", wife="Mary", no.children=3)
> a2 <- list(name="Tom", wife="Joy", no.children=9)
> a3 <- list(name="Paul", wife="Alic", no.children=5)
> 
> I want the columns to have titles, in the example above, I want to see the
> title "name", "wife" and "no.children" in the excel file.


Use a data frame to do the work, and save it with write.table or write.csv

maxallocate=10 # we assume no more than 10 members
myfamily = data.frame(name=rep(NA,maxallocate),wife=NA,nchildren=NA)
myfamily[1,]=c("Fred","Ginger",3)
myfamily[2,]=c("Charles","Mary",1)
myfamily[4,]=c("Frank","Salsa",4)
myfamily$name[3]="Anton"
myfamily$wife[3]="Sue"
myfamily$name[10] = "Charly"
myfamily$name[8] = "Fuhrman"
myfamily= myfamily[-1,] # delete first row
myfamily= myfamily[-1,] # delete current first row, i.e. Charles
# cleanup: assume that all entries having a name are valid
myfamily = myfamily[!is.na(myfamily$name),]
# oops .. I forgot .. another family member turned up unexpectedly
#Add it explicitely
rbind(myfamily,c("Tango","Tanga",33))
# The easy part. Check write.table for other options
write.csv(myfamily,file="myfamily.csv",row.names=FALSE)

__
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] latex of ftable (Hmisc?)

2007-06-23 Thread Dieter Menne
Chuck Cleland  optonline.net> writes:

>   How about a Sweave approach?  Something like this in the *.Rnw file:
> 
> \documentclass[letter]{article}
... 
> 
> ftable(symptom ~ treatment + sex)
> 
>   
> 
> \end{document}
> 
>   Then Sweave() the *.Rnw file to produce a *.tex file in the working
> directory.

Well, this IS for Sweave, and I currently use that solution as a surrogate, but
it definitively not a good looking table for a report.

Dieter

__
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] latex of ftable (Hmisc?)

2007-06-23 Thread Dieter Menne
Dear latexRs,

I tried to make a latex printout of a simple categorial ftable. It should
look like the output of print.ftable. Any ideas how to get the syntax of
summary.formula right. Or some alternative? As far I see, xtable does not
have method for ftable.

Dieter


library(Hmisc)
n=500
sex <- factor(sample(c("m","f"), n, rep=TRUE))
treatment <- factor(sample(c("Drug","Placebo"), n, rep=TRUE))
symptom <- factor(sample( c('H','S','G'), n,TRUE))
# I want this output in latex
ftable(symptom~treatment+sex)
# No, it's not the same
ss = summary(symptom~treatment+sex,fun=table)
latex(ss)

__
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] Linear Mixed Models with nlme, more than one random effect

2007-06-21 Thread Dieter Menne
  cropdesign.com> writes:

> Have a look at Rnew volume 5/1 (http://cran.r-project.org/doc/Rnews/) where
> Doug Bates explains this nicely. Consider using lme4 for your purpose.

But be aware of 
if you currently want to use lme4.

Dieter

__
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] User Defined R Functions in Sweave/Latex

2007-06-21 Thread Dieter Menne
M. Jankowski  gmail.com> writes:

> My Sweave code is intended to make lots of plots and create a *.pdf
> document. Sweave is perfect for this. The only problem is that  I find
> myself using the same R code, within my Sweave input file over an
> over. 

 
> This is the R function:
> basicplot <- function(x, nplots, sectionname){
> # Begin to make figure here
> file = paste("scatter",nplots, ".pdf", sep="")
> pdf(file = file,paper="special", width=6, height = 6)
> plot(x)
> dev.off()
> cat("\\begin{figure}\n")
> cat("\\includegraphics{",file,"}\n", sep="")
> cat("\\caption{", sectionname,"}\n", sep = "")
> cat("\\end{figure}\n")
> #End figure making
> }
> 
I don't know if this is exactly what you want, but below an example of using
includegraphics in a latex macro. For a real application, I recommend
\FloatBarrier instead of \clearpage when you have lots of figures/tables and
little text, as it's common in technical stuff.

Dieter

% -- Begin Sweave example
\documentclass[a4paper]{article}
\usepackage{Sweave}
\SweaveOpts{engine=R,eval=TRUE,eps=FALSE,pdf=TRUE, strip.white=TRUE}
\SweaveOpts{echo=FALSE,results=hide,width=6,height=4}

\bibliography{menne}
\begin{document}
\section{Hello}

\newcommand\doaplot[3]{

\begin{figure}
  \centering
\subsection{ #1}
\includegraphics{#2}
  \caption{3}
  \label{fig:#2}
\end{figure}
The meaning of life is The meaning of life is
The meaning of life is
The meaning of life is
The meaning of life is
\clearpage

}

<>=
 for (nplots in 1:3) {
   file = paste("scatter",nplots, ".pdf", sep="")
   pdf(file = file,paper="special", width=6, height = 6)
   plot(rnorm(100),rnorm(100),main=paste("Plot",nplots))
   dev.off()
   cat("\\doaplot{Section",nplots,"}{scatter",nplots,"}{My caption for ",
 nplots,"}\n",sep="")
 }
@

\end{document}

__
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] How to draw several ROC curves on a common graph

2007-06-20 Thread Dieter Menne
Tirthadeep  gmail.com> writes:

> >library(ROCR)
> 
> >plot(roc1)
> >plot(roc2)
> 
> gives two plots on two different graph. Now i want to merge on a single
> graph. 
> 
> >plot(roc1)
> >points(roc2)


Use parameter add=TRUE in all but the first call

Dieter

__
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] Stacked barchart color

2007-06-12 Thread Dieter Menne
hadley wickham  gmail.com> writes:

> 
> On 6/12/07, Dieter Menne  menne-biomed.de> wrote:
> > Dear Latticer,
> >
> > I want to give individual colors to all elements in a simple stacked
> > barchart. I know why the example below does not work (and it is a excellent
> > default), but is there any workaround for this?
> >
> 
> You can do this with ggplot2 (http://had.co.nz/ggplot2) as follows:
> 
> library(ggplot2)
... 

Thanks, Hadley and Deepayan. Hadley's version required the latest update of
ggplot2 (0.5.1).

Dieter

__
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] Stacked barchart color

2007-06-12 Thread Dieter Menne
Dear Latticer,

I want to give individual colors to all elements in a simple stacked
barchart. I know why the example below does not work (and it is a excellent
default), but is there any workaround for this?

Dieter


# This only colors red and green, but I want blue and gray for Peatland.

barchart(yield ~ variety , groups=year, data = barley,  stack = TRUE,
  subset=site=="Grand Rapids" & variety %in% c("Velvet","Peatland"),
col=c("red","green","blue","gray"))

__
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] how to ignore error messages?

2007-06-11 Thread Dieter Menne
Jianping Jin  email.unc.edu> writes:
...
> I wrote a code to iterate a non-linear fit with a set of data. The entire 
> process didn't implemented to the end because an error message, "singular 
> gradient". I knew that some sub-sets (columns) do not fit my formula well 
> and may result in parameters going to infinity. It is pretty hard to remove 
> those sub sets before running the code since that will take a lot of time.
> 
> I added some logic assessments prior to running nonlinear fit. It helped 
> but some exceptions still existed. I am wondering if there is any way in R 
> by which I can continue to run the entire code to the end by ignoring the 
> error message?
...

?try

Or, even easier, use nlsList in nlme, which does exactly what you want, handling
convergence errors graciously.

Dieter

__
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] Standard errors of the predicted values from a lme (or lmer)

2007-06-04 Thread Dieter Menne
Fränzi Korner  oikostat.ch> writes:

> sorry for not being more specific. I would like to use R to get a prediction
> (with standard error) of the response in a mixed model at selected values of
> the fixed-effects factors. Hence, in a mixed model, say, for response body
> size with, say, fixed factors sex and age, I would like to get a prediction
> of size for each sex and at selected ages such as 5, 10, 15; and I want a SE
> for that prediction as well. 
 

In that case, estimable in gmodels (by Greg Warnes, as also suggested by Michael
Kubovy) and glht in Thorsten Hothorn's multcomp are best. The first works for
lme out of the box, the very powerful glht can handle lmer(lme4), with strong
support for multiple testing. Too bad the latter does not immediately work with
lme, but it can be tweaked.

In both cases, you have to construct the contrast matrix, which can be
error-prone for complex models. To my knowledge (??), there is no
simple-to-handle package that generates this matrix with an intuitive interface.

Dieter

__
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] Standard errors of the predicted values from a lme (or lmer)-object

2007-06-01 Thread Dieter Menne
Fränzi Korner  oikostat.ch> writes:

> 
> how do I obtain standard errors of the predicted values from a lme (or
> lmer)-object?

Not totally clear what you mean. intervals(lmeresult) gives the confidence
intervals for the coefficients. Otherwise, you can do some calculations with
residuals(lmeresult). Most useful for diagnostic purposes is plot(lmeresult).

Dieter

__
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] Function to Sort and test AIC for mixed model lme?

2007-05-24 Thread Dieter Menne
Ken Nussear  mac.com> writes:

> I'm running a series of mixed models using lme, and I wonder if there  
> is a way to sort them by AIC prior to testing using anova 
> (lme1,lme2,lme3,lme7) other than by hand.

You can try something like the following. However, also consider using 
dropterm or stepAIC in MASS.

Dieter


#-
library(nlme)
fmlist = vector("list",2)
fmlist[[1]] = lme(distance ~ age, data = Orthodont,method="ML") 
fmlist[[2]] = lme(distance ~ age + Sex, data = Orthodont, 
  random = ~ 1,method="ML")
aic0 = unlist(lapply(fmlist,AIC))
aic0 # larger first
fmlist1 = fmlist[order(aic0)]
unlist(lapply(fmlist1,AIC)) # smaller first

__
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] RColorBrewer Package Color index

2007-05-23 Thread Dieter Menne
W. Katy  hotmail.com> writes:

> 
> Can anyone kindly help me with the interpretation of colors in the 
> RColorBrewer Package (brewer.pal) ? 
> 
> For example, in brewer.pal command, when picking up the "RdBu" palette, 
> does red means larger or smaller value?

Conventionally, the redder colors feel warmer, so they are associated with
higher (temperature) values. Try the original page http://colorbrewer.org where
you can experiment with the color sets and receive recommendations on their use.

Dieter

__
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] Multivariate Outlier Detection - Robust

2007-05-13 Thread Dieter Menne
Fiona Sammut  um.edu.mt> writes:

> Whilst reading a book on robust statistics, in particular a section on 
> multivariate outlier detection, I came across the functions outmve, 
> outmgv and outpro.  I tried the help.search command to try and find 
> documentation on these 3 commands in R.  I also searched online, but no 
> to avail.  I suppose that these 3 functions are not in an inbuilt 
> package in R.  Can you please tell me in which package can I find these 
> functions?
> 

Try to remember the author's name, and use google, you will find the code
(I did).

Dieter

__
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] Need an working examples

2007-05-09 Thread Dieter Menne
Aurel Razvan Duica  amdocs.com> writes:

> Can you please provide me with an working example of clustering in R
> (not very complicated) and with an example of survey in R.
> 
> We would appreciate this very much. We need them as soon as possible.

Sooner is not possible: there are really simple examples both in stat (e.g.
hclust) and in package cluster (starting from agnes).


Dieter

__
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] ANOVA results in R conflicting with results in ot her software packages

2007-04-26 Thread Dieter Menne
Simon Blomberg  uq.edu.au> writes:

.
> I won't discuss the dangers of "types" of sums of squares and different
> contrast codings. That would be tempting the wrath of the gods. See
> section 7.18 in the R FAQ. John Fox's "Companion" book also has a brief
> discussion (p. 140).

And  

Dieter

__
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] SweaveInput and absolute paths

2007-04-26 Thread Dieter Menne
Kevin R. Coombes  mdacc.tmc.edu> writes:

> 
> Is there a way to turn off the automatic inclusion of "./" at the 
> beginning of a path specified in an \SweaveInput{} instruction?
> 

Giving a full file path name works for me (Windows, R 2.4.1)

\SweaveInput{C:/tmp/MyTitle.rnw}

Note the if the path does not exist, e.g

\SweaveInput{C:/tmpnotexist/MyTitle.rnw},

the error message refert to  "./C:/tmpnotexist/MyTitle.rnw", so it could be that
the path you chose had been incorrectly entered.

Dieter

__
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] Multiple trellis plots without intervening space

2007-04-26 Thread Dieter Menne
David Lindelof  ieee.org> writes:

> I'm trying to create a 10x7 rectangular grid of individual plots, each
> of which is a contour plot that shows a slice from a three-dimensional
> matrix.

The problem is that you construct individual plots, and then try to glue these
together. This is a bit against the trellis philosophy. Think of one data.frame,
one plot, broken down by panels.
 
> How can I specify that I do not want any margin at all between the
> plots, nor tick marks or axis labels? I have tried setting every
> layout.widths$XXX to zero without success.
> 

And then try the last example on the contourplot page, which does exactly what
you want.

Dieter

__
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] xyplot source file only work with echo=TRUE

2007-04-24 Thread Dieter Menne
Ronaldo Reis Junior  gmail.com> writes:

> I write several xyplot graphics on a source file. When I try to use 
> source("graphics.R") the source don't work, but if I use 
> source("graphics.R",echo=T) it work. Generally some commands work without 
> echo=T, but xyplot dont work. Why it dont work without echo=T? It is possible 
> to write a source that dont need echo=T on source command?
> 

Most likely another variant of 

<http://post.gmane.org/post.php?group=gmane.comp.lang.r.general&followup=83924>

See: Why do lattice/trellis graphics not work?

Dieter Menne

__
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] Regarding Vista

2007-03-29 Thread Dieter Menne
  ccilindia.co.in> writes:

> 
> I am facing the same problem in my case. R 2.4.1 have installed 
> successfully, but when i try to install the packages from a local zip 
> file. It gives the following error message. 
> +++
> > utils:::menuInstallLocal()
> Error in zip.unpack(pkg, tmpDir) : cannot open file 'C:/Program 
> Files/R/R-2.4.1/library/file5d2b5841/aaMI/chtml/aaMI.chm'
> > 
> +++
> 
> Please tell me how to install the packages in a corporate environment. I 
> mean i could not understand your reply, may you be a bit more elaborate so 
> that i can fix up the problem in my corporate laptop.

The general recommendation in the FAQ Prof. Ripley mentions works for me; so
does switching of User Account Control (english?) totally. This may not be
feasible for you on a corporate laptop. I tried the following method: Download
the updates locally, remove the chm folder, install from local zip file. Works
for some packages, but when a DLL is included, the story starts again, and you
cannot remove these. 

So, sorry, currently no simple solution for corporate laptops where you don't
have full rights.

Dieter

__
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] Wikibooks

2007-03-29 Thread Dieter Menne
Ben Bolker  zoo.ufl.edu> writes:

>   Well, we do have an R wiki -- http://wiki.r-project.org/rwiki/doku.php --
> although it is not as active as I'd like.  (We got stuck halfway through
> porting Paul Johnson's "R Tips" to it ...)   Please contribute!

I once tried:

http://wiki.r-project.org/rwiki/doku.php?id=guides:lmer-tests

but I don't think I will do this again on the existing Wiki. I am a frequent
Wikipedia-Writer, so I know how it works, but this was discouraging.

1) The structure of the Wiki was and is still incomprehensibly to me. I needed
too much time to find out how to put the stuff into it.

2) I decided to use the "large guides" section, because I wanted the thread
transcript to be one one page. If you check the revision history, you will find
that I needed more than three hours to get it working. The main reason is the
sluggish response, and the incomprehensible error messages or the lack of it
when some " was not matched or whatever (Thanks, Ben, for correcting the
remaining errors). This is a problem of the Wiki software used, other Wikis such
as Media(pedia) are much more tolerant or informant.

Then, Philippe Grosjean informed me: "Your page is way too long and is a rather
crude copy and paste from the long thread in the mailing list."

I disagree. Why do you have a "large guides" section? And taking into account
the amount of work I put into reformatting the transcript, I decided it was my
first and last contribution to the Wiki.

Dieter Menne

__
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] Regarding Vista

2007-03-29 Thread Dieter Menne
  shell.com> writes:

> The Vista issue is not innocent as it threatens the life of R within large
corporations. So any posts on how R
> runs under Vista and what has to be done to make it work and what cannot be
done etc will be very useful. 

Main problem seems to be the installation of chm-files when upgrading. I had to
switch off all security mechanisms to get it done. Which is probably not what
you would like to have in a corporate environment.

As a temporary workaround, it would probably be best to optionally disable chm
installation. Or do a poll if is is required, after all it's considered a legacy
format nowadays.

Dieter

__
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] equivalent datatypes

2007-03-29 Thread Dieter Menne
Duncan Murdoch  stats.uwo.ca> writes:

> 
> On 3/29/2007 6:45 AM, Schmitt, Corinna wrote:
> > - cell array
> 
> I don't know what a cell is in C.
> 

This is MathLabish.

Dieter

__
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] tcltk crashing R after the (ab)use of tkwait

2007-03-29 Thread Dieter Menne
Alberto Monteiro  centroin.com.br> writes:

> library(tcltk)
> tt <- tktoplevel()
> done <- tclVar(0)
> but <- tkbutton(tt, text="OK", command=function() tclvalue(done) <- 1)
> tkpack(but)
> tkwait.variable(done)
> 
> works as fine as long as I click the OK. However, if I close
> the window (by clicking in the X), R enters into an infinite loop
> and there's no way of returning except by closing the R window.
> 
Works for me with R-2.4.1 on Windows 2000. So better tell us about the details
of your operating system.

Dieter

__
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] logistic regression on contingency table

2007-03-05 Thread Dieter Menne
Bingshan Li  bcm.tmc.edu> writes:

> I am wondering if there is a way in R to fit logistic regression on  
> contingency table. If I have original data, I can transform the data  
> into a design matrix and then call glm to fit the regression. But now  
> I have a 2x3 contingency table with first row for response 0 and  
> second row for response 1, and the columns are 3 levels of predictor  
> variable. The 3 levels are not ordinal though and indicator variables  
> would be more appreciate.

>From Documentation of GLM:

For binomial and quasibinomial families the response can also be specified 
as a factor (when the first level denotes failure and all others success) 
or as a two-column matrix with the columns giving the numbers of successes 
and failures.  


Dieter Menne

__
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] LD50 contrasts with lmer/lme4

2007-02-26 Thread Dieter Menne
Dear R-list,

I have a data set from 20 pigs, each of which is tested at crossed 9 doses
(logdose -4:4) and 3 skin treatment substances when exposed to a standard
polluted environment. So there are 27 patches on each pig. The response is
irritation=yes/no.

I want to determine "equally effective 50% doses" (similar to old LD50), and
to test the treatments against each other. I am looking for something like
dose.p in MASS generalized to lmer (or glmmPQL or whatever). The direct as
output by lmer are not useful, because saying "30% irritation with A and 40%
with B at dose xx" has less meaning than giving "equivalent effective
doses".

Dieter

- Simulated data -
library(lme4)
animal = data.frame(ID = as.factor(1:20), da = rnorm(1:20))
treat = data.frame(treat=c('A','B','C'), treatoff=c(1,2,1.5),
   treatslope = c(0.5,0.6,0.7))

gr = expand.grid(animal=animal$ID,treat=treat$treat,logdose=c(-4:4))
gr$resp = as.integer(treat$treatoff[gr$treat]+
  treat$treatslope[gr$treat]*gr$logdose+
  animal$da[gr$animal] +  rnorm(nrow(gr),0,2) >0)

gr.lmer = lmer(resp ~ treat*logdose+(1|animal),data=gr,family=binomial)
summary(gr.lmer)

--- Output
Fixed effects:
   Estimate Std. Error z value Pr(>|z|)
(Intercept)  0.9553 0.30743.11   0.0019 **
treatB   0.8793 0.33132.65   0.0079 **
treatC   0.5516 0.30771.79   0.0730 .
logdose  0.3733 0.07744.82  1.4e-06 ***
treatB:logdose   0.3081 0.13232.33   0.0198 *
treatC:logdose   0.2666 0.12492.13   0.0328 *

- Goal
Value SD  p
50% logdose (A-B)  xx   xx  xx
50% logdose (A-C)  yy   yy  yy

__
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] Google, hard disc drives and R

2007-02-19 Thread Dieter Menne
Tim Churches  optushome.com.au> writes:

> 
> A recent paper from Google Labs, interesting in many respects, not the
> least the exclusive use of R for data analysis and graphics (alas not
> cited in the approved manner):
> 
> http://labs.google.com/papers/disk_failures.pdf
> 
...
For all of you who noted that the first author is E. Pinheiro: This is not the
first half of D Bates, who's first name is José.

Dieter

__
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] fit.contrast (package gmodels) and lmer

2007-02-17 Thread Dieter Menne
Friends of lme,

following the documentation of fit.contrast in package gmodels, it should be
possible to use it with lmer. At least with sim.lmer=TRUE and lmer(not 2),
because the latter has no mcmcsamp yet.

I could not get this to work. UseR error?

--
library(gmodels)
library(lme4)
options(show.signif.stars = FALSE)
data(ergoStool)
fm1 <- lmer(effort ~ Type + (1|Subject), ergoStool)
mcmcsamp(fm1) ## works

fit.contrast(fm1,"Type",c(1,1,0,0),sim.lmer=TRUE)
# Not an applicable method


--
Note: I am well aware of the discussion about df/lmer in

http://wiki.r-project.org/rwiki/doku.php?id=guides:lmer-tests
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/76742.html

so I don't expect the method to work with sim.lmer=FALSE. And yes, the
example is simple and results can be obtained directly. However, I looking
for an easy-to-use general contrast test, and fit.contrast and estimable are
the only ones I know of that work rather generally.

Dieter

__
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] Suppresing default text in pairs.lmList() in package = nlme

2007-02-11 Thread Dieter Menne
Michael Kubovy  virginia.edu> writes:

> 
> I would like to suppress the text 'Scatter Plot Matrix' that appears  
> under the plot. Could someone please suggest how?

Must be as special Virginia Brand of lmList. That Test does not turn up in my
output, and the only place I found it in the sources was as a comment

## scatter plot matrix plots, generally based on coef or ranef



Dieter

__
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] Near function?

2007-02-10 Thread Dieter Menne
Bart Joosen  hotmail.com> writes:

> 
> Hi,
> 
> I have an integer which is extracted from a dataframe, which is sorted by
another column of the dataframe.
> Now I would like to remove some elements of the integer, which are near to
others by their value. For example:
> integer: c(1,20,2,21) should be c(1,20).


> Sorting the integer is not an option, the order is important.

Why not? It's extremely efficient for large series and the only method that
would work with large array. The idea: Keep the indexes of the sort order, mark
the "near others" for example making their index NA, and restore original order.
No for-loop needed.

Dieter

__
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] "lme" in R and Splus-7

2007-02-06 Thread Dieter Menne
yyan liu  yahoo.com> writes:

>   I used the function "lme" in R and Splus-7. With the same dataset and same
argument for the function, I got
> quite different estimation results from these two software. Anyone has this
experience before?

>From the FAQ:

R by default uses treatment contrasts in the unordered case, whereas S uses the
Helmert ones. This is a deliberate difference reflecting the opinion that
treatment contrasts are more natural.

Dietr

__
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] coefficients of each local polynomial from loess() or locfit()

2007-01-08 Thread Dieter Menne
Liu, Delong (NIH/CIT) [C]  mail.nih.gov> writes:

> Instead, I am more interested in obtaining the
> coefficient estimates of local polynomial from loess().  Is it
> straightforward to modify loess() so that the coefficient estimates can
> be put into the return list of loess()?  

No need to change loess.
> 
> cars.lo <- loess(dist ~ speed, cars)
> str(cars.lo)
> 
> List of 17
...
>  $ kd   :List of 5
>   ..$ parameter: Named int [1:7] 1 50 2 19 11 1049 849
>   .. ..- attr(*, "names")= chr [1:7] "d" "n" "vc" "nc" ...
>   ..$ a: int [1:19] 1 1 1 1 1 1 1 0 0 0 ...
>   ..$ xi   : num [1:19] 15 12 19 9 13 17 20 0 0 0 ...
>   ..$ vert : num [1:2]  3.90 25.11
>   ..$ vval : num [1:22]  5.71  1.72 96.46 10.88 41.21 ...

As I showed you, they are in cars.lo$kd, but you must dig into the source code
to find out how they are used. And after reading Brian Ripley's warning, I would
recommend that you don't try it if you are not sure how "extract" these.

Dieter

__
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] coefficients of each local polynomial from loess() or locfit()

2007-01-05 Thread Dieter Menne
Liu, Delong (NIH/CIT) [C]  mail.nih.gov> writes:

> 
> I want to extract estimated coeffiicents of each local polynomial at given x
from loess(),  locfit(), or
> KernSmooth().  Can some experts provide me with suggestions?  Thanks.

Before you start on your own, also note Brian Ripleys recent posting on

http://article.gmane.org/gmane.comp.lang.r.general/76625


Dieter

__
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] coefficients of each local polynomial from loess() or locfit()

2007-01-05 Thread Dieter Menne
Liu, Delong (NIH/CIT) [C]  mail.nih.gov> writes:

>>> 
I want to extract estimated coeffiicents of each local polynomial at 
given x from loess(),  locfit(), or KernSmooth().  Can some experts 
provide me with suggestions?  Thanks.
>>

Try 

cars.lo <- loess(dist ~ speed, cars)
str(cars.lo)

List of 17
 $ n: int 50
 $ fitted   : num [1:50]  5.89  5.89 12.57 12.57 15.37 ...
 $ residuals: Named num [1:50] -3.894  4.106 -8.568  9.432  0.631 ...
... omitted
  ..$ cell   : num 0.2
  ..$ family : chr "gaussian"
  ..$ iterations : num 1
 $ kd   :List of 5
  ..$ parameter: Named int [1:7] 1 50 2 19 11 1049 849
  .. ..- attr(*, "names")= chr [1:7] "d" "n" "vc" "nc" ...
  ..$ a: int [1:19] 1 1 1 1 1 1 1 0 0 0 ...
  ..$ xi   : num [1:19] 15 12 19 9 13 17 20 0 0 0 ...
  ..$ vert : num [1:2]  3.90 25.11
  ..$ vval : num [1:22]  5.71  1.72 96.46 10.88 41.21 ...
 $ call : language loess(formula = dist ~ speed, data = cars)

Looks like kd holds information about the polynomials. Then, try

getAnywhere(predict.loess)

which will show you that the real work is done in function predLoess. 
Trying again

getAnywhere(predLoess)

you get an idea how the parameters are used for prediction.

fit[inside] <- .C(R_loess_ifit, as.integer(kd$parameter), 
 as.integer(kd$a), as.double(kd$xi), as.double(kd$vert), 
as.double(kd$vval), as.integer(M1), as.double(x.evaluate[inside, 
  ]), fit = double(M1))$fit

Dieter

__
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] Help with filled.contour()

2007-01-02 Thread Dieter Menne
Michael Kubovy  virginia.edu> writes:

> 
> I tried and it gave a strange result. See
> http://people.virginia.edu/~mk9y/mySite/twoGaussian.R
> and
> http://people.virginia.edu/~mk9y/mySite/twoGaussian.pdf
> 
> *
> Session Info
> *
>  > sessionInfo()
> R version 2.4.1 (2006-12-18)
> powerpc-apple-darwin8.8.0

Hmm, strange, I can reproduce your problem on Windows (otherwise same config)
with pdf, but it looks beautifully on screen for me if I mentally remove the
ugly legend.

Dieter

__
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] Help with filled.contour()

2007-01-01 Thread Dieter Menne
Michael Kubovy  virginia.edu> writes:

> 
> The following plot is a first approximation to what I need:
.. see below 

> ***
> It has four drawbacks. I would like:
> (1) to remove the white grid;
> (2) to remove the white contours;
> (3) its appearance to be smooth;
> (4) to remove the key.


In partial fulfillment of your requirements, increasing the levels gives a nice
smooth plot.

mu1 <- 0
mu2 <- 5
s <- 1
x <- seq(-2.5, 7.5, length = 41)
y <- seq(-2.5, 2.5, length = 41)
f <- function(x,y){
term1 <- 1/(2*pi*sqrt(s*s))
term2 <- -1/2
term3 <- (x - mu1)^2/s
term4 <- (y - mu1)^2/s
term5 <- (x - mu2)^2/s
term1*(.5 * exp(term2*(term3 + term4)) + .5 * exp(term2*(term5 +  
term4)))
}

z <- outer(x, y, f)
persp(x, y, z)
require(grDevices)
filled.contour(x, y, z, axes = F, frame.plot = F, asp = 1,
 col = palette(gray(seq(0, 0.9, len = 500))), nlevels = 500)

I thought that lattice would be more flexible, and getting rid of the keys was
easy, only I could not get the smooth plot. Deepayan, are we missing something?

library(lattice)
dt <- expand.grid(x=x,y=y)
dt$z <- apply(dt, 1,function(xy)  f(xy[1],xy[2]))
col.regions = palette(gray(seq(0, 0.9, len = 500)))
contourplot(z~x*y,data=dt,cuts=20,col.regions=col.regions,colorkey=FALSE,
  contour=TRUE,region=TRUE)


Dieter

__
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] zero random effect sizes with binomial lmer

2007-01-01 Thread Dieter Menne
Daniel Ezra Johnson  babel.ling.upenn.edu> writes:

> 
> I am fitting models to the responses to a questionnaire that has
> seven yes/no questions (Item). For each combination of Subject and
> Item, the variable Response is coded as 0 or 1.
> 
> I want to include random effects for both Subject and Item. While I
> understand that the datasets are fairly small, and there are a lot of
> invariant subjects, I do not understand something that is happening
> here, and in comparing other subsets of the data.
> 
> In the data below, which has been adjusted to show this phenomenon
> clearly, the Subject random effect variance is comparable for A
> (1.63) and B (1.712), but the Item random effect variance comes out
> as 0.109 for B and essentially zero for A (5.00e-10).
...

Check the list archives for quite a few postings of Professor Brian Ripley on
the subject of Hauk-Donner.


Dieter

__
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] Types of objects?

2007-01-01 Thread Dieter Menne
Raymond Balise  gmail.com> writes:

> 
> Is there a list of object types used by R?  Is there a function that I can
> use to tell the type of an object?
typeof()

Dieter

__
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] Crosstab from sql dump

2006-12-30 Thread Dieter Menne
Alan Gibson  gmail.com> writes:

> Im looking for a simple function to produce a crosstab from a dumped
> sql query result. 


xtabs in stats is a simple solution, but package reshape is much more flexible
and comes with a good introduction.pdf.

Dieter

__
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] how to do muliple comparisons in linear mixed models

2006-12-20 Thread Dieter Menne
liu, jcheng  gmail.com> writes:

> i want to compare the several main effects in a linear model. i wonder
> how to do the multiple comparisons for less confident intervals.

Package multcomp by Torsten Hothorn.

Dieter

__
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] exporting a table to latex

2006-12-13 Thread Dieter Menne
Rainer M Krug  sun.ac.za> writes:

> I am using the latex() command from the Hmisc package to export  table 
> to latex. For formating of the values, I use the format() function. But 
> I don't manage to get the format of the values right: I don't want 
> scientific notation, but if I say scientific=FALSE, I get many digits 
> after the decimal point which I can not control with digits=... and 
> nsmall=... in the format command.
> 
> Is there another way of formating the values to three decimal digits?
> 
> Or another way of exporting them to LaTeX?

There were a few bugs in the current versions of format.df (called by latex),
and the "scientific" problem could have been among them.

Try to download latex.s from 

http://biostat.mc.vanderbilt.edu/svn/R/Hmisc/branches/release_3.2-1/R/latex.s

do 

library(Hmisc)
source("latex.s")

and check if the problem disappears. If it does, write a mail to [charles.dupont
at vanderbilt.edu] and ask him to make the version public as soon as possible.

Dieter

__
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] solving non linear system of eq

2006-12-11 Thread Dieter Menne
Paulino Perez Rodriguez  colpos.mx> writes:

> How can I solve a non linear system of equations using R?

Have your tried to enter "nonlinear equations" into http://search.r-project.org?

Dieter

__
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] Switch and integer

2006-12-11 Thread Dieter Menne
Knut Krueger  einthal.de> writes:

> 
> Switch is working with character , with integer, but not in the third 
> example
... 
> #  not working
test = c(3,9,3,9,3,9,8,9,8,9,8,9,3,9,3,9,5,9,3,9,1,2,7,9,3,9,1,1,
2,2,3,9,2,1,2,5, 9,8,9,1,2)
> count1 <- 0
> for (i in 1:length(test))
>   switch (EXPR=test[i],
>   4 = count1 <- count1 +1,
>   5 = count1 <- count1 +1,
>   6 = count1 <- count1 +1,
>   7 = count1 <- count1 +1,
>   8 = count1 <- count1 +1
>   )
>   count1
> 

switch has a different behavior when an integer is use, which is a bit hidden 
in the term "corresponding". 

"If the value of EXPR is an integer between 1 and nargs()-1 then the
corresponding element of ... is evaluated and the result returned."

So something like the example below might come close to what you want. 
In each case you have to add the default last item to avoid a NULL.

"In the case of no match, if there's a further argument in switch that one 
is returned, otherwise NULL."

Dieter

test =c(4,5,8,1,13)
count1 <- 0
for (i in 1:length(test)) {
  count1 <- switch (EXPR=as.character(test[i]),
  "4" = count1 +1,
  "5" = count1 +1,
  "6" = count1 +1,
  "7" = count1 +1,
  "8" = count1 +1,
  count1
  )
}
count1

__
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] What training algorithm does nnet package use?

2006-11-22 Thread Dieter Menne
Wee-Jin Goh  brookes.ac.uk> writes:

> 
> Just to add to this, I also need to know what language is the "nnet"  
> package written in? Is it in pure R or is it a wrapper for a C  
> library. 

As usual, you can download the full source to find out what you want, but it's a
bit hidden. Simply said, nnet (R+C) is part of package MASS is part of bundle
VR, and can be downloaded as a tar.gz from

http://cran.at.r-project.org/src/contrib/Descriptions/VR.html

(No private flames, please, in case I should have mixed up package and bundle).

/*  nnet/nnet.c by W. N. Venables and B. D. Ripley  Copyright (C) 1992-2002
 *
 * weights are stored in order of their destination unit.
 * the array Conn gives the source unit for the weight (0 = bias unit)
 * the array Nconn gives the number of first weight connecting to each unit,
 * so the weights connecting to unit i are Nconn[i] ... Nconn[i+1] - 1.
 *
 */

#include 
#include 

__
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] error in format.df when using dec

2006-11-07 Thread Dieter Menne
Rainer M Krug  sun.ac.za> writes:

> 
> When using format.df with dec, the formating does not work (see code 
> below).

 
>  > format.df(x, dec=2)
>a   b   m 1 m 2
> 1 "1.120" "3" "5" "7"
> 2 "2.230" "4" "6" "8"

This is the same bug introduced in the latest version of Hmisc as reported in 

http://article.gmane.org/gmane.comp.lang.r.general/73186


Dieter

__
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] Hmisc, latex cdec not as expected - again

2006-11-06 Thread Dieter Menne
Henrik Frederik Thomsen  DCE.AU.DK> writes:


> I have encountered at problem when using the Hmisc package to generate
> latex-tabels. 
> 
> I can't seem to control the number of digits in the latex-file. I have
> used the Design and Hmisc packages for a while without this problem, but
> after upgrading to R-2.4.0 the problem has occured. 
...

This bug has been confirmed by Frank Harrell and Thomas Dupont on October 25.
They are working on it.

Dieter

__
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] Using a deriv function in nlme

2006-11-03 Thread Dieter Menne
Lisa Avery  sympatico.ca> writes:

> 
> Hello,
> 
> I have a deriv function that I am feeding to nlme. It works, and I can use
> it in nls, but when I try to use it in nlme I get Error: subscript out of
> bounds.  I can fit the model using SSasympOrig, instead of the deriv

It might by a similar problem as in 

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/4555.html

Dieter Menne

__
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] Rank transformation and the linear mixed model

2006-11-03 Thread Dieter Menne
Bruno L. Giordano  music.mcgill.ca> writes:

> 
> I am looking for references about mixed models built on rank transformed 
> data.


To complement Frank H: Try lrm in package Design.

Dieter

__
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] Prediction intervals for predict.gls

2006-11-03 Thread Dieter Menne
Spencer Jones  gmail.com> writes:

> 
> I am using R 2.3.0, Is there a way to get prediction intervals using
> predict.gls?
> 
A r-project site search (alway recommended) would have given you

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/42932.html

Dieter

__
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] Compare linear regressios for significant differenc es of the slopes

2006-11-03 Thread Dieter Menne

Rainer M Krug wrote:
> > I have (8 measures * 96 groups) = 768 datasets for which I did linear
> > regressions using lm().
> > 
> > Now I want to compare the slopes for each of the 8 measures in each of 
> > the 96 groups. As I understand , I can not use
> >> anova(lm1, ..., lm8)
> > as the lm1 ... lm8 are based on different datasets.
> > 

Instead of doing this in two steps, you would better use lme in package nlme to
test the hypothesis in one run. I don't understand the details of you design,
but is looks like the oxboys example in Pinheiro/Bates (the book of nlme) could
give you a first starter.

Dieter

__
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] Lmer, heteroscedasticity and permutation, need help please

2006-10-23 Thread Dieter Menne
Alan Juilland  unil.ch> writes:

 
> 2/ I read somewhere that lme is more adequate when heteroscedasticity is 
> strong. Do I have to use lme instead of lmer ?

This is correct, because currently lme has the "weights" argument to handle this
(i.e. weights=varPower()), while lmer is under development an does not support
this argument YET.

Dieter Menne

__
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] toggleDoc: clutter reduction mainly for S4 documentation files

2006-10-23 Thread Dieter Menne
The following perl-script is available from

http://www.menne-biomed.de/download/toggleDoc.zip

After it is tested on other systems (currently only Windows),
I plan to upload it to

http://cran.mirroring.de/other-software.html


toggleDoc.pl: Clutter reduction for S4-R documentation files.

Version 1.0, 23.10.2006


[EMAIL PROTECTED]

Perl script to optionally reduce clutter in the index file of S4 html and in
S3
files with many repetitive functions documentation. For an example using the
documentation of the coin package, see
http://www.menne-biomed.de/download/00Index.html .

Install and Convert

Put the file toggleDoc.pl and the javascript file toggleDoc.js into the
Rxxx/library
directory (you should  find the R.css file there).
For the protection of your valuable assets,  when you run this script
unmodified
new files 00IndexNew.html will be generated in each directory.

If you want to replace your original 00Index.html with the modified ones,
re-run
this script with the two commented lines a the bottom of the Perl script
commented out.

* Warning: this script has been tested under Windows only.
Please report required changes for Linux to [EMAIL PROTECTED]

What it does:

Only 00Index.html files are changed by adding a javascript reference and a
checkbox to switch between the "Show All" mode and the short mode; the
latter
is made the default on startup.
All references that have a "," are hidden in the short mode, e.g.

dperm,IndependenceTest-method

In addition, repetitive similar entries with a common target file are
collapsed
to the first entry. For example, in R2HTML the following list only shows the
first HTML reference in short mode.

HTML  Outputs an object to a HTML file
HTML.anova.loglm  Outputs an object to a HTML file
HTML.aovOutputs an object to a HTML file

The program does not touch files with the string "toggleDoc.js" in the
header, so if you want to protect single files from being processed, simply
add this string in a comment to the html file (but not that this will be
overridden anyway on the next update.)


The function has been tested with IE and Firefox 1.5.

__
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] write data to pdf

2006-10-19 Thread Dieter Menne
Franco Mendolia  gmx.de> writes:

> 
> Is there a possibility in R to save data in pdf-format?
> I do not want to save a plot but some lines of simple text.

I remember that about 4  years ago there was a thread on the subject, but I
could not find it any more. But, maybe, it's anyway better to think the other
way round, asking "How can I generate nice pdf tables with R". For that, you
should have a look at Sweave (latex), or package odfWeave if you prefer Open
Office output.

Dieter

__
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] Adding locfit confidence intervals in trelis xyplot

2006-10-19 Thread Dieter Menne
Deepayan Sarkar  gmail.com> writes:

> 
> On 10/18/06, juan f poyatos  cnio.es> wrote:
> > Dear all,
> > I am trying to include confidence intervals in a xyplot.
> >
...
 
> Well, panel.locfit doesn't have any options to draw confidence bands,
> so you'll have to write a panel function that does. Shouldn't be hard
> to extend panel.locfit if you know how to extract that information
> from a locfit object.

plot.locfit has bands. I think Juan mixed trellis and standard plot 
documentation.


x <- rnorm(100)
y <- dnorm(x) + rnorm(100) / 5
plot(locfit(y~x), band="global")

__
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] Nested source() errors

2006-10-19 Thread Dieter Menne
Pierce, Ken  oregonstate.edu> writes:

> 
> Does anyone know of any issues with nesting source() calls within
> multiple scripts? I have at least one script which always finds errors
> when I source it but runs fine when run on its own. It containd source()
> calls to other scripts and it seems to fail during the first nested
> source() command.
> 
This could happen when the last line in one of the files has no linefeed 
appended. But probably better take Andy's advice.

Dieter

__
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] creating bins for a plot

2006-10-19 Thread Dieter Menne
Jeffrey Stratford  auburn.edu> writes:

> 
> I'm trying to plot the ratio of used versus unused bird houses
> (coded 1 or 0) versus a continuous environmental gradient (proportion of
>  urban cover [purban2]) that I would like to convert into bins (0 -
> 0.25, 0.26 - 0.5, 0.51 - 0.75, 0.76 - 1.0) and I'm not having much luck
> figuring this out.  I ran a logistic regression and purban2 ends up
> driving the probability of a box being occupied so it would be nice to
> show this relationship.  I'm also plotting the fitted values vs. purban2
> but that's done.  
 
Check the example under predict.glm. It does not use binning, though.

--- Code below added because gmane complains about too much quoted text.

## example from Venables and Ripley (2002, pp. 190-2.)
ldose <- rep(0:5, 2)
numdead <- c(1, 4, 9, 13, 18, 20, 0, 2, 6, 10, 12, 16)
sex <- factor(rep(c("M", "F"), c(6, 6)))
SF <- cbind(numdead, numalive=20-numdead)
budworm.lg <- glm(SF ~ sex*ldose, family=binomial)
summary(budworm.lg)



Dieter

__
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] sqlSave, fast=F option, bug?

2006-10-18 Thread Dieter Menne
Paul MacManus  gmail.com> writes:

> Using the fast=F option, sqlSave saves without matching column names.
> It looks like a bug to me..
 
> In other words, sqlSave didn't check column names, it simply mapped
> column 1 to column 1 and column 2 to column 2.

This seems to be a problem with SQLServer. The following example with 
Access works correctly for me, even if I close the connection in between. 
(Win2k, R 2.4.0)

Dieter Menne

-
library(RODBC)
channel <- odbcConnectAccess("db1.mdb")
df <- data.frame(T=1, S=10)
sqlSave(channel, df, "test", rownames=F)
#odbcClose(channel)

#channel <- odbcConnectAccess("db1.mdb")
df <- data.frame(S=20, T=2)
sqlSave(channel, df, "test", rownames=F, append=T,fast=T)
odbcClose(channel)

__
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] if statement error

2006-10-17 Thread Dieter Menne
Jenny Stadt  yahoo.ca> writes:

> if(length(real.d)>=30 && length(real.b)>=30 && 
   beta1*beta2*theta1*theta2>0 )
> 
> { r <- 1;  corr <- 1;  }
> 
> real.d and real.b are two vectors, beta1,beta2,theta1,and theta2 are
> constants. The error occurred like this:
> 
> Error in 
> if (length(real.d) >= 30 && length(real.b) >= 30 && beta1 * beta2 *  : 
> missing value where TRUE/FALSE needed

Please follow the advice and provide a full example, where beta1 really is
a vector. This works for me below, but it give the message you mentioned if 
you uncomment second line.

Dieter

-
beta1 = beta2 =  theta1 = theta2 = 1.0
#beta1 = NULL
real.d = runif(35)
real.b = runif(35)
r=corr=0
if(
  length(real.d)>=30 && 
  length(real.b)>=30 && 
  beta1*beta2*theta1*theta2>0 ) { 
  r <- 1;  
  corr <- 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.


Re: [R] Transcript of "Conservative ANOVA tables"

2006-10-09 Thread Dieter Menne
Marc Schwartz (via MN  mn.rr.com> writes:

> If the content of this particular transcript is likely to be static,
> consider an alternative of making it available in a PDF document that is
> linked on that page.
> 
> Then others can perhaps contribute by providing other relevant content
> in that section as may be desired/required.

Well, I thought it would be better to leave it editable in case someone would
like to add corrections. And in case some VIP was not quoted correctly.

The worst part is the story of the disappearing pages, when something with the
quotes is incorrect. Reminds me of latex, but there I have much better (at least
more...) messages. 

Dieter

__
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] syntax of nlme

2006-10-09 Thread Dieter Menne
Thomas Wutzler  bgc-jena.mpg.de> writes:

> without grouped data (athough I recommend using grouped data after
> reading the book), the call can be formulated as:

Well, this is probably the only point where I disagree with Douglas Bates. I
found using grouped data introduces a level of indirection that makes life more
difficult. And, if you check the examples in this list, very few of them use
grouped data.

So I would wish that in the coming book there were more examples without grouped
data, as I know that finding the right syntax for these is difficult when the
book mainly hast groupedData examples.

Dieter

__
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] Transcript of "Conservative ANOVA tables"

2006-10-09 Thread Dieter Menne
Dear friends of lmer,

http://wiki.r-project.org/rwiki/doku.php?id=guides:lmer-tests

I have put a transcript of the long thread on lmer/lme4 statistical test
into the Wiki. For all those who missed it life, and for those like me, who
don't like the special style of the R-list to keep full length quotes.

Creating the text there was not much fun, waiting times are simply
unacceptable and the Wiki only give an empty page when syntax errors (for
example from quotes) are detected.

Dieter Menne

__
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] latex and anova.lme problem

2006-10-08 Thread Dieter Menne
Frank E Harrell Jr  vanderbilt.edu> writes:


> As far as I know, no one has implemented a latex method for anova.lme 
> objects.  

Well, I have, based on your latex/Hmisc, but it's a bit to my private taste, so
I won't upload it to CRAN. Also has latex.glm, .lme, .summary.lme.

http://www.menne-biomed.de/download/dmisc.zip
http://www.menne-biomed.de/download/dmisc_0.3.tar.gz


Dieter

__
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] Estimate in Wilcox_test vs wilcox.exact

2006-10-07 Thread Dieter Menne
  sanofi-aventis.com> writes:

> 
> Does any one know why wilcox.exact sometimes doesn't agree with wilcox_test on
the estimate of the
> difference of medians in two levels ?
> 

Example removed

See: 
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/85893.html


Dieter

__
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] "which" command

2006-10-06 Thread Dieter Menne
AgusSusanto  gmail.com> writes:

> 
> I obtained error messages when I run these commands in UNIX, but I 
> obtained correct result when I run these command in WINDOWS.  Can 
> somebody point out the problem and give the solution. Thanks.
> 
>  > dt<-read.table(file="Fall.dat")
>  > dim(dt)
> [1] 19415

Windows file names are not case sensitive, UNIX is. Check you effective 
filename.

Dieter

__
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] Fitting a cumulative gaussian

2006-10-06 Thread Dieter Menne
Gamer, Matthias  uni-mainz.de> writes:

> Specifically, I have data from a psychometric function relating the 
> frequency a subject's binary response (stimulus present / absent) to the 
> strength of a physical stimulus. Such data is often modeled using a 
> cumulative gaussian function. 

Well, more often by a logistic function, and there are quite a few tools
powerful for doings this around, for example glm, or lmer/lme4, glmmPQL/MASS,
glmmML/glmmML . The latter three are the tools of choice when you have within
subject repeats, as it's standard in psychophysics. See
http://finzi.psych.upenn.edu/R/Rhelp02a/archive/33737.html for a comparison.

If you really want a cumlative gaussian, you can misuse drfit/drfit, which is
primarily for dose/response curves and ld50 determination. I think there is a
fitdistr/MASS example around (somewhere in the budworms chapter), but I don't
have the book at hand currently.

Dieter

__
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] plotting

2006-10-01 Thread Dieter Menne
Anupam Tyagi  yahoo.com> writes:

> 
> Is there something in R that will display both observed values and their
> influence on calculated statistics?

In general : yes. You may give the example in the "lm" documentation a first
try, and then rephrase your question.

Dieter

__
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] S4 documentation - Was: "exact Wilcoxon signed rank test "

2006-08-27 Thread Dieter Menne
Torsten Hothorn  rzmail.uni-erlangen.de> writes:

... 
> indeed, this is the only gap to be filled in `coin', I just haven't had 
> the time to implement this. And of course, `exactRankTests' is still 
> available and will be available in the future. So you _can_ use it!

 
Torsten, and R-Coders,

"coin" is really a great step forward, but looking at the documentation of both
"exactRankTest" and "coin" together shows one bad thing about S4 documentation: 

You can't find the important things any more. (not your fault, Torsten)

The functions you are going to need are drowned in a dozen "initialize" and
other stuff that is irrelevant for those who only want to use do the tests. It's
similar in nlme/lme4(currently documented in matrix). Normally I just try
print.xx and plot.xx. When I really have problems with some specialized
versions, I look into the code, because the documentation rarely give the right
answers for special cases.

Therefore, I would like to propose that S4 documentation should be conditionally
made available in an condensed form. Since in C++ code one probably would mark
these secondary functions as "protected", I propose a keyword "protected" in the
.rd files to mark those parts that should only be included in the "full"
documentation.

(For fear of being rip...ed into pieces, going off for vacation now).

Dieter Menne

__
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] xyplot tick marks and line thickness

2006-08-25 Thread Dieter Menne
Deepayan Sarkar  gmail.com> writes:

> Right. the grid call shouldn't be necessary, "axis.line" controls the
> panel borders. And tck can be a vector, to get rid of the ugly bumps
> on top:
> 
> xyplot(x ~ x | g, type = "l", lwd = lwd,
>scales = list(tck = c(-1, 0)),
>par.settings =
>list(axis.line = list(lwd = lwd),
> strip.border = list(lwd = lwd)))
> 

The tickmarks look strange for me (Windows, R 2.3.1, all packages updated today)

See http://www.menne-biomed.de/uni/gridit.png.

This was created on screen, saved as a bitmap, and 3x enlarged lower portion.

Dieter

__
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] Finney's fiducial confidence intervals of LD50

2006-08-21 Thread Dieter Menne
carlos riveira  yahoo.com> writes:

> 
> I am working with Probit regression (I cannot switch to logit) can anybody 
> help me in finding out how to  obtain with R Finney's fiducial confidence 
> intervals for the levels of the predictor (Dose) needed to
> produce a proportion of 50% of responses(LD50, ED50 etc.)? 

See the example in MASS on . Don't know if it is comes out the same as
SPSS, though.

ldose <- rep(0:5, 2)
numdead <- c(1, 4, 9, 13, 18, 20, 0, 2, 6, 10, 12, 16)
sex <- factor(rep(c("M", "F"), c(6, 6)))
SF <- cbind(numdead, numalive = 20 - numdead)
budworm.lg0 <- glm(SF ~ sex + ldose - 1, family = binomial)

dose.p(budworm.lg0, cf = c(1,3), p = 1:3/4)
dose.p(update(budworm.lg0, family = binomial(link=probit)),
   cf = c(1,3), p = 1:3/4)

Dieter

__
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] nls convergence problem

2006-08-17 Thread Dieter Menne
Yours truly  menne-biomed.de> writes:
...
> Recently, a colleague fitted gastric emptying
> curves using GraphPad, with 100% success, and
> nls failed for one third of  these.  When we
> checked GraphPads output more closely, some of
> the coefficients looked like 2.1 with a confidence
> interval in the range  -27128 ... 314141. Nobody
> forces you to look at these, though, when using
> GraphPad.
>

Since my comment has stirred a bit of an uproar, I should add
that this is not the fault of GraphPad, but that most non-linear
fitting programs, including those in the big SXXX, give the same
results. Harvey Motulsky from Graphpad/Prism informed me that
they were going to add special tests in the new versions. Their
pdf-manual on nonlinear fitting is worth a look anyway if
Bates/Watts is over your head.

And if anyone want to see sample data:

http://www.menne-biomed.de/gastempt/gastempt1.html

> I only wish nls were a little bit more polite in telling me what went wrong.

I stand corrected:

I only wish nls were less politically correct, but rather inform me
WHY it faltered.

Dieter

__
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] nls convergence problem

2006-08-17 Thread Dieter Menne
nls not converging for zero-noise cases

  epamail.epa.gov> writes:

> 
> No doubt Doug Bates would gladly accept patches ... .
> 

The zero-noise case is irrlevant in practice, but quite often I have uttered
&/(!! (vituperation filter on) when nls did not converge with real data. The
dreaded "min step reduced...". And yet, I found that nls is damned right not to
behave nicely in many cases. Recently, a colleague fitted gastric emptying
curves using GraphPad, with 100% success, and nls failed for one third of these.
When we checked GraphPads output more closely, some of the coefficients looked
like 2.1 with a confidence interval in the range  -27128 ... 314141. Nobody
forces you to look at these, though, when using GraphPad.

I only wish nls were a little bit more polite in telling me what went wrong.

Dieter

__
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] Presentation of multiple models in one table using xtable

2006-08-15 Thread Dieter Menne
Ajay Narottam Shah  mayin.org> writes:

> 
> Consider this situation:
> > x1 <- runif(100); x2 <- runif(100); y <- 2 + 3*x1 - 4*x2 + rnorm(100)
> > m1 <- summary(lm(y ~ x1))
> > m2 <- summary(lm(y ~ x2))
> > m3 <- summary(lm(y ~ x1 + x2))
> 
> Now you have estimated 3 different "competing" models, and suppose you
> want to present the set of models in one table. xtable(m1) is cool,
> but doing that thrice would give us 3 different tables.
> 
> What I want is this one table:
> 
> ---
> M1 M2  M3
> ---
> Intercept 0.0816 3.6292 2.2272
>  (0.5533)   (0.2316)***(0.2385)***
.. (my gmane newreader complains when I quote too much, and contrary to the
general believe on this list, I think he is right).

There is no standard way of doing this, so the first formatting must be done
manually. For a nice output, check the R2HTML packages and the latex() derivates
in Frank Harrell's Hmisc package.


Dieter

__
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] A model for possibly periodic data with varying amp litude [repost, much edited]

2006-08-15 Thread Dieter Menne
Andrew Robinson  ms.unimelb.edu.au> writes:

> I have up to 12 measures of a protein for each of 6 patients, taken
> every two or three days. The pattern of the protein looks periodic,
> but the height of the peaks is highly variable.  I'm testing for
> periodicity using a Monte Carlo simulation envelope approach applied
> to a cumulative periodogram.  Now I want to predict the location of
> the peaks in time.  Of course, the peaks might be occurring on
> unmeasured days.

Have you checked one of the methods in Chapter 13. of MASS to obtain a smoothed
estimate?

Dieter

__
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] nls convergence problem

2006-08-15 Thread Dieter Menne
Earl F. Glynn  stowers-institute.org> writes:

> 
> It's not clear to me why this problem cannot be "fixed" somehow. You 

You might try optim instead of nls, which always (well, as far I used it)
converges. However, resulting coefficients may be totally off, and you should
use profiling to check the reliability. 

Dieter

__
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] nls convergence problem

2006-08-15 Thread Dieter Menne
Earl F. Glynn  stowers-institute.org> writes:

> 
> Here's my toy problem:
> > ?nls.control
> > ?nls
> > # Method 2
> > X <- 0:15
> > Y <- 9.452 * exp(-0.109*X) + 5.111   # Toy problem
> >
> > nls.out <- nls(Y ~ a*exp(b*X)+c,
> +start=list(a=6,b=-0.5,c=1),
> +control=nls.control(maxiter=15, tol=0.01),  # nothing makes 
> sense here
> +trace=TRUE)

This toy problem is exactly what the warning is for:

Warning
Do not use nls on artificial "zero-residual" data. 

Add some noise and try again.

Dieter Menne

__
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] How to order or sort a data.frame

2006-08-13 Thread Dieter Menne
John Kane  yahoo.ca> writes:

> 
> I have a dataframe where I would like to order first
> by  variable, year, and then within that variable by
> month.

http://www.ats.ucla.edu/STAT/r/faq/sort.htm

and

http://wiki.r-project.org/rwiki/doku.php?id=misc:rtips-status

Dieter

__
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] How to reply to a thread if receiving R-help mails in digest form

2006-08-13 Thread Dieter Menne
Dirk Enzmann  uni-hamburg.de> writes:

> 
> I receive R-help messages in digest form that makes it difficult to 
> answer a post. I noticed that my answer is not added to the thread 
> (instead, a new thread is started) although I use the same subject line 
> (starting with "Re: ") as the original post. Is there a solution (I 
> prefer the digest to separate messages for several reasons and don't 
> want to change my email reader)?
> 
Dirk,

this is one of the reasons I dislike the list format, but that's a subject has
been discussed already several times, with no hope of change.

I don't use the digest, but rely on 

http://news.gmane.org/gmane.comp.lang.r.general

instead.


Dieter

__
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] failed to load gplots

2006-08-07 Thread Dieter Menne
Veronika Bókony  enternet.hu> writes:

> 
> Hi everyone!
> I get the following message anyhow I try to load the package gplots:
> 
> Error in lazyLoadDBfetch(key, datafile, compressed, envhook) :
>  ReadItem: unknown type 241
> Error in library(pkg, character.only = TRUE) :
>  package/namespace load failed for 'gplots'
> 
> Could any of you tell me what goes wrong? (I am using R 2.0.1. on Windows)
> 
First update your R-version to the current. gplots is a fairly new package,
don't know if it was tested with old versions of R.

Dieter

__
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] Help with short time series

2006-08-07 Thread Dieter Menne
Simone Vincenzi  nemo.unipr.it> writes:

> 
> Dear R-list, 
> I have a statistical problem with the comparison of two short time-series of 
> density data in an ecological framework. I have to compare two short time 
> series (5 years, one value for each year) of species density data (it is the 
> density of fish in two different streams) to test if the two means of the 
> five densities are significantly different, so basically if the two mean 
> stream-specific fish densities are significantly different. 
> I don't think I can use a straight t-test due to the problem of 
> autocorrelation and I don't think I can use a repeated measure ANOVA as I 
> don't have any replicates. 
> Any help would be greatly appreciated. 

try something like 

library(nlme)
summary(lme(dens~stream+year,data=mystreamdata,random=~year|stream))

This should also give you an estimate if the slopes are different if you test
against the simplified model

summary(lme(dens~stream+year,data=mystreamdata,random=~1|stream))

Since you did not provide a short example data set, this is only approximatively
right.

Dieter

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


  1   2   3   >