[R] Fwd: nonlinearity and interaction

Thomas Levine thomas.levine at gmail.com
Fri May 14 14:47:59 CEST 2010

```Creating the 5 indicator variables will be easy if you post your code
and sample data. This may also allow people to help with the first
problem you were having.

Tom

2010/5/14 William Simpson <william.a.simpson at gmail.com>:
> [posted this at 9:25 and still hasn't appeared on the list at 13:26]
>
>
> I have the following set-up.
>
> 6 values of a continuous variable (let's say light intensity) are
> presented to a system.
> The input is presented as a random series of blocks lasting (say) 5 sec each.
>              ----
>     ----
> ----                         etc
>         ----
> time ->
>
> The output is measured and sampled at say 10 samples/sec. Please
> ignore the fact that this is a time series and don't suggest things
> like ar() and arima(). I have looked at the autocorrelation function
> of the output and it is an amazing spike at a lag of zero and zilch
> elsewhere.
>
> Call the input x and the output y.
>
> I can find the relationship between x and y by
> fit<-lm(y~x)
> coef(fit) tells me the line that best fits x vs y (as shown in the
> plot of the 6 values of x vs the mean values of y at those values).
>
> ****Question:
> Suppose that the system is nonlinear such that the response to the
> sequence 0,2 is not the same as the response to 2, 0 -- it is not just
> a change of the response by the same amount. Or nonlinear in other
> weird ways (I don't just mean simple things like y~x^2).
>
> I am thinking that a way to characterise this might be to pretend that
> x is not a continuous variable and to represent it with 5 indicator
> variables. And then interactions between them would tell me about
> nonlinear effects?
> e.g.
> lm(y~ d1 + d2 + d3 + d4 + d5 + d1*d2) etc
> Does this make any sense? If so, please suggest a good way to go about
> this; how to set up the dummy variables and how to interpret the
> results.
>
> Ideally, the same lm() fit would tell me about the linear effect y~x
> and the nonlinearities. Both sorts of effect will co-exist.
>
> Thanks very much for any help!
>
> Bill
>
> ______________________________________________
> 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.
>

```