[R] Multivariate function from univariate functions
Mitchell Maltenfort
mmalten at gmail.com
Sun Mar 25 17:30:57 CEST 2012
Naïve question: would a saturated multivariate model work as an
interpolation function?
On 3/24/12, physicistintheory <physicistintheory at gmail.com> wrote:
> I'm relatively new to R and I'm stuck.
>
> I'm trying to construct a surface to optimize from a multivariate dataset.
> The dataset contains the response of a system to various stimuli. I am
> trying to optimize the mix of stimuli to maximize the response. To do so,
> I've interpolated the various datasets of type response vs. stimuli and I
> now have an array of functions "interps" whose length is the length of the
> array of the names of the various stimuli. I've also created a vector
> containing names for the stimuli, vars = x.1, x.2, x.3...
>
> Anyway, each of the functions in interps depends only on one variable
> (obviously). I would like to construct a function, call it, "surface" which
> is essentially: surface(vars) = interps[[1]]vars[[1]] +
> interps[[2]]vars[[2]]+...
>
> I've tried constructing surface recursively in a for loop:
> surface <- function(vars){0}
> for(i in 1:length(vars)){
> surface <- function(vars){surface(vars) + interps[[i]](vars[[i]])}
> }
>
> This results in an infinite recursion error...which I think I understand.
> Essentially, I'm trying to do the analog of something like i = i+1, but
> instead of adding integers, I want to add terms to a function.
>
> Any help is appreciated.
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Multivariate-function-from-univariate-functions-tp4502670p4502670.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
--
Sent from my mobile device
____________________________
Ersatzistician and Chutzpahthologist
I can answer any question. "I don't know" is an answer. "I don't know yet"
is a better answer.
More information about the R-help
mailing list