[R] Simulate multinomial data

2015-06-29 Thread Christoph Scherber
? ymult=rmultinom(.,) ## Many thanks and best wishes, Christoph [using R 3.1.1 on Windows 7 64-Bit] -- PD Dr. Christoph Scherber Senior Lecturer DNPW, Agroecology University of Goettingen Grisebachstrasse 6 37077 Goettingen Germany telephone +49 551 39 8807 facsimile +49 551 39 8806

Re: [R] Simulate multinomial data

2015-06-29 Thread Christoph Scherber
, Don: See the combinat package: combinat::rmultinomial Generate random samples from multinomial distributions -Don -- PD Dr. Christoph Scherber Senior Lecturer DNPW, Agroecology University of Goettingen Grisebachstrasse 6 37077 Goettingen Germany telephone +49 551 39 8807 facsimile +49

Re: [R] Expressing a multinomial GLM as a series of binomial GLMs

2014-07-23 Thread Christoph Scherber
between GLM and multinom fits: apply(cbind(ee0,ee1,ee2,ee3),2,mean) apply(predict(m2,type=probs),2,mean) # [using R 3.1.1 on Windows 7 32-bit] -- PD Dr. Christoph Scherber Senior Lecturer DNPW, Agroecology University of Goettingen Grisebachstrasse 6 37077 Goettingen Germany

Re: [R] R GUI for undergraduate lab class?

2014-07-13 Thread Christoph Scherber
The best GUI I know for such purposes is John Fox 's Rcmdr package. It was built for undergraduate courses. Cheers, Christoph  Von Samsung Mobile gesendet Ursprüngliche Nachricht Von: Louise Stevenson louise.steven...@lifesci.ucsb.edu Datum: 12.07.2014 22:47 (GMT+01:00)

Re: [R] lattice : superpose symbols with a great many points

2014-06-22 Thread Christoph Scherber
20/06/2014 21:50, Christoph Scherber a écrit : Dear Laurent for numeric x variables, you could try jitter: xyplot(y~jitter(x,0.5)) Cheers Christoph Am 20.06.2014 21:45, schrieb Laurent Rhelp: Hi, I like to use with xyplot (package lattice) the groups argument and superpose.symbol

Re: [R] lattice : superpose symbols with a great many points

2014-06-20 Thread Christoph Scherber
Dear Laurent for numeric x variables, you could try jitter: xyplot(y~jitter(x,0.5)) Cheers Christoph Am 20.06.2014 21:45, schrieb Laurent Rhelp: Hi, I like to use with xyplot (package lattice) the groups argument and superpose.symbol to compare several curves. But, when there are a

Re: [R] How to illustrate an interaction with plotLMER.fnc

2014-05-16 Thread Christoph Scherber
Dear Ulla, Wouldn´t it be more straightforward to use John Fox´s effects package for this? library(effects) plot(effect(variable1:variable2,model)) Best wishes Christoph Am 16.05.2014 16:50, schrieb Haverinen-Shaughnessy Ulla: Hello, I have built a linear mixed model (with lmer). To

Re: [R] plot() function: color transparency

2013-12-18 Thread Christoph Scherber
you will need to specify colours as RGB values and then set transparency via the alpha argument. e.g.: color=rgb(0,0,0,alpha=0.3) # will give black (0,0,0) and a transparency of 30%. Best wishes Christoph On 18/12/2013 23:23, capricy gao wrote: I checked as you suggested. However, I found

[R] Multiple regression (with interactions) by hand

2013-09-03 Thread Christoph Scherber
returned by coef(m1)? Thanks very much for your help! Best regards, Christoph [using R 3.0.1 on Windows 7 32-Bit] -- PD Dr Christoph Scherber Georg-August University Goettingen Department of Crop Science Agroecology Grisebachstrasse 6 D-37077 Goettingen Germany phone 0049 (0)551 39 8807

Re: [R] Multiple regression (with interactions) by hand

2013-09-03 Thread Christoph Scherber
that: all.equal(crossprod(X), t(X) %*% X) Cheers, Joshua On Tue, Sep 3, 2013 at 2:51 AM, Christoph Scherber christoph.scher...@agr.uni-goettingen.de wrote: Dear all, I´ve played around with the airquality dataset, trying to solve the matrix equations of a simple multiple regression by hand

[R] MGCV: Degrees of freedom of smooth terms

2013-07-23 Thread Christoph Scherber
): bilinear effect (?) or how would I call this? And what does ref.df in the summary output mean; is this the unpenalized degrees of freedom for each term? Thank you very much for answering! Best wishes, Christoph -- PD Dr Christoph Scherber Georg-August University Goettingen Department of Crop

[R] MGCV: overlay fitted (marginal) curves over a plot of the original data

2013-07-16 Thread Christoph Scherber
=400,dist=normal,scale=2) b - gam(y~s(x0)+s(x1)+s(x2)+s(x3),data=dat) plot(b,select=1) plot(y~x0,dat) mydata=data.frame(x0=0:1,x1=mean(dat$x1),x2=mean(dat$x2),x3=mean(dat$x3)) lines(0:1,predict(b,mydata,type=response)) ## Best wishes, Christoph -- PD Dr Christoph Scherber Georg-August

Re: [R] MGCV: overlay fitted (marginal) curves over a plot of the original data

2013-07-16 Thread Christoph Scherber
) plot(y~x0,dat) mydata=data.frame(x0=0:200/200,x1=mean(dat$x1),x2=mean(dat$x2),x3=mean(dat$x3)) pv - predict(b,mydata,type=response,se=TRUE) lines(mydata$x0,pv$fit) lines(mydata$x0,pv$fit+2*pv$se.fit,lty=2) lines(mydata$x0,pv$fit-2*pv$se.fit,lty=2) On 16/07/13 09:52, Christoph Scherber

Re: [R] MGCV: overlay fitted (marginal) curves over a plot of the original data

2013-07-16 Thread Christoph Scherber
,pv$fit-2*pv$se.fit,lty=2) On 16/07/13 09:52, Christoph Scherber wrote: Dear R users, I´ve stumbled over a problem that can be easily seen from the R code below: - When I use plot.gam() on a fitted model object, I get a nice and well-looking smooth curve for all terms in the model

[R] Creating a pdf with layers?

2012-07-20 Thread Christoph Scherber
Dear all, Is it possible to create a pdf file with layers using the pdf() device in R? Many thanks for your help! Christoph (using R 2.15.1 on Windows 7 64-Bit) -- PD Dr Christoph Scherber Georg-August University Goettingen Department of Crop Science Agroecology Grisebachstrasse 6 D-37077

Re: [R] Creating a pdf with layers?

2012-07-20 Thread Christoph Scherber
be interesting to be able to divert output to different layers inside a PDF structure. Best regards Christoph Scherber Am 20.07.2012 13:48, schrieb Prof Brian Ripley: On 20/07/12 12:07, Christoph Scherber wrote: Dear all, Is it possible to create a pdf file with layers using the pdf() device in R

[R] Windows 7 issues with installing packages and setting library paths

2011-08-19 Thread Christoph Scherber
wishes Christoph -- Dr. rer.nat. Christoph Scherber University of Goettingen DNPW, Agroecology Grisebachstr. 6 D-37077 Goettingen Germany phone +49 (0)551 39 8807 fax +49 (0)551 39 8806 Homepage http://www.gwdg.de/~cscherb1 __ R-help@r-project.org

[R] Extract Crawley´s datasets and pack them into a new package

2011-01-14 Thread Christoph Scherber
? I know that package.skeleton() should do the job, but somehow I got stuck here... Many thanks for your help! Best wishes Christoph [using R 2.12.1 on Windows XP] -- *PLEASE NOTE OUR NEW POSTAL ADDRESS!* Dr. rer.nat. Christoph Scherber University of Goettingen DNPW, Agroecology

[R] Exporting a list of data frames

2010-06-03 Thread Christoph Scherber
,mylist.txt) or format (mylist...) But somehow I cannot get the information contained in mylist exported in a nicely looking way. Any ideas? Many thanks for any help! Best wishes, Christoph (using R 2.11.0 on Windows XP) -- Dr. rer.nat. Christoph Scherber University of Goettingen DNPW, Agroecology

Re: [R] Exporting a list of data frames

2010-06-03 Thread Christoph Scherber
Dear all, I found one possible solution using a single call to write.table: # assuming that mylist is a named list of data.frames: data(Orange) mylist=list(Orange1=Orange,Orange2=Orange,Orange3=Orange) sapply(1:length(mylist), function(x){ write.table(

[R] contr.sdif from MASS

2009-11-24 Thread Christoph Scherber
Dear all, When using contr.sdif (from MASS), is it true that the *Intercept* is the mean of the response variable *across all levels* of the explanatory variables included in the model? Somehow, it doesn´t seem to be the overall mean. Many thanks for any help! Christoph # Below is an example:

[R] nested, repeated measure lme

2009-08-20 Thread Christoph Scherber
=~time|unique.ID.of.every.individual I have read that (2) is the only approach that works. But how could I then still include the nesting information from (1)? Many thanks for your help! Best wishes Christoph (using R 2.9.0 and the nlme library on Windows XP) -- Dr. rer.nat. Christoph Scherber

[R] stepAICc function (based on MASS:::stepAIC.default)

2009-05-05 Thread Christoph Scherber
Dear all, I have tried to modify the code of MASS:::stepAIC.default(), dropterm() and addterm() to use AICc instead of AIC for model selection. The code is appended below. Somehow the calculations are still not correct and I would be grateful if anyone could have a look at what might be wrong

[R] stepAICc

2009-04-30 Thread Dr. Christoph Scherber
Dear R users, Would it be difficult to change the code of stepAIC (from the MASS library) to use AICc instead of AIC? It would be great to know of someone has tried this already. Best wishes Christoph. __ R-help@r-project.org mailing list

[R] Extracting degrees of freedom from a gnls object

2009-01-07 Thread Christoph Scherber
Dear all, How can I extract the total and residual d.f. from a gnls object? I have tried str(summary(gnls.model)) and str(gnls.model) as well as gnls(), but couldn´t find the entry in the resulting lists. Many thanks! Best wishes Christoph -- Dr. rer.nat. Christoph Scherber University

[R] glm or transformation of the response?

2008-11-25 Thread Christoph Scherber
with this kind of analysis? What would be your recommendation to the students, given the fact that most of the standard glm models obviously don?t seem to produce good fits here? Many thanks and best wishes Christoph (using R 2.8.0 on Windows XP) -- Dr. rer.nat. Christoph Scherber University

Re: [R] glm or transformation of the response?

2008-11-25 Thread Christoph Scherber
) lines(explanatory,predict(model7,data.frame(explanatory=explanatory),type=response),lty=1,col=green) Peter Dalgaard schrieb: Christoph Scherber wrote: Dear all, For an introductory course on glm?s I would like to create an example to show the difference between glm and transformation

[R] Bootstrapping gnls models

2008-11-07 Thread Christoph Scherber
wishes Christoph -- Dr. rer.nat. Christoph Scherber University of Goettingen DNPW, Agroecology Waldweg 26 D-37073 Goettingen Germany phone +49 (0)551 39 8807 fax +49 (0)551 39 8806 Homepage http://www.gwdg.de/~cscherb1 __ R-help@r-project.org mailing

Re: [R] Bootstrapping gnls models

2008-11-07 Thread Christoph Scherber
)) booted-boot.ci(model.boot,index=1,type=c(norm)) booted$t0 booted$normal ### Best wishes, Christoph. Prof Brian Ripley schrieb: On Fri, 7 Nov 2008, Christoph Scherber wrote: Dear all, I am trying to bootstrap predictions from gnls models using the following code: # a is the dataframe

Re: [R] standard errors for predict.nls?

2008-11-07 Thread Christoph Scherber
. for the predicted value? Many thanks and best wishes, Christoph Prof Brian Ripley schrieb: On Mon, 3 Nov 2008, Ben Bolker wrote: Prof Brian Ripley wrote: Christoph Scherber Christoph.Scherber at agr.uni-goettingen.de writes: Dear all, Is there a way to retrieve standard errors from nls models

[R] replacing characters in formulae / models

2008-11-06 Thread Christoph Scherber
objects... Many thanks and best wishes Christoph -- Dr. rer.nat. Christoph Scherber University of Goettingen DNPW, Agroecology Waldweg 26 D-37073 Goettingen Germany phone +49 (0)551 39 8807 fax +49 (0)551 39 8806 Homepage http://www.gwdg.de/~cscherb1

Re: [R] replacing characters in formulae / models

2008-11-06 Thread Christoph Scherber
. --- Christoph Scherber [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Dear all, How can I replace text in objects that are of class formula? y=a * x + b class(y)=formula grep(x,y) y[1] Suppose I would like to replace the x by w in the formula object y. How

[R] standard errors for predict.nls?

2008-11-03 Thread Christoph Scherber
Dear all, Is there a way to retrieve standard errors from nls models? The help page tells me that arguments such as se.fit are ignored... Many thanks and best wishes Christoph -- Dr. rer.nat. Christoph Scherber University of Goettingen DNPW, Agroecology Waldweg 26 D-37073 Goettingen

Re: [R] how to store lme/lmer fit result

2008-11-03 Thread Christoph Scherber
Dear Julia, I think the best thing to do is to save your workspace, including all your objects. This works conveniently using the drop-down menu on Windows. Alternatively, you can use sink(), for example using the Windows clibboard: sink(clipboard) summary(...) # your object(s) here sink()

[R] Problem with error handling inside a function

2008-10-25 Thread Dr. Christoph Scherber
printed? Many thanks for any help! All the best Christoph -- Christoph Scherber Agroecology, Univ. Goettingen 37073 Goettingen Germany __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide

[R] A covariate correlated with other explanatory variables

2008-10-17 Thread Christoph Scherber
. Christoph Scherber University of Goettingen DNPW, Agroecology Waldweg 26 D-37073 Goettingen Germany phone +49 (0)551 39 8807 fax +49 (0)551 39 8806 Homepage http://www.gwdg.de/~cscherb1 __ R-help@r-project.org mailing list https://stat.ethz.ch

[R] An AIC model selection question

2008-10-02 Thread Christoph Scherber
it uses up less df and the delta-AIC between model2 and model3 is just 1? Many thanks for any suggestions/comments! Best wishes Christoph -- Dr. rer.nat. Christoph Scherber University of Goettingen DNPW, Agroecology Waldweg 26 D-37073 Goettingen Germany phone +49 (0)551 39 8807 fax +49

[R] Minimizing both AIC and df in model selection

2008-10-01 Thread Christoph Scherber
for your help! Best wishes, Christoph -- Dr. rer.nat. Christoph Scherber University of Goettingen DNPW, Agroecology Waldweg 26 D-37073 Goettingen Germany phone +49 (0)551 39 8807 fax +49 (0)551 39 8806 Homepage http://www.gwdg.de/~cscherb1 __ R-help

Re: [R] lme questions re: repeated measures covariance structure

2008-08-22 Thread Christoph Scherber
-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. . -- Dr. rer.nat. Christoph Scherber University of Goettingen DNPW, Agroecology Waldweg 26

[R] summary.lme and anova question

2008-08-21 Thread Christoph Scherber
Dear all, When analyzing data from a climate change experiment using linear mixed-effects models, I recently came across a situation where: - the summary(model) showed a significant difference between the levels of a two-level factor, - while the anova(model) showed no significance for that

Re: [R] summary.lme and anova question

2008-08-21 Thread Christoph Scherber
-tests for any other coefficient than the third-order interaction violates the marginality principle. And the third-order interaction seems to be important. On Thu, 21 Aug 2008, Christoph Scherber wrote: Dear all, When analyzing data from a climate change experiment using linear mixed

[R] Three contrast matrices on the same linear model

2008-07-25 Thread Christoph Scherber
Christoph (using R 2.7.1 on Windows XP) -- Dr. rer.nat. Christoph Scherber University of Goettingen DNPW, Agroecology Waldweg 26 D-37073 Goettingen Germany phone +49 (0)551 39 8807 fax +49 (0)551 39 8806 Homepage http://www.gwdg.de/~cscherb1

Re: [R] lmer model with continuos non normal response variable, transformation needed?

2008-07-24 Thread Christoph Scherber
Dear Arams, I would suggest to use lme() instead of lmer(), and then to use a variance function to model the heteroscedasticity in the within-group errors, such as: model.new=update(model,weights=varPower(form=~primary.covariate)) where model and model.new are lme fits, and primary.covariate

Re: [R] Functions similar to step() and all.effects() that work for lme() objects?

2008-07-24 Thread Christoph Scherber
Dear Jon, The function stepAIC() in Venable´s Ripley´s MASS library does the job. Best wishes Christoph Jon Zadra schrieb: Hello, I make frequent use of the *step()* and, for plotting, *all.effects() *functions for *lm()* objects. I am now doing more with *lme()* random effects models,

[R] What is wrong with this contrast matrix?

2008-07-24 Thread Christoph Scherber
. rer.nat. Christoph Scherber University of Goettingen DNPW, Agroecology Waldweg 26 D-37073 Goettingen Germany phone +49 (0)551 39 8807 fax +49 (0)551 39 8806 Homepage http://www.gwdg.de/~cscherb1 __ R-help@r-project.org mailing list https

Re: [R] What is wrong with this contrast matrix?

2008-07-24 Thread Christoph Scherber
for me if my contrast matrix is orthogonal or not. Is there some built-in function in R for that? Best wishes Christoph. On 24-Jul-08 15:30:57, Christoph Scherber wrote: Dear all, I am fitting a multivariate linear model with 7 response variables and 1 explanatory variable. The following

Re: [R] Problems with lm()

2008-07-17 Thread Christoph Scherber
=as.factor(d), Max=e) lm3- lm(Max ~ subject*sequence + period + drug+sequence , data=KK) print(lm3) anova(lm3) However, it can not work!! So, where is the problems? Do I misunderstand what you mean? Best regards, Hsin-Ya Dr. Christoph Scherber wrote: Dear Hsin-Ya Lee, The problem seems

Re: [R] lm() question

2008-07-17 Thread Christoph Scherber
]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. . -- Dr. rer.nat. Christoph Scherber University of Goettingen

Re: [R] Problems with lm()

2008-06-21 Thread Dr. Christoph Scherber
Dear Hsin-Ya, Then it might be that you have checked Type 3 sums of squares in SPSS, while R uses type 1 by default. Dear Dr. Andrew Robinson: Thanks for your reply. In my data, subject is nested within sequence. According to Dr. Christoph's reply, I have change the sequence data. It

Re: [R] The Green Book and its relevance to R

2008-06-21 Thread Dr. Christoph Scherber
Dear Ben, Do you mean Statistical Computing by Crawley? In that case, there is a web appendix showing some differences between R and S-Plus. There is also John Fox´s Book Companion to Applied Linear Regression that compares R and S-Plus, and Richard Heiberger´s book (Heiberger Holland)

Re: [R] Problems with lm()

2008-06-19 Thread Christoph Scherber
Dear Hsin-Ya Lee, The problem seems to be that every subject always only received one sequence: sequence subject 1 2 1 0 2 2 2 0 3 0 2 4 2 0 5 0 2 6 2 0 7 0 2 8 2 0 9 0 2 10 2 0 11 0 2 12 2 0 13 0 2 14 2 0 You

[R] Nonlinear multivariate regression

2008-06-18 Thread Christoph Scherber
on Windows XP) -- Dr. rer.nat. Christoph Scherber University of Goettingen DNPW, Agroecology Waldweg 26 D-37073 Goettingen Germany phone +49 (0)551 39 8807 fax +49 (0)551 39 8806 Homepage http://www.gwdg.de/~cscherb1 __ R-help@r-project.org

[R] Multivariate LM: calculating F-values after calling linear.hypothesis

2008-06-07 Thread Dr. Christoph Scherber
)),79) ## The last two lines of code are what I am stuck with; I thought using diag() on the SSPH and SSPE matrices should give me the sums of squares for hypothesis and error; so division should yield the F values? I would be most grateful for any help! Best wishes Christoph -- Dr. Christoph

[R] Comparing two regression lines

2008-06-04 Thread Christoph Scherber
Dear R users, Suppose I have two different response variables y1, y2 that I regress separately on the same explanatory variable, x; sample sizes are n1=n2. Is it legitimate to compare the regression slopes (equal variances assumed) by using lm(y~x*FACTOR), where FACTOR gets y1 if y1 is the

Re: [R] problem pasting into Illustrator CS2

2008-06-04 Thread Dr. Christoph Scherber
Dear Courtney, Are you exporting the graphs as postscript files? This is the usual way I do it when moving graphs between R and Illustrator CS2. I´m afraid I do not have a Mac, but I suppose CS2 runs similarly on both systems. Best wishes Christoph To Whom it May Concern: I have been using

[R] Rotated text on a regression line

2008-05-27 Thread Dr. Christoph Scherber
Dear all, I stumbled over a problem recently when trying to use srt with text() on a windows device. What I intended to do was to plot a simple regression line, and to rotate a piece of text such that the text has the same angle as the regression line. However, the text is always plotted in a

Re: [R] Rotated text on a regression line

2008-05-27 Thread Dr. Christoph Scherber
Thanks to all for the postings so far! I found that setting asp=0.5 and then dividing the slope by 2 seems to do the trick: ## x=1:10 y=x*2-rnorm(1:10) plot(x,y,pch=16,asp=0.5) abline(lm(y~x)) yval=predict(lm(y~x),list(x=rep(2,length(x[1] slope=as.numeric(lm(y~x)[[1]][2])

[R] Simultaneously summarizing many models

2008-02-22 Thread Christoph Scherber
the quotation marks. Thanks very much for your help! Best wishes, Christoph (using R 2.5.1 on Windows XP SP2) -- Dr. Christoph Scherber DNPW, Agroecology University of Goettingen Waldweg 26 D-37073 Goettingen Germany phone +49(0)551 39 8807 fax +49(0)551 39 8806 homepage www.gwdg.de

Re: [R] how to generate sequence a - z

2008-01-29 Thread Christoph Scherber
-- X-USF-Spam-Status: hits=-2.6 tests=BAYES_00 X-USF-Spam-Flag: NO Hello, Sequences of letters can be generated by typing LETTERS #for capital letters or letters #for small letters Best wishes Christoph skestin schrieb: I suppose it's very simple but I can't find the way to generate a

Re: [R] F distribution from lme()?

2007-11-09 Thread Christoph Scherber
Dear Bill Venables, Does this mean that in a conventional aov object, the summary.lm gives the parameter estimates and p-values computed marginally, while the summary.aov table by default gives sequential sums of squares? This question arose recently when a colleague and I were discussing

Re: [R] multcomp and lme4

2007-11-09 Thread Christoph Scherber
Hi all, I would also be very interested in a solution to that (although I know that using orthogonal contrasts is usually the method of choice) All the best Christoph Andrew Dolman schrieb: Dear list members, Can anyone please point to an example of how to use glht(multcomp) with lmer

Re: [R] Extract correlations from a matrix

2007-11-09 Thread Christoph Scherber
correlations is another question. --- Christoph Scherber [EMAIL PROTECTED] wrote: Dear John, Thanks very much for your help; but actually I would like to have the colNames and rowNames for the correlations -such that I can say: Only (a and c ) and (d and f) were correlated with r0.6

[R] Extract correlations from a matrix

2007-11-08 Thread Christoph Scherber
around it. I would very much appreciate any help! Best wishes Christoph (using R 2.5.1 on Windows XP) -- Dr. Christoph Scherber DNPW, Agroecology University of Goettingen Waldweg 26 D-37073 Goettingen Germany phone +49(0)551 39 8807 fax +49(0)551 39 8806 homepage www.gwdg.de/~cscherb1

[R] detrending a time series

2007-10-10 Thread Christoph Scherber
Dear R users, I am trying to ´detect´ the trend in an artificial time series created by the simple function x=seq(pi,10*pi,0.1) my.ts=0.1*x+sin(x) my.ts=ts(my.ts,start=1800) plot(my.ts) I have tried stl(my.ts), but because I don´t have ´replications´ at every time point, this somehow doesn´t