NewtRaphXi: Newton-Raphson for Xi

Description Usage Arguments Details Value Author(s) Examples

View source: R/NewtRaphXi.R

Description

Function for Newton-Raphson method for xi

Usage

1
NewtRaphXi(xiseed, theta, Y, X, tol = 10^(-5))

Arguments

xiseed

Initial value

theta

theta

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
##---- 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 (xiseed, theta, Y, X, tol = 10^(-5)) 
{
    rho = exp(X %*% theta)
    n = length(Y)
    kiter = 0
    OK = FALSE
    xi0 = xiseed
    while (!OK) {
        kiter = kiter + 1
        g = sum((Y - rho)^2 - rho * (1 + (1 + rho)/xi0))
        gp = sum(rho * (1 + rho))/xi0^2
        xi1 = xi0 - g/gp
        if (abs(xi1 - xi0) < tol) {
            OK = TRUE
        }
        xi0 = xi1
        if (xi1 < 0) {
            OK = FALSE
            xiseed = xiseed/2
            xi0 = xiseed
            kiter = 0
        }
    }
    return(list(kiter = kiter, xi = xi1))
  }

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