Displaying 17 results from an estimated 17 matches for "lpmatrix".
Did you mean:
pmatrix
2008 Apr 09
1
mgcv::predict.gam lpmatrix for prediction outside of R
This is in regards to the suggested use of type="lpmatrix" in the
documentation for mgcv::predict.gam. Could one not get the same result more
simply by using type="terms" and interpolating each term directly? What is
the advantage of the lpmatrix approach for prediction outside R? Thanks.
--
View this message in context: http://www.nabble....
2008 Apr 06
0
mgcv::gam prediction using lpmatrix
The documentation for predict.gam in library mgcv gives an example of using
an "lpmatrix" to do approximate prediction via interpolation. However, the
code is specific to the example wrt the number of smooth terms, df's for
each,etc. (which is entirely appropriate for an example)
Has anyone generalized this to directly generate code from a gam object (eg
SAS or C code)? I wa...
2011 Aug 10
0
GAM Prediction
...ine fit, I think I would just need the
coefficients and the basis generating function.
I've been looking at Chapter 5 (p243-247) in Wood (2006) "GAMs: An
Introduction with R", and I've been trying to understand what is needed for
the smooth.construct and the predict.gam(type='lpmatrix') functions.
It's possible to generate a new prediction matrix with predict(gm, newdata,
type='lpmatrix), but the entire model object is needed as input. I looked
into it further, and the predict method (using type='lpmatrix") depends on
the following model components:
ob...
2012 Sep 25
1
REML - quasipoisson
...]
S<-matrix(0,19,19)
for (i in 2:10)
{
for (j in 2:10)
{
S[i,j]=S1[i-1,j-1]
S[i+9,j+9]=S2[i-1,j-1]
}
}
beta<-m1$coef
#penalised deviance
Dp<-m1$dev+t(beta)%*%S%*%beta
F1<-Dp/(2*phi)
#2nd term
F2<-sum(ifelse(y==0,0,y*log(y)-y-log(factorial(y))))
#3rd term
X<-predict(m1,type="lpmatrix")
W<-diag(fitted(m1))
H<-t(X)%*%W%*%X
ldhs<-determinant(H+S,log=TRUE)$modulus[1]
eigS<-eigen(S,only.values=TRUE)$val
lds<-sum(log(eigS[1:16]))
F3<-(ldhs-lds)/2
#4th term
Mp=3
F4<-Mp/2*log(2*pi*phi)
F1-F2+F3-F4
m1$gcv
#reml score = formula
##quasipoisson with scale = 1
#...
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
2008 Oct 01
1
Simon Wood GAMsetup
...am function under mgcv and I thought that
with the gam function I could obtain H using s(). Is this wrong?
e.g.
mod_spline<-gam(yy~s(x.summer,k=16,bs="cr",fx=FALSE,by=NA,m=1),sp=c(0.001),data=dstime,family=poisson,fit.method="mgcv")
H<-predict.gam(mod_spline,type="lpmatrix")
H<-H[,2:16]
I presume that the vectors obtained using the predict.gam() are different
from the ones obtained using GAM.setup().
Thank for your help.
Looking forward to hearing from you.
Michela
[[alternative HTML version deleted]]
2012 Oct 01
0
[Fwd: REML - quasipoisson]
...,j]=S1[i-1,j-1]
> S[i+9,j+9]=S2[i-1,j-1]
> }
> }
> beta<-m1$coef
> #penalised deviance
> Dp<-m1$dev+t(beta)%*%S%*%beta
> F1<-Dp/(2*phi)
>
> #2nd term
> F2<-sum(ifelse(y==0,0,y*log(y)-y-log(factorial(y))))
>
> #3rd term
> X<-predict(m1,type="lpmatrix")
> W<-diag(fitted(m1))
> H<-t(X)%*%W%*%X
> ldhs<-determinant(H+S,log=TRUE)$modulus[1]
> eigS<-eigen(S,only.values=TRUE)$val
> lds<-sum(log(eigS[1:16]))
> F3<-(ldhs-lds)/2
>
> #4th term
> Mp=3
> F4<-Mp/2*log(2*pi*phi)
>
> F1-F2+F3-F4
>...
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
2010 Sep 26
1
Basis functions of cubic regression spline in mgcv
I have a question about the basis functions of cubic regression spline in
mgcv. Are there some ways I can get the exact forms of the basis functions
and the penalty matrix that are used in mgcv? Thanks in advance!
Yan
[[alternative HTML version deleted]]
2012 Aug 06
0
GAM and interpolation?
...ements of the
variables (except geographic coordinates) for the whole area: only for the
individuals in the dataset.
I am kind of lost...I have been searching for a couple of days now and I
tried the predict.gam function with the easy type="response" and the more
mysterious type="lpmatrix", and other possibilities but cannot find what I
am looking for. I only calculate the risk for my individuals. I thought that
the non-parametric spline component of the GAM/GAMM models could have helped
me interpolate and "fill the gaps".
Did I miss something big? Are there solut...
2013 Apr 20
0
Calculate confidence intervals in mgcv for unconditional on the, smoothing parameters
...rix%*%vcov(gam_fit,dispersion=1)%*%t(basis_matrix)
stdv_f_x <- sqrt(diag(sigma_2_epsilon * smooth_matrix))
set.seed(123)
R_sim <- 100000
mean_val <- rep(0, nrow(cov_beta_diff))
coef_diff <- mvrnorm(n = R_sim, mu = mean_val , Sigma = cov_beta_diff)
Xp <- predict(gam_fit, type = "lpmatrix")
sim_bet <- Xp %*% t(coef_diff)
abs_ratio <- abs(sim_bet / stdv_f_x)
ratio_max <- apply(abs_ratio, 2, max)
cv <- quantile(ratio_max, probs = 0.95)
So everything is fine until this point. My problem is:everything has
been presented conditional on the smoothing parameter estimate...
2007 Apr 15
1
Use estimated non-parametric model for sensitivity analysis
Dear all,
I fitted a non-parametric model using GAM function in R. i.e.,
gam(y~s(x1)+s(x2)) #where s() is the smooth function
Then I obtained the coefficients(a and b) for the non-parametric terms. i.e.,
y=a*s(x1)+b*s(x2)
Now if I want to use this estimated model to do optimization or sensitivity analysis, I am not sure how to incorporate the smooth function since s() may not
2005 Feb 27
1
prediction, gam, mgcv
I fitted a GAM model with Poisson distribution
using the function gam() in the mgcv package.
My model is of the form:
mod<-gam(y~s(x0)+s(x1)+s(x2),family=poisson).
To extract estimates at a specified set of covariate
values I used the gam `predict' method.
But I want to get
estimate and standard error of the difference of two fitted values.
Can someone explain what should I do?
Thank
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
2003 May 16
2
glm and gam confidence intervals
How can I obtain the values of confidence intervals from gam anf glm
objects?
Thanks in advance
--
David Nogu?s Bravo
Functional Ecology and Biodiversity Department
Pyrenean Institute of Ecology
Spanish Research Council
Av. Monta?ana 1005
Zaragoza - CP 50059
976716030 - 976716019 (fax)
2007 Mar 27
1
gam parameter predictions --Sorry for double posting
R-help,
Sorry for posting again the same question (dated 26-03-2007) but
all my mails have been sent to the recycle bin without possibility
of recovering and thus I don't know if anyone has answer my query.
Here is the original message:
I'm applying a gam model (package mgcv) to predict
relative abundances of a fish species.
The covariates are year, month, vessel and statistical
2011 Apr 19
1
Prediction interval with GAM?
Hello,
Is it possible to estimate prediction interval using GAM? I looked through
?gam, ?predict.gam etc and the mgcv.pdf Simon Wood. I found it can
calculate confidence interval but not clear if I can get it to calculate
prediction interval. I read "Inference for GAMs is difficult and somewhat
contentious." in Kuhnert and Venable An Introduction to R, and wondering why
and if that