当我尝试这些代码时收到这些错误
> fk <- function(u.vect, lambda, alpha, beta, x, k) {
+ res <- sapply(u.vect, function(u) {
+ # Cause-specific hazard
+ hk <-
+ lambda[k] * alpha[k] * (uˆ(alpha[k] - 1)) * exp(sum(unlist(beta[, k]) * x))
Error: unexpected input in:
" hk <-
lambda[k] * alpha[k] * (uˆ"
> # Cumulative cause-specific hazard
> Hk <-
+ lambda * (rep(u, length(lambda))ˆalpha) * exp((t(beta) %*% matrix(x, ncol = 1))[, 1])
Error: unexpected input in:
" Hk <-
lambda * (rep(u, length(lambda))ˆ"
> # Cause-specific hazard x Overall survival
> aux <- hk * exp(-sum(Hk))
Error: object 'hk' not found
> return(aux)
Error: object 'aux' not found
> })
Error: unexpected '}' in " }"
> return(res)
Error: no function to return from, jumping to top level
> }
Error: unexpected '}' in "}"
错误是什么意思,我该如何解决?
请帮忙,谢谢