search for: gamsim

Displaying 20 results from an estimated 20 matches for "gamsim".

2011 Dec 16
1
mgcv 1.7-12 crashes R
...t from the R shell: <pre> R version 2.14.0 (2011-10-31) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: x86_64-pc-linux-gnu (64-bit) > library(mgcv) This is mgcv 1.7-12. For overview type 'help("mgcv-package")'. > dat <- gamSim(1 , n=400 , dist="normal",scale = 2) Gu & Wahba 4 term additive model > gam( y ~ s(x0) , data = dat) Aborted </pre> I am using Ubuntu 11.10 - amd64, R version 2.14.0 and mgcv 1.7-12. any ideas? Reinhard [[alternative HTML version deleted]]
2011 Oct 26
2
gam predictions with negbin model
Hi, I wonder if predict.gam is supposed to work with family=negbin() definition? It seems to me that the values returned by type="response" are far off the observed values. Here is an example output from the negbin examples: > set.seed(3) > n<-400 > dat<-gamSim(1,n=n) > g<-exp(dat$f/5) > dat$y<-rnbinom(g,size=3,mu=g) > b<-gam(y~s(x0)+s(x1)+s(x2)+s(x3),family=negbin(3),data=dat) > summary(y) Min. 1st Qu. Median Mean 3rd Qu. Max. 0.6061 1.6340 2.8120 2.7970 3.9250 4.9830 > summary(predict(b,type="response&...
2008 Jul 01
1
Simulate from a GAM model
...ction in the mgcv package to fit a variable coefficient model like the following from the examples. I would like simulate based on the fitted model like the simulate function in the stats package does for lm models. library(mgcv) set.seed(10) ## simulate date from y = f(x2)*x1 + error dat <- gamSim(3,n=400) b<-gam(y ~ s(x2,by=x1),data=dat) Thanks for any help you can give, Mark Lyman
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 <- model.matrix(~b-1) Xab <- model.matrix(~a:b-1) ## random interaction dat$y <- dat$y + Xa%*%rnorm(...
2012 Nov 06
1
options()$width ignored by print.formula
...rinted at an arbitrary length regardless of the desired width. I've tracked the problem back to print.formula(), so at a lower level than summary.gam(). Is there a way around this that I'm missing? library(mgcv) # start with example from ?gam set.seed(2) ## simulate some data... dat <- gamSim(1,n=400,dist="normal",scale=2) colnames(dat)[1:5] <- c("reallylongnamey", "reallylongnamex0", "reallylongnamex1", "reallylongnamex2", "reallylongnamex3") b <- gam(reallylongnamey~s(reallylongnamex0)+s(reallylongnamex1)+s(reallylong...
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
2012 Feb 17
1
Standard errors from predict.gam versus predict.lm
...r and gam fit is not so pronounced but the gam still clearly fits better than linear, but all gam se's are WAY above their linear equivalents when used to predict for representative new data in order to present results as interaction plots. cheers Mike require(mgcv) require(MASS) dat <- gamSim(1,n=200,dist="normal",scale=2) summary(b <- gam(y~s(x0)+s(x1)+s(x2)+s(x3),data=dat)) summary(a <- lm(y~x0 + x1 + x2 + x3,data=dat)) se.result <- data.frame(linear.se=predict(a, se.fit=TRUE)$se.fit, gam.se=predict(b, se.fit=TRUE)$se.fit) with(se.result, eqscplot(linear.se, gam.se...
2012 Jun 21
2
check.k function in mgcv packages
Hi,everyone, I am studying the generalized additive model and employ the package 'mgcv' developed by professor Wood. However,I can not understand the example listed in check.in function. For example, library(mgcv) set.seed(1) dat <- gamSim(1,n=400,scale=2) ## fit a GAM with quite low `k' b<-gam(y~s(x0,k=6)+s(x1,k=6)+s(x2,k=6)+s(x3,k=6),data=dat) plot(b,pages=1,residuals=TRUE) ## hint of a problem in s(x2) ## the following suggests a problem with s(x2) gam.check(b) ## Another approach (see below for more obvious method).......
2012 May 29
1
GAM interactions, by example
...y b1) I see that the results look in fact quite different (edf, and also deviance explained for example???) Are those two models (b and b1) really testing the same things??? If yes, why are the results so different between models??? Thanks a lot if anyone can help with that... Geraldine dat <- gamSim(4) ## fit model... b <- gam(y ~ fac+s(x2,by=fac)+s(x0),data=dat) plot(b,pages=1) summary(b) Family: gaussian Link function: identity Formula: y ~ fac + s(x2, by = fac) + s(x0) Parametric coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.1784 0.1985 5.937...
2010 Mar 04
2
which coefficients for a gam(mgcv) model equation?
...e equation used. I am an ecologist not a statistician - and have no access to statistical advice. How would I use values from the model below to complete the equation: log{E(yi )} = ?+ ?xi + f (zi )? Many thanks, Darren ## from the help library(mgcv) set.seed(0) ## simulate some data... dat <- gamSim(1,n=400,dist="normal",scale=2) b<-gam(y~s(x0)+s(x1)+s(x2)+s(x3),data=dat) summary(b) I have tried searching help forum with "gam equation" I was not able to find an answer from the 18 threads returned. Also tried looking at "?predict.gam" and simply "predict....
2011 Feb 04
1
GAM quasipoisson in MuMIn
...I'm having no luck with script from an example in MuMIn help file. In MuMIn help they advise "include only models with smooth OR linear term (but not both) for each variable". Their example is: # Example with gam models (based on "example(gam)") require(mgcv) dat <- gamSim(1, n = 500, dist="poisson", scale=0.1) gam1 <- gam(y ~ s(x0) + s(x1) + s(x2) + s(x3) + (x1+x2+x3)^2, family = poisson, data = dat, method = "REML") cat(dQuote(getAllTerms(gam1)), "\n") # include only models with smooth OR linear term (but not both) for ea...
2011 Feb 04
0
GAM quasipoisson in MuMIn - SOLVED
...xample in MuMIn help file. > In MuMIn help they advise "include only models with smooth OR linear term > (but not both) for each variable". Their example is: > > # Example with gam models (based on "example(gam)") > > require(mgcv) > > > > dat <- gamSim(1, n = 500, dist="poisson", scale=0.1) > > > > gam1 <- gam(y ~ s(x0) + s(x1) + s(x2) + s(x3) + (x1+x2+x3)^2, family = > poisson, data = dat, method = "REML") > > > > cat(dQuote(getAllTerms(gam1)), "\n") > > > > > > # incl...
2012 Feb 23
1
mgcv: Smoothing matrix
Dear All, I would like to extract the smoothing matrix of the fitted GAM, \hat{y} = Sy. I can't seem to find the function or am I missing something? Thanks, any help is greatly appreciated Man Zhang [[alternative HTML version deleted]]
2013 Apr 23
1
GAM Penalised Splines - Intercept
Hey all, I'm using the gam() function inside the mgcv package to fit a penalised spline to some data. However, I don't quite understand what exactly the intercept it includes by default is / how to interpret it. Ideally I'd like to understand what the intercept is in terms of the B-Spline and/or truncated power series basis representation. Thanks!
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
2012 Sep 11
1
plotting smoother function on raw data
Hi, I have used the mgcv library to generate a simple additive model. I want to know how to plot the function on the raw data with confidence intervals whan I have TWO variables in the model. I get it to work with one variable but not with two. I am on the limit for what I understand in R, so be gentle. I have read the help file on predict.gam, but did not get any help out of it. #My model:
2012 May 29
1
strucchange Fstats() example
...y b1) I see that the results look in fact quite different (edf, and also deviance explained for example???) Are those two models (b and b1) really testing the same things??? If yes, why are the results so different between models??? Thanks a lot if anyone can help with that... Geraldine dat <- gamSim(4) ## fit model... b <- gam(y ~ fac+s(x2,by=fac)+s(x0),data=dat) plot(b,pages=1) summary(b) Family: gaussian Link function: identity Formula: y ~ fac + s(x2, by = fac) + s(x0) Parametric coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 1.1784 0.1985 5.937...
2010 Jan 26
1
AIC for comparing GLM(M) with (GAM(M)
Hello I'm analyzing a dichotomous dependent variable (dv) with more than 100 measurements (within-subjects variable: hours24) per subject and more than 100 subjects. The high number of measurements allows me to model more complex temporal trends. I would like to compare different models using GLM, GLMM, GAM and GAMM, basically do demonstrate the added value of GAMs/GAMMs relative to
2010 Aug 05
2
compare gam fits
Hi folks, I originally tried R-SIG-Mixed-Models for this one (https://stat.ethz.ch/pipermail/r-sig-mixed-models/2010q3/004170.html), but I think that the final steps to a solution aren't mixed-model specific, so I thought I'd ask my final questions here. I used gamm4 to fit a generalized additive mixed model to data from a AxBxC design, where A is a random effect (human participants in