NewtRaph: Newton-Raphson Method

Description Usage Arguments Details Value Author(s) Examples

View source: R/NewtRaph.R

Description

Function for Newton-Raphson method

Usage

1
NewtRaph(thseed, xiseed, Y, X, tol = 10^(-5))

Arguments

thseed

Initial value for theta

xiseed

Initial value for xi

Y

data

X

data

tol

approximation tolerance

Details

Okay

Value

list

Author(s)

E. A. Pena

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (thseed, xiseed, Y, X, tol = 10^(-5)) 
{
    p = length(thseed)
    kiter = 0
    th0 = thseed
    xi0 = xiseed
    OK = FALSE
    while (!OK) {
        kiter = kiter + 1
        est0 = c(th0, xi0)
        out = UHFuncs(th0, xi0, Y, X)
        U = out$U
        H = out$H
        UUt = out$UUt
        Hinv = solve(H)
        est1 = est0 - Hinv %*% U
        th0 = est1[-(p + 1)]
        xi0 = est1[(p + 1)]
        dist = sqrt(sum((est1 - est0)^2))
        if (dist < tol) {
            OK = TRUE
        }
    }
    XiCov = Hinv %*% UUt %*% t(Hinv)
    return(list(kiter = kiter, th = th0, xi = xi0, U = U, H = H, 
        Hinv = Hinv, UUt = UUt, XiCov = XiCov))
  }

fblues/Test documentation built on June 27, 2020, 12:18 a.m.