Thank you very much. It worked. I think I need to digest this further
later. Thanks again for the help.
On Thu, Jul 16, 2015 at 4:51 PM, William Dunlap wrote:
> This might do what you want:
>
> OPoly <- function(x, degree=1, weight=1, coefs=NULL, rangeX=NULL){
> weight <- round(weight,0)# weig
Thanks Bill for your quick reply.
I tried your solution and it did work for the simple user defined function
xploly. But when I try with other function, it gave me error again:
OPoly<-function(x,degree=1,weight=1){
weight=round(weight,0)# weight need to be integer
if(length(weight)!=length(x)
This might do what you want:
OPoly <- function(x, degree=1, weight=1, coefs=NULL, rangeX=NULL){
weight <- round(weight,0)# weight need to be integer
if(length(weight)!=length(x)) {
weight <- rep(1,length(x))
}
if (is.null(rangeX)) {
rangeX <- range(x)
}
p <- poly(4*(rep(x,wei
OPoly<-function(x,degree=1,weight=1){
weight=round(weight,0)# weight need to be integer
if(length(weight)!=length(x))weight=rep(1,length(x))
p=poly(4*(rep(x,weight)-mean(range(x)))/diff(range(x)),degree)
Z<-(t(t(p[cumsum(weight),])*sqrt(attr(p,"coefs")$norm2[-
seq(2)]))[,degree])
class(Z)
Read about the 'makepredictcall' generic function. There is a method,
makepredictcall.poly(), for poly() that attaches the polynomial coefficients
used during the fitting procedure to the call to poly() that predict()
makes.
You ought to supply a similar method for your xpoly(), and xpoly() needs
Hello, I have a question about the formula and the user defined function:
I can do following:
###Case 1:
> clotting <- data.frame(
+ u = c(5,10,15,20,30,40,60,80,100),
+ lot1 = c(118,58,42,35,27,25,21,19,18),
+ lot2 = c(69,35,26,21,18,16,13,12,12))
> g1=glm(lot1 ~ log(u) + poly(u,1), d
6 matches
Mail list logo