Displaying 20 results from an estimated 2000 matches similar to: "gam function in the mgcv library"
2009 Oct 13
2
How to choose a proper smoothing spline in GAM of mgcv package?
Hi, there,
I have 5 datasets. I would like to choose a basis spline with same knots in
GAM function in order to obtain same basis function for 5 datasets.
Moreover, the basis spline is used to for an interaction of two covarites.
I used "cr" in one covariate, but it can only smooth w.r.t 1 covariate. Can
anyone give me some suggestion about how to choose a proper smoothing spline
2013 Jan 28
2
Why are the number of coefficients varying? [mgcv][gam]
Dear List,
I'm using gam in a multiple imputation framework -- specifying the knot
locations, and saving the results of multiple models, each of which is
fit with slightly different data (because some of it is predicted when
missing). In MI, coefficients from multiple models are averaged, as are
variance-covariance matrices. VCV's get an additional correction to
account for how
2013 Mar 11
1
Use pcls in "mgcv" package to achieve constrained cubic spline
Hello everyone,
Dr. wood told me that I can adapting his example to force cubic spline to pass through certain point.
I still have no idea how to achieve this. Suppose we want to force the cubic spline to pass (1,1), how can
I achieve this by adapting the following code?
# Penalized example: monotonic penalized regression spline .....
# Generate data from a monotonic truth.
2012 Nov 29
1
[mgcv][gam] Manually defining my own knots?
Dear List,
I'm using GAMs in a multiple imputation project, and I want to be able
to combine the parameter estimates and covariance matrices from each
completed dataset's fitted model in the end. In order to do this, I
need the knots to be uniform for each model with partially-imputed
data. I want to specify these knots based on the quantiles of the
unique values of the non-missing
2011 Mar 28
2
mgcv gam predict problem
Hello
I'm using function gam from package mgcv to fit splines. ?When I try
to make a prediction slightly beyond the original 'x' range, I get
this error:
> A = runif(50,1,149)
> B = sqrt(A) + rnorm(50)
> range(A)
[1] 3.289136 145.342961
>
>
> fit1 = gam(B ~ s(A, bs="ps"), outer.ok=TRUE)
> predict(fit1, newdata=data.frame(A=149.9), outer.ok=TRUE)
Error
2013 Mar 23
1
Time trends with GAM
Hi all,
I am using GAM to model time trends in a logistic regression. Yet I would
like to extract the the fitted spline from it to add it to another model,
that cannot be fitted in GAM or GAMM.
Thus I have 2 questions:
1) How can I fit a smoother over time so that I force one knot to be at a
particular location while letting the model to find the other knots?
2) how can I extract the matrix
2010 Aug 04
2
more questions on gam/gamm(mgcv)...
Hi R-users,
I'm using R 2.11.1, mgcv 1.6-2 to fit a generalized additive mixed model.
I'm new to this package...and just got more and more problems...
1. Can I include correlation and/or random effect into gam( ) also? or only
gamm( ) could be used?
2. I want to estimate the smoothing function s(x) under each level of
treatment. i.e. different s(x) in each level of treatment. shall I
2005 Nov 23
1
1st derivative {mgcv} gam smooth
Dear R-hep,
I'm trying to get the first derivative of a smooth from a gam
model like:
model<-gam(y~s(x,bs="cr", k=5)+z) and need the derivative: ds(x)/dx. Since
coef(model) give me all the parameters, including the parameters of the
basis, I just need the 1st derivative of the basis s(x).1, s(x).2, s(x).3,
s(x).4. If the basis were generated with the function
2007 Oct 03
1
How to avoid overfitting in gam(mgcv)
Dear listers,
I'm using gam(from mgcv) for semi-parametric regression on small and
noisy datasets(10 to 200
observations), and facing a problem of overfitting.
According to the book(Simon N. Wood / Generalized Additive Models: An
Introduction with R), it is
suggested to avoid overfitting by inflating the effective degrees of
freedom in GCV evaluation with
increased "gamma"
2009 Jun 23
1
Model fitting with GAM and "by" term
Hello R Users,
I have a question regarding fitting a model with GAM{mgcv}. I have data
from several predictor (X) variables I wish to use to develop a model to
predict one Y variable. I am working with ecological data, so have data
collected many times (about 20) over the course of two years. Plotting
data independently for each date there appears to be relationships
between Y (fish density)
2007 Dec 13
1
Probelms on using gam(mgcv)
Dear all,
Following the help from gam(mgcv) help page, i tried to analyze my
dataset with all the default arguments. Unfortunately, it can't be run
successfully. I list the errors below.
#m.gam<-gam(mark~s(x,y)+s(lstday2004)+s(slope)+s(ndvi2004)+s(elevation)+s(disbinary),family=binomial(logit),data=point)
2011 Jun 08
1
predict with model (rms package)
Dear R-help,
In the rms package, I have fitted an ols model with a variable
represented as a restricted cubic spline, with the knot locations
specified as a previously defined vector. When I save the model object
and open it in another workspace which does not contain the vector of
knot locations, I get an error message if I try to predict with that
model. This also happens if only one workspace
2010 Apr 14
1
Selecting derivative order penalty for thin plate spline regression (GAM - mgcv)
Hi,
I am using GAMs (package mgcv) to smooth event rates in a penalized regression setting and I was wondering if/how one can
select the order of the derivative penalty.
For my particular problem the order of the penalty (parameter "m" inside the "s" terms of the formula argument) appears to
have a larger effect on the AIC/deviance of the estimated model than the
2013 Jul 23
1
Help with using unpenalised te smooth in negative binomial mgcv gam
Hi,
I have been trying to fit an un-penalised gam in mgcv (in order to get more
reliable p-values for hypothesis testing), but I am struggling to get the
model to fit sucessfully when I add in a te() interaction. The model I am
trying to fit is:
gam(count~ s(x1, bs = "ts", k = 4, fx = TRUE) +
s(x2, bs = "ts", k = 4, fx = TRUE) +
te(x2, x3, bs =
2006 Jun 18
1
GAM selection error msgs (mgcv & gam packages)
Hi all,
My question concerns 2 error messages; one in the gam package and one in
the mgcv package (see below). I have read help files and Chambers and
Hastie book but am failing to understand how I can solve this problem.
Could you please tell me what I must adjust so that the command does not
generate error message?
I am trying to achieve model selection for a GAM which is required for
2008 Mar 19
1
Smoothing z-values according to their x, y positions
Dear All,
I'm sure this is not the first time this question comes up but I
couldn't find the keywords that would point me out to it - so
apologies if this is a re-post.
Basically I've got thousands of points, each depending on three variables:
x, y, and z.
if I do a plot(x,y, col=z), I get something very messy.
So I would like to smooth the values of z according to the values of
2009 Sep 30
1
rcs fits in design package
Hi all,
I have a vector of proportions (post_op_prw) such that
>summary(amb$post_op_prw)
Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
0.0000 0.0000 0.0000 0.3985 0.9134 0.9962 1.0000
> summary(cut2(amb$post_op_prw,0.0001))
[0.0000,0.0001) [0.0001,0.9962] NA's
1904 1672 1
2006 Nov 15
1
splineDesign and not-a-knot conditions
Hi,
I would like to fit an (interpolating) spline to data where the
derivatives at the endpoints of the interval are nonzero, thus the
natural spline endpoint-specification does not make sense. Books (de
Boor, etc) suggest that in this case I use not-a-knot splines.
I know what not-a-knot splines are (so if I were solving for the
coefficients directly I knew how to do this), but I don't
2008 May 01
1
Optimal knot locations for splines
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. I know I can solve this problem using some optimization function in
R, but I was wondering if anyone
2003 May 26
0
knots fixed in gam(), library(mgcv)
Dear all,
I have a problem with specifying the no. of knots in our function which
include gam(). I last worked with this in mid September but since then I
have reinstalled R and Simon Wood's library(mgcv), which he has changed
since then. The statistician (and good R-coder) with whom I co-operate is
now unfortunately overloaded with teaching, and I'm in the sprut of my
thesis.... I