Suppose I have two variables, x and y. For a fixed number of knots, I want
to create a spline transformation of x such that a loss function is
minimized. Presumably, this loss function would be least squares, i.e. sum
(f(x)-y)^2. The spline transformations would be linear, quadratic or
cubic.
Thanks for the help. I tried out the one promising lead, curfit.free.knot,
and it doesn't work for linear or quadratic splines. The documentation says
it should, but when I specify a linear spline, it returns a cubic.
On 5/1/08, Spencer Graves [EMAIL PROTECTED] wrote:
RSiteSearch('free
Great suggestions. I tested the code on an example and the run time was
reduced from 1 min 12 sec to 3 sec. Also, I like the suggestion to look at
the quantiles. I will see what insight it provides in terms of detecting
masked interactions.
I have a couple questions about your code.
First, why
Hey all,
The code below creates a partial dependence plot for the variable x1 in the
linear model y ~ x1 + x1^2 + x2.
I have noticed that the for loop in the code takes a long time to run if the
size of the data is increased. Is there a way to change the for loop into
an apply statement? The
, byrow=T)
a[2,] - apply(b,2,FUN=function(x)
{mean(predict(lm1,cbind(m[,-match(x1,names(m))],x1=x))) })
plot(a[1,],a[2,],xlab=x1,ylab=Response,type=l,main=Partial Dependence
Plot)
Mike Dugas
[[alternative HTML version deleted]]
__
R-help@r
, Mike Dugas [EMAIL PROTECTED] wrote:
The answer to my post is yes (which I just figured out).
Switching from for to apply isn't going to speed up your code. If you
carefully read the source code of apply, you'll see the guts of the
work is done by:
for (i in 1:d2) {
tmp - FUN(array
wrote does this using predict() which is useful for modeling
approaches like GAMs.
Mike
On Wed, Apr 23, 2008 at 8:47 PM, hadley wickham [EMAIL PROTECTED] wrote:
On Wed, Apr 23, 2008 at 7:31 PM, Mike Dugas [EMAIL PROTECTED] wrote:
Thanks for the help. That explains why my time testing showed
7 matches
Mail list logo