Skip to content
Prev 176971 / 398503 Next

Jacobian

Hi?R-users,

?I would like to use jacobian function from numDeriv package.? If I have more than one parameters how do I modify it?

This is the example given in the package:

func2 <- function(x) c(sin(x), cos(x))
?? x <- (0:1)*2*pi
?? jacobian(func2, x)

Can I do the following:

z <- c(x,y)
func2 <- function(z) c(sin(xy), cos(x^2*y))
?? x <- (0:1)*2*pi
?? y <- (0:1)*2*pi
?? jacobian(func2, z)

output:
Error in func(x, ...) : object "xy" not found

Thank you so much for any help given.