Closed wiz21b closed 2 years ago
Hi, Try bw <- npudensbw(formula=~year+gdp) fhat <- npudens(bws=bw) fhat.pred <- predict(fhat,newdata=data.eval) I have not run this but first fit the model then use predict(…,newdata=) which ought to work… Jeff
From: wiz21b @.> Reply-To: JeffreyRacine/R-Package-np @.> Date: Wednesday, June 22, 2022 at 15:43 To: JeffreyRacine/R-Package-np @.> Cc: Subscribed @.> Subject: [JeffreyRacine/R-Package-np] How to use npudens correctly ? (Issue #36)
Hello, I'm trying to compute densities with the npudens function of the np package. Here's the code: data("Italy") attach(Italy) nrow(Italy) year.seq <- sort(unique(year)) gdp.seq <- seq(1,36,length=500) data.eval <- expand.grid(year=year.seq,gdp=gdp.seq) bw <- npudensbw(formula=~year+gdp) fhat <- fitted(npudens(bws=bw, newdata=data.eval)) length(fhat) == nrow(data.eval) # TRUE bw <- npudensbw(Italy) fhat <- fitted(npudens(bws=bw, newdata=data.eval)) length(fhat) == nrow(data.eval) # FALSE ??? Why are the two lengths different ? I expect that both calls to npudensbw are equivalent. I've checked the documentation, the vignettes and even the source code... Note that the code seems fine if the number of rows in data.eval is smaller than in Italy... — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>
Hello,
I'm trying to compute densities with the
npudens
function of thenp
package. Here's the code:Why are the two lengths different ? I expect that both calls to
npudensbw
are equivalent. I've checked the documentation, the vignettes and even the source code... Note that the code seems fine if the number of rows indata.eval
is smaller than inItaly
...