R/estimation-pl.R

Defines functions fj_pl

###########################################
## Functions to estimate the parameters  ##
###########################################

## Estimate F
fj_pl <- function(x, y, pij, sigma2, lambda,
                  B = getbasismatrix(x,
                                     create.bspline.basis(range(x),
                                                          min(N %/% 4, 40))),
                  R = getbasispenalty(create.bspline.basis(range(x),
                                                           min(N %/% 4, 40))), ...) {
    N <- length(y)
    w_j <- (pij/sigma2) / (sum(pij/sigma2) / N)
    hat_matrix <- B %*% solve(t(B) %*% diag(w_j) %*% B +
                              2*exp(lambda)*R) %*%
                                  t(B) %*% diag(w_j)
    list(f_hat = hat_matrix %*% y,
         H = hat_matrix,
         trace = sum(pij * diag(hat_matrix)))
}

Try the switchnpreg package in your browser

Any scripts or data that you put into this service are public.

switchnpreg documentation built on May 2, 2019, 3:47 p.m.