Re: [R] Learning, if and else

2005-06-13 Thread Mwalili, S. M.
This may be of help dat - data.frame(dbh = c(30, 29 , 28, 27, 26, 25, 24, 23, 22, 21, 20, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20), form = c( tree, tree, tree, tree, tree, tree, tree, tree, tree,

[R] glm with variance = mu+theta*mu^2?

2005-06-12 Thread Mwalili, S. M.
You can fit negative binomial using the 'zicounts' package library(zicounts) data(teeth) names(teeth) ## c) fit negative binomial regression model nb.zc - zicounts(resp = dmft~.,x =~gender + age,data=teeth, distr = NB) nb.zc Even, library(zicounts) library(Fahrmeir) # use

Re: [R] mask a matrix

2005-06-10 Thread Mwalili, S. M.
Jiang, This example could help: A - matrix(rbinom(20,1,.8),ncol=2) B - cbind(rnorm(20,-1,0),rnorm(20,1,0)) B - ifelse(A==0,NA,B) B A S M Mwalili. Lei Jiang [EMAIL PROTECTED] wrote: Hi, there. I have two matrix with identical dimentions. matrix A contains information of 0 and 1, and matrix

Re: [R] summing values by group

2005-03-26 Thread Mwalili, S. M.
Dear Larry, dat - data.frame(CAT=sample(c(a,b,c,d),100,rep=T), x=rnorm(100)) tapply(dat[,2],dat[,1, drop = FALSE], mean) tapply(dat[,2],dat[,1, drop = FALSE], sum) I hope this helps, Samuel. Larry White [EMAIL PROTECTED] wrote: At the risk of being wacked for asking what should be