1 Aug 2006 01:43

### questions regarding spline functions

```Greetings,

A couple general questions regarding the use of splines to interpolate depth
profile data.

Here is an example of a set of depths, with associated attributes for a given
soil profile, along  with a function for calculating midpoints from a set of
soil horizon boundaries:

#calculate midpoints:
mid <- function(x) {
for( i in 1:length(x)) {
if( i > 1) {
a[i] = (x[i] - x[i-1]) / 2 + x[i-1]
}
}
#reurn the results
a[which(!is.na(a))]
}

#horizon depth bounds
z <- c(0,2,18,24,68,160,170,192,200)

#horizon midpoints, associated with horizon attribute
x <- mid(z)

#clay pct
y <- c(0,1,2,2,4,7,6,1)

#plot them
```

1 Aug 2006 01:29

### question about prediction etc. in Ridge regression (MASS library)

```Dear all,

I am trying to apply Ridge regression to my dataset, and then I would like
to predict the Y responses using the Ridge model (of certain lambda) for
new data point. The only Ridge regression functions I found is in "MASS"
library. However, there are very few functions available: lm.ridge(),
plot(), and select(). I didn't see any option to "predict" the Y response.

Does anyone know what else functions I could use to make prediction (using
Ridge model) or how I should write my own code to do the prediction? Also,
is there any way to calculate R^2 (or q^2) or the LOO-CV for Ridge model?

Sincerely,
Jeny

______________________________________________
R-help <at> stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
and provide commented, minimal, self-contained, reproducible code.

```
1 Aug 2006 01:43

### standard dev in glmmPQL

```Hi!

Can anyone let me know how can I get the stdDev of the random intercept from the output  of glmmPQL?

Thanks

Salomé

______________________________________________
R-help <at> stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
and provide commented, minimal, self-contained, reproducible code.

```
1 Aug 2006 02:33

### rgb and col2rgb color conversion/modification/shading

```I want to get a lighter shade of a color...I have a lot of colored objects and
want each one printed as a foreground against a slightly lighter background.

I thought I could try something like changing the alpha channel by first
converting it to rgb.

But prior to trying that, I'm stuck with how to get the color after converting
using col2rgb() to be interpreted again as a color, rather than a simple
vector?

Anyone have any help/ or alternative suggestion...

Thanks, -c
----------------------
TRYING WITH A SINGLE COLOR:

mycol<-"red"

> col2rgb(mycol)
[,1]
red    255
green    0
blue     0

> rgb(col2rgb(mycol),maxColorValue=255)

Error in rgb(col2rgb("red")) : argument "green" is missing, with no default

______________________________________________
R-help <at> stat.math.ethz.ch mailing list
```

1 Aug 2006 06:08

### Fitting models in a loop

```If I want to display a few polynomial regression fits I can do something
like

for (i in 1:6) {
mod <- lm(y ~ poly(x,i))
print(summary(mod))
}

Suppose that I don't want to over-write the fitted model objects,
though. How do I create a list of blank fitted model objects for later
use in a loop?

Murray Jorgensen
--

--
Dr Murray Jorgensen      http://www.stats.waikato.ac.nz/Staff/maj.html
Department of Statistics, University of Waikato, Hamilton, New Zealand
Email: maj <at> waikato.ac.nz                                Fax 7 838 4155
Phone  +64 7 838 4773 wk    Home +64 7 825 0441    Mobile 021 1395 862

______________________________________________
R-help <at> stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
and provide commented, minimal, self-contained, reproducible code.

```
1 Aug 2006 06:30

### Confirmation Request (3355406281)

```This is an automated message from the
<CNI-COPYRIGHT <at> cni.org> mailing list manager

Somebody (probably you) have requested the subscribe(digest) operation

If you want to confirm this operation,

Check that the Subject of the reply message contains
the confirmation ID: 3355406281,

If you do not want to confirm the requested operation, simply do nothing

should be sent to <CNI-COPYRIGHT-request <at> cni.org>

______________________________________________
R-help <at> stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
and provide commented, minimal, self-contained, reproducible code.

```
1 Aug 2006 07:16

### Re: Fitting models in a loop

```Murray,

Here is a general paradigm I tend to use for such problems.  It extends
to fairly general model sequences, including different responses, &c

First a couple of tiny, tricky but useful functions:

subst <- function(Command, ...) do.call("substitute", list(Command,
list(...)))

abut <- function(...)  ## jam things tightly together
do.call("paste", c(lapply(list(...), as.character), sep = ""))

Name <- function(...) as.name(do.call("abut", list(...)))

Now the gist.

fitCommand <- quote({
MODELi <- lm(y ~ poly(x, degree = i), theData)
print(summary(MODELi))
})
for(i in 1:6) {
thisCommand <- subst(fitCommand, MODELi = Name("model_", i), i =
i)
print(thisCommand)  ## only as a check
eval(thisCommand)
}

At this point you should have the results and

```

1 Aug 2006 09:15

### Re: question about dataframe ("sensory") in PLS package

```Hello, I do this in such way:

DATAX <- matrix(seq(1,6,1),2,3)
DATAY <- matrix (seq(1,4,1),2,2)
rownames(DATAX) <- c("s1","s2")
rownames(DATAY) <- c("s1","s2")
colnames (DATAX) <- c("v1","v2","v3")
colnames (DATAY) <- c("respone_1","response_2")
KAL <- data.frame (N = rownames(DATAX))
KAL\$Y <- DATAY
KAL\$X <- DATAX
KAL\$X
KAL\$Y

DATAX is a matrix of testing data, but DATAY is a matrix of responses.

Andris Jankevics

On Pirmdiena, 31. Jūlijs 2006 05:45, jz7 <at> duke.edu wrote:
> Dear all,
>
> I am trying to my dataframe for the PLS analysis using the PLS package.
> However I have some trouble generating the correct dataframe. The main
> problem is how to use one name to represent several columns in the
> dataframe.
>
> The example dataframe in PLS package is called "sensory". I cannot
> directly read the data file since it's a binary file. If I use
> "names(sensory)" command, I will get two names: "Quality" and "Panel". But
> if I use "summary(sensory)" command, I will get information of five
```

1 Aug 2006 09:43

### R crashes using pdf() windows() or postscript()

```Dear HelpeRs,
I have a script where I save several thousands of graphics. These are
then used in Latex through Sweave. Unfortunately R crashes while making
these plots and Windows pops up some message that I run low on virtual
memory. I tried to save the plots using pdf(), windows() and
postscript() and also tried to run it with R CMD BATCH myscript.R. But
after a while R slows down and crashes eventually or stops computing.
I'm using windows XP with R 2.3.1. I included a script that shows the
problem if you let it run for a while.
> R.version
_
platform       i386-pc-mingw32
arch           i386
os             mingw32
system         i386, mingw32
status
major          2
minor          3.1
year           2006
month          06
day            01
svn rev        38247
language       R
version.string Version 2.3.1 (2006-06-01)

draw.rectangle <- function(
label,
figurename="figure",
figurepath=getwd(),
```

1 Aug 2006 10:10

### Re: rgb and col2rgb color conversion/modification/shading

```ccarey <at> fhcrc.org wrote:
> I want to get a lighter shade of a color...I have a lot of colored objects and
> want each one printed as a foreground against a slightly lighter background.
>
> I thought I could try something like changing the alpha channel by first
> converting it to rgb.
>
> But prior to trying that, I'm stuck with how to get the color after converting
> using col2rgb() to be interpreted again as a color, rather than a simple
> vector?
>
> Anyone have any help/ or alternative suggestion...
>
> Thanks, -c
> ----------------------
> TRYING WITH A SINGLE COLOR:
>
> mycol<-"red"
>
>> col2rgb(mycol)
>       [,1]
> red    255
> green    0
> blue     0
>
>> rgb(col2rgb(mycol),maxColorValue=255)

rgb() required separate arguments for red green and blue.

Hence saying
```