Sunday, 15 January 2012

r - Problems with Newton's Method for finding coefficient and Hessian -


I'm trying to write a function which is Newton's method (Coefficient ++ (Inverted hessian) * gradient ) To find a multiplier for a linear model, here and there

I am using the following code:

## Reading in data data & lt; -read.csv ('hw8.csv') Summary (data) # yi and xi with data file attached (dat) ## x of x and lt; -cbind (1, xi) mle & lt; -function (c) {gi & lt; - Making columns of 1-yi * exp (c [1] + c [2] * Xi) Hello & lt; - G-1H & LT; - -1 * (T (x)% *% high% *% x) G & lt; -T (x)% *% gi c & lt; -c + solution (h)% *

When I run the code, I get the following error:

previous> error in t (x )% *% Hi% *% x: Non-submissive arguments stopped at RMate line 29

Given that the formula has been designed with the problem of Green, set me not It seems that this is a thread problem, I think I am doing something wrong in passing my work.

How can I fix this? Any help with this function will be greatly appreciated.

As Jonathan said in the comment, you need a proper dimension:

  R & gt; X & LT; - Matrix (1: 4, Niacal = 2) R & gt; T (X)% *% X [, 1] [, 2] [1,] 5 11 [2,] 11 25 R & gt;  

But you should use the appropriate tool so that the log in function can be found in the stats package and / or MASS package in the> loglm function. Both will be installed by default with their R installation.


No comments:

Post a Comment