Displaying 20 results from an estimated 3000 matches similar to: "Setting up 3D tensor product interactions in mgcv"
2009 Aug 24
2
Formulas in gam function of mgcv package
Dear R-experts,
I have a question on the formulas used in the gam function of the mgcv
package.
I am trying to understand the relationships between:
y~s(x1)+s(x2)+s(x3)+s(x4)
and
y~s(x1,x2,x3,x4)
Does the latter contain the former? what about the smoothers of all
interaction terms?
I have (tried to) read the manual pages of gam, formula.gam, smooth.terms,
linear.functional.terms but
2009 Aug 24
2
Formulas in gam function of mgcv package
Dear R-experts,
I have a question on the formulas used in the gam function of the mgcv
package.
I am trying to understand the relationships between:
y~s(x1)+s(x2)+s(x3)+s(x4)
and
y~s(x1,x2,x3,x4)
Does the latter contain the former? what about the smoothers of all
interaction terms?
I have (tried to) read the manual pages of gam, formula.gam, smooth.terms,
linear.functional.terms but
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
2012 Apr 02
1
gamm: tensor product and interaction
Hi list,
I'm working with gamm models of this sort, using Simon Wood's mgcv library:
gm<- gamm(Z~te(x,y),data=DATA,random=list(Group=~1))
gm1<-gamm(Z~te(x,y,by=Factor)+Factor,data=DATA,random=list(Group=~1))
with a dataset of about 70000 rows and 110 levels for Group
in order to test whether tensor product smooths vary across factor levels. I was wondering if comparing those two
2011 Jun 07
2
gam() (in mgcv) with multiple interactions
Hi! I'm learning mgcv, and reading Simon Wood's book on GAMs, as recommended to me earlier by some folks on this list. I've run into a question to which I can't find the answer in his book, so I'm hoping somebody here knows.
My outcome variable is binary, so I'm doing a binomial fit with gam(). I have five independent variables, all continuous, all uniformly
2018 May 24
2
Problem with adding a raster and a brick
Hi,
I seem to be having a problem adding the following two raster objects
together - one is a rasterLayer, the other is a rasterBrick. The extent,
resolution, and origin are the same, so according to my understand it
should work. The objects look like so:
> obs.clim
class : RasterLayer
dimensions : 60, 200, 12000 (nrow, ncol, ncell)
resolution : 0.5, 0.5 (x, y)
extent : -70,
2008 Jul 29
1
tensor product of equi-spaced B-splines in the unit square
Dear all,
I need to compute tensor product of B-spline defined over equi-spaced
break-points.
I wrote my own program (it works in a 2-dimensional setting)
library(splines)
# set the break-points
Knots = seq(-1,1,length=10)
# number of splines
M = (length(Knots)-4)^2
# short cut to splineDesign function
bspline = function(x) splineDesign(Knots,x,outer.ok = T)
# bivariate tensor product of
2012 Jul 30
2
mgcv 1.7-19, vis.gam(): "invalid 'z' limits'
Hi everyone,
I ran a binomial GAM consisting of a tensor product of two continuous
variables, a continuous parametric term and crossed random intercepts on a
data set with 13,042 rows. When trying to plot the tensor product with
vis.gam(), I get the following error message:
Error in persp.default(m1, m2, z, col = col, zlim = c(min.z, max.z), xlab =
view[1], :
invalid 'z' limits
In
2006 Nov 07
1
gamm(): nested tensor product smooths
I'd like to compare tests based on the mixed model representation of additive models, testing among others
y=f(x1)+f(x2) vs y=f(x1)+f(x2)+f(x1,x2)
(testing for additivity)
In mixed model representation, where X represents the unpenalized part of the spline functions and Z the "wiggly" parts, this would be:
y=X%*%beta+ Z_1%*%b_1+ Z_2%*%b_2
vs
y=X%*%beta+ Z_1%*%b_1+ Z_2%*%b_2 + Z_12
2009 Mar 11
1
matrix multiplication, tensor product, block-diagonal and fast computation
Dear R-users,
I am searching to the "best" way to compute a series of n matrix
multiplications between each matrix (mXm) in an array (mXmXn), and each
column of a matrix (mXn).
Please find below an example with four possible solutions.
The first is a simple for-loop which one might avoid; the second
solution employs the tensor product but then manually selects the right
outcomes. The
2018 Jan 17
1
mgcv::gam is it possible to have a 'simple' product of 1-d smooths?
I am trying to test out several mgcv::gam models in a scalar-on-function regression analysis.
The following is the 'hierarchy' of models I would like to test:
(1) Y_i = a + integral[ X_i(t)*Beta(t) dt ]
(2) Y_i = a + integral[ F{X_i(t)}*Beta(t) dt ]
(3) Y_i = a + integral[ F{X_i(t),t} dt ]
equivalents for discrete data might be:
1) Y_i = a + sum_t[ L_t * X_it * Beta_t ]
(2) Y_i
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
1999 Jul 20
2
tensor() function and sets
Hi Everyone,
To complete the outer() and kronecker() functions in the base, may I
suggest the following tensor() function, which allows the multiplication
of arrays through sets of conformable dimensions. I am happy to write a
help page if required.
The code also needs a setdiff() function which prompts me to ask: what
about simple set functions? I expect many of us have written our own
2011 Dec 10
2
efficiently finding the integrals of a sequence of functions
Hi folks,
I am having a question about efficiently finding the integrals of a list of
functions. To be specific,
here is a simple example showing my question.
Suppose we have a function f defined by
f<-function(x,y,z) c(x,y^2,z^3)
Thus, f is actually corresponding to three uni-dimensional functions
f_1(x)=x, f_2(y)=y^2 and f_3(z)=z^3.
What I am looking for are the integrals of these three
2012 Jul 17
2
Problem creation tensor
Hi guys,
I need some help to analyzing my data.
I start to describe my data: I have 21 matrices, every matrix on the
rows has users and on columns has items, in my case films.
Element of index (i, j) represent the rating expressed by user i about item j.
I have a matrix for each of professions.
An example of a this type of matrix is:
item 1 item 2 item 3 item4
id
2012 Feb 13
3
mgcv: increasing basis dimension
hi
Using a ts or tprs basis, I expected gcv to decrease when increasing the
basis dimension, as I thought this would minimise gcv over a larger
subspace. But gcv increased. Here's an example. thanks for any comments.
greg
#simulate some data
set.seed(0)
x1<-runif(500)
x2<-rnorm(500)
x3<-rpois(500,3)
d<-runif(500)
linp<--1+x1+0.5*x2+0.3*exp(-2*d)*sin(10*d)*x3
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
2012 Jul 30
1
te( ) interactions and AIC model selection with GAM
Hello R users,
I'm working with a time-series of several years and to analyze it, I?m using
GAM smoothers from the package mgcv. I?m constructing models where
zooplankton biomass (bm) is the dependent variable and the continuous
explanatory variables are:
-time in Julian days (t), to creat a long-term linear trend
-Julian days of the year (t_year) to create an annual cycle
- Mean temperature
2012 Jun 21
2
MGCV: Use of irls.reg option
Hi,
In the help files in the ?mgcv package for the gam.control() function,
there is an option irls.reg. The help files describe this option as:
For most models this should be 0. The iteratively re-weighted least squares
method by which GAMs are fitted can fail to converge in some circumstances.
For example, data with many zeroes can cause problems in a model with a log
link, because a mean of
2005 Mar 11
0
mgcv 1.2-0
mgcv version 1.2 is on CRAN now. mgcv provides generalized additive models
and generalized additive mixed models with automatic estimation of the
smoothness of model components.
Changes in this version are:
* A new gam fitting method is implemented for the generalized case. It
provides more reliable convergence than the previous default, but can be
a little slower. See ?gam.method,