Skip to content
Prev 319705 / 398502 Next

help with simple function

Hello,

You are missing a '*' in your first try.
(As for the second, in R parenthesis are round, not [])

sqrt(var(Y1) + var(Y2))^2 - 4*(var(Y1)*(var(Y2) - cov(Y1, Y2)^2))

This written as a function becomes

fun <- function(Y1, Y2)
	sqrt(var(Y1) + var(Y2))^2 - 4*(var(Y1)*(var(Y2) - cov(Y1, Y2)^2))

x1 <- rnorm(10)
x2 <- rnorm(10)
fun(x1, x2)


Hope this helps,

Rui Barradas

Em 17-03-2013 15:47, Miguel Eduardo Delgado Burbano escreveu: