diff --git a/R/spline.R b/R/spline.R index 395ec3f..3d67c23 100644 --- a/R/spline.R +++ b/R/spline.R @@ -113,8 +113,7 @@ dbase.survspline <- function(q, gamma, knots, scale, deriv=FALSE, spline="rp"){ if(!is.matrix(gamma)) gamma <- matrix(gamma, nrow=1) if(!is.matrix(knots)) knots <- matrix(knots, nrow=1) else if (spline=="splines2ns") stop("matrix knots not supported with spline=\"splines2ns\"") - lg <- nrow(gamma) - nret <- max(length(q), lg) + nret <- max(length(q), nrow(gamma), nrow(knots)) q <- rep(q, length.out=nret) gamma <- matrix(rep(as.numeric(t(gamma)), length.out = ncol(gamma) * nret), @@ -165,7 +164,6 @@ dsurvspline <- function(x, gamma, beta=0, X=0, knots=c(-10,10), scale="hazard", d <- dbase.survspline(q=x, gamma=gamma, knots=knots, scale=scale, spline=spline) for (i in seq_along(d)) assign(names(d)[i], d[[i]]) if (any(ind)){ - if (length(knots)==0) browser() eta <- rowSums(basis(knots, tsfn(q, timescale), spline=spline) * gamma) # log cumulative hazard/odds eeta <- exp(ldlink(scale)(eta)) ret[ind][eeta==0] <- 0 @@ -219,13 +217,12 @@ psurvspline <- function(q, gamma, beta=0, X=0, knots=c(-10,10), scale="hazard", ret[ind][q==0] <- 0 ret[ind][q==Inf] <- 1 finite <- q>0 & q