[R] How to test a model with two unkown constants

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Wed Aug 27 18:17:21 CEST 2003


Sven Garbade <garbade at psy.uni-muenchen.de> writes:

> Hi all,
> 
> suppose I've got a vector y with some data (from a repeated measure
> design) observed given the conditions in f1 and f2. I've got a model
> with two unknown fix constants a and b which tries to predict y with
> respect to the values in f1 and f2. Here is an exsample
> 
> # "data"
> y <- c(runif(10, -1,0), runif(10,0,1))
> # f1
> f1 <- rep(c(-1.4, 1.4), rep(10,2))
> # f2
> f2 <- rep(c(-.5, .5), rep(10,2))
> 
> Suppose my simple model looks like
> 
> y = a/f1 + b*f2
> 
> Is there a function in R which can compute the estimates for a and b?
> And is it possible to test the model, eg how "good" the fits of the
> model are?

f2 and 1/f1 are exactly collinear, so no, not in R, nor any other way.

Apart from that, the model is linear in a and b so lm() can fit it
(with different f1 and f2) if you're not too squeamish about the error
distribution.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list