[R] Use estimated non-parametric model for sensitivity analysis

Simon Wood s.wood at bath.ac.uk
Mon Apr 16 11:42:11 CEST 2007


On Sunday 15 April 2007 23:36, Jin Huang wrote:
> 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)
-- do you mean y = \sum_i a_i d_i(x1) + \sum_i b_i e_i(x2)
where d_i and e_i are basis functions? Or do you mean something else by a and 
b here?

>
>   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 be recognized outside GAM environment.
>
- do you actually need the whole smooth functions, or only the smooths 
evaluated at particular x1/x2 values? If it is the latter then you can use 
the `type="lpmatrix" argument to predict.gam, in order to obtain the matrix 
which maps the model coefficients to the estimated linear predictor of the 
GAM. The columns of this matrix are made up of the evaluated basis functions 
for the smooth terms, which is usually all you need.

There are some examples of this sort of thing in ?predict.gam.

best,
Simon


>   Thank you in advance!
>
>   Jin Huang
>   North Carolina State University
>
>
>
>
>
>
>
>
> ---------------------------------
> Ahhh...imagining that irresistible "new car" smell?
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html and provide commented, minimal,
> self-contained, reproducible code.

-- 
> Simon Wood, Mathematical Sciences, University of Bath, Bath, BA2 7AY UK
> +44 1225 386603  www.maths.bath.ac.uk/~sw283



More information about the R-help mailing list