# [R] Predicting responses using ace

Frank E Harrell Jr f.harrell at vanderbilt.edu
Wed Sep 7 23:58:53 CEST 2005

```Luis Pineda wrote:
> I sent this email before, but I got a r-help-bounce message and I don know
> if it got to the m-list. Sorry if you had already seen it.
>
> I'm using the areg.boot function to do an ace regression. So far I've been
> able to do some simple running tests to fit a model with some input data,
> predict the response with new data, and find the inverse transform of such
> prediction (apparently). The commands I'm using are the following:
>
> library(MASS)
> library(Hmisc)
> xyt = read.table("tra100unifxy.dat") #2x100 table of training data (expl.
> variables)
> zt = read.table("tra100unifzR.dat") #1x100 table of training data (resp.
> variables)
> zs = read.table("sim10000z.dat") #2x10000 table of new data to predict
> (expl. variables)
> xys = read.table("sim10000xy.dat") #1x10000 table of expected responses
> x = xyt[,1]
> y = xyt[,2]
> z = zt[,1]
> xynew = data.frame(x=xys[,1],y=xys[,2])
> ace.r = areg.boot(z ~ x + y, B = 100)
> f = Function(ace.r, ytype='inverse')
> za = f\$z(predict(ace.r,xynew))
>
> I have a couple question:
>
> 1.) Is that the correct way of finding the inverse transform for the
> responses?

Yes

> 2.) I'm evaluating the model's goodness of fit using the Fraction of
> Variance Unexplained, which I'm calculating as:
>
> rsa = za - zs
> FVUa = sum(rsa*rsa)/(10000*var(zs)) #10000 is the size of the test set

That is not corrected for overfitting.  You need to use the print method
for the areg.boot object and note the Bootstrap validated R2

>
> The thing is I'm not getting satisfactory results. Is there a way to improve
> the results of the regression?. At the moment I'm not too confident with the
> formula I'm using as a parameter for areg.boot, since the response variables
> were generated as a substantially more complex function than z = x+y. I
> don't get this formula thing yet and maybe I'm passing a totally unrelated
> formula to the function.

z ~ x + y tells areg.boot to fit a model f(z) = g(x) + h(y) which is
quite general, if x and y are additive.

Frank

>
> On 9/7/05, Frank E Harrell Jr <f.harrell at vanderbilt.edu> wrote:
>
>>Luis Pineda wrote:
>>
>>>Well, I had no idea, since I read this in the documentation:
>>>
>>>"|x| - for |transace| a numeric matrix. For |areg.boot| |x| may be a
>>>numeric matrix or a formula...||"
>>>
>>>Luis Pineda
>>
>>Sorry about that - you are right.
>>
>>Thomas - please debug the code to make areg.boot work with x = numeric
>>matrix, or correct the help file. Thanks -Frank
>>
>>--

--
Frank E Harrell Jr   Professor and Chair           School of Medicine
Department of Biostatistics   Vanderbilt University

```