[R] How to find the likelihood function?

2007-08-28 Thread francogrex
Hi, I am writing a BRugs code and I need to specify the likelihood for the gamma distribution and I am specifying it as the pdf: (pow(b1,a1)/(exp(loggam(a1)))*(exp(-b1*lambda[i]))*pow(lambda[i],(a1-1))) But it is not accepting it although I know that I could use the pdf in R to estimate the

[R] deriv; loop

2007-07-30 Thread francogrex
Hi, 2 questions: Question 1: example of what I currently do: for(i in 1:6){sink(temp.txt,append=TRUE) dput(i+0) sink()} x=scan(file=temp.txt) print(prod(x)) file.remove(C:/R-2.5.0/temp.txt) But how to convert the output of the loop to a vector that I can manipulate (by prod or sum etc),

[R] Extracting S code from a C program

2007-07-08 Thread francogrex
There is a C program called GPS: 'gamma poisson shrinker' at ftp://ftp.research.att.com/dist/gps/ The algorithms in GPS are based on S-Plus programs written by William DuMouchel with support from Columbia University and ATT Labs. My question is: is there a relatively easy way to extract some of

[R] GLM, log-binomial likelihood

2007-06-26 Thread francogrex
Dear R-help users, I have a question concerning re-writing a function in R: Suppose I have the data, y is number of successes and N is total number of trials and x is the variable (example:) x y N 1 10 150 0 1 100 I want to estimate the risk ratio by

[R] Reading old S-plus dmp files

2007-06-11 Thread francogrex
I'm sorry that this question has been asked before but I ask it again because in the archives I didn't see a solution. It's an old S-plus dmp file for a hierarchical bayes linear model program written by DuMouchel and available publicly and freely at:

[R] Metropolis code help

2007-06-01 Thread francogrex
Dears, I have the below code for metropolis of the GLM logit (logistic regression) using a flat prior. Can someone help me modify the prior so that the model becomes hierarchical by using a flat prior for mu and sigma, the derived density for beta ~ N(mu, sigma^2)? Actually I took my code from a

[R] Where is package Umacs?

2007-05-23 Thread francogrex
We were promised this package last spring but I can't find it anywhere! Does anyone have any info? Thanks. From RNews: Umacs (Universal Markov chain sampler) is an R package (to be released in Spring 2006) that facilitates the construction of the Gibbs sampler and Metropolis algorithm for

[R] Cross-validation for logistic regression with lasso2

2007-05-18 Thread francogrex
Hello, I am trying to shrink the coefficients of a logistic regression for a sparse dataset, I am using the lasso (lasso2) and I am trying to determine the shrinkinage factor by cross-validation. I would like please some of the experts here to tell me whether i'm doing it correctly or not. Below

Re: [R] {10,20,30}={25,30,15}

2007-05-18 Thread francogrex
At the alpha level you set, A is neither greater nor less than B. Supposing you don't use paired t.test: data: c(10, 20, 30) and c(25, 30, 15) t = -0.4588, df = 3.741, p-value = 0.6717 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval:

Re: [R] Hierarchical models in R

2007-05-14 Thread francogrex
Hi, yes I know but in many cases BUGS and BRUGS just crash or worse still they can generate wrong results that's why i was wondering if there's a package like the MCMCpack etc that can allow hierarchical regression... Cody_Hamilton wrote: Franco, What about calling the BUGS model below from

[R] Response as matrix in MCMClogit?

2007-05-05 Thread francogrex
I hope some of the authors of the package MCMCpack read this. I don't know if there is a way to set the response in the model formula of MCMClogit other than a (numeric) response vector. I think the MCMClogit in the MCMCpack needs some development so that the response in the formula could be set

[R] Bayesian logistic regression with a beta prior (MCMClogit)

2007-05-03 Thread francogrex
Dear all, I am trying to use the logistic regression with MCMClogit (package: MCMCpack/Coda) and I want to put a beta prior on the parameters, but it's giving me error message (please see output below) no matter what shape 1 or 2 I use. It works perfect with the cauchy or normal priors. Do you

Re: [R] Bayesian logistic regression with a beta prior (MCMClogit)

2007-05-03 Thread francogrex
Hi, yes but I realized afterwards that it's the logfun argument that had to be put to logfun=F and the logpriorfun function had to be log=F logpriorfun - function(beta,shape1,shape2){ sum(dbeta(beta,shape1,shape2,log=F)) } But that's just for that particular example. I find I am having problems

[R] Comparing MCMClogit, glm and BRUGS

2007-04-28 Thread francogrex
Hello, I have two related questions, one about MCMClogit and the other about BRUGS: Given the data on nausea due to diuretic and nsaid below: nsaid diureticyes no 0 0 185 6527 0 1 53 1444 1 0 42 1293 1

[R] How to solve difficult equations?

2007-04-25 Thread francogrex
This below is not solvable with uniroot to find a: fn=function(a){ b=(0.7/a)-a (1/(a+b+1))-0.0025 } uniroot(fn,c(-500,500)) gives Error in uniroot(fn, c(-500, 500)) : f() values at end points not of opposite sign I read R-help posts and someone wrote a function:

Re: [R] Conditional power, predictive power

2007-04-20 Thread francogrex
Or more elegantly the function below where a and b are the parameters of the beta prior, xa and xb are the current number of events in group A and B respectively; na and nb are the current total number of subjects in group A and B respectively; Na and Nb are the final total number of subject in

[R] A structured output from for(i...)?

2007-04-19 Thread francogrex
Hello I am using the for (i...) and a sink() into a file. But the output I am having is not arranged in either a vector or any other good structure. I would like to have the output in a file directly as a vector so that I do not have to edit the [1] and [6] etc and that the values are comma

Re: [R] A structured output from for(i...)?

2007-04-19 Thread francogrex
OK it works thanks. francogrex wrote: Hello I am using the for (i...) and a sink() into a file. But the output I am having is not arranged in either a vector or any other good structure. I would like to have the output in a file directly as a vector so that I do not have to edit the [1

Re: [R] Conditional power, predictive power

2007-04-19 Thread francogrex
Ok I am replying to my own message! I wrote a function, it works well but it's a bit twisted because you will have to edit the last file in excel or other. This is to analyze the bayesian predictive power in an analysis where treatment x is compared to treatment y. Example: Total final subject

[R] Conditional power, predictive power

2007-04-18 Thread francogrex
is there no package/function in R to calculate the conditional power or the bayesian predictive power for trials with binary endpoints? Thanks -- View this message in context: http://www.nabble.com/Conditional-power%2C-predictive-power-tf3603396.html#a10066991 Sent from the R help mailing list

Re: [R] R equivalent of S+SeqTrial?

2007-03-30 Thread francogrex
Distributions), but i'm not comfortable yet using the bayesian methods. On Wed, 2007-03-28 at 10:49 -0500, Douglas Bates wrote: On 3/28/07, Marc Schwartz [EMAIL PROTECTED] wrote: On Wed, 2007-03-28 at 02:42 -0700, francogrex wrote: Does anyone know of an R package that is equivalent of S

[R] R equivalent of S+SeqTrial?

2007-03-28 Thread francogrex
Does anyone know of an R package that is equivalent of S+SeqTrial for analysis of clinical trials using group sequential methods? Thanks. -- View this message in context: http://www.nabble.com/R-equivalent-of-S%2BSeqTrial--tf3478858.html#a9708877 Sent from the R help mailing list archive at

[R] Logistic regression for drugs Interactions

2007-03-14 Thread francogrex
I have the model below, for which I run a logistic regression including the interaction term (NSAID*Diuretic) fit1=glm(resp ~ nsaid+diuretic+I(nsaid*diuretic), family= binomial,data=w) NSAID DiureticPresent Absent 0 0 185 6527 0 1

Re: [R] Woolf's test, Odds ratio, stratification

2007-02-25 Thread francogrex
Thanks Mark for taking the time to provide me with a very well detailed reply and explanation. It helps a lot. Regards. -- View this message in context: http://www.nabble.com/Woolf%27s-test%2C-Odds-ratio%2C-stratification-tf3284589.html#a9146699 Sent from the R help mailing list archive at

[R] Woolf's test, Odds ratio, stratification

2007-02-24 Thread francogrex
Just a general question concerning the woolf test (package vcd), when we have stratified data (2x2 tables) and when the p.value of the woolf-test is below 0.05 then we assume that there is a heterogeneity and a common odds ratio cannot be computed? Does this mean that we have to try to add more

[R] automated integration?

2007-01-23 Thread francogrex
When I run the script below it works well it ouputs the result that I need, in this case were n=45 and e=5.02689 the result is: 6.669578 --- dens-function(x){ n=45 e=5.02689 a1=0.0987 b1=0.04261 a2=1.043 b2=1.222 p=0.121 if (n200) c((n=n/2),(e=e/2))

[R] How to formulate an analytical gradient?

2007-01-18 Thread francogrex
How to formulate an analytical gradient? Suppose I have the following function/expression: fr-function(x){ x1=x[1] x2=x[2] x3=x[3] x4=x[4] x5=x[5] z-((gamma(x1+n)))/((gamma(x1)*factorial(n))*((1+(e/x2))^x1)*((1+(x2/e))^n))

[R] maximum likelihood, 1st and 2nd derivative

2007-01-11 Thread francogrex
Hi guys again, it seems I haven't been doing the maximum likelihood estimation correctly. I quote below, can someone explain to me please what does it mean that the 2nd and 3rd derivatives of the function equals zero and how to compute that in R. We have our initial estimated, subjective

[R] maximum likelihood estimation of 5 parameters

2007-01-05 Thread francogrex
Hi Guys, it would be great if you could help me with a MLE problem in R. I am trying to evaluate the maximum likelihood estimates of theta = (a1, b1, a2, b2, P) which defines a mixture of a Poisson distribution and two gamma prior distributions (where the Poisson means have a gamma

Re: [R] maximum likelihood estimation of 5 parameters

2007-01-05 Thread francogrex
Franco, You can provide lower and upper bounds on the parameters if you use optim with method=L-BFGS-B. Hth, Ingmar Thanks, but when I use L-BFGS-B it tells me that there is an error in optim(start, f, method = method, hessian = TRUE, ...) : L-BFGS-B needs finite values of 'fn' -- View this

Re: [R] maximum likelihood estimation of 5 parameters

2007-01-05 Thread francogrex
/People/Faculty/Varadhan.html -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of francogrex Sent: Friday, January 05, 2007 10:42 AM To: r-help@stat.math.ethz.ch