0

I’ve been reading the documentations and discussions I can find but couldn’t get an answer, so I hope someone can help.

  I want to use gam in the context of an optimization algorithm (EM). In a simpler scenario, if I wanted to fit a 1d Gaussian using gam, I could have done

fit <- gam(y ~ 1)

However, in my case there are 2 complications:

  1. My y is a 2d Gaussian; and
  2. Not only do I need (mu1, sigma1, mu2, sigma2) from the fitting, but also mu1 and mu2 are some non-linear functions of the observables.

I would like to know whether in this case I can still make use of gam, or do I have to create my own function.

Edit:

To be precise, the problem is in the form

n(x, mu1, sigma1) * n(y, x + mu2(beta), sigma2)

where n() is the Gaussian pdf, x and y are independent variables, and mu2 is a (non-linear) function of an independent variable beta.

Zheyuan Li
  • 71,365
  • 17
  • 180
  • 248
  • I think "some non-linear functions" is way too vague to support a programming answer. – IRTFM Dec 16 '13 at 19:03
  • Apologize. I am dealing with a problem about backing out the parameters of a 2d gaussian, with zero correlation between dimensions. One of the dimension x is simple, the drift being a constant mu; the other dimension y is more involved, the drift beingx times some coefficient to also be estimated. – user1222538 Dec 17 '13 at 01:11
  • If you wnat to gather support for reopening this question you should edit the question body to include that information and post a small example in R code that illustrates the problem. I do not get the idea that you anticipate needing polynomial or smooth terms. A coefficient would automatically be calculated for any term in the formula. – IRTFM Dec 17 '13 at 01:15
  • You may be looking for [multivariate regression](http://stats.stackexchange.com/questions/4517/regression-with-multiple-dependent-variables), and to get this with `gam` there may be something similar to `lm(cbind(y1, y2) ~ ...)` described [here on `r-help`](https://stat.ethz.ch/pipermail/r-help/2009-December/222835.html). Or more likely it seems like you are trying to do regression `response = m * predictor + c` where you have some functional form `predictor = phi(x)` in mind, and think that for first dimension, m is 1, and for 2nd dim you want to estimate `m` which regression will do anyway. – Senti Bachcha Dec 17 '13 at 07:20

0 Answers0