I've gotten a MLE estimator that is written in GAUSS that I am trying to re-code into R. I do not use, nor have I ever used GAUSS itself (and do not have access to it). In the code, there is a line that is a bit confusing to me.
In the validated GAUSS code there is a line under the "inputs" (part of the comments) that states:
invsig: scalar or m-by-m matrix with inverse of sigma
I am working on getting the code to work piece by piece, but my first question is something relatively simple.
Here is the GAUSS snippet that confuses me:
...
local m, k, tobs, invsig
m = rows(y);k = rows(x); tobs = rows(dat)
invsig= eye(m)*invsig
...
I understand that this is the identity matrix multiplied by the "input" invsig, but in simulated examples that works (from log files attached to the code), the program can be started using the scalar value of invsig. IE: setting an initial value as invsig = 1
In R, this is not working. Here is the simple "test" code to try to get this:
y.mat <- rep(rexp(3))
x.mat <- matrix(rexp(36), 12, 3)
myfct <- function(x,invsig){
m <- nrow(x)
invsig <- diag(m)%*%invsig
return(invsig)
}
t1 <- myfct(x.mat, 1) ##Non-conformable error
t2 <- myfct(x.mat, y.mat) ##Works
I understand the non-conformable error that I am getting in R. The question is am I missing something in the conversion between GAUSS and R? In reading the help manuals online, GAUSS does matrix operations by using the individual symbols (*/+-) and to do things element-wise, you add a "." before each operation. So to me, the GAUSS code is saying to do matrix multiplication (%*%
in R)and that is what the simple function tries to do.
Any comments or suggestions are greatly appreciated!