projects
/
morpheus.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix typos and mistakes
[morpheus.git]
/
pkg
/
R
/
optimParams.R
diff --git
a/pkg/R/optimParams.R
b/pkg/R/optimParams.R
index
c061fcf
..
a5818ed
100644
(file)
--- a/
pkg/R/optimParams.R
+++ b/
pkg/R/optimParams.R
@@
-31,7
+31,7
@@
#' o$f( o$linArgs(par0) )
#' o$f( o$linArgs(par1) )
#' @export
#' o$f( o$linArgs(par0) )
#' o$f( o$linArgs(par1) )
#' @export
-optimParams
=
function(X, Y, K, link=c("logit","probit"))
+optimParams
<-
function(X, Y, K, link=c("logit","probit"))
{
# Check arguments
if (!is.matrix(X) || any(is.na(X)))
{
# Check arguments
if (!is.matrix(X) || any(is.na(X)))
@@
-119,13
+119,13
@@
setRefClass(
{
dim <- d + d^2 + d^3
W <<- solve( matrix( .C("Compute_Omega",
{
dim <- d + d^2 + d^3
W <<- solve( matrix( .C("Compute_Omega",
- X=as.double(X), Y=as.double(Y), M=as.double(M(θ)),
+ X=as.double(X), Y=as.double(Y), M=as.double(M
oments
(θ)),
pn=as.integer(n), pd=as.integer(d),
W=as.double(W), PACKAGE="morpheus")$W, nrow=dim, ncol=dim) )
NULL #avoid returning W
},
pn=as.integer(n), pd=as.integer(d),
W=as.double(W), PACKAGE="morpheus")$W, nrow=dim, ncol=dim) )
NULL #avoid returning W
},
- M
<-
function(θ)
+ M
oments =
function(θ)
{
"Vector of moments, of size d+d^2+d^3"
{
"Vector of moments, of size d+d^2+d^3"
@@
-148,7
+148,7
@@
setRefClass(
{
"Product t(Mi - hat_Mi) W (Mi - hat_Mi) with Mi(theta)"
{
"Product t(Mi - hat_Mi) W (Mi - hat_Mi) with Mi(theta)"
- A <- M(θ) - Mhat
+ A <- M
oments
(θ) - Mhat
t(A) %*% W %*% A
},
t(A) %*% W %*% A
},
@@
-156,8
+156,8
@@
setRefClass(
{
"Gradient of f, dimension (K-1) + d*K + K = (d+2)*K - 1"
{
"Gradient of f, dimension (K-1) + d*K + K = (d+2)*K - 1"
- -2 * t(grad_M(θ)) %*%
getW(θ) %*% (Mhat - M
(θ))
- }
+ -2 * t(grad_M(θ)) %*%
W %*% (Mhat - Moments
(θ))
+ }
,
grad_M = function(θ)
{
grad_M = function(θ)
{
@@
-256,10
+256,11
@@
setRefClass(
ci=c(-1,rep(0,K-1)) )
# debug:
ci=c(-1,rep(0,K-1)) )
# debug:
- print(computeW(expArgs(op_res$par)))
+ #computeW(expArgs(op_res$par))
+ #print(W)
# We get a first non-trivial estimation of W
# TODO: loop, this redefine f, so that we can call constrOptim again...
# We get a first non-trivial estimation of W
# TODO: loop, this redefine f, so that we can call constrOptim again...
- # Stopping condition? N iterations? Delta <=
ε
?
+ # Stopping condition? N iterations? Delta <=
epsilon
?
expArgs(op_res$par)
}
expArgs(op_res$par)
}