[R] enquiry
Vladimir Eremeev
wl2776 at gmail.com
Wed Sep 12 13:26:15 CEST 2007
ah06981 wrote:
>
> Dear R-help,
>
> I am trying to estimate a Cox model with nested effects basing on the
> minimization of the overall AIC; I have two frailties terms, both gamma
> distributed. There is a error message (theta2 argument misses) and I
> don?t understand why. I would like to know what I have wrong. Thank you
> very much for your time.
>
>
> fitM7 <- coxph(Surv(lifespan,censured) ~ south + frailty(id,
> dist='gamma')+ frailty(mob, dist='gamma'), data= usa)
>
>
> tempfun <- function(theta1, theta2) {
>
> fit <- coxph(Surv(lifespan,censured) ~ south + frailty(id,
> dist='gamma', sparse= TRUE, theta=theta1)+ frailty(mob, dist='gamma',
> sparse =TRUE, theta=theta2), data=usa)
> aic <- (fit$loglik[2] - fit$loglik[1]) - sum(fit$df)
> return(2*aic)
> }
> nlminb(c(theta1=3.2,theta2=.2), tempfun)
>
> Error in (get(temp))(x, ...) : argument "theta2" is missing, with no
> default
>
> Best,
> Silvia
>
You need to
(1) either rewrite your function to accept a single argument and treat it as
a numeric vector:
tempfun <- function(thetas) {
theta1<-thetas[1]
theta2<-thetas[2]
<the rest of function code>
}
(2) or change the call to nlminb:
nlminb(3.2, tempfun,theta2=.2)
But, I suspect, the optimization in this case will be only on theta1.
--
View this message in context: http://www.nabble.com/enquiry-tf4428517.html#a12633376
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list