Skip to content

Commit

Permalink
Barebone function for PLNfit initialization (useful for variance_jack…
Browse files Browse the repository at this point in the history
…knife and variance_bootsrap)
  • Loading branch information
mahendra-mariadassou committed Nov 17, 2023
1 parent f89d7d0 commit df51164
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,14 @@ create_parameters <- function(
Sigma = sigma * toeplitz(x = rho^seq(0, p-1)),
depths = depths)
}

#' barebone function to compute starting points for B and M
#' @importFrom stats lm.fit
starting_point <- function(Y, X, O, w) {
# Y = responses, X = covariates, O = offsets, w = weights
n <- nrow(Y); p <- ncol(Y); d <- ncol(X)
fits <- lm.fit(w * X, w * log((1 + Y)/exp(O)))
list(B = matrix(fits$coefficients, d, p),
M = matrix(fits$residuals, n, p),
S = matrix(.1, n, p))
}

0 comments on commit df51164

Please sign in to comment.