Displaying 20 results from an estimated 6000 matches similar to: "mgcv: Smoothing matrix"
2012 Jul 23
1
mgcv: Extract random effects from gam model
Hi everyone,
I can't figure out how to extract by-factor random effect adjustments from a
gam model (mgcv package).
Example (from ?gam.vcomp):
library(mgcv)
set.seed(3)
dat <- gamSim(1,n=400,dist="normal",scale=2)
a <- factor(sample(1:10,400,replace=TRUE))
b <- factor(sample(1:7,400,replace=TRUE))
Xa <- model.matrix(~a-1) ## random main effects
Xb <-
2011 Feb 16
1
retrieving partial residuals of gam fit (mgcv)
Dear list,
does anybody know whether there is a way to easily retrieve the so called "partial residuals" of a gam fit with package mgcv? The partial residuals are the residuals you would get if you would "leave out" a particular predictor and are the dots in the plots created by
plot(gam.object,residuals=TRUE)
residuals.gam() gives me whole model residuals and
2012 May 23
1
mgcv: How to calculate a confidence interval of a ratio
Dear R-Users,
Dr. Wood replied to a similar topic before where confidence intervals were
for a ratio of two treatments (
https://stat.ethz.ch/pipermail/r-help/2011-June/282190.html). But my
question is more complicated than that one. In my case, log(E(y)) = s(x)
where y is a smooth function of x. What I want is the confidence interval
of a ratio of log[(E(y2))/E(y1)] given two fixed x values of
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
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
2008 May 06
1
mgcv::gam shrinkage of smooths
In Dr. Wood's book on GAM, he suggests in section 4.1.6 that it might be
useful to shrink a single smooth by adding S=S+epsilon*I to the penalty
matrix S. The context was the need to be able to shrink the term to zero if
appropriate. I'd like to do this in order to shrink the coefficients towards
zero (irrespective of the penalty for "wiggliness") - but not necessarily
all the
2010 May 19
1
Displaying smooth bases - mgcv package
Dear all,
for demonstration purposes I want to display the basis functions used by a
thin plate regression spline in a gamm model. I've been searching the help
files, but I can't really figure out how to get the plots of the basis
functions. Anybody an idea?
Some toy code :
require(mgcv)
require(nlme)
x1 <- 1:1000
x2 <- runif(1000,10,500)
fx1 <- -4*sin(x1/50)
fx2 <-
2007 Jun 21
1
mgcv: lowest estimated degrees of freedom
Dear list,
I do apologize if these are basic questions. I am fitting some GAM
models using the mgcv package and following the model selection criteria
proposed by Wood and Augustin (2002, Ecol. Model. 157, p. 157-177). One
criterion to decide if a term should be dropped from a model is if the
estimated degrees of freedom (EDF) for the term are close to their lower
limit.
What would be the
2007 Dec 26
1
Cubic splines in package "mgcv"
R-users
E-mail: r-help@r-project.org
My understanding is that package "mgcv" is based on
"Generalized Additive Models: An Introduction with R (by Simon N. Wood)".
On the page 126 of this book, eq(3.4) looks a quartic equation with respect
to
"x", not a cubic equation. I am wondering if all routines which uses
cubic splines in mgcv are based on this quartic
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 Mar 01
2
smoothing a matrix (interpolate in plane)
Hi R-users,
I'd like to smooth a matrix to dismiss spikes and to interpolate in plane
example of a matrix:
Map[1:3,1:3]
[,1] [,2] [,3]...
[1,] 34.4 34.2 35.1
[2,] 33.4 34.2 35.4
[3,] 34.1 33.2 32.1
....
dim(Map)[1] =/= dim(Map)[2]
What functions can I use?
Thanks a lot for any response, M
[[alternative HTML version deleted]]
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 May 08
2
mgcv: inclusion of random intercept in model - based on p-value of smooth or anova?
Dear useRs,
I am using mgcv version 1.7-16. When I create a model with a few
non-linear terms and a random intercept for (in my case) country using
s(Country,bs="re"), the representative line in my model (i.e.
approximate significance of smooth terms) for the random intercept
reads:
edf Ref.df F p-value
s(Country) 36.127 58.551 0.644
2007 Oct 04
1
Convergence problem in gam(mgcv)
Dear all,
I'm trying to fit a pure additive model of the following formula :
fit <- gam(y~x1+te(x2, x3, bs="cr"))
,with the smoothing parameter estimation method "magic"(default).
Regarding this, I have two questions :
Question 1 :
In some cases the value of "mgcv.conv$fully.converged" becomes
"FALSE", which tells me that the method stopped with a
2011 Nov 09
2
Problem with simple random slope in gam and bam (mgcv package)
Dear useRs,
This is the first time I post to this list and I would appreciate any
help available. I've used the excellent mgcv package for a while now
to investigate geographical patterns of language variation, and it has
has always worked without any problems for me. The problem below
occurs using R 2.14.0 (both 32 and 64 bit versions in Windows and the
64 bit version in Unix) and mgcv (both
2010 Jun 16
3
mgcv, testing gamm vs lme, which degrees of freedom?
Dear all,
I am using the "mgcv" package by Simon Wood to estimate an additive mixed
model in which I assume normal distribution for the residuals. I would
like to test this model vs a standard parametric mixed model, such as the
ones which are possible to estimate with "lme".
Since the smoothing splines can be written as random effects, is it
correct to use an (approximate)
2008 Oct 10
2
bivariate non-parametric smoothing
Hi,
I was wondering if there is a function in R which performs bivariate non parametric smoothing
which allows for the possibility of including some weights in the smoothing (for each data points
in my grid I have some predefined weights that I would like to include in the smoothing).
Thanks,
Ben
_________________________________________________________________
[[alternative HTML
2006 Dec 15
1
DF for GAM function (mgcv package)
For summary(GAM) in the mgcv package smooth the degrees of freedom for
the F value for test of smooth terms are the rank of covariance matrix
of \hat{beta} and the residuals df. I've noticed that in a lot of GAMs
I've fit the rank of the covariance turns out to be 9. In Simon Wood's
book, the rank of covariance matrix is usually either 9 or 99 (pages
239-230 and 259).
Can anyone
2009 Feb 07
1
paraPen in gam [mgcv 1.4-1.1] and centering constraints
Dear Mr. Simon Wood, dear list members,
I am trying to fit a similar model with gam from mgcv compared to what I
did with BayesX, and have discovered the relatively new possibility of
incorporating user-defined matrices for quadratic penalties on
parametric terms using the "paraPen" argument. This was really a very
good idea!
However, I would like to constraint the coefficients
2010 Feb 04
3
mgcv problem
Dear friends,
I have install the last version 2.10 and now I have probles with 'mgcv' which can be load. I proved to eliminated and reinstalled but always obtain the same message:
> library (mgcv)
This is mgcv 1.6-1. For overview type `help("mgcv-package")'.
Error in runif(1) :
.Random.seed is not an integer vector but of type 'list'
Error : .onAttach non