[R] Root mean square on binned GAM results
Joris Meys
jorismeys at gmail.com
Sun Jun 20 01:27:51 CEST 2010
Just for the record, if you have NA's in it, you do :
tapply(d,cut(d,round(length(d)/5)),mean, na.rm=T)
tapply applies a function over a vector by groups defined by another
vector. In this case, it applies the function mean with the argument
na.rm=T over the vector d by the groups defined by the cut function.
cut splits a numeric vector in bins of equal size. In this case the
vector is d and the amount of bins is round(length(d)/5).
Cheers
Joris
On Sun, Jun 20, 2010 at 1:24 AM, Joris Meys <jorismeys at gmail.com> wrote:
> On Sat, Jun 19, 2010 at 4:29 AM, David Jarvis <thangalin at gmail.com> wrote:
>> Hi, Joris.
>>
>> Thanks again; I don't get it. Reading the help pages for R reminds me of
>> reading the manual pages for Unix: great for people who already know what it
>> means.
>
> Just read them, from top to bottom, and take a look at the examples.
> If you scare away from them, forget about ever finding your way around
> R. Never skip the details, and just run the examples at the bottom.
> Then you can see what's going on, it often clarifies things a whole
> lot.
>
>>
>> I can see how cut is dividing the data into 14 rows, and I can take the
>> factor results from cut:
>>
>> tapply(d,cut(d,round(length(d)/5)),mean)
>>
>> But the results are ... well, negative?
>
> That is explained in the help file. The left side is not included in
> the interval - (0,1] is equivalent to ]0,1]. To include the extreme
> values, the lower limit is extended with 0.1% of the range.
>
>>
>>> tapply(d,cut(d,round(length(d)/5)),mean)
>> (-0.009,0.685] (0.685,1.38] (1.38,2.07] (2.07,2.77] (2.77,3.46]
>> 0 1 2 NA 3
>> (3.46,4.15] (4.15,4.85] (4.85,5.54] (5.54,6.23] (6.23,6.93]
>> 4 NA 5 6 NA
>> (6.93,7.62] (7.62,8.32] (8.32,9.01]
>> 7 8 9
>>
>> I don't see how rounding up with ceiling would apply.
>
> well : 67/5 = 13,4. Round gives 13 bins, ceiling gives 14 bins. It's a
> matter of choice.
>
>>
>> I appreciate your patience; I think this might be beyond my capacity to
>> understand.
>
> You ain't stupid. Lazy maybe, but definitely not stupid ;)
>
> Cheers
> Joris
>
>
> --
> Joris Meys
> Statistical consultant
>
> Ghent University
> Faculty of Bioscience Engineering
> Department of Applied mathematics, biometrics and process control
>
> tel : +32 9 264 59 87
> Joris.Meys at Ugent.be
> -------------------------------
> Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
>
--
Joris Meys
Statistical consultant
Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control
tel : +32 9 264 59 87
Joris.Meys at Ugent.be
-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php
More information about the R-help
mailing list