Dear memberships, I'm trying to estimate the following multivariate local regression model using the "locfit" package: BMI=m1(RCC)+m2(WCC) where (m1) and (m2) are unknown smooth functions. My problem is that once I get the regression done I cannot get the fitted values of each of this smooth functions (m1) and (m2). What I write is the following library(locfit) data(ais) fit2<-locfit.raw(x=lp(ais$RCC,h=0.5,deg=1)+lp(ais$WCC,deg=1,h=0.75),y=ais$BMI,ev=dat(),kt="prod",kern="gauss") g21<-predict(fit2,type="terms") If I done this on the computer the results of (g21) is a vector when I should have a matrix with 2 columns (one for each fitted smooth function). Please, somebody knows how can I get the estimated fitted values of both smooth functions (m1) and (m2) using a local linear regression with kernel weights as this example? thanks a lot in advance I'm very desperate. Alexandra [[alternative HTML version deleted]]
On 2012-03-19 02:12, Soberon Velez, Alexandra Pilar wrote:> Dear memberships, > > > > I'm trying to estimate the following multivariate local regression model using the "locfit" package: > > BMI=m1(RCC)+m2(WCC) > > where (m1) and (m2) are unknown smooth functions. > > > My problem is that once I get the regression done I cannot get the fitted values of each of this smooth functions (m1) and (m2). What I write is the following > > library(locfit) > > data(ais) > fit2<-locfit.raw(x=lp(ais$RCC,h=0.5,deg=1)+lp(ais$WCC,deg=1,h=0.75),y=ais$BMI,ev=dat(),kt="prod",kern="gauss") > g21<-predict(fit2,type="terms") > > > If I done this on the computer the results of (g21) is a vector when I should have a matrix with 2 columns (one for each fitted smooth function). >?predict.locfit doesn't indicate the option of a 'terms' argument. Also, your model specification doesn't look correct: either provide a formula to locfit() or a matrix x to locfit.raw. Peter Ehlers> > Please, somebody knows how can I get the estimated fitted values of both smooth functions (m1) and (m2) using a local linear regression with kernel weights as this example? > > > thanks a lot in advance I'm very desperate. > > Alexandra > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org 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.
I believe you are expecting the software to do what it did not claim being able to do. predict.locfit() does not have a "type" argument, nor can that take on "terms". When you specify two variables in the smooth, a bivariate smooth is done, so you get one bivariate smooth function, not the sum of two univariate smooths. If the latter is what you want, use packages that fits additive models. Best, Andy> -----Original Message----- > From: r-help-bounces at r-project.org > [mailto:r-help-bounces at r-project.org] On Behalf Of Soberon > Velez, Alexandra Pilar > Sent: Monday, March 19, 2012 5:13 AM > To: r-help at r-project.org > Subject: [R] fitted values with locfit > > Dear memberships, > > > > I'm trying to estimate the following multivariate local > regression model using the "locfit" package: > > BMI=m1(RCC)+m2(WCC) > > where (m1) and (m2) are unknown smooth functions. > > > My problem is that once I get the regression done I cannot > get the fitted values of each of this smooth functions (m1) > and (m2). What I write is the following > > library(locfit) > > data(ais) > fit2<-locfit.raw(x=lp(ais$RCC,h=0.5,deg=1)+lp(ais$WCC,deg=1,h> 0.75),y=ais$BMI,ev=dat(),kt="prod",kern="gauss") > g21<-predict(fit2,type="terms") > > > If I done this on the computer the results of (g21) is a > vector when I should have a matrix with 2 columns (one for > each fitted smooth function). > > > Please, somebody knows how can I get the estimated fitted > values of both smooth functions (m1) and (m2) using a local > linear regression with kernel weights as this example? > > > thanks a lot in advance I'm very desperate. > > Alexandra > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org 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. >Notice: This e-mail message, together with any attachme...{{dropped:11}}