Re: [R] notation question

2011-07-19 Thread Carson Farmer
Thank you Rolf, >> Using the analysis of co-variance example from MASS (fourth edition, p >> 142), what is the correct notation for the formula "Gas, ~ Insul/Temp >    There shouldn't be a comma after ``Gas'' in that formula. >> - 1"? Obviously, if we fit it as two separate models (as in the >> exa

[R] notation question

2011-07-19 Thread Carson Farmer
Dear list, I am currently writing up some of my R models in a more formal sense for a paper, and I am having trouble with the notation. Although this isn't really an 'R' question, it should help me to understand a bit better what I am actually doing when fitting my models! Using the analysis of co

[R] Deviance of zeroinfl/hurdle models

2011-07-12 Thread Carson Farmer
Dear list, I'm wondering if anyone can help me calculate the deviance of either a zeroinfl or hurdle model from package pscl? Even if someone could point me to the correct formula for calculating the deviance, I could do the rest on my own. I am trying to calculate a pseudo-R-squared measure based

[R] 'constrained' negative.binomial model estimates

2011-05-26 Thread Carson Farmer
Hello list, I am not sure if the terminology that I am using here is widely used, however, I provide an example in the hopes that my problem will become clear. My basic problem is that I am unsure of how to 'constrain' my model estimates to reproduce the aggregate (by factor levels) observed depen

Re: [R] rank of Matrix

2011-03-31 Thread Carson Farmer
Hmm, looks like I'm 'answering' my own question here... library(Matrix) data(KNex) mm <- KNex$mm str(mmQR <- qr(mm)) # new stuff: R <- mmQR@R Rdiag <- diag(R) rank <- sum(Rdiag > max(dim(mm))*.Machine$double.eps*abs(R[1,1])) # this is the matlab default I think? # 712 for comparison, rankMatrix f

[R] rank of Matrix

2011-03-31 Thread Carson Farmer
Dear list, Can anyone tell me how to obtain the rank of a sparse Matrix, for example from package Matrix (class dgCMatrix)? Here is an example of QR decomposition of a sparse matrix (from the sparseQR class help). library(Matrix) data(KNex) mm <- KNex$mm str(mmQR <- qr(mm)) Similarly, using the

[R] model diagnostics for MatrixModels

2011-03-27 Thread Carson Farmer
Dear list, I have been working with the MatrixModels package quite a bit this week, and it is proving to be extremely valuable for my current work (I am working with several factors with many levels, leading to a sparse model matrix). However, as my knowledge of statistical theory leaves much to b

Re: [R] mixture models/latent class regression comparison

2011-02-28 Thread Carson Farmer
Thanks for the reply Christian, > I have never used mmlcr for this, but quite generally when fitting such > models, the likelihood has often very many local optima. This means that the > result of the EM (or a similar) algorithm depends on the initialisation, > which in flexmix (and perhaps also i

[R] mixture models/latent class regression comparison

2011-02-28 Thread Carson Farmer
Dear list, I have been comparing the outputs of two packages for latent class regression, namely 'flexmix', and 'mmlcr'. What I have noticed is that the flexmix package appears to come up with a much better fit than the mmlcr package (based on logLik, AIC, BIC, and visual inspection). Has anyone e

[R] negative binomial latent class regression in package flexmix

2011-02-23 Thread Carson Farmer
Hello list, Has anyone had any luck creating an M-step driver for negative binomial regression for use with package flexmix? I've had a look here: http://cran.r-project.org/web/packages/flexmix/vignettes/flexmix-intro.pdf as well as poking around in the flexmix source, but I haven't had much luck

[R] spatial interaction (gravity) model as Poisson regression

2010-10-04 Thread Carson Farmer
Dear list, I posted essentially this same question to the r-sig-geo mailing list last week with no response :( Unfortunately I am no closer to reaching a solution, so I now post it here (with some clarifications) in the hope that someone following this list might have an answer for me: Has anyone

[R] plotting radial dendrograms

2010-06-17 Thread Carson Farmer
Dear list, I am trying to plot a radial dendrogram using the ape package, which requires my data to be of class 'phylo'. Currently I have my dendrogram stored as an object of class 'dendrogram' which was produced from an outside bit of C code, but was made into an object of class 'igraph.eigenc' a

[R] set values in data.frame to NA conditional on another data.frame

2008-07-02 Thread Carson Farmer
Hello List, Is there a faster way to set values in one data.frame equal to NA conditional on the corresponding value in another data.frame? Currently I am using: > b[is.na(a)] <- NA where 'a' and 'b' are data.frames of equal size/dimensions, and 'a' contains NAs but 'b' does not. This is extr

[R] Replace values in data.frame conditional on another data.frame

2008-03-05 Thread Carson Farmer
Dear List, I am looking for an efficient method for replacing values in a data.frame conditional on the values of a separate data.frame. Here is my scenario: I have a data.frame (A) with say 1000 columns, and 365 rows. Each cell in the data.frame has either valid value, or NA. I have an additional

Re: [R] [Fwd: Re: Fourier Analysis and Curve Fitting in R]

2008-01-29 Thread Carson Farmer
ion and maybe we can help On 1/28/08, Carson Farmer [1]<[EMAIL PROTECTED]> wrote: Rolf Turner wrote: On 26/01/2008, at 10:54 AM, Carson Farmer wrote: Dear List, I am attempting to perform a harmonic analysis on a time series of snow depth, in which the annual curve is essentially a

Re: [R] Fourier Analysis and Curve Fitting in R

2008-01-28 Thread Carson Farmer
Rolf Turner wrote: >> >> On 26/01/2008, at 10:54 AM, Carson Farmer wrote: >> >>> Dear List, >>> >>> I am attempting to perform a harmonic analysis on a time series of snow >>> depth, in which the annual curve is essentially asymmetric (i.e. sno

[R] Fourier Analysis and Curve Fitting in R

2008-01-25 Thread Carson Farmer
Dear List, I am attempting to perform a harmonic analysis on a time series of snow depth, in which the annual curve is essentially asymmetric (i.e. snow accumulates slowly over time, and the subsequent melt occurs relatively rapidly). I am trying to fit a curve to the data, however, the actual

[R] Cycle Regression Analysis in R?

2008-01-10 Thread Carson Farmer
Hello R community, Does anyone know of a package that will perform cycle regression analysis? I have searched the R-help archives etc. but have come up with nothing so far. If I am unable to find an existing R package to do so, is there anyone familiar with fitting sine functions to data. My p