Hello, I have this generalized linear formula: log(x[i]/n[i])=log(sum(x)/sum(n)) + beta[i] where the the x[i] and the n[i] are known. Is there a way to program the GLM procedure to input the formula above and get the beta[i] estimates? If not the GLM is there another procedure to do that? The aim also afterwards is to estimate the profile-likelihood CIs for the beta parameters. -- View this message in context: http://www.nabble.com/User-defined-GLM--tp24150859p24150859.html Sent from the R help mailing list archive at Nabble.com.
On Jun 22, 2009, at 12:35 PM, francogrex wrote:> > Hello, I have this generalized linear formula: > log(x[i]/n[i])=log(sum(x)/sum(n)) + beta[i] > where the the x[i] and the n[i] are known. > Is there a way to program the GLM procedure to input the formula > above and > get the beta[i] estimates? If not the GLM is there another procedure > to do > that? The aim also afterwards is to estimate the profile-likelihood > CIs for > the beta parameters.Not as stated. That would be expecting R to have symbolic algebraic capabilities. Maybe next year^Wdecade? That model is equivalent to:> log(x[i]/n[i])=log(sum(x)) - log(sum(n)) + beta[i]So you could use a no-intercept model with log link in glm() and an offset term for the first two terms of the r.h.s. probi <- (x[i]/n[i]) glm(probi ~ 0 + offset(log(sum(x)) - log(sum(n) ), family=poisson) -- David Winsemius, MD Heritage Laboratories West Hartford, CT
Le lundi 22 juin 2009 ? 09:35 -0700, francogrex a ?crit :> Hello, I have this generalized linear formula: > log(x[i]/n[i])=log(sum(x)/sum(n)) + beta[i]I do not understand the problem as stated. if x[i] and n[i] are known, and unless sum(n)=0, your dataset reduces to a set of nrow(dataset) independent linear equations with nrow(dataset) unknowns (the beta[i]), whose solution is trivially beta[i]=log(x[i]/n[i])-log(sum(x)/sum(n), except when n[i]=0 in which case your equation has no solution. Could you try to re-express your problem ? Emmanuel Charpentier