Re: [R] Trouble with optim function

2010-02-18 Thread Ian Fiske
You're minimizing the log likelihood, but you want to minimize the *negative* log likelihood. Also, optimize() is better than optim() if you have a function of only one argument. Replace Jon Moroney wrote: #Create the log likelihood function LL-function(x) {(trials*log(x))-(x*sumvect)}

Re: [R] rpois formula

2009-10-06 Thread Ian Fiske
try sum(a b) sum(b a) sum(a == b) Ian nedmt60 wrote: i have a = rpois (10, x) b = rpois (10, y) what is the code to show that ab, ba and a=b to show just the number of occurances? at the moment when I type ab I get a nice long list of true or false. -- View this

Re: [R] Calculating distance between spatial points

2009-06-26 Thread Ian Fiske
If your goal is to get the distance between geographic points, you might try computing the distance along the great circle arc and forget about projection. Several packages have functions that do this. See https://stat.ethz.ch/pipermail/r-help/2007-October/144546.html. hope that helps, Ian

Re: [R] Roxygen to ignore a block of code?

2009-06-22 Thread Ian Fiske
I think that you want the the @nord tag which is in development. I am eager for the release of the Roxygen version with this tag too! See their mailing list on R-Forge for more details on this. cheers, Ian Ken-JP wrote: I don't want any zoo.Rd to be generated - I am a user of the library,

Re: [R] Sending a function as an argument to C code.

2009-06-12 Thread Ian Fiske
Christophe Genolini wrote: In order to optimize the code, I would like to write myFunc in C. Is it possible, in the C code, to call a function define in R (dist1 or dist2) that will be send to myFunc as an argument ? Christophe You want to read section 5.11: Evaluating R

Re: [R] standard error beta glm

2009-06-12 Thread Ian Fiske
Ricardo Arias Brito wrote: Dear All, Is posible calculate Std. Error for glm as lm, using cov(hat beta) = phi * solve(t(X) %*% hat W %*% X)^-1 on R? Who is hat W and phi output glm? y=rpois(20,4) fit.glm - glm(y ~ x, family=poisson summary(fit.glm) Fitted to a model glm using

Re: [R] How to google for R stuff?

2009-05-20 Thread Ian Fiske
www.rseek.org is the best solution to this that I have found. Ian kynn wrote: Hi! I'm new to R programming, though I've been programming in other languages for years. One thing I find most frustrating about R is how difficult it is to use Google (or any other search tool) to look for

Re: [R] Re turn values 0 from Matrix

2009-02-09 Thread Ian Fiske
If your matrix is called mat, how about mat[which(mat[,2] 0), ] mat[which(mat[,2] 0), ] -Ian mentor_ wrote: Hi, I have a matrix with negative and positiv values. How can I get either the negative or positive values from the matrix? Matrix: [,1] [,2] [1,]1 -3 [2,]

Re: [R] percentage of variance explained by factors

2009-02-09 Thread Ian Fiske
Try the functions Anova() or linear.hypthesis() in the package car. If using Anova(), you probably want the type II table. Ian Fiske dl7631 wrote: Hello! I've run a simple linear model: result-lm(DV~A+B+C,data=Data) My Data$A,Data$B, and Data$C are factors. So, lm automatically

Re: [R] one-sample t-test with correlated (clustered) observations

2009-02-06 Thread Ian Fiske
To handle the correlations, you can treat individuals as random blocks. So you have a mixed model with measurement technique crossed with measured attribute and random intercepts for each individual. You can fit this with lmer() in the lme4 package. Keep in mind there are a number of

Re: [R] Linear model: contrasts

2009-02-06 Thread Ian Fiske
The problem comes from mixing up general linear model (LM) theory to compute B with the classical anova estimators. The two methods use different approaches to solving the normal equations. LM theory uses any generalized inverse of X'X to solve the normal equations. Yours comes from ginv()

[R] ggplot: problem with fill option in stat_smooth()

2009-02-04 Thread Ian Fiske
) + stat_smooth(fill=grey50) I even tried the Cairo library as one R-help post suggested, but to no avail. Any suggestions? Thanks much, Ian Fiske -- View this message in context: http://www.nabble.com/ggplot%3A-problem-with-fill-option-in-stat_smooth%28%29-tp21832398p21832398.html Sent from the R help

Re: [R] chi squared goodness of fit test with R

2009-02-04 Thread Ian Fiske
You might try the cut() function to convert your data from a continuous measure into an ordinal factor. Then use the table() function to get your contingency table. The R help system is very extensive. Type ?cut to get the help on the function cut(). This works with all functions. Look at

Re: [R] counting entries in vector

2009-02-04 Thread Ian Fiske
Try: table(k)[rank(unique(k))] -ian Armin Meier wrote: Hi all, I've a vector with entries, which are all of the same type, e.g. string: k - c(bb, bb, bb, aa, cc, cc) and want to create a second vector containing the number of each entry in k in the same order as in k, i.e. c(3, 1, 2)

Re: [R] ggplot: problem with fill option in stat_smooth()

2009-02-04 Thread Ian Fiske
wickham h.wick...@gmail.com wrote: On Wed, Feb 4, 2009 at 9:12 AM, Ian Fiske ianfi...@gmail.com wrote: Hi all, I am using ggplot2 and continuing to find it very useful and pretty. However, I am trying to create some graphics for publication that would be included in an MS Word document (not my

Re: [R] ggplot: problem with fill option in stat_smooth()

2009-02-04 Thread Ian Fiske
:55 PM, hadley wickham h.wick...@gmail.com wrote: On Wed, Feb 4, 2009 at 10:55 AM, Ian Fiske ianfi...@gmail.com wrote: Thanks for the suggestion, Hadley. I tried: stat_smooth(fill=alpha(grey,1)) and got the same problem. The shaded band shows up in the graphics windows, but the only file

Re: [R] ggplot: problem with fill option in stat_smooth()

2009-02-04 Thread Ian Fiske
could try to open the pdf in Inkscape http://www.inkscape.org/ and export it as a .emf or .png ? Etienne Ian Fiske a écrit : Hi all, I am using ggplot2 and continuing to find it very useful and pretty. However, I am trying to create some graphics for publication that would be included

Re: [R] Re turning variable names with variables (in a function)

2008-05-08 Thread Ian Fiske
You want to set the names attribute of your results vector. You can do this with the names() function (see ?names). Specifically, you might use something like this: results - c(se, upper, lower, cv) names(results) - c(se, upper, lower, cv) Good luck, Ian Stropharia wrote: