Skip to content

Commit

Permalink
Fixes for si smooths
Browse files Browse the repository at this point in the history
  • Loading branch information
Matteo Fasiolo committed Apr 10, 2024
1 parent 82f48b6 commit ad85487
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions R/I_prepareInnerNested.R
Expand Up @@ -33,7 +33,7 @@
Jac <- inner$d1
nobs <- length(fit)
se <- sqrt(pmax(0, rowSums((Jac %*% Va) * Jac)))
edf <- sum(gObj$edf[prange[-1]])
edf <- sum(gObj$edf[prange])
ylabel <- .subEDF(paste0("expsm(", sm$term, ")"), edf)
xlabel <- "Index"
if( !is.null(xlim) ) {
Expand All @@ -51,7 +51,11 @@
"xlim" = xlim,
xlab = xlabel, ylab = ylabel, main = NULL, type = "nexpsm")
} else {
alpha <- drop(B %*% alpha)
a0 <- si$a0
if( is.null(a0) ){
a0 <- alpha * 0
}
alpha <- drop(B %*% (alpha + a0))
Va <- B %*% Va %*% t(B)
se <- sqrt(pmax(0, diag(Va)))
edf <- sum(gObj$edf[prange])
Expand Down
3 changes: 2 additions & 1 deletion R/I_prepareOuterNested.R
Expand Up @@ -8,13 +8,14 @@
sm <- gObj$smooth[[ o$ism ]]
si <- sm$xt$si
alpha <- si$alpha
a0 <- si$a0
dsi <- length( alpha )

rescale <- function(x){ exp(alpha[1]) * (x - si$xm) }

type <- class(o)[1]
if( type == "si" ){
raw <- sort( si$X %*% alpha )
raw <- sort( si$X %*% (alpha + a0) )
rescale <- function(x) x # No rescaling needed!
trnam <- "proj"
}
Expand Down

0 comments on commit ad85487

Please sign in to comment.