I've been trying to figure out how to get the names of the parameter vector
variables when inside the function that nlm calls to return the objective
function value:

knls <- function( theta, eqns, data, fitmethod="OLS", instr=NULL, S=NULL )
  {

    ##     print( names( theta ) )              # returns NULL
    ## get the values of the parameters
    for( i in 1:length( theta ) )
      {
        val <- theta[i]
        storage.mode( val ) <-  "double"
        assign( names( theta )[i], val )          # gags here cause I can't
get the names...
      }

    ## resids = eval( lhs ) - eval( rhs )
    for( i in length( eqns ) )
      {
        lhs[[i]] <- eval( formula( eqns[[i]] )[2] )
        rhs[[i]] <- eval( formula( eqns[[i]] )[3] )
        residi[[i]] <- lhs[[i]] - rhs[[i]]
        r <- rbind( r, as.matrix( residi[[i]] ) )
      }

    ## blah, blah, blah....

    knls <- obj
}


print( "calling nlstest" )
demand2 <- q ~ d0 + d1 * p + d2 * d
supply2 <- q ~ s0 + s1 * p + s2 * f + s3 * a
system2 <- list( demand2, supply2 )
sv2 <- c(d0=3,d2=4,d1=4.234,s0=-2.123,s2=2.123,s3=4.234,s1=0.234)

### call the nlm function to get the estimates...
estnew <- nlm( knls, sv2, hessian=TRUE, print.level=1, eqns=system2,
data=kmenta, fitmethod="OLS" )


My question is why can't I simply call names on the vector (sv2) that is
passed into the nlm function to get the parameters?

Thanks,
Jeff.



---
Jeff D. Hamann
Hamann, Donald and Associates, Inc.
PO Box 1421
Corvallis, Oregon USA 97339-1421
(office) 541-754-1428
(cell) 541-740-5988
[EMAIL PROTECTED]
www.hamanndonald.com

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to