Displaying 20 results from an estimated 4000 matches similar to: "[mgcv][gam] Manually defining my own knots?"
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
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
2009 Sep 20
1
How to choose knots for GAM?
Hi, all
I want to choose same knots in GAM for 10 different studies so that they has
the same basis function. Even though I choose same knots and same dimensions
of basis smoothing, the basis representations are still not same.
My command is as follows:
data.gam<-gam(y~s(age,bs='cr',k=10)+male,family=binomial,knots=list(age=seq(45,64,length=10)))
What is my mistake for choice of
2007 Jun 25
1
gam function in the mgcv library
I would like to fit a logistic regression using a smothing spline, where the spline is a piecewise cubic polynomial. Is the knots option used to define the subintervals for each piece of the cubic spline? If yes and there are k knots, then why does the coefficients field in the returned object from gam only list k coefficients? Shouldn't there be 4k -4 coefficients?
Sincerely,
Bill
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
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
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
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
2012 Jan 16
0
choosing a proper knot in GAM mgcv package
hi
I want to choose proper knot for the following formula
formula = y~ s(x1) + s(x2) + s(x3) + s(x4) + s(x5) + s(x6) +s(x7) + s(x8)
gam(fromula,data=dat)
if i run the error is
Error in smooth.construct.tp.smooth.spec(object, dk$data, dk$knots) :
A term has fewer unique covariate combinations than specified maximum
degrees of freedom
how to find k and rectify this error
-----
Thanks in
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"
2004 Dec 01
2
step.gam
Dear R-users:
Im trying (using gam package) to develop a stepwise analysis. My gam
object contains five pedictor variables (a,b,c,d,e,f). I define the
step.gam:
step.gam(gamobject, scope=list("a"= ~s(a,4), "b"= ~s(b,4), "c"= ~s(c,4),
"d"= ~s(d,4), "e"= ~s(e,4), "f"= ~s(f,4)))
However, the result shows a formula containing the whole
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)
2006 Nov 28
4
GAMS and Knots
Hi
I was wondering if anyone knew how to work out the number of knots that
should be applied to each variable when using gams in the mgcv library?
Any help or references would be much appreciated.
Thanks
Kathryn Baldwin
2013 Feb 27
1
Finding the knots in a smoothing spline using nknots
Hi r-helpers.
Please forgive my ignorance, but I would like to plot a smoothing spline
(smooth.spline) from package "stats", and show the knots in the plot, and I
can't seem to figure out where smooth.spline has located the knots (when I
use nknots). Unfortunately, I don't know a lot about splines, but I know
that they provide me an easy way to estimate the location of local
2010 Jun 27
1
mgcv out of memory
Hello, I am trying to update the mgcv package on my Linux box and I keep
getting an "Out of memory!" error. Does anyone know of a fix for this?
Below is a snippet of the message that I keep getting: Thank you. Geoff
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
>>> Building/Updating help pages for package 'mgcv'
Formats:
2010 Mar 04
2
which coefficients for a gam(mgcv) model equation?
Dear users,
I am trying to show the equation (including coefficients from the model
estimates) for a gam model but do not understand how to.
Slide 7 from one of the authors presentations (gam-theory.pdf URL:
http://people.bath.ac.uk/sw283/mgcv/) shows a general equation
log{E(yi )} = ?+ ?xi + f (zi ) .
What I would like to do is put my model coefficients and present the
equation used. I am an
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 =
2007 Jul 04
3
Problem/bug with smooth.spline and all.knots=T
Dear list,
if I do
smooth.spline(tmpSec, tmpT, all.knots=T)
with the attached data, I get this error-message:
Error in smooth.spline(tmpSec, tmpT, all.knots = T) :
smoothing parameter value too small
If I do
smooth.spline(tmpSec[-single arbitrary number], tmpT[-single arbitrary number], all.knots=T)
it works!
I just don't see it. It works for hundrets other datasets, but not for
2009 Mar 12
3
Unable to run smoother in qplot() or ggplot() - complains about knots
I get the following error when I run qplot()
qplot(grade, read,data = hhm.long.m, geom = c("point", "smooth"))
Error in smooth.construct.cr.smooth.spec(object, data, knots) :
x has insufficient unique values to support 10 knots: reduce k.
I am not sure how to tackle this problem. When I take a subsample (<
1000) than I am able to run that function but with my sample
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